def __init__(self, fc2, fc3, supercell, primitive, supercell_extra=None, nac_params=None, nac_q_direction=None, ion_clamped=False, factor=VaspToTHz, symprec=1e-5): self._fc2 = fc2 self._fc3 = fc3 self._scell = supercell if supercell_extra is not None: self._scell_extra = supercell_extra else: self._scell_extra = supercell self._pcell = primitive self._ion_clamped = ion_clamped self._factor = factor self._symprec = symprec if nac_params is None: self._dm = DynamicalMatrix(self._scell_extra, self._pcell, self._fc2, symprec=self._symprec) else: self._dm = DynamicalMatrixNAC(self._scell_extra, self._pcell, self._fc2, symprec=self._symprec) self._dm.set_nac_params(nac_params) self._nac_q_direction = nac_q_direction self._shortest_vectors, self._multiplicity = get_smallest_vectors( self._scell, self._pcell, self._symprec) self._shortest_vectors_extra, self._multiplicity_extra = get_smallest_vectors( self._scell_extra, self._pcell, self._symprec) if self._ion_clamped: num_atom_prim = self._pcell.get_number_of_atoms() self._X = np.zeros((num_atom_prim, 3, 3, 3), dtype=float) else: self._X = self._get_X() self._dPhidu = self._get_dPhidu() self._gruneisen_parameters = None self._frequencies = None self._qpoints = None self._mesh = None self._band_paths = None self._band_distances = None self._run_mode = None self._weights = None
def _run_c(self, g_zero=None): import anharmonic._phono3py as phono3c num_band = self._primitive.get_number_of_atoms() * 3 svecs, multiplicity = get_smallest_vectors(self._supercell, self._primitive, self._symprec) masses = np.array(self._primitive.get_masses(), dtype='double') p2s = self._primitive.get_primitive_to_supercell_map() s2p = self._primitive.get_supercell_to_primitive_map() if g_zero is None: _g_zero = np.zeros(self._interaction_strength.shape, dtype='byte', order='C') else: _g_zero = g_zero phono3c.interaction(self._interaction_strength, _g_zero, self._frequencies, self._eigenvectors, self._triplets_at_q, self._grid_address, self._mesh, self._fc3, svecs, multiplicity, masses, p2s, s2p, self._band_indices, self._symmetrize_fc3_q, self._cutoff_frequency) self._interaction_strength *= self._unit_conversion
def _run_c(self): import anharmonic._phono3py as phono3c self.set_phonon(self._triplets_at_q.ravel()) num_band = self._primitive.get_number_of_atoms() * 3 svecs, multiplicity = get_smallest_vectors(self._supercell, self._primitive, self._symprec) masses = np.array(self._primitive.get_masses(), dtype='double') p2s = self._primitive.get_primitive_to_supercell_map() s2p = self._primitive.get_supercell_to_primitive_map() phono3c.interaction(self._interaction_strength, self._frequencies, self._eigenvectors, self._triplets_at_q, self._grid_address, self._mesh, self._fc3, svecs, multiplicity, masses, p2s, s2p, self._band_indices, self._symmetrize_fc3_q, self._cutoff_frequency) self._interaction_strength *= self._unit_conversion
def _run_c(self): import anharmonic._phono3py as phono3c self.set_phonon(self._triplets_at_q.ravel()) num_band = self._primitive.get_number_of_atoms() * 3 svecs, multiplicity = get_smallest_vectors(self._supercell, self._primitive, self._symprec) masses = np.array(self._primitive.get_masses(), dtype='double') p2s = self._primitive.get_primitive_to_supercell_map() s2p = self._primitive.get_supercell_to_primitive_map() phono3c.interaction(self._interaction_strength, self._frequencies, self._eigenvectors, self._triplets_at_q, self._grid_address, self._mesh, self._fc3, svecs, multiplicity, masses, p2s, s2p, self._band_indices, self._symmetrize_fc3_q, self._cutoff_frequency)
def _calculate_fc4_normal_c(self): import anharmonic._phono4py as phono4c svecs, multiplicity = get_smallest_vectors(self._supercell, self._primitive, self._symprec) p2s = self._primitive.get_primitive_to_supercell_map() s2p = self._primitive.get_supercell_to_primitive_map() gp = self._grid_point self._set_phonon_c([gp]) self._set_phonon_c(self._quartets_at_q) phono4c.fc4_normal_for_frequency_shift( self._fc4_normal, self._frequencies, self._eigenvectors, gp, self._quartets_at_q, self._grid_address, self._mesh, np.double(self._fc4), svecs, multiplicity, self._masses, p2s, s2p, self._band_indices, self._cutoff_frequency)
def __init__(self, primitive, supercell, frequencies=None, eigenvectors=None, symprec=1e-5): self._primitive = primitive self._supercell = supercell supercell_matrix = np.linalg.inv(self._primitive.get_primitive_matrix()) supercell_matrix = np.rint(supercell_matrix).astype("intc") self._commensurate_points = get_commensurate_points(supercell_matrix) (self._shortest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._dynmat = None n = self._supercell.get_number_of_atoms() self._force_constants = np.zeros((n, n, 3, 3), dtype="double") if frequencies is not None and eigenvectors is not None: self.set_dynamical_matrices(frequencies, eigenvectors)
def __init__(self, fc4, supercell, primitive, mesh, symprec=1e-5): self._fc4 = fc4 self._supercell = supercell self._primitive = primitive self._mesh = mesh self._symprec = symprec num_satom = supercell.get_number_of_atoms() self._p2s_map = np.intc(primitive.get_primitive_to_supercell_map()) self._s2p_map = np.intc(primitive.get_supercell_to_primitive_map()) (self._smallest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._quartet = None self._fc4_reciprocal = None
def __init__(self, fc3, supercell, primitive, mesh, symprec=1e-5): self._fc3 = fc3 self._supercell = supercell self._primitive = primitive self._mesh = mesh self._symprec = symprec num_satom = supercell.get_number_of_atoms() self._p2s_map = primitive.get_primitive_to_supercell_map() self._s2p_map = primitive.get_supercell_to_primitive_map() # Reduce supercell atom index to primitive index (self._smallest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._fc3_reciprocal = None
def _calculate_fc4_normal_c(self): import anharmonic._phono4py as phono4c svecs, multiplicity = get_smallest_vectors(self._supercell, self._primitive, self._symprec) p2s = np.intc(self._primitive.get_primitive_to_supercell_map()) s2p = np.intc(self._primitive.get_supercell_to_primitive_map()) gp = self._grid_point self._set_phonon_c([gp]) self._set_phonon_c(self._quartets_at_q) phono4c.fc4_normal_for_frequency_shift( self._fc4_normal, self._frequencies, self._eigenvectors, gp, self._quartets_at_q, self._grid_address, self._mesh, np.double(self._fc4), svecs, multiplicity, self._masses, p2s, s2p, self._band_indices, self._cutoff_frequency)
def __init__( self, supercell, primitive, velocities, symmetry=None, symprec=1e-5 # in m/s either real or reciprocal ): if symmetry is not None: symprec = symmetry.get_symmetry_tolerance() self._point_group_opts = symmetry.get_pointgroup_operations() else: self._point_group_opts = None self._supercell = supercell self._primitive = primitive self._velocities = velocities (self._shortest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._qpoints = None self._weights = None self._velocities_q = None # [timestep, p_atom, qpoitns, 3]
def __init__(self, primitive, supercell, frequencies=None, eigenvectors=None, symprec=1e-5): self._primitive = primitive self._supercell = supercell self._commensurate_points = get_commensurate_points( primitive, supercell) (self._shortest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._dynmat = None n = self._supercell.get_number_of_atoms() self._force_constants = np.zeros((n, n, 3, 3), dtype='double') if frequencies is not None and eigenvectors is not None: self.set_dynamical_matrices(frequencies, eigenvectors)
def __init__(self, fc3, supercell, primitive, mesh, symprec=1e-5): self._fc3 = fc3 self._supercell = supercell self._primitive = primitive self._mesh = mesh self._symprec = symprec num_satom = supercell.get_number_of_atoms() self._p2s_map = primitive.get_primitive_to_supercell_map() self._s2p_map = primitive.get_supercell_to_primitive_map() # Reduce supercell atom index to primitive index try: (self._smallest_vectors, self._multiplicity) = primitive.get_smallest_vectors() except AttributeError: from phonopy.harmonic.dynamical_matrix import get_smallest_vectors (self._smallest_vectors, self._multiplicity) = get_smallest_vectors( supercell, primitive, symprec) self._fc3_reciprocal = None
def _generate_force_constants_site(self): """ natoms_supercell: The number of atoms in the supercell. natoms_primitive: The number of atoms in the primitive cell. """ supercell = self._supercell_average primitive = self._primitive_average natoms_supercell = supercell.get_number_of_atoms() p2s_map = primitive.get_primitive_to_supercell_map() smallest_vectors, multiplicity = get_smallest_vectors( supercell, primitive, symprec=self._symprec) natoms_primitive = primitive.get_number_of_atoms() relative_positions_site = [[] for _ in range(natoms_primitive)] force_constants_site = [[] for _ in range(natoms_primitive)] for index, i in enumerate(p2s_map): for j in range(natoms_supercell): if i == j: continue nsites = multiplicity[j][i] # TODO(ikeda): # "get_fc_tmp" should be renamed. # Finally, force_constants_pair format will change, # and this part should also change. # Instead, new variable fora the correspondence between # the symbols and the order should be given. # TODO(ikeda): # relative_positions should be a "numpy.array". # TODO(ikeda): # Check what happen if we exchange "i" and "j". # Maybe we should take the correspondence to the enlarged # force constants. fc_tmp = get_fc_tmp(i, j, self._force_constants_pair, nsites) for k in range(nsites): relative_positions_site[index].append( smallest_vectors[j][i][k]) force_constants_site[index].append(fc_tmp) self._relative_positions_site = relative_positions_site self._force_constants_site = force_constants_site
def __init__(self, fc3, supercell, primitive, mesh, symprec=1e-5, atom_triplet_cut=None): self._fc3 = fc3 self._supercell = supercell self._primitive = primitive self._mesh = mesh self._symprec = symprec self._atc = atom_triplet_cut # atom_triplet cut (dtype=bool) num_satom = supercell.get_number_of_atoms() self._p2s_map = np.intc(primitive.get_primitive_to_supercell_map()) self._s2p_map = np.intc(primitive.get_supercell_to_primitive_map()) # Reduce supercell atom index to primitive index (self._smallest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._fc3_reciprocal = None
def __init__(self, fc3, supercell, primitive, mesh, symprec=1e-5): self._fc3 = fc3 self._supercell = supercell self._primitive = primitive self._mesh = mesh self._symprec = symprec num_satom = supercell.get_number_of_atoms() self._p2s_map = np.intc(primitive.get_primitive_to_supercell_map()) self._s2p_map = np.intc(primitive.get_supercell_to_primitive_map()) # Reduce supercell atom index to primitive index (self._smallest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._fc3_reciprocal = None
def __init__(self, supercell, primitive, velocities, # in m/s either real or reciprocal symmetry=None, symprec=1e-5): if symmetry is not None: symprec = symmetry.get_symmetry_tolerance() self._point_group_opts = symmetry.get_pointgroup_operations() else: self._point_group_opts = None self._supercell = supercell self._primitive = primitive self._velocities = velocities (self._shortest_vectors, self._multiplicity) = get_smallest_vectors(supercell, primitive, symprec) self._qpoints = None self._weights = None self._velocities_q = None # [timestep, p_atom, qpoitns, 3]
def __init__(self, fc3, supercell, primitive, mesh, band_indices=None, frequency_factor_to_THz=VaspToTHz, is_nosym=False, symmetrize_fc3_q=False, symprec=1e-3, triplet_cut_super = None, triplet_cut_prim = None, cutoff_frequency=None, cutoff_hfrequency=None, cutoff_delta = None, is_triplets_dispersed=False, is_read_amplitude=False, is_write_amplitude = False, is_triplets_permute=True, lapack_zheev_uplo='L'): self._fc3 = fc3 self._supercell = supercell self._primitive = primitive self._mesh = np.intc(mesh) num_band = primitive.get_number_of_atoms() * 3 if band_indices is None: self._band_indices = np.arange(num_band, dtype='intc') else: self._band_indices = band_indices.astype("intc") self._frequency_factor_to_THz = frequency_factor_to_THz self._symprec = symprec self._is_tripelts_permute=is_triplets_permute natom_super = supercell.get_number_of_atoms() natom_prim = primitive.get_number_of_atoms() if triplet_cut_super is None: self._triplet_cut_super=np.zeros((natom_super, natom_super, natom_super), dtype='bool') else: self._triplet_cut_super=triplet_cut_super if triplet_cut_prim is None: self._triplet_cut_prim=np.zeros((natom_prim, natom_prim, natom_prim), dtype='bool') else: self._triplet_cut_prim=triplet_cut_prim if cutoff_delta is None: self._cutoff_delta = 1000.0 else: self._cutoff_delta = cutoff_delta if cutoff_frequency is None: self._cutoff_frequency = 0 else: self._cutoff_frequency = cutoff_frequency if cutoff_hfrequency is None: self._cutoff_hfrequency = 10000.0 # THz elif symmetrize_fc3_q: print "Warning: symmetryze_fc3_q and cutoff_hfrequency are not compatible" self._cutoff_hfrequency = 10000.0 else: self._cutoff_hfrequency = cutoff_hfrequency self._is_nosym = is_nosym self._symmetrize_fc3_q = symmetrize_fc3_q self._lapack_zheev_uplo = lapack_zheev_uplo self._symmetry = Symmetry(primitive, symprec=symprec) if self._is_nosym: self._point_group_operations = np.array([np.eye(3)],dtype="intc") self._kpoint_operations = get_kpoint_group(self._mesh, self._point_group_operations, is_time_reversal=False) else: self._point_group_operations = self._symmetry.get_pointgroup_operations() self._kpoint_operations = get_kpoint_group(self._mesh, self._point_group_operations) if self.is_nosym(): grid_mapping = np.arange(np.prod(self._mesh)) grid_mapping_rots = np.zeros(len(grid_mapping), dtype="intc") else: grid_mapping, grid_mapping_rots = get_mappings(self._mesh, self.get_point_group_operations(), qpoints=np.array([0,0,0],dtype="double")) self._svecs, self._multiplicity = get_smallest_vectors(self._supercell, self._primitive, self._symprec) self._grid_mapping = grid_mapping self._grid_mapping_rot = grid_mapping_rots self._is_read_amplitude = is_read_amplitude self._is_write_amplitude = is_write_amplitude self._grid_point = None self._triplets_at_q = None self._weights_at_q = None self._grid_address = None self._interaction_strength = None self._phonon_done = None self._frequencies = None self._eigenvectors = None self._degenerates = None self._grid_points = None self._dm = None self._nac_q_direction = None self._triplets = None self._triplets_mappings = None self._triplets_sequence = None self._unique_triplets = None self._amplitude_all = None self._is_dispersed = is_triplets_dispersed self._allocate_phonon()
def __init__(self, supercell, primitive, mesh, symmetry, fc3=None, band_indices=None, constant_averaged_interaction=None, frequency_factor_to_THz=VaspToTHz, unit_conversion=None, is_mesh_symmetry=True, symmetrize_fc3_q=False, cutoff_frequency=None, lapack_zheev_uplo='L'): self._fc3 = fc3 self._supercell = supercell self._primitive = primitive self._mesh = np.array(mesh, dtype='intc') self._symmetry = symmetry self._band_indices = None self._set_band_indices(band_indices) self._constant_averaged_interaction = constant_averaged_interaction self._frequency_factor_to_THz = frequency_factor_to_THz # Unit to eV^2 if unit_conversion is None: num_grid = np.prod(self._mesh) self._unit_conversion = ((Hbar * EV) ** 3 / 36 / 8 * EV ** 2 / Angstrom ** 6 / (2 * np.pi * THz) ** 3 / AMU ** 3 / num_grid / EV ** 2) else: self._unit_conversion = unit_conversion if cutoff_frequency is None: self._cutoff_frequency = 0 else: self._cutoff_frequency = cutoff_frequency self._is_mesh_symmetry = is_mesh_symmetry self._symmetrize_fc3_q = symmetrize_fc3_q self._lapack_zheev_uplo = lapack_zheev_uplo self._symprec = symmetry.get_symmetry_tolerance() self._grid_point = None self._triplets_at_q = None self._weights_at_q = None self._triplets_map_at_q = None self._ir_map_at_q = None self._grid_address = None self._bz_map = None self._interaction_strength = None self._phonon_done = None self._frequencies = None self._eigenvectors = None self._dm = None self._nac_q_direction = None self._band_index_count = 0 try: svecs, multiplicity = self._primitive.get_smallest_vectors() except AttributeError: from phonopy.harmonic.dynamical_matrix import get_smallest_vectors svecs, multiplicity = get_smallest_vectors(self._supercell, self._primitive, self._symprec) self._smallest_vectors = svecs self._multiplicity = multiplicity self._masses = np.array(self._primitive.get_masses(), dtype='double') self._p2s = self._primitive.get_primitive_to_supercell_map() self._s2p = self._primitive.get_supercell_to_primitive_map() self._allocate_phonon()