本文整理匯總了Python中phonopy.Phonopy.produce_force_constants方法的典型用法代碼示例。如果您正苦於以下問題:Python Phonopy.produce_force_constants方法的具體用法?Python Phonopy.produce_force_constants怎麽用?Python Phonopy.produce_force_constants使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phonopy.Phonopy
的用法示例。
在下文中一共展示了Phonopy.produce_force_constants方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: obtain_eigenvectors_from_phonopy
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def obtain_eigenvectors_from_phonopy(structure, q_vector, NAC=False):
# Checking data
force_atoms_file = structure.get_force_set().item(0)["natom"]
force_atoms_input = np.product(np.diagonal(structure.get_super_cell_phonon())) * structure.get_number_of_atoms()
if force_atoms_file != force_atoms_input:
print("Error: FORCE_SETS file does not match with SUPERCELL MATRIX")
exit()
# Preparing the bulk type object
bulk = PhonopyAtoms(
symbols=structure.get_atomic_types(),
scaled_positions=structure.get_scaled_positions(),
cell=structure.get_cell().T,
)
phonon = Phonopy(
bulk,
structure.get_super_cell_phonon(),
primitive_matrix=structure.get_primitive_matrix(),
is_auto_displacements=False,
)
# Non Analytical Corrections (NAC) from Phonopy [Frequencies only, eigenvectors no affected by this option]
if NAC:
print("Phonopy warning: Using Non Analytical Corrections")
get_is_symmetry = True # from phonopy: settings.get_is_symmetry()
primitive = phonon.get_primitive()
nac_params = parse_BORN(primitive, get_is_symmetry)
phonon.set_nac_params(nac_params=nac_params)
phonon.set_displacement_dataset(copy.deepcopy(structure.get_force_set()))
phonon.produce_force_constants()
frequencies, eigenvectors = phonon.get_frequencies_with_eigenvectors(q_vector)
# Making sure eigenvectors are orthonormal (can be omitted)
if True:
eigenvectors = eigenvectors_normalization(eigenvectors)
print("Testing eigenvectors orthonormality")
np.set_printoptions(precision=3, suppress=True)
print(np.dot(eigenvectors.T, np.ma.conjugate(eigenvectors)).real)
np.set_printoptions(suppress=False)
# Arranging eigenvectors by atoms and dimensions
number_of_dimensions = structure.get_number_of_dimensions()
number_of_primitive_atoms = structure.get_number_of_primitive_atoms()
arranged_ev = np.array(
[
[
[eigenvectors[j * number_of_dimensions + k, i] for k in range(number_of_dimensions)]
for j in range(number_of_primitive_atoms)
]
for i in range(number_of_primitive_atoms * number_of_dimensions)
]
)
return arranged_ev, frequencies
示例2: _get_phonon
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def _get_phonon(self, cell):
phonon = Phonopy(cell,
np.diag([2, 2, 2]),
primitive_matrix=[[0, 0.5, 0.5],
[0.5, 0, 0.5],
[0.5, 0.5, 0]])
force_sets = parse_FORCE_SETS(filename=os.path.join(data_dir,"FORCE_SETS_moment"))
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
supercell = phonon.get_supercell()
born_elems = {'Na': [[1.08703, 0, 0],
[0, 1.08703, 0],
[0, 0, 1.08703]],
'Cl': [[-1.08672, 0, 0],
[0, -1.08672, 0],
[0, 0, -1.08672]]}
born = [born_elems[s] for s in ['Na', 'Cl']]
epsilon = [[2.43533967, 0, 0],
[0, 2.43533967, 0],
[0, 0, 2.43533967]]
factors = 14.400
phonon.set_nac_params({'born': born,
'factor': factors,
'dielectric': epsilon})
return phonon
示例3: _get_phonon
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def _get_phonon(self, cell):
phonon = Phonopy(cell,
np.diag([1, 1, 1]),
is_auto_displacements=False)
force_sets = parse_FORCE_SETS()
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
return phonon
示例4: _get_phonon
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def _get_phonon(self, spgtype, dim, pmat):
cell = read_vasp(os.path.join(data_dir,"POSCAR_%s" % spgtype))
phonon = Phonopy(cell,
np.diag(dim),
primitive_matrix=pmat)
force_sets = parse_FORCE_SETS(filename=os.path.join(data_dir,"FORCE_SETS_%s" % spgtype))
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
return phonon
示例5: _get_phonon_NaCl
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def _get_phonon_NaCl(self):
cell = read_vasp(os.path.join(data_dir, "..", "POSCAR_NaCl"))
phonon = Phonopy(cell,
np.diag([2, 2, 2]),
primitive_matrix=[[0, 0.5, 0.5],
[0.5, 0, 0.5],
[0.5, 0.5, 0]])
filename = os.path.join(data_dir, "..", "FORCE_SETS_NaCl")
force_sets = parse_FORCE_SETS(filename=filename)
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
filename_born = os.path.join(data_dir, "..", "BORN_NaCl")
nac_params = parse_BORN(phonon.get_primitive(), filename=filename_born)
phonon.set_nac_params(nac_params)
return phonon
示例6: test_properties
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def test_properties(self):
cell = read_vasp(os.path.join(data_dir, "..", "POSCAR_NaCl"))
phonon = Phonopy(cell,
np.diag([2, 2, 2]),
primitive_matrix=[[0, 0.5, 0.5],
[0.5, 0, 0.5],
[0.5, 0.5, 0]])
filename = os.path.join(data_dir, "..", "FORCE_SETS_NaCl")
force_sets = parse_FORCE_SETS(filename=filename)
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
dynmat = phonon.dynamical_matrix
dynmat.set_dynamical_matrix([0, 0, 0])
self.assertTrue(id(dynmat.primitive)
== id(dynmat.get_primitive()))
self.assertTrue(id(dynmat.supercell)
== id(dynmat.get_supercell()))
np.testing.assert_allclose(dynmat.dynamical_matrix,
dynmat.get_dynamical_matrix())
示例7: _get_phonon
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def _get_phonon(self, cell):
phonon = Phonopy(cell, np.diag([1, 1, 1]))
force_sets = parse_FORCE_SETS(
filename=os.path.join(data_dir, "FORCE_SETS"))
phonon.dataset = force_sets
phonon.produce_force_constants()
supercell = phonon.get_supercell()
born_elems = {'Na': [[1.08703, 0, 0],
[0, 1.08703, 0],
[0, 0, 1.08703]],
'Cl': [[-1.08672, 0, 0],
[0, -1.08672, 0],
[0, 0, -1.08672]]}
born = [born_elems[s]
for s in supercell.get_chemical_symbols()]
epsilon = [[2.43533967, 0, 0],
[0, 2.43533967, 0],
[0, 0, 2.43533967]]
factors = 14.400
phonon.set_nac_params({'born': born,
'factor': factors,
'dielectric': epsilon})
return phonon
示例8: obtain_phonon_dispersion_spectra
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
def obtain_phonon_dispersion_spectra(structure, bands_ranges, NAC=False, band_resolution=30):
print("Calculating phonon dispersion spectra...")
bulk = PhonopyAtoms(
symbols=structure.get_atomic_types(),
scaled_positions=structure.get_scaled_positions(),
cell=structure.get_cell().T,
)
phonon = Phonopy(
bulk,
structure.get_super_cell_phonon(),
primitive_matrix=structure.get_primitive_matrix(),
is_auto_displacements=False,
)
if NAC:
print("Phonopy warning: Using Non Analitical Corrections")
print("BORN file is needed to do this")
get_is_symmetry = True # sfrom phonopy: settings.get_is_symmetry()
primitive = phonon.get_primitive()
nac_params = parse_BORN(primitive, get_is_symmetry)
phonon.set_nac_params(nac_params=nac_params)
phonon.set_displacement_dataset(copy.deepcopy(structure.get_force_set()))
phonon.produce_force_constants()
bands = []
for q_start, q_end in bands_ranges:
band = []
for i in range(band_resolution + 1):
band.append(np.array(q_start) + (np.array(q_end) - np.array(q_start)) / band_resolution * i)
bands.append(band)
phonon.set_band_structure(bands)
return phonon.get_band_structure()
示例9: read_vasp
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
from phonopy import Phonopy
from phonopy.interface.vasp import read_vasp
from phonopy.file_IO import parse_FORCE_SETS
from phonopy.file_IO import parse_FORCE_CONSTANTS, write_FORCE_CONSTANTS
cell = read_vasp("POSCAR")
phonon = Phonopy(cell, [[2, 0, 0], [0, 2, 0], [0, 0, 2]])
force_sets = parse_FORCE_SETS()
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
write_FORCE_CONSTANTS(phonon.get_force_constants(), filename="FORCE_CONSTANTS")
force_constants = parse_FORCE_CONSTANTS()
phonon.set_force_constants(force_constants)
phonon.symmetrize_force_constants(iteration=1)
write_FORCE_CONSTANTS(phonon.get_force_constants(), filename="FORCE_CONSTANTS_NEW")
示例10: Atoms
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import produce_force_constants [as 別名]
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]
set_of_forces.append(forces)
# Phonopy post-process
phonon.produce_force_constants(forces=set_of_forces)
print
print "[Phonopy] Phonon frequencies at Gamma:"
for i, freq in enumerate(phonon.get_frequencies((0, 0, 0))):
print "[Phonopy] %3d: %10.5f THz" % (i + 1, freq) # THz