本文整理汇总了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
示例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