本文整理汇总了Python中pymatgen.core.Structure.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.from_dict方法的具体用法?Python Structure.from_dict怎么用?Python Structure.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.Structure
的用法示例。
在下文中一共展示了Structure.from_dict方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_task
# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import from_dict [as 别名]
def run_task(self, fw_spec):
user_incar_settings = self["user_incar_settings"]
interpolation_type = self.get("interpolation_type", "IDPP")
idpp_species = fw_spec.get("idpp_species")
user_kpoints_settings = self.get("user_kpoints_settings")
try:
ep0 = Structure.from_dict(fw_spec["ep0"])
ep1 = Structure.from_dict(fw_spec["ep1"])
except:
ep0 = fw_spec["ep0"]
ep1 = fw_spec["ep1"]
# Get number of images.
nimages = user_incar_settings.get("IMAGES", self._get_nimages(ep0, ep1))
if interpolation_type == "IDPP":
from pymatgen_diffusion.neb.pathfinder import IDPPSolver
obj = IDPPSolver.from_endpoints([ep0, ep1], nimages=nimages)
images = obj.run(species=idpp_species)
images_dic_list = [image.as_dict() for image in images]
elif interpolation_type == "linear":
images = self._get_images_by_linear_interp(nimages, ep0, ep1)
images_dic_list = [i.as_dict() for i in images]
else:
raise ValueError("The interpolation method must either be 'linear' or 'IDPP'!")
write = WriteNEBFromImages(neb_label='1', user_incar_settings=user_incar_settings,
user_kpoints_settings=user_kpoints_settings)
fw_spec["neb"] = [images_dic_list]
write.run_task(fw_spec=fw_spec)
示例2: from_dict
# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import from_dict [as 别名]
def from_dict(cls, d):
structure = Structure.from_dict(d["structure"])
return cls(structure, np.array(d["displacements"]), specie=d["specie"],
temperature=d["temperature"], time_step=d["time_step"],
step_skip=d["step_skip"], min_obs=d["min_obs"],
smoothed=d.get("smoothed", "max"),
avg_nsteps=d.get("avg_nsteps", 1000))
示例3: from_dict
# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import from_dict [as 别名]
def from_dict(cls, d):
"""
As in :Class: `pymatgen.core.Structure` except
restoring graphs using `from_dict_of_dicts`
from NetworkX to restore graph information.
"""
s = Structure.from_dict(d['structure'])
return cls(s, d['graphs'])
示例4: setUp
# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import from_dict [as 别名]
def setUp(self):
with open(os.path.join(test_dir, 'si_structure.json'),'r') as sth:
si_str = Structure.from_dict(json.load(sth))
with open(os.path.join(test_dir, 'si_bandstructure_line.json'),'r') as bsh:
si_bs_line = BandStructureSymmLine.from_dict(json.load(bsh))
si_bs_line.structure = si_str
with open(os.path.join(test_dir, 'si_bandstructure_uniform.json'),'r') as bsh:
si_bs_uniform = BandStructure.from_dict(json.load(bsh))
si_bs_uniform.structure = si_str
self.si_kpts = list(HighSymmKpath(si_str).kpath['kpoints'].values())
self.df = pd.DataFrame({'bs_line': [si_bs_line], 'bs_uniform': [si_bs_uniform]})
with open(os.path.join(test_dir, 'VBr2_971787_bandstructure.json'), 'r') as bsh:
vbr2_uniform = BandStructure.from_dict(json.load(bsh))
self.vbr2kpts = [k.frac_coords for k in vbr2_uniform.labels_dict.values()]
self.vbr2kpts = [[0.0, 0.0, 0.0], # \\Gamma
[0.2, 0.0, 0.0], # between \\Gamma and M
[0.5, 0.0, 0.0], # M
[0.5, 0.0, 0.5]] # L
self.df2 = pd.DataFrame({'bs_line': [vbr2_uniform]})
示例5: process_entry
# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import from_dict [as 别名]
def process_entry(self, defect_entry, perform_corrections = True):
"""
Process a given DefectEntry with qualifiers given from initialization of class.
Order of processing is:
1) perform all possible defect corrections with information given
2) consider delocalization analyses based on qualifier metrics
given initialization of class. If delocalized, flag entry as delocalized
3) update corrections to defect entry and flag as delocalized
Corrections are applied based on:
i) if free charges are more than free_chg_cutoff then will not apply charge correction,
because it no longer is applicable
ii) use charge correction set by preferred_cc
iii) only use BandFilling correction if use_bandfilling is set to True
iv) only use BandEdgeShift correction if use_bandedgeshift is set to True
"""
for struct_key in ["bulk_sc_structure", "initial_defect_structure", "final_defect_structure"]:
if struct_key in defect_entry.parameters.keys() and isinstance(defect_entry.parameters[struct_key], dict):
defect_entry.parameters[struct_key] = Structure.from_dict(defect_entry.parameters[struct_key])
if perform_corrections:
self.perform_all_corrections(defect_entry)
self.delocalization_analysis(defect_entry)
# apply corrections based on delocalization analysis
corrections = {}
skip_charge_corrections = False
if "num_hole_vbm" in defect_entry.parameters.keys():
if (self.free_chg_cutoff < defect_entry.parameters["num_hole_vbm"]) or (
self.free_chg_cutoff < defect_entry.parameters["num_elec_cbm"]):
logger.info('Will not use charge correction because too many free charges')
skip_charge_corrections = True
if skip_charge_corrections:
corrections.update({'charge_correction': 0.})
else:
if ('freysoldt' in self.preferred_cc.lower()) and ('freysoldt_meta' in defect_entry.parameters.keys()):
frey_meta = defect_entry.parameters['freysoldt_meta']
frey_corr = frey_meta["freysoldt_electrostatic"] + frey_meta["freysoldt_potential_alignment_correction"]
corrections.update({'charge_correction': frey_corr})
elif ('kumagai_meta' in defect_entry.parameters.keys()):
kumagai_meta = defect_entry.parameters['kumagai_meta']
kumagai_corr = kumagai_meta["kumagai_electrostatic"] + \
kumagai_meta["kumagai_potential_alignment_correction"]
corrections.update({'charge_correction': kumagai_corr})
else:
logger.info('Could not use any charge correction because insufficient metadata was supplied.')
if self.use_bandfilling:
if "bandfilling_meta" in defect_entry.parameters.keys():
bfc_corr = defect_entry.parameters["bandfilling_meta"]["bandfilling_correction"]
corrections.update({'bandfilling_correction': bfc_corr})
else:
logger.info('Could not use band filling correction because insufficient metadata was supplied.')
else:
corrections.update({'bandfilling_correction': 0.})
if self.use_bandedgeshift and ("bandshift_meta" in defect_entry.parameters.keys()):
corrections.update({'bandedgeshifting_correction':
defect_entry.parameters["bandshift_meta"]["bandedgeshifting_correction"] })
# also want to update relevant data for phase diagram
defect_entry.parameters.update({
'phasediagram_meta': {
'vbm': defect_entry.parameters['hybrid_vbm'],
'gap': defect_entry.parameters['hybrid_cbm'] - defect_entry.parameters['hybrid_vbm']
}
})
else:
corrections.update({'bandedgeshifting_correction': 0.})
if (type(defect_entry.parameters['vbm']) == float) and (type(defect_entry.parameters['cbm']) == float):
# still want to have vbm and gap ready for phase diagram
defect_entry.parameters.update({
'phasediagram_meta': {
'vbm': defect_entry.parameters['vbm'],
'gap': defect_entry.parameters['cbm'] - defect_entry.parameters['vbm']
}
})
defect_entry.corrections.update(corrections)
return defect_entry