Extract dielectric tensor from local DB

Hello!

I am running atomate on a single test node and was experimenting with submitting elastic and dielectric workflows to compare the tensorial values obtained to self performed VASP calculations. My workflows have run and completed properly and I have been able to extract the elastic tensor info from a run via the bit of code following this message. My question is how can I extract the dielectric tensor and derived properties in a similar way?

My mongo instance does not have a ‘dielectric’ collection in the main collection, i.e.

$mongo

use fireworks
show collections
bandstructure_fs.chunks
bandstructure_fs.files
counter
dos_fs.chunks
dos_fs.files
elasticity
fireworks
fw_gridfs.files
fw_id_assigner
gibbs_tasks
launches
tasks
workflows

#code I used for extracting elastic properties.

import numpy as np
from pymatgen import Structure
from atomate.vasp.database import VaspCalcDb
from atomate.utils.utils import get_database
from pymatgen.analysis.elasticity.elastic import ElasticTensor

# create the atomate db from your db.json
PATH_TO_MY_DB_JSON = '/home/dennis/atomate/config/db.json'
atomate_db = VaspCalcDb.from_db_file(PATH_TO_MY_DB_JSON,admin=True)
elasticity_collection=atomate_db.db['elasticity']
elasticity_entry=elasticity_collection.find_one({'formula_pretty':'SrTiO3'})

#for item in elasticity_entry['derived_properties']:
# print(item)

Cij = elasticity_entry['elastic_tensor']['ieee_format'] # convert to pymatgen object
Sij = np.linalg.inv(Cij)
Sij = Sij * 1e3

print("Cij [GPa]")
for item in Cij:
print(item)
print()

print("Sij [1e-12 Pa]")
for item in Sij:
print(item)

Also it does look like the workflows completed properly and did not fizzle:

$lpad get_wflows
{
“created_on”: “2020-01-22T04:00:12.700000”,
“name”: “SrTiO3–1”,
“states_list”: “C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C-C”,
“state”: “COMPLETED”
},
{
“created_on”: “2020-01-28T21:01:14.398000”,
“state”: “COMPLETED”,
“states_list”: “C-C”,
“name”: “SrTiO3–27”
}

Hi,

Apologies for the delayed response. You can try running the builders provided in atomate to generate a “materials” collection in the database. For example:

from pymongo import MongoClient
from atomate.vasp.builders.tasks_materials import TasksMaterialsBuilder
from atomate.vasp.builders.dielectric import DielectricBuilder

mapi_key = None  # set this if PMG_MAPI_KEY not set in ~/.pmgrc.yaml

# change these with your values
host = "hostname"
port = 00000 
name = "database_name"
username_rw = "read_write_username"
password_rw = "read_write_passport"
username_r = "read_only_username"
password_r = "read_only_password"


db_rw = MongoClient(host, port)[name]
db_rw.authenticate(username_rw, password_rw)

db_r = MongoClient(host, port)[name]
db_r.authenticate(username_r, password_r)

# set up builders
tasks = TasksMaterialsBuilder(db_rw.materials, db_rw.counter, db_r.tasks)
dielectric = DielectricBuilder(db_rw.materials)

tasks.run()
dielectric.run()

Once that has finished running, the materials collection will contain one entry for each distinct material you have run (even if you have run multiple separate workflows for that material). The dielectric constant will be in the materials collection under the "dielectric" key.

The subkeys are:

  • "dielectric.epsilon_ionic": Ionic contribution to dielectric constant as a 3x3 tensor.
  • "dielectric.epsilon_static": High frequency contribution to dielectric constant as a 3x3 tensor.
  • "dielectric.epsilon_avg": The average of the eigenvalues of the sum of both components of the dielectric constant.
  • "dielectric.epsilon_ionic_avg": The average of the eigenvalues of the ionic dielectric constant.
  • "dielectric.epsilon_static_avg": The average of the eigenvalues of the static dielectric constant.

I hope this helps.

Best,
Alex

1 Like

Thanks so much! I’ll try this out. I was able to figure out the location of the dielectric tensor buried in the output section of the static_dielectric calc in my DB with some digging but this is much more convenient.