本文整理匯總了Python中phonopy.Phonopy.get_supercells_with_displacements方法的典型用法代碼示例。如果您正苦於以下問題:Python Phonopy.get_supercells_with_displacements方法的具體用法?Python Phonopy.get_supercells_with_displacements怎麽用?Python Phonopy.get_supercells_with_displacements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phonopy.Phonopy
的用法示例。
在下文中一共展示了Phonopy.get_supercells_with_displacements方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_displaced_structures
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_supercells_with_displacements [as 別名]
def get_displaced_structures(pmg_structure, atom_disp=0.01,
supercell_matrix=None, yaml_fname=None, **kwargs):
"""
Generate a set of symmetrically inequivalent displaced structures for
phonon calculations.
Args:
pmg_structure (Structure): A pymatgen structure object.
atom_disp (float): Atomic displacement. Default is 0.01 $\\AA$.
supercell_matrix (3x3 array): Scaling matrix for supercell.
yaml_fname (string): If not None, it represents the full path to
the outputting displacement yaml file, e.g. disp.yaml.
**kwargs: Parameters used in Phonopy.generate_displacement method.
Return:
A list of symmetrically inequivalent structures with displacements, in
which the first element is the perfect supercell structure.
"""
is_plusminus = kwargs.get("is_plusminus", "auto")
is_diagonal = kwargs.get("is_diagonal", True)
is_trigonal = kwargs.get("is_trigonal", False)
ph_structure = get_phonopy_structure(pmg_structure)
if supercell_matrix is None:
supercell_matrix = np.eye(3) * np.array((1, 1, 1))
phonon = Phonopy(unitcell=ph_structure, supercell_matrix=supercell_matrix)
phonon.generate_displacements(distance=atom_disp,
is_plusminus=is_plusminus,
is_diagonal=is_diagonal,
is_trigonal=is_trigonal)
if yaml_fname is not None:
displacements = phonon.get_displacements()
directions = phonon.get_displacement_directions()
write_disp_yaml(displacements=displacements,
supercell=phonon.get_supercell(),
directions=directions, filename=yaml_fname)
# Supercell structures with displacement
disp_supercells = phonon.get_supercells_with_displacements()
# Perfect supercell structure
init_supercell = phonon.get_supercell()
# Structure list to be returned
structure_list = [get_pmg_structure(init_supercell)]
for c in disp_supercells:
if c is not None:
structure_list.append(get_pmg_structure(c))
return structure_list
示例2: GPAW
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_supercells_with_displacements [as 別名]
calc = GPAW(mode=PW(300),
kpts={'size': (4, 4, 4)},
symmetry={'symmorphic': False})
phonon = Phonopy(bulk,
[[1,0,0],[0,1,0],[0,0,1]],
primitive_matrix=[[0, 0.5, 0.5],
[0.5, 0, 0.5],
[0.5, 0.5, 0]],
distance=0.01)
print "[Phonopy] Atomic displacements:"
disps = phonon.get_displacements()
for d in disps:
print "[Phonopy]", d[0], d[1:]
supercells = phonon.get_supercells_with_displacements()
# Force calculations by calculator
set_of_forces = []
for scell in supercells:
cell = Atoms(symbols=scell.get_chemical_symbols(),
scaled_positions=scell.get_scaled_positions(),
cell=scell.get_cell(),
pbc=True)
cell.set_calculator(calc)
forces = cell.get_forces()
drift_force = forces.sum(axis=0)
print "[Phonopy] Drift force:", "%11.5f"*3 % tuple(drift_force)
# Simple translational invariance
for force in forces:
force -= drift_force / forces.shape[0]