當前位置: 首頁>>代碼示例>>Python>>正文


Python phonopy.Phonopy類代碼示例

本文整理匯總了Python中phonopy.Phonopy的典型用法代碼示例。如果您正苦於以下問題:Python Phonopy類的具體用法?Python Phonopy怎麽用?Python Phonopy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Phonopy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_phonon

 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
開發者ID:Johnson-Wang,項目名稱:phonopy,代碼行數:8,代碼來源:test_unfolding.py

示例2: _get_phonon

 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
開發者ID:gcgs1,項目名稱:phonopy,代碼行數:9,代碼來源:test_tetrahedron_mesh.py

示例3: obtain_eigenvectors_from_phonopy

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
開發者ID:vanceeasleaf,項目名稱:DynaPhoPy,代碼行數:60,代碼來源:phonopy_link.py

示例4: _get_phonon

 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
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例5: _set_phonon

    def _set_phonon(self):
        if self._supercell_matrix is None:
            cell = sort_cell_by_symbols(
                get_crystallographic_cell(self.get_cell()))
            self._supercell_matrix = estimate_supercell_matrix(
                cell,
                max_num_atoms=self._max_num_atoms)
        else:
            cell = self.get_cell()

        phonopy_cell = cell2atoms(cell)
        self._phonon = Phonopy(phonopy_cell,
                               self._supercell_matrix,
                               primitive_matrix=self._primitive_matrix,
                               dynamical_matrix_decimals=14,
                               force_constants_decimals=14,
                               symprec=self._symmetry_tolerance)
        self._phonon.generate_displacements(
            distance=self._distance,
            is_plusminus=self._displace_plusminus,
            is_diagonal=self._displace_diagonal)
        supercell = self._phonon.get_supercell()
        displacements = self._phonon.get_displacements()

        write_poscar(cell, filename="POSCAR-unitcell")
        write_poscar_yaml(cell, filename="POSCAR-unitcell.yaml")
        write_disp_yaml(displacements, supercell)
開發者ID:atztogo,項目名稱:cogue,代碼行數:27,代碼來源:phonon.py

示例6: phonopy_pre_process

def phonopy_pre_process(cell, supercell_matrix=None):

    if supercell_matrix is None:
        smat = [[2,0,0], [0,2,0], [0,0,2]],
    else:
        smat = supercell_matrix
    phonon = Phonopy(cell,
                     smat,
                     primitive_matrix=[[0, 0.5, 0.5],
                                       [0.5, 0, 0.5],
                                       [0.5, 0.5, 0]])
    phonon.generate_displacements(distance=0.03)
    print("[Phonopy] Atomic displacements:")
    disps = phonon.get_displacements()
    for d in disps:
        print("[Phonopy] %d %s" % (d[0], d[1:]))
    return phonon
開發者ID:atztogo,項目名稱:phonopy,代碼行數:17,代碼來源:8Si-phonon.py

示例7: test_properties

 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())
開發者ID:atztogo,項目名稱:phonopy,代碼行數:19,代碼來源:test_dynamical_matrix.py

示例8: get_displaced_structures

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
開發者ID:ExpHP,項目名稱:pymatgen,代碼行數:53,代碼來源:phonopy.py

示例9: get_phonopy_qha

def get_phonopy_qha(energies, volumes, force_constants, structure, t_min, t_step, t_max, mesh, eos,
                      pressure=0):
    """
    Return phonopy QHA interface.

    Args:
        energies (list):
        volumes (list):
        force_constants (list):
        structure (Structure):
        t_min (float): min temperature
        t_step (float): temperature step
        t_max (float): max temperature
        mesh (list/tuple): reciprocal space density
        eos (str): equation of state used for fitting the energies and the volumes.
            options supported by phonopy: vinet, murnaghan, birch_murnaghan
        pressure (float): in GPa, optional.

    Returns:
        PhonopyQHA
    """
    from phonopy import Phonopy
    from phonopy.structure.atoms import Atoms as PhonopyAtoms
    from phonopy import PhonopyQHA
    from phonopy.units import EVAngstromToGPa

    phon_atoms = PhonopyAtoms(symbols=[str(s.specie) for s in structure],
                              scaled_positions=structure.frac_coords,
                              cell=structure.lattice.matrix)
    scell = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
    phonon = Phonopy(phon_atoms, scell)
    # compute the required phonon thermal properties
    temperatures = []
    free_energy = []
    entropy = []
    cv = []
    for f in force_constants:
        phonon.set_force_constants(-np.array(f))
        phonon.set_mesh(list(mesh))
        phonon.set_thermal_properties(t_step=t_step, t_min=t_min, t_max=t_max)
        t, g, e, c = phonon.get_thermal_properties()
        temperatures.append(t)
        free_energy.append(g)
        entropy.append(e)
        cv.append(c)

    # add pressure contribution
    energies = np.array(energies) + np.array(volumes) * pressure / EVAngstromToGPa
    # quasi-harmonic approx
    return PhonopyQHA(volumes, energies, eos=eos, temperatures=temperatures[0],
                      free_energy=np.array(free_energy).T, cv=np.array(cv).T,
                      entropy=np.array(entropy).T, t_max=np.max(temperatures[0]))
開發者ID:montoyjh,項目名稱:MatMethods,代碼行數:52,代碼來源:phonopy.py

示例10: _get_phonon_NaCl

 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
開發者ID:atztogo,項目名稱:phonopy,代碼行數:15,代碼來源:test_random_displacements.py

示例11: get_frequency

def get_frequency(poscar_filename, force_sets_filename):
    bulk = read_vasp(poscar_filename)
    volume = bulk.get_volume()
    phonon = Phonopy(bulk, [[2, 0, 0], [0, 2, 0], [0, 0, 2]],
                     is_auto_displacements=False)
    force_sets = parse_FORCE_SETS(filename=force_sets_filename)
    phonon.set_force_sets(force_sets)
    phonon.set_post_process([[0, 0.5, 0.5], [0.5, 0, 0.5], [0.5, 0.5, 0]])
    return phonon.get_frequencies([0.5, 0.5, 0]), volume
開發者ID:Johnson-Wang,項目名稱:phonopy,代碼行數:9,代碼來源:Si.py

示例12: _set_phonon

    def _set_phonon(self):
        cell = self.get_cell()
        phonopy_cell = Atoms(
            cell=cell.get_lattice().T,
            scaled_positions=cell.get_points().T,
            symbols=cell.get_symbols())
        
        self._phonon = Phonopy(phonopy_cell,
                               self._supercell_matrix,
                               is_auto_displacements=False)
        self._phonon.generate_displacements(distance=self._distance,
                                            is_diagonal=False)

        supercell = self._phonon.get_supercell()
        displacements = self._phonon.get_displacements()

        write_poscar(cell, "POSCAR-unitcell")
        write_disp_yaml(displacements, supercell)
開發者ID:mgtekns,項目名稱:cogue,代碼行數:18,代碼來源:phonon.py

示例13: _set_phonon

    def _set_phonon(self):
        cell = self.get_cell()
        phonopy_cell = cell2atoms(cell)
        self._phonon = Phonopy(phonopy_cell,
                               self._supercell_matrix,
                               primitive_matrix=self._primitive_matrix,
                               is_auto_displacements=False,
                               dynamical_matrix_decimals=14,
                               force_constants_decimals=14)
        self._phonon.generate_displacements(
            distance=self._distance,
            is_plusminus=self._displace_plusminus,
            is_diagonal=self._displace_diagonal)
        supercell = self._phonon.get_supercell()
        displacements = self._phonon.get_displacements()

        write_poscar(cell, "POSCAR-unitcell")
        write_disp_yaml(displacements, supercell)
開發者ID:vanceeasleaf,項目名稱:cogue,代碼行數:18,代碼來源:phonon.py

示例14: _set_phonon_fc3

 def _set_phonon_fc3(self):
     cell = self.get_cell()
     phonopy_cell = cell2atoms(cell)
     self._phonon = Phonopy(phonopy_cell,
                            self._supercell_matrix,
                            primitive_matrix=self._primitive_matrix,
                            dynamical_matrix_decimals=14,
                            force_constants_decimals=14)
     self._phonon_fc3 = Phono3py(phonopy_cell,
                                 self._supercell_matrix,
                                 primitive_matrix=self._primitive_matrix)
     self._phonon_fc3.generate_displacements(distance=self._distance,
                                             is_diagonal=self._is_diagonal)
     supercell = self._phonon_fc3.get_supercell()
     disp_dataset = self._phonon_fc3.get_displacement_dataset()
     self._phonon.set_displacement_dataset(disp_dataset)
     write_poscar(cell, "POSCAR-unitcell")
     write_disp_yaml(self._phonon.get_displacements(),
                     supercell,
                     directions=self._phonon.get_displacement_directions())
     write_disp_fc3_yaml(disp_dataset, supercell)
開發者ID:atztogo,項目名稱:cogue,代碼行數:21,代碼來源:phonon_fc3.py

示例15: _get_phonon

 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
開發者ID:atztogo,項目名稱:phonopy,代碼行數:23,代碼來源:_test_unfolding.py


注:本文中的phonopy.Phonopy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。