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


Python Structure.from_file方法代码示例

本文整理汇总了Python中abipy.core.structure.Structure.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.from_file方法的具体用法?Python Structure.from_file怎么用?Python Structure.from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在abipy.core.structure.Structure的用法示例。


在下文中一共展示了Structure.from_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: abifile_subclass_from_filename

# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import from_file [as 别名]
def abifile_subclass_from_filename(filename):
    from abipy.iotools.files import AbinitFile, AbinitLogFile, AbinitOutputFile
    from abipy.electrons import SIGRES_File, GSR_File, MDF_File
    from abipy.waves import WFK_File
    #from abipy.phonons import PHDOS_File, PHBST_File

    ext2ncfile = {
        "SIGRES.nc": SIGRES_File,
        "WFK-etsf.nc": WFK_File,
        "MDF.nc" : MDF_File,
        "GSR.nc": GSR_File
        #"PHDOS.nc": PHDOS_File,
        #"PHBST.nc": PHBST_File,
    }

    #if filename.endswith(".abi"):
    #    return AbinitInputFile
                                                                                        
    if filename.endswith(".abo"):
        return AbinitOutputFile
    
    if filename.endswith(".log"):
        return AbinitLogFile

    # CIF files.
    if filename.endswith(".cif"):
        from abipy.core.structure import Structure
        return Structure.from_file(filename)

    ext = filename.split("_")[-1]
    try:
        return ext2ncfile[ext]
    except KeyError:
        raise KeyError("No class has been registered for extension %s" % ext)
开发者ID:srirampr,项目名称:abipy,代码行数:36,代码来源:abilab.py

示例2: work_for_pseudo

# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import from_file [as 别名]
    def work_for_pseudo(self, pseudo, accuracy="normal", kppa=6750, ecut=None, pawecutdg=None,
                        toldfe=1.e-9, smearing="fermi_dirac:0.1 eV", workdir=None, manager=None, **kwargs):
        """
        Returns a :class:`Work` object from the given pseudopotential.

        Args:
            kwargs: Extra variables passed to Abinit.

        .. note::

            0.001 Rydberg is the value used with WIEN2K
        """
        pseudo = Pseudo.as_pseudo(pseudo)
        symbol = pseudo.symbol

        if pseudo.ispaw and pawecutdg is None:
            raise ValueError("pawecutdg must be specified for PAW calculations.")

        try:
            cif_path = self.get_cif_path(symbol)
        except Exception as exc:
            raise self.Error(str(exc))

        # Include spin polarization for O, Cr and Mn (antiferromagnetic)
        # and Fe, Co, and Ni (ferromagnetic).
        # antiferromagnetic Cr, O
        # ferrimagnetic Mn
        spin_mode = "unpolarized"

        if symbol in ["Fe", "Co", "Ni"]:
            spin_mode = "polarized"
            if symbol == "Fe":
                kwargs['spinat'] = 2 * [(0, 0, 2.3)]
            if symbol == "Co":
                kwargs['spinat'] = 2 * [(0, 0, 1.2)]
            if symbol == "Ni":
                kwargs['spinat'] = 4 * [(0, 0, 0.6)]

        if symbol in ["O", "Cr", "Mn"]:
            spin_mode = "afm"
            if symbol == 'O':
                kwargs['spinat'] = [(0, 0, 1.5), (0, 0, 1.5), (0, 0, -1.5), (0, 0, -1.5)]
            elif symbol == 'Cr':
                kwargs['spinat'] = [(0, 0, 1.5), (0, 0, -1.5)]
            elif symbol == 'Mn':
                kwargs['spinat'] = [(0, 0, 2.0), (0, 0, 1.9), (0, 0, -2.0), (0, 0, -1.9)]

        # DO NOT CHANGE THE STRUCTURE REPORTED IN THE CIF FILE.
        structure = Structure.from_file(cif_path, primitive=False)

        # Magnetic elements:
        # Start from previous SCF run to avoid getting trapped in local minima 
        connect = symbol in ("Fe", "Co", "Ni", "Cr", "Mn", "O", "Zn", "Cu")

        return DeltaFactorWork(
            structure, pseudo, kppa, connect,
            spin_mode=spin_mode, toldfe=toldfe, smearing=smearing,
            accuracy=accuracy, ecut=ecut, pawecutdg=pawecutdg, ecutsm=0.5,
            workdir=workdir, manager=manager, **kwargs)
开发者ID:davidwaroquiers,项目名称:pseudo_dojo,代码行数:61,代码来源:works.py

示例3: work_for_pseudo

# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import from_file [as 别名]
    def work_for_pseudo(self, pseudo, kppa=6750, ecut=None, pawecutdg=None,
                        toldfe=1.e-9, smearing="fermi_dirac:0.1 eV", include_soc=False,
                        workdir=None, manager=None, **kwargs):
        """
        Returns a :class:`Work` object from the given pseudopotential.

        Args:
            pseudo: :class:`Pseudo` object.
            kppa: kpoint per reciprocal atom
            ecut: Cutoff energy in Hartree
            pawecutdg: Cutoff energy of the fine grid (PAW only)
            toldfe: Tolerance on the energy (Ha)
            smearing: Smearing technique.
            include_soc: True if pseudo has SO contributions and calculation should be done with nspinor=2
            workdir: String specifing the working directory.
            manager: :class:`TaskManager` responsible for the submission of the tasks.
            kwargs: Extra variables passed to Abinit.

        .. note::

            0.001 Rydberg is the value used with WIEN2K
        """
        symbol = pseudo.symbol
        if pseudo.ispaw and pawecutdg is None:
            raise ValueError("pawecutdg must be specified for PAW calculations.")

        if pseudo.xc != self._dfdb.xc:
            raise ValueError(
                "Pseudo xc differs from the XC used to instantiate the factory\n"
                "Pseudo: %s, Database: %s" % (pseudo.xc, self._dfdb.xc))

        try:
            cif_path = self.get_cif_path(symbol)
        except Exception as exc:
            raise self.Error(str(exc))

        # WARNING: DO NOT CHANGE THE STRUCTURE REPORTED IN THE CIF FILE.
        structure = Structure.from_file(cif_path, primitive=False)

        # Include spin polarization and initial spinat for particular elements
        # TODO: Not sure spinat is ok if LDA.
        kwargs["spinat"], spin_mode = self._dfdb.spinat_spinmode_for_symbol(symbol)
        if include_soc: spin_mode = "spinor"
        # This is needed for LDA
        if symbol in ("O", "Mn"):
            print("Got Oxygen or Mn")
            spin_mode = "polarized"

        # Magnetic elements:
        # Start from previous SCF run to avoid getting trapped in local minima
        connect = symbol in ("Fe", "Co", "Ni", "Cr", "Mn", "O", "Zn", "Cu")

        return DeltaFactorWork(
            structure, pseudo, kppa, connect,
            spin_mode=spin_mode, include_soc=include_soc, toldfe=toldfe, smearing=smearing,
            ecut=ecut, pawecutdg=pawecutdg, ecutsm=0.5,
            workdir=workdir, manager=manager, **kwargs)
开发者ID:gmatteo,项目名称:pseudo_dojo,代码行数:59,代码来源:works.py

示例4: read_structure

# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import from_file [as 别名]
 def read_structure(self):
     from abipy.core.structure import Structure
     return Structure.from_file(self.path)
开发者ID:davidwaroquiers,项目名称:abipy,代码行数:5,代码来源:__init__.py

示例5: structure_from_cif

# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import from_file [as 别名]
def structure_from_cif(filename):
    """
    Returnn an Abipy structure from the basename of the cif file in data/cifs.
    """
    return Structure.from_file(cif_file(filename))
开发者ID:gmatteo,项目名称:abipy,代码行数:7,代码来源:__init__.py


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