本文整理汇总了Python中pymatgen.entries.compatibility.MaterialsProjectCompatibility类的典型用法代码示例。如果您正苦于以下问题:Python MaterialsProjectCompatibility类的具体用法?Python MaterialsProjectCompatibility怎么用?Python MaterialsProjectCompatibility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MaterialsProjectCompatibility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_stability
def test_get_stability(self):
entries = self.rester.get_entries_in_chemsys(["Fe", "O"])
modified_entries = []
for entry in entries:
# Create modified entries with energies that are 0.01eV higher
# than the corresponding entries.
if entry.composition.reduced_formula == "Fe2O3":
modified_entries.append(
ComputedEntry(entry.composition,
entry.uncorrected_energy + 0.01,
parameters=entry.parameters,
entry_id="mod_{}".format(entry.entry_id)))
rest_ehulls = self.rester.get_stability(modified_entries)
all_entries = entries + modified_entries
compat = MaterialsProjectCompatibility()
all_entries = compat.process_entries(all_entries)
pd = PhaseDiagram(all_entries)
for e in all_entries:
if str(e.entry_id).startswith("mod"):
for d in rest_ehulls:
if d["entry_id"] == e.entry_id:
data = d
break
self.assertAlmostEqual(pd.get_e_above_hull(e),
data["e_above_hull"])
示例2: test_requires_hubbard
def test_requires_hubbard(self):
compat = MaterialsProjectCompatibility()
self.assertTrue(compat.requires_hubbard("Fe2O3"))
self.assertTrue(compat.requires_hubbard("FeSO4"))
self.assertFalse(compat.requires_hubbard("FeS2"))
self.assertFalse(compat.requires_hubbard("Li2O"))
self.assertTrue(compat.requires_hubbard("FeOF"))
示例3: setUp
def setUp(self):
self.entry1 = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.entry2 = ComputedEntry(
'Fe3O4', -2, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.entry3 = ComputedEntry(
'FeO', -2, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 4.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.compat = MaterialsProjectCompatibility(check_potcar_hash=False)
self.ggacompat = MaterialsProjectCompatibility("GGA", check_potcar_hash=False)
示例4: test_get_explanation_dict
def test_get_explanation_dict(self):
compat = MaterialsProjectCompatibility(check_potcar_hash=False)
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel': 'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': "7a25bc5b9a5393f46600a4939d357982"}]})
d = compat.get_explanation_dict(entry)
self.assertEqual('MPRelaxSet Potcar Correction', d["corrections"][0][
"name"])
示例5: test_get_corrections_dict
def test_get_corrections_dict(self):
compat = MaterialsProjectCompatibility()
ggacompat = MaterialsProjectCompatibility("GGA")
#Correct parameters
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_symbols': ['PAW_PBE Fe_pv 06Sep2000',
'PAW_PBE O 08Apr2002']})
c = compat.get_corrections_dict(entry)
self.assertAlmostEqual(c["MP Gas Correction"], -2.10687)
self.assertAlmostEqual(c["MP Advanced Correction"], -5.466)
entry.parameters["is_hubbard"] = False
del entry.parameters["hubbards"]
c = ggacompat.get_corrections_dict(entry)
self.assertNotIn("MP Advanced Correction", c)
示例6: test_get_corrections_dict
def test_get_corrections_dict(self):
compat = MaterialsProjectCompatibility(check_potcar_hash=False)
ggacompat = MaterialsProjectCompatibility("GGA", check_potcar_hash=False)
#Correct parameters
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': "7a25bc5b9a5393f46600a4939d357982"}]})
c = compat.get_corrections_dict(entry)
self.assertAlmostEqual(c["MP Anion Correction"], -2.10687)
self.assertAlmostEqual(c["MP Advanced Correction"], -5.466)
entry.parameters["is_hubbard"] = False
del entry.parameters["hubbards"]
c = ggacompat.get_corrections_dict(entry)
self.assertNotIn("MP Advanced Correction", c)
示例7: calculate_phase_stability
def calculate_phase_stability(args):
#This initializes the REST adaptor.
a = MPRester(args.api_key)
drone = VaspToComputedEntryDrone()
entry = drone.assimilate(args.directory)
compat = MaterialsProjectCompatibility()
entry = compat.process_entry(entry)
if not entry:
print "Calculation parameters are not consistent with Materials " + \
"Project parameters."
sys.exit()
syms = [el.symbol for el in entry.composition.elements]
#This gets all entries belonging to the relevant system.
entries = a.get_entries_in_chemsys(syms)
entries.append(entry)
#Process entries with Materials Project compatibility.
entries = compat.process_entries(entries)
print [e.composition.reduced_formula for e in entries]
示例8: run_task
#.........这里部分代码省略.........
data['dir_name'] = get_block_part(dir)
data['task_id'] = m_task['task_id']
del data['hall'] # remove because it is too large and not useful
fs = gridfs.GridFS(tdb, "boltztrap_full_fs")
btid = fs.put(json.dumps(jsanitize(data)))
"""
# now for the "sanitized" data
ted = bta.as_dict()
del ted['seebeck']
del ted['hall']
del ted['kappa']
del ted['cond']
# ted['boltztrap_full_fs_id'] = btid
ted['snlgroup_id'] = fw_spec['snlgroup_id']
ted['run_tags'] = fw_spec['run_tags']
ted['snl'] = fw_spec['mpsnl'].as_dict()
ted['dir_name_full'] = dir
ted['dir_name'] = get_block_part(dir)
ted['task_id'] = m_task['task_id']
ted['pf_doping'] = bta.get_power_factor(output='tensor', relaxation_time=self.TAU)
ted['zt_doping'] = bta.get_zt(output='tensor', relaxation_time=self.TAU, kl=self.KAPPAL)
ted['pf_eigs'] = self.get_eigs(ted, 'pf_doping')
ted['pf_best'] = self.get_extreme(ted, 'pf_eigs')
ted['pf_best_dope18'] = self.get_extreme(ted, 'pf_eigs', max_didx=3)
ted['pf_best_dope19'] = self.get_extreme(ted, 'pf_eigs', max_didx=4)
ted['zt_eigs'] = self.get_eigs(ted, 'zt_doping')
ted['zt_best'] = self.get_extreme(ted, 'zt_eigs')
ted['zt_best_dope18'] = self.get_extreme(ted, 'zt_eigs', max_didx=3)
ted['zt_best_dope19'] = self.get_extreme(ted, 'zt_eigs', max_didx=4)
ted['seebeck_eigs'] = self.get_eigs(ted, 'seebeck_doping')
ted['seebeck_best'] = self.get_extreme(ted, 'seebeck_eigs')
ted['seebeck_best_dope18'] = self.get_extreme(ted, 'seebeck_eigs', max_didx=3)
ted['seebeck_best_dope19'] = self.get_extreme(ted, 'seebeck_eigs', max_didx=4)
ted['cond_eigs'] = self.get_eigs(ted, 'cond_doping')
ted['cond_best'] = self.get_extreme(ted, 'cond_eigs')
ted['cond_best_dope18'] = self.get_extreme(ted, 'cond_eigs', max_didx=3)
ted['cond_best_dope19'] = self.get_extreme(ted, 'cond_eigs', max_didx=4)
ted['kappa_eigs'] = self.get_eigs(ted, 'kappa_doping')
ted['kappa_best'] = self.get_extreme(ted, 'kappa_eigs', maximize=False)
ted['kappa_best_dope18'] = self.get_extreme(ted, 'kappa_eigs', maximize=False, max_didx=3)
ted['kappa_best_dope19'] = self.get_extreme(ted, 'kappa_eigs', maximize=False, max_didx=4)
try:
from mpcollab.thermoelectrics.boltztrap_TE import BoltzSPB
bzspb = BoltzSPB(ted)
maxpf_p = bzspb.get_maximum_power_factor('p', temperature=0, tau=1E-14, ZT=False, kappal=0.5,\
otherprops=('get_seebeck_mu_eig', 'get_conductivity_mu_eig', \
'get_thermal_conductivity_mu_eig', 'get_average_eff_mass_tensor_mu'))
maxpf_n = bzspb.get_maximum_power_factor('n', temperature=0, tau=1E-14, ZT=False, kappal=0.5,\
otherprops=('get_seebeck_mu_eig', 'get_conductivity_mu_eig', \
'get_thermal_conductivity_mu_eig', 'get_average_eff_mass_tensor_mu'))
maxzt_p = bzspb.get_maximum_power_factor('p', temperature=0, tau=1E-14, ZT=True, kappal=0.5, otherprops=('get_seebeck_mu_eig', 'get_conductivity_mu_eig', \
'get_thermal_conductivity_mu_eig', 'get_average_eff_mass_tensor_mu'))
maxzt_n = bzspb.get_maximum_power_factor('n', temperature=0, tau=1E-14, ZT=True, kappal=0.5, otherprops=('get_seebeck_mu_eig', 'get_conductivity_mu_eig', \
'get_thermal_conductivity_mu_eig', 'get_average_eff_mass_tensor_mu'))
ted['zt_best_finemesh'] = {'p': maxzt_p, 'n': maxzt_n}
ted['pf_best_finemesh'] = {'p': maxpf_p, 'n': maxpf_n}
except:
import traceback
traceback.print_exc()
print 'COULD NOT GET FINE MESH DATA'
# add is_compatible
mpc = MaterialsProjectCompatibility("Advanced")
try:
func = m_task["pseudo_potential"]["functional"]
labels = m_task["pseudo_potential"]["labels"]
symbols = ["{} {}".format(func, label) for label in labels]
parameters = {"run_type": m_task["run_type"],
"is_hubbard": m_task["is_hubbard"],
"hubbards": m_task["hubbards"],
"potcar_symbols": symbols}
entry = ComputedEntry(Composition(m_task["unit_cell_formula"]),
0.0, 0.0, parameters=parameters,
entry_id=m_task["task_id"])
ted["is_compatible"] = bool(mpc.process_entry(entry))
except:
traceback.print_exc()
print 'ERROR in getting compatibility, task_id: {}'.format(m_task["task_id"])
ted["is_compatible"] = None
tdb.boltztrap.insert(jsanitize(ted))
update_spec = {'prev_vasp_dir': fw_spec['prev_vasp_dir'],
'boltztrap_dir': os.getcwd(),
'prev_task_type': fw_spec['task_type'],
'mpsnl': fw_spec['mpsnl'].as_dict(),
'snlgroup_id': fw_spec['snlgroup_id'],
'run_tags': fw_spec['run_tags'], 'parameters': fw_spec.get('parameters')}
return FWAction(update_spec=update_spec)
示例9: test_process_entry
def test_process_entry(self):
compat = MaterialsProjectCompatibility()
ggacompat = MaterialsProjectCompatibility("GGA")
#Correct parameters
self.assertIsNotNone(compat.process_entry(self.entry1))
self.assertIsNone(ggacompat.process_entry(self.entry1))
#Correct parameters
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': False, "hubbards": {}, 'run_type': 'GGA',
'potcar_symbols': ['PAW_PBE Fe_pv 06Sep2000',
'PAW_PBE O 08Apr2002']})
self.assertIsNone(compat.process_entry(entry))
self.assertIsNotNone(ggacompat.process_entry(entry))
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_symbols': ['PAW_PBE Fe_pv 06Sep2000',
'PAW_PBE O 08Apr2002']})
self.assertIsNotNone(compat.process_entry(entry))
#Check actual correction
self.assertAlmostEqual(compat.process_entry(entry).correction,
- 2.733 * 2 - 0.70229 * 3)
entry = ComputedEntry(
'FeF3', -2, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'F': 0},
'run_type': 'GGA+U',
'potcar_symbols': ['PAW_PBE Fe_pv 06Sep2000',
'PAW_PBE F 08Apr2002']})
self.assertIsNotNone(compat.process_entry(entry))
#Check actual correction
self.assertAlmostEqual(compat.process_entry(entry).correction, -2.733)
#Wrong U value
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True,
'hubbards': {'Fe': 5.2, 'O': 0}, 'run_type': 'GGA+U',
'potcar_symbols': ['PAW_PBE Fe_pv 06Sep2000',
'PAW_PBE O 08Apr2002']})
self.assertIsNone(compat.process_entry(entry))
#GGA run of U
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': False, 'hubbards': None,
'run_type': 'GGA',
'potcar_symbols': ['PAW_PBE Fe_pv 06Sep2000',
'PAW_PBE O 08Apr2002']})
self.assertIsNone(compat.process_entry(entry))
#GGA+U run of non-U
entry = ComputedEntry(
'Al2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Al': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_symbols': ['PAW_PBE Al 06Sep2000',
'PAW_PBE O 08Apr2002']})
self.assertIsNone(compat.process_entry(entry))
#Materials project should not have a U for sulfides
entry = ComputedEntry(
'FeS2', -2, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'S': 0},
'run_type': 'GGA+U',
'potcar_symbols': ['PAW_PBE Fe_pv 06Sep2000',
'PAW_PBE S 08Apr2002']})
self.assertIsNone(compat.process_entry(entry))
#Wrong psp
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_symbols': ['PAW_PBE Fe 06Sep2000',
'PAW_PBE O 08Apr2002']})
self.assertIsNone(compat.process_entry(entry))
#Testing processing of elements.
entry = ComputedEntry(
'O', -1, 0.0,
parameters={'is_hubbard': False, 'hubbards': {},
'potcar_symbols': ['PAW_PBE O 08Apr2002'],
'run_type': 'GGA'})
entry = compat.process_entry(entry)
# self.assertEqual(entry.entry_id, -8)
self.assertAlmostEqual(entry.energy, -1)
self.assertAlmostEqual(ggacompat.process_entry(entry).energy,
-1)
示例10: test_process_entries
def test_process_entries(self):
compat = MaterialsProjectCompatibility()
entries = compat.process_entries([self.entry1, self.entry2,
self.entry3])
self.assertEqual(len(entries), 2)
示例11: get_entries
def get_entries(self, chemsys_formula_id_criteria, compatible_only=True,
inc_structure=None, property_data=None):
"""
Get a list of ComputedEntries or ComputedStructureEntries corresponding
to a chemical system, formula, or materials_id or full criteria.
Args:
chemsys_formula_id_criteria (str/dict): A chemical system
(e.g., Li-Fe-O), or formula (e.g., Fe2O3) or materials_id
(e.g., mp-1234) or full Mongo-style dict criteria.
compatible_only (bool): Whether to return only "compatible"
entries. Compatible entries are entries that have been
processed using the MaterialsProjectCompatibility class,
which performs adjustments to allow mixing of GGA and GGA+U
calculations for more accurate phase diagrams and reaction
energies.
inc_structure (str): If None, entries returned are
ComputedEntries. If inc_structure="final",
ComputedStructureEntries with final structures are returned.
Otherwise, ComputedStructureEntries with initial structures
are returned.
property_data (list): Specify additional properties to include in
entry.data. If None, no data. Should be a subset of
supported_properties.
Returns:
List of ComputedEntry or ComputedStructureEntry objects.
"""
# TODO: This is a very hackish way of doing this. It should be fixed
# on the REST end.
params = ["run_type", "is_hubbard", "pseudo_potential", "hubbards",
"potcar_symbols"]
if compatible_only:
props = ["energy", "unit_cell_formula", "task_id"] + params
if property_data:
props += property_data
if inc_structure:
if inc_structure == "final":
props.append("structure")
else:
props.append("initial_structure")
if not isinstance(chemsys_formula_id_criteria, dict):
criteria = MPRester.parse_criteria(chemsys_formula_id_criteria)
else:
criteria = chemsys_formula_id_criteria
data = self.query(criteria, props)
entries = []
for d in data:
d["potcar_symbols"] = [
"%s %s" % (d["pseudo_potential"]["functional"], l)
for l in d["pseudo_potential"]["labels"]]
data = {k: d[k] for k in property_data} if property_data else None
if not inc_structure:
e = ComputedEntry(d["unit_cell_formula"], d["energy"],
parameters={k: d[k] for k in params},
data=data,
entry_id=d["task_id"])
else:
s = d["structure"] if inc_structure == "final" else d[
"initial_structure"]
e = ComputedStructureEntry(
s, d["energy"],
parameters={k: d[k] for k in params},
data=data,
entry_id=d["task_id"])
entries.append(e)
from pymatgen.entries.compatibility import \
MaterialsProjectCompatibility
entries = MaterialsProjectCompatibility().process_entries(entries)
else:
entries = []
for d in self.get_data(chemsys_formula_id_criteria,
prop="task_ids"):
for i in d["task_ids"]:
e = self.get_task_data(i, prop="entry")
e = e[0]["entry"]
if inc_structure:
s = self.get_task_data(i,
prop="structure")[0]["structure"]
e = ComputedStructureEntry(
s, e.energy, e.correction, e.parameters, e.data,
e.entry_id)
entries.append(e)
return entries
示例12: assimilate
#.........这里部分代码省略.........
struct=Structure.from_dict(d["output"]["crystal"])
d["oxide_type"]=oxide_type(struct)
except:
logger.error("can't get oxide_type for {}".format(d["task_id"]))
d["oxide_type"] = None
#Override incorrect outcar subdocs for two step relaxations
if "optimize structure" in d['task_type'] and \
os.path.exists(os.path.join(path, "relax2")):
try:
run_stats = {}
for i in [1,2]:
o_path = os.path.join(path,"relax"+str(i),"OUTCAR")
o_path = o_path if os.path.exists(o_path) else o_path+".gz"
outcar = Outcar(o_path)
d["calculations"][i-1]["output"]["outcar"] = outcar.as_dict()
run_stats["relax"+str(i)] = outcar.run_stats
except:
logger.error("Bad OUTCAR for {}.".format(path))
try:
overall_run_stats = {}
for key in ["Total CPU time used (sec)", "User time (sec)",
"System time (sec)", "Elapsed time (sec)"]:
overall_run_stats[key] = sum([v[key]
for v in run_stats.values()])
run_stats["overall"] = overall_run_stats
except:
logger.error("Bad run stats for {}.".format(path))
d["run_stats"] = run_stats
# add is_compatible
mpc = MaterialsProjectCompatibility("Advanced")
try:
func = d["pseudo_potential"]["functional"]
labels = d["pseudo_potential"]["labels"]
symbols = ["{} {}".format(func, label) for label in labels]
parameters = {"run_type": d["run_type"],
"is_hubbard": d["is_hubbard"],
"hubbards": d["hubbards"],
"potcar_symbols": symbols}
entry = ComputedEntry(Composition(d["unit_cell_formula"]),
0.0, 0.0, parameters=parameters,
entry_id=d["task_id"])
d['is_compatible'] = bool(mpc.process_entry(entry))
except:
traceback.print_exc()
print 'ERROR in getting compatibility'
d['is_compatible'] = None
#task_type dependent processing
if 'static' in d['task_type']:
launch_doc = launches_coll.find_one({"fw_id": d['fw_id'], "launch_dir": {"$regex": d["dir_name"]}}, {"action.stored_data": 1})
for i in ["conventional_standard_structure", "symmetry_operations",
"symmetry_dataset", "refined_structure"]:
try:
d['stored_data'][i] = launch_doc['action']['stored_data'][i]
except:
pass
#parse band structure if necessary
if ('band structure' in d['task_type'] or "Uniform" in d['task_type'])\
示例13: MaterialsProjectCompatibilityTest
class MaterialsProjectCompatibilityTest(unittest.TestCase):
def setUp(self):
self.entry1 = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.entry2 = ComputedEntry(
'Fe3O4', -2, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.entry3 = ComputedEntry(
'FeO', -2, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 4.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.compat = MaterialsProjectCompatibility(check_potcar_hash=False)
self.ggacompat = MaterialsProjectCompatibility("GGA", check_potcar_hash=False)
def test_process_entry(self):
#Correct parameters
self.assertIsNotNone(self.compat.process_entry(self.entry1))
self.assertIsNone(self.ggacompat.process_entry(self.entry1))
#Correct parameters
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': False, "hubbards": {}, 'run_type': 'GGA',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.assertIsNone(self.compat.process_entry(entry))
self.assertIsNotNone(self.ggacompat.process_entry(entry))
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'O': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.assertIsNotNone(self.compat.process_entry(entry))
def test_correction_values(self):
#test_corrections
self.assertAlmostEqual(self.compat.process_entry(self.entry1).correction,
- 2.733 * 2 - 0.70229 * 3)
entry = ComputedEntry(
'FeF3', -2, 0.0,
parameters={'is_hubbard': True, 'hubbards': {'Fe': 5.3, 'F': 0},
'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE F 08Apr2002',
'hash': '180141c33d032bfbfff30b3bea9d23dd'}]})
self.assertIsNotNone(self.compat.process_entry(entry))
#Check actual correction
self.assertAlmostEqual(self.compat.process_entry(entry).correction, -2.733)
def test_U_values(self):
#Wrong U value
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': True,
'hubbards': {'Fe': 5.2, 'O': 0}, 'run_type': 'GGA+U',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.assertIsNone(self.compat.process_entry(entry))
#GGA run of U
entry = ComputedEntry(
'Fe2O3', -1, 0.0,
parameters={'is_hubbard': False, 'hubbards': None,
'run_type': 'GGA',
'potcar_spec': [{'titel':'PAW_PBE Fe_pv 06Sep2000',
'hash': '994537de5c4122b7f1b77fb604476db4'},
{'titel': 'PAW_PBE O 08Apr2002',
'hash': '7a25bc5b9a5393f46600a4939d357982'}]})
self.assertIsNone(self.compat.process_entry(entry))
#GGA+U run of non-U
entry = ComputedEntry(
#.........这里部分代码省略.........
示例14: __init__
def __init__(self):
# some MP analysis power tools
self.compat = MaterialsProjectCompatibility()
return
示例15: AnalyseMaterialsProjectJsonDataWithComputedEntries
class AnalyseMaterialsProjectJsonDataWithComputedEntries():
"""
Class which will wrap around boilerplate analysis of MaterialsProject-like
json files, containing data extracted using borgs and queens.
It will be assumed that we are providing ComputedEntries objects directly.
"""
def __init__(self):
# some MP analysis power tools
self.compat = MaterialsProjectCompatibility()
return
def extract_alkali_energy(self, computed_Alkali_entry ):
processed_Alkali_entry = self.compat.process_entry(computed_Alkali_entry)
self.E_Alkali = processed_Alkali_entry.energy
return
def extract_phase_diagram_info(self,MP_phase_diagram_json_data_filename):
computed_entries = self._extract_MP_data(MP_phase_diagram_json_data_filename)
processed_entries = self.compat.process_entries(computed_entries)
pd = PhaseDiagram(processed_entries)
self.phase_diagram_analyser = PDAnalyzer(pd)
return
def extract_processed_entries(self,computed_entries):
processed_entries = self.compat.process_entries(computed_entries)
return processed_entries
def extract_energies_above_hull(self,computed_entries,alkali):
processed_entries = self.extract_processed_entries(computed_entries)
list_energy_above_hull = []
list_alkali_content = []
for entry in processed_entries:
decomposition_dict, energy_above_hull = \
self.phase_diagram_analyser.get_decomp_and_e_above_hull(entry, allow_negative=True)
list_energy_above_hull.append(energy_above_hull)
list_alkali_content.append(entry.composition[alkali])
list_energy_above_hull = np.array(list_energy_above_hull)
list_alkali_content = np.array(list_alkali_content )
return list_alkali_content, list_energy_above_hull
def extract_energies(self,computed_entries,alkali):
processed_entries = self.extract_processed_entries(computed_entries)
list_energy = []
list_alkali_content = []
for entry in processed_entries:
list_energy.append(entry.energy)
list_alkali_content.append(entry.composition[alkali])
list_energy = np.array(list_energy)
list_alkali_content = np.array(list_alkali_content )
I = np.argsort(list_alkali_content )
return list_alkali_content[I], list_energy[I]
def _extract_MP_data(self,MP_data_filename):
drone = VaspToComputedEntryDrone()
queen = BorgQueen(drone, "dummy", 1)
queen.load_data(MP_data_filename)
computed_entries = queen.get_data()
del drone
del queen
return computed_entries