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


Python Phonopy.set_qpoints_phonon方法代碼示例

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


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

示例1: DynmatToForceConstants

# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_qpoints_phonon [as 別名]
                                   [0.5, 0.5, 0]],
                 is_auto_displacements=False)

primitive = phonon.get_primitive()
supercell = phonon.get_supercell()
dynmat2fc = DynmatToForceConstants(primitive, supercell)
com_points = dynmat2fc.get_commensurate_points()

print "Commensurate points"
for i, q in enumerate(com_points):
    print i + 1, q

force_sets = parse_FORCE_SETS()
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()
phonon.set_qpoints_phonon(com_points,
                          is_eigenvectors=True)
frequencies, eigenvectors = phonon.get_qpoints_phonon()
dynmat2fc.set_dynamical_matrices(frequencies / VaspToTHz, eigenvectors)
dynmat2fc.run()
fc = dynmat2fc.get_force_constants()

phonon2 = Phonopy(bulk,
                  [[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]],
                  is_auto_displacements=False)
phonon2.set_force_constants(fc)
bands = []
開發者ID:Johnson-Wang,項目名稱:phonopy,代碼行數:34,代碼來源:dynmat2fc.py

示例2: PhononFC3Base

# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_qpoints_phonon [as 別名]

#.........這裏部分代碼省略.........
        self._tasks = self._get_displacement_tasks(start=start_index)
        self._phonon_fc3_tasks += self._tasks

    def _reset_stage2(self):
        self._traverse = False
        disp_terminated = []
        for i, task in enumerate(self._tasks):
            if task.get_status() == "terminate":
                disp_terminated.append(i)

        if self._check_imaginary:
            disp_dataset = self._phonon_fc3.get_displacement_dataset()
            start_index = len(disp_dataset['first_atoms'])
        else:
            start_index = 0
        tasks = self._get_displacement_tasks(start=start_index)
        self._tasks = []
        for i in disp_terminated:
            self._tasks.append(tasks[i])
            self._phonon_fc3_tasks[i + 1 + start_index] = tasks[i]
        self._status = "fc3_displacements"

    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)

    def _exist_imaginary_mode(self):
        if self._primitive_matrix is None:
            pmat = np.eye(3)
        else:
            pmat = self._primitive_matrix
        exact_point_matrix = np.dot(np.linalg.inv(self._supercell_matrix),
                                    pmat).T
        max_integer = np.rint(np.amax(np.abs(np.linalg.inv(exact_point_matrix))))
        q_points = []
        for i in np.arange(-max_integer, max_integer + 1):
            for j in np.arange(-max_integer, max_integer + 1):
                for k in np.arange(-max_integer, max_integer + 1):
                    q = np.dot(exact_point_matrix, [i, j, k])
                    if (-1 < q).all() and (q < 1).all():
                        q_points.append(q)
        self._phonon.set_qpoints_phonon(q_points)
        frequencies = self._phonon.get_qpoints_phonon()[0]
        if (frequencies < self._cutoff_frequency).any():
            self._log = "Stop at phonon calculation due to imaginary modes"
            return True
        else:
            return False

    def _write_yaml(self):
        w = open("%s.yaml" % self._directory, 'w')
        if self._lattice_tolerance is not None:
            w.write("lattice_tolerance: %f\n" % self._lattice_tolerance)
        if self._stress_tolerance is not None:
            w.write("stress_tolerance: %f\n" % self._stress_tolerance)
            w.write("pressure_target: %f\n" % self._pressure_target)
        w.write("force_tolerance: %f\n" % self._force_tolerance)
        if self._max_increase is None:
            w.write("max_increase: unset\n")
        else:
            w.write("max_increase: %f\n" % self._max_increase)
        w.write("max_iteration: %d\n" % self._max_iteration)
        w.write("min_iteration: %d\n" % self._min_iteration)
        w.write("supercell_matrix:\n")
        for row in self._supercell_matrix:
            w.write("- [ %3d, %3d, %3d ]\n" % tuple(row))
        if self._primitive_matrix is not None:
            w.write("primitive_matrix:\n")
            for row in self._primitive_matrix:
                w.write("- [ %6.3f, %6.3f, %6.3f ]\n" % tuple(row))
        w.write("distance: %f\n" % self._distance)
        if self._phonon_fc3_tasks[0] is not None:
            w.write("iteration: %d\n" % self._phonon_fc3_tasks[0].get_stage())
            if self._energy:
                w.write("electric_total_energy: %20.10f\n" % self._energy)
        w.write("status: %s\n" % self._status)
        w.write("tasks:\n")
        for task in self._phonon_fc3_tasks:
            if task and task.get_status():
                w.write("- name:   %s\n" % task.get_name())
                w.write("  status: %s\n" % task.get_status())
        w.close()
開發者ID:atztogo,項目名稱:cogue,代碼行數:104,代碼來源:phonon_fc3.py

示例3: read_vasp

# 需要導入模塊: from phonopy import Phonopy [as 別名]
# 或者: from phonopy.Phonopy import set_qpoints_phonon [as 別名]
unitcell = read_vasp("POSCAR")
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]])
force_sets = parse_FORCE_SETS()
phonon.set_displacement_dataset(force_sets)
phonon.produce_force_constants()

q = [0.1, 0.1, 0.1]
dynmat = phonon.get_dynamical_matrix_at_q(q)
print(dynmat)
phonon.set_qpoints_phonon(q, write_dynamical_matrices=True)
print(phonon.get_qpoints_phonon()[0][0])
phonon.write_yaml_qpoints_phonon()

data = yaml.load(open("qpoints.yaml"))
dynmat_from_yaml = []
dynmat_data = data['phonon'][0]['dynamical_matrix']
for row in dynmat_data:
    vals = np.reshape(row, (-1, 2))
    dynmat_from_yaml.append(vals[:, 0] + vals[:, 1] * 1j)
dynmat_from_yaml = np.array(dynmat_from_yaml)
print(dynmat_from_yaml)
eigvals, eigvecs, = np.linalg.eigh(dynmat)
frequencies = np.sqrt(np.abs(eigvals.real)) * np.sign(eigvals.real)
conversion_factor_to_THz = 15.633302
print(frequencies * conversion_factor_to_THz)
開發者ID:atztogo,項目名稱:phonopy,代碼行數:33,代碼來源:NaCl-dynmat.py


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