当前位置: 首页>>代码示例>>Python>>正文


Python Spin.from_int方法代码示例

本文整理汇总了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)
开发者ID:materialsgenome,项目名称:pymatgen,代码行数:30,代码来源:bandstructure.py

示例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)
开发者ID:dbroberg,项目名称:pymatgen_chgdef,代码行数:31,代码来源:bandstructure.py

示例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
开发者ID:gmatteo,项目名称:pymatgen-db,代码行数:35,代码来源:query_engine.py

示例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()})
开发者ID:sonium0,项目名称:pymatgen,代码行数:9,代码来源:dos.py

示例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"]),
     )
开发者ID:chenweis,项目名称:pymatgen,代码行数:12,代码来源:dos.py

示例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,
        )
开发者ID:sikisis,项目名称:pymatgen,代码行数:41,代码来源:bandstructure.py

示例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))
开发者ID:NadezhdaBzhilyanskaya,项目名称:pymatgen,代码行数:4,代码来源:test_core.py

示例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)
开发者ID:NadezhdaBzhilyanskaya,项目名称:pymatgen,代码行数:6,代码来源:test_core.py


注:本文中的pymatgen.electronic_structure.core.Spin.from_int方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。