本文整理匯總了Python中phonopy.Phonopy.get_primitive方法的典型用法代碼示例。如果您正苦於以下問題:Python Phonopy.get_primitive方法的具體用法?Python Phonopy.get_primitive怎麽用?Python Phonopy.get_primitive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類phonopy.Phonopy
的用法示例。
在下文中一共展示了Phonopy.get_primitive方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: obtain_eigenvectors_from_phonopy
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_primitive [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_NaCl
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_primitive [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
示例3: obtain_phonon_dispersion_spectra
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_primitive [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()
示例4: Phonopy
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_primitive [as 別名]
phonon = Phonopy(unitcell,
[[2, 0, 0],
[0, 2, 0],
[0, 0, 2]],
primitive_matrix=[[0, 0.5, 0.5],
[0.5, 0, 0.5],
[0.5, 0.5, 0]])
symmetry = phonon.get_symmetry()
print "Space group:", symmetry.get_international_table()
force_sets = parse_FORCE_SETS()
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
primitive = phonon.get_primitive()
# Born effective charges and dielectric constants are read from BORN file.
nac_params = parse_BORN(primitive, filename="BORN")
# Or it can be of course given by hand as follows:
# born = [[[1.08703, 0, 0],
# [0, 1.08703, 0],
# [0, 0, 1.08703]],
# [[-1.08672, 0, 0],
# [0, -1.08672, 0],
# [0, 0, -1.08672]]]
# epsilon = [[2.43533967, 0, 0],
# [0, 2.43533967, 0],
# [0, 0, 2.43533967]]
# factors = 14.400
# nac_params = {'born': born,
示例5: parse_FORCE_SETS
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_primitive [as 別名]
print "Space group:", symmetry.get_international_table()
# Read and convert forces and displacements
force_sets = parse_FORCE_SETS(cell.get_number_of_atoms() * 4)
# Sets of forces have to be set before phonon.set_post_process or
# at phonon.set_post_process(..., sets_of_forces=sets_of_forces, ...).
phonon.set_force_sets(force_sets)
# To activate non-analytical term correction.
phonon.set_post_process(primitive_matrix=[[2./3, -1./3, -1./3],
[1./3, 1./3, -2./3],
[1./3, 1./3, 1./3]])
# Parameters for non-analytical term correction can be set
# also after phonon.set_post_process
born = parse_BORN(phonon.get_primitive())
phonon.set_nac_params(born)
# Example to obtain dynamical matrix
dmat = phonon.get_dynamical_matrix_at_q([0,0,0])
print dmat
# Example of band structure calculation
bands = []
q_start = np.array([1./3, 1./3, 0])
q_end = np.array([0, 0, 0])
band = []
for i in range(51):
band.append(q_start + (q_end - q_start) / 50 * i)
bands.append(band)
示例6: read_vasp_from_strings
# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import get_primitive [as 別名]
-1.9721233333333332 0 0 0 -1.9721233333333332 0 0 0 -1.9721233333333332"""
#
# initial settings
#
cell = read_vasp_from_strings(poscar_str)
phonon = Phonopy(cell, np.diag([2, 2, 2]))
force_sets = parse_FORCE_SETS_from_strings(force_sets_str,
cell.get_number_of_atoms() * 8)
phonon.set_force_sets(force_sets)
phonon.set_post_process(primitive_matrix=[[0, 0.5, 0.5],
[0.5, 0, 0.5],
[0.5, 0.5, 0]],
is_nac=True)
born_params = parse_BORN_from_strings(born_str,
phonon.get_primitive())
phonon.set_nac_params(born_params)
print phonon.get_symmetry().get_international_table()
primitive = phonon.get_primitive()
reclat = np.linalg.inv(primitive.get_cell())
print reclat
ndiv = 100
band = get_band([0.0, 0.0, 0.0], [0.5, 0.5, 0.0], ndiv)
bands = [band]
phonon.set_band_structure(bands)
#
# Run1
#