本文整理汇总了Python中pymatgen.electronic_structure.core.Spin.from_int方法的典型用法代码示例。如果您正苦于以下问题:Python Spin.from_int方法的具体用法?Python Spin.from_int怎么用?Python Spin.from_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.electronic_structure.core.Spin
的用法示例。
在下文中一共展示了Spin.from_int方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_dict
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def from_dict(d):
"""
Args:
A dict with all data for a band structure symm line object.
Returns:
A BandStructureSymmLine object
"""
labels_dict = d['labels_dict']
projections = {}
structure = None
if 'projections' in d and len(d['projections']) != 0:
structure = Structure.from_dict(d['structure'])
projections = {
Spin.from_int(int(spin)): [
[{Orbital.from_string(orb): [
d['projections'][spin][i][j][orb][k]
for k in range(len(d['projections'][spin][i][j][orb]))]
for orb in d['projections'][spin][i][j]}
for j in range(len(d['projections'][spin][i]))]
for i in range(len(d['projections'][spin]))]
for spin in d['projections']}
return BandStructureSymmLine(
d['kpoints'], {Spin.from_int(int(k)): d['bands'][k]
for k in d['bands']},
Lattice(d['lattice_rec']['matrix']), d['efermi'],
labels_dict, structure=structure, projections=projections)
示例2: from_dict
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def from_dict(cls, d):
"""
Args:
A dict with all data for a band structure symm line object.
Returns:
A BandStructureSymmLine object
"""
# Strip the label to recover initial string (see trick used in as_dict to handle $ chars)
labels_dict = {k.strip(): v for k, v in d['labels_dict'].items()}
projections = {}
structure = None
if 'projections' in d and len(d['projections']) != 0:
structure = Structure.from_dict(d['structure'])
projections = {
Spin.from_int(int(spin)): [
[{Orbital.from_string(orb): [
d['projections'][spin][i][j][orb][k]
for k in range(len(d['projections'][spin][i][j][orb]))]
for orb in d['projections'][spin][i][j]}
for j in range(len(d['projections'][spin][i]))]
for i in range(len(d['projections'][spin]))]
for spin in d['projections']}
return BandStructureSymmLine(
d['kpoints'], {Spin.from_int(int(k)): d['bands'][k]
for k in d['bands']},
Lattice(d['lattice_rec']['matrix']), d['efermi'],
labels_dict, structure=structure, projections=projections)
示例3: get_dos_from_id
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def get_dos_from_id(self, task_id):
"""
Overrides the get_dos_from_id for the MIT gridfs format.
"""
args = {'task_id': task_id}
fields = ['calculations']
structure = self.get_structure_from_id(task_id)
dosid = None
for r in self.query(fields, args):
dosid = r['calculations'][-1]['dos_fs_id']
if dosid != None:
self._fs = gridfs.GridFS(self.db, 'dos_fs')
with self._fs.get(dosid) as dosfile:
s = dosfile.read()
try:
d = json.loads(s)
except:
s = zlib.decompress(s)
d = json.loads(s)
tdos = Dos.from_dict(d)
pdoss = {}
for i in range(len(d['pdos'])):
ados = d['pdos'][i]
all_ados = {}
for j in range(len(ados)):
orb = Orbital.from_vasp_index(j)
odos = ados[str(orb)]
all_ados[orb] = {Spin.from_int(int(k)): v
for k, v
in odos['densities'].items()}
pdoss[structure[i]] = all_ados
return CompleteDos(structure, tdos, pdoss)
return None
示例4: from_dict
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def from_dict(cls, d):
"""
Returns Dos object from dict representation of Dos.
"""
return Dos(d["efermi"], d["energies"],
{Spin.from_int(int(k)): v
for k, v in d["densities"].items()})
示例5: from_dict
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def from_dict(d):
"""
Returns PDos object from dict representation.
"""
return PDos(
d["efermi"],
d["energies"],
{Spin.from_int(int(k)): v for k, v in d["densities"].items()},
Orbital.from_string(d["orbital"]),
)
示例6: from_dict
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def from_dict(cls, d):
"""
Args:
A dict with all data for a band structure symm line object.
Returns:
A BandStructureSymmLine object
"""
labels_dict = d["labels_dict"]
projections = {}
structure = None
if "projections" in d and len(d["projections"]) != 0:
structure = Structure.from_dict(d["structure"])
projections = {
Spin.from_int(int(spin)): [
[
{
Orbital.from_string(orb): [
d["projections"][spin][i][j][orb][k]
for k in range(len(d["projections"][spin][i][j][orb]))
]
for orb in d["projections"][spin][i][j]
}
for j in range(len(d["projections"][spin][i]))
]
for i in range(len(d["projections"][spin]))
]
for spin in d["projections"]
}
return BandStructureSymmLine(
d["kpoints"],
{Spin.from_int(int(k)): d["bands"][k] for k in d["bands"]},
Lattice(d["lattice_rec"]["matrix"]),
d["efermi"],
labels_dict,
structure=structure,
projections=projections,
)
示例7: test_cached
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def test_cached(self):
self.assertEquals(id(Spin.from_int(1)), id(Spin.up))
示例8: test_from_int
# 需要导入模块: from pymatgen.electronic_structure.core import Spin [as 别名]
# 或者: from pymatgen.electronic_structure.core.Spin import from_int [as 别名]
def test_from_int(self):
self.assertEquals(Spin.from_int(1), Spin.up)
self.assertEquals(Spin.from_int(-1), Spin.down)
self.assertRaises(ValueError, Spin.from_int, 0)