當前位置: 首頁>>代碼示例>>Python>>正文


Python Structure.from_sites方法代碼示例

本文整理匯總了Python中abipy.core.structure.Structure.from_sites方法的典型用法代碼示例。如果您正苦於以下問題:Python Structure.from_sites方法的具體用法?Python Structure.from_sites怎麽用?Python Structure.from_sites使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在abipy.core.structure.Structure的用法示例。


在下文中一共展示了Structure.from_sites方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: scf_for_phonons

# 需要導入模塊: from abipy.core.structure import Structure [as 別名]
# 或者: from abipy.core.structure.Structure import from_sites [as 別名]
def scf_for_phonons(structure, pseudos, kppa=None, ecut=None, pawecutdg=None, nband=None, accuracy="normal",
                    spin_mode="polarized", smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None,
                    shift_mode="Symmetric"):
    abiinput = scf_input(structure=structure, pseudos=pseudos, kppa=kppa, ecut=ecut, pawecutdg=pawecutdg, nband=nband,
                         accuracy=accuracy, spin_mode=spin_mode, smearing=smearing, charge=charge,
                         scf_algorithm=scf_algorithm, shift_mode=shift_mode)
    # set symmetrized k-point
    if shift_mode[0].lower() == 's':
        # need to convert to abipy structure to get the calc_shiftk method
        structure = Structure.from_sites(structure)
        shiftk = structure.calc_shiftk()
        abiinput.set_vars(shiftk=shiftk, nshiftk=len(shiftk))

    # enforce symmetries and add a buffer of bands to ease convergence with tolwfr
    abiinput.set_vars(chksymbreak=1, nbdbuf=4, tolwfr=1.e-22)

    return abiinput
開發者ID:akakcolin,項目名稱:abipy,代碼行數:19,代碼來源:factories.py

示例2: cube_read_structure_mesh_data

# 需要導入模塊: from abipy.core.structure import Structure [as 別名]
# 或者: from abipy.core.structure.Structure import from_sites [as 別名]
def cube_read_structure_mesh_data(file):
    with open(file, 'r') as fh:
        # The two first lines are comments
        for ii in range(2):
            fh.readline()
        # Number of atoms
        natoms = int(fh.readline().split()[0])
        # The next three lines give the mesh and the vectors
        sp = fh.readline().split()
        nx = int(sp[0])
        dvx = np.array([float(sp[ii]) for ii in range(1, 4)]) * bohr_to_angstrom
        sp = fh.readline().split()
        ny = int(sp[0])
        dvy = np.array([float(sp[ii]) for ii in range(1, 4)]) * bohr_to_angstrom
        sp = fh.readline().split()
        nz = int(sp[0])
        dvz = np.array([float(sp[ii]) for ii in range(1, 4)]) * bohr_to_angstrom
        uc_matrix = np.array([nx*dvx, ny*dvy, nz*dvz])
        sites = []
        lattice = Lattice(uc_matrix)
        for ii in range(natoms):
            sp = fh.readline().split()
            cc = np.array([float(sp[ii]) for ii in range(2, 5)]) * bohr_to_angstrom
            sites.append(PeriodicSite(int(sp[0]), coords=cc, lattice=lattice, to_unit_cell=False,
                                      coords_are_cartesian=True))
        data = np.zeros((nx, ny, nz))
        ii = 0
        for line in fh:
            for val in line.split():
                data[ii//(ny*nz), (ii//nz)%ny, ii%nz] = float(val)
                ii += 1
        data = data / (bohr_to_angstrom ** 3)
        if ii != nx*ny*nz:
            raise ValueError('Wrong number of data points ...')
        from abipy.core.structure import Structure
        structure = Structure.from_sites(sites=sites)
        from abipy.core.mesh3d import Mesh3D
        mesh = Mesh3D(shape=[nx, ny, nz], vectors=uc_matrix)

        return structure, mesh, data
開發者ID:gmatteo,項目名稱:abipy,代碼行數:42,代碼來源:cube.py


注:本文中的abipy.core.structure.Structure.from_sites方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。