本文整理汇总了Python中pymatgen.electronic_structure.dos.CompleteDos.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python CompleteDos.from_dict方法的具体用法?Python CompleteDos.from_dict怎么用?Python CompleteDos.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.electronic_structure.dos.CompleteDos
的用法示例。
在下文中一共展示了CompleteDos.from_dict方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def setUp(self):
with open(os.path.join(test_dir, 'si_dos.json'), 'r') as sDOS:
si_dos = CompleteDos.from_dict(json.load(sDOS))
self.df = pd.DataFrame({'dos': [si_dos], 'site': [0]})
with open(os.path.join(test_dir, 'nb3sn_dos.json'), 'r') as sDOS:
nb3sn_dos = CompleteDos.from_dict(json.load(sDOS))
self.nb3sn_df = pd.DataFrame({'dos': [nb3sn_dos]})
示例2: get_dos
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def get_dos(self, task_id):
m_task = self.collection.find_one({"task_id": task_id}, {"calcs_reversed": 1})
fs_id = m_task['calcs_reversed'][0]['dos_fs_id']
fs = gridfs.GridFS(self.db, 'dos_fs')
dos_json = zlib.decompress(fs.get(fs_id).read())
dos_dict = json.loads(dos_json.decode())
return CompleteDos.from_dict(dos_dict)
示例3: setUp
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def setUp(self):
self.vbm_val = 2.6682
self.gap = 1.5
self.entries = list(loadfn(os.path.join(os.path.dirname(__file__), "GaAs_test_defentries.json")).values())
for entry in self.entries:
entry.parameters.update( {'vbm': self.vbm_val})
self.pd = DefectPhaseDiagram(self.entries, self.vbm_val, self.gap)
self.mu_elts = {Element("As"): -4.658070555, Element("Ga"): -3.7317319750000006}
# make Vac_As (q= -2) only defect test single-stable-charge exceptions
self.extra_entry = DefectEntry(self.entries[5].defect.copy(), 100.)
sep_entries = [ent for ent in self.entries if not (ent.name == 'Vac_As_mult4' and
ent.charge in [-2,-1,0,1,2])]
sep_entries.append( self.extra_entry.copy())
self.sep_pd = DefectPhaseDiagram( sep_entries, self.vbm_val, self.gap)
# make Vac_As (q= -2) is incompatible for larger supercell
ls_entries = self.entries[:]
for entry in ls_entries:
if entry.name == 'Vac_As_mult4' and entry.charge == -2.:
entry.parameters['is_compatible'] = False
self.pd_ls_fcTrue = DefectPhaseDiagram(ls_entries, self.vbm_val, self.gap, filter_compatible=True)
self.pd_ls_fcFalse = DefectPhaseDiagram(ls_entries, self.vbm_val, self.gap, filter_compatible=False)
# load complete dos for fermi energy solving
with open(os.path.join(test_dir, "complete_dos.json"), "r") as f:
dos_dict = json.load(f)
self.dos = CompleteDos.from_dict(dos_dict)
示例4: setUp
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def setUp(self):
try:
import scipy
except ImportError:
raise SkipTest("scipy not present. Skipping...")
with open(os.path.join(test_dir, "complete_dos.json"), "r") as f:
self.dos = CompleteDos.from_dict(json.load(f))
self.plotter = DosPlotter(sigma=0.2, stack=True)
示例5: from_dict
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def from_dict(complete_dos_dict):
"""
Returns FeffLdos object from dict representation.
Args:
complete_dos_dict:
dict representation os complete_dos
"""
complete_dos = CompleteDos.from_dict(complete_dos_dict)
return FeffLdos(complete_dos)
示例6: from_dict
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def from_dict(d):
"""
Returns FeffLdos object from dict representation
Args:
complete_dos: dict representation of complete_dos
"""
complete_dos = CompleteDos.from_dict(d['complete_dos'])
charge_transfer = d['charge_transfer']
return FeffLdos(complete_dos, charge_transfer)
示例7: featurize
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def featurize(self, dos, decay_length=None):
"""
takes in the density of state and return the orbitals contributions
and hybridizations.
Args:
dos (pymatgen CompleteDos): note that dos.structure is required
decay_length (float or None): if set, it overrides the instance
variable self.decay_length.
Returns ([float]): features, see class doc for more info
"""
decay_length = decay_length or self.decay_length
if isinstance(dos, dict):
dos = CompleteDos.from_dict(dos)
if dos.structure is None:
raise ValueError('The input dos must contain the structure.')
orbscores = get_cbm_vbm_scores(dos,
decay_length,
self.sampling_resolution,
self.gaussian_smear)
feat = OrderedDict()
for ex in ['cbm', 'vbm']:
for orbital in ['s', 'p', 'd', 'f']:
feat['{}_{}'.format(ex, orbital)] = 0.0
for specie in self.species:
feat['{}_{}_{}'.format(ex, specie, orbital)] = 0.0
for hybrid in ['sp', 'sd', 'sf', 'pd', 'pf', 'df']:
feat['{}_{}'.format(ex, hybrid)] = 0.0
for contrib in orbscores:
character = contrib['character']
feat['cbm_{}'.format(character)] += contrib['cbm_score']
feat['vbm_{}'.format(character)] += contrib['vbm_score']
for specie in self.species:
if contrib['specie'] == specie:
feat['cbm_{}_{}'.format(specie, character)] += contrib[
'cbm_score']
feat['vbm_{}_{}'.format(specie, character)] += contrib[
'vbm_score']
for ex in ['cbm', 'vbm']:
for hybrid in ['sp', 'sd', 'sf', 'pd', 'pf', 'df']:
orb1 = feat['{}_{}'.format(ex, hybrid[0])]
orb2 = feat['{}_{}'.format(ex, hybrid[1])]
feat['{}_{}'.format(ex, hybrid)] = (orb1 * orb2) * 4.0 # 4x so max=1.0
return list(feat.values())
示例8: test_to_from_dict
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def test_to_from_dict(self):
d = self.dos.as_dict()
dos = CompleteDos.from_dict(d)
el_dos = dos.get_element_dos()
self.assertEqual(len(el_dos), 4)
spd_dos = dos.get_spd_dos()
sum_spd = spd_dos[OrbitalType.s] + spd_dos[OrbitalType.p] + spd_dos[OrbitalType.d]
sum_element = None
for pdos in el_dos.values():
if sum_element is None:
sum_element = pdos
else:
sum_element += pdos
# The sums of the SPD or the element doses should be the same.
self.assertTrue((abs(sum_spd.energies - sum_element.energies) < 0.0001).all())
示例9: setUp
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def setUp(self):
with open(os.path.join(test_dir, "complete_dos.json"), "r",
encoding='utf-8') as f:
self.dos = CompleteDos.from_dict(json.load(f))
self.plotter = DosPlotter(sigma=0.2, stack=True)
示例10: setUp
# 需要导入模块: from pymatgen.electronic_structure.dos import CompleteDos [as 别名]
# 或者: from pymatgen.electronic_structure.dos.CompleteDos import from_dict [as 别名]
def setUp(self):
with open(os.path.join(test_dir, "complete_dos.json"), "r") as f:
self.dos = CompleteDos.from_dict(json.load(f))