本文整理匯總了Python中phonopy.Phonopy.set_displacement_dataset方法的典型用法代碼示例。如果您正苦於以下問題:Python Phonopy.set_displacement_dataset方法的具體用法?Python Phonopy.set_displacement_dataset怎麽用?Python Phonopy.set_displacement_dataset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phonopy.Phonopy
的用法示例。
在下文中一共展示了Phonopy.set_displacement_dataset方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_phonon
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_displacement_dataset [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
示例2: obtain_eigenvectors_from_phonopy
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_displacement_dataset [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
示例3: _get_phonon
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_displacement_dataset [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 set_displacement_dataset [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 set_displacement_dataset [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 set_displacement_dataset [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: obtain_phonon_dispersion_spectra
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_displacement_dataset [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()
示例8: read_vasp
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_displacement_dataset [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")
示例9: PhononFC3Base
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_displacement_dataset [as 別名]
#.........這裏部分代碼省略.........
pass
def done(self):
return (self._status == "terminate" or
self._status == "done" or
self._status == "max_iteration" or
self._status == "next" or
self._status == "imaginary_mode")
def __next__(self):
return self.next()
def next(self):
if self._stage == 0:
if "next" in self._status:
self._energy = self._tasks[0].get_energy()
self._comment = "%s\\n%f" % (
self._tasks[0].get_space_group()['international'],
self._energy)
self._set_stage1()
return self._tasks
elif "terminate" in self._status and self._traverse == "restart":
self._traverse = False
self._set_stage0()
return self._tasks
else:
raise StopIteration
elif self._stage == 1:
if "next" in self._status:
disp_dataset = self._phonon_fc3.get_displacement_dataset()
for disp1, task in zip(disp_dataset['first_atoms'], self._tasks):
disp1['forces'] = task.get_properties()['forces'][-1]
write_FORCE_SETS(disp_dataset)
self._phonon.set_displacement_dataset(disp_dataset)
self._phonon.produce_force_constants(
calculate_full_force_constants=False)
if self._exist_imaginary_mode():
self._status = "imaginary_mode"
self._write_yaml()
self._tasks = []
raise StopIteration
else:
self._set_stage2()
return self._tasks
elif "terminate" in self._status and self._traverse == "restart":
self._reset_stage1()
return self._tasks
else:
raise StopIteration
elif self._stage == 2:
if "next" in self._status:
self._status = "done"
forces_fc3 = []
for i, task in enumerate(self._phonon_fc3_tasks[1:]):
forces_fc3.append(task.get_properties()['forces'][-1])
disp_dataset = self._phonon_fc3.get_displacement_dataset()
write_FORCES_FC3(disp_dataset, forces_fc3)
self._tasks = []
raise StopIteration
elif "terminate" in self._status and self._traverse == "restart":
self._reset_stage2()
return self._tasks
else:
raise StopIteration
else: # stage2
pass