コード例 #1
0
ファイル: dynamical_matrix.py プロジェクト: ladyteam/phonopy
    def make_Gonze_nac_dataset(self):
        """Prepare Gonze-Lee force constants.

        Dipole-dipole interaction contribution is subtracted from
        supercell force constants.

        """
        try:
            import phonopy._phonopy as phonoc  # noqa F401

            self._run_c_recip_dipole_dipole_q0()
        except ImportError:
            print("Python version of dipole-dipole calculation is not well "
                  "implemented.")
            sys.exit(1)

        fc_shape = self._force_constants.shape
        d2f = DynmatToForceConstants(self._pcell,
                                     self._scell,
                                     is_full_fc=(fc_shape[0] == fc_shape[1]))
        dynmat = []
        num_q = len(d2f.commensurate_points)
        for i, q_red in enumerate(d2f.commensurate_points):
            if self._log_level > 2:
                print("%d/%d %s" % (i + 1, num_q, q_red))
            self._run(q_red)
            dm_dd = self._get_Gonze_dipole_dipole(q_red, None)
            self._dynamical_matrix -= dm_dd
            dynmat.append(self._dynamical_matrix)
        d2f.dynamical_matrices = dynmat
        d2f.run()

        self._Gonze_force_constants = d2f.force_constants
        self._Gonze_count = 0
コード例 #2
0
def test_with_dynamical_matrices(ph_nacl, ph_nacl_nonac):
    for ph in (ph_nacl, ph_nacl_nonac):
        d2f = DynmatToForceConstants(ph.primitive, ph.supercell)
        ph.run_qpoints(d2f.commensurate_points,
                       with_dynamical_matrices=True)
        ph_dict = ph.get_qpoints_dict()
        d2f.dynamical_matrices = ph_dict['dynamical_matrices']
        d2f.run()
        np.testing.assert_allclose(ph.force_constants, d2f.force_constants,
                                   atol=1e-5)
コード例 #3
0
ファイル: test_dynmat_to_fc.py プロジェクト: ladyteam/phonopy
def test_with_dynamical_matrices(ph_nacl, ph_nacl_nonac, is_nac, lang):
    """Test transformation from dynamical matrix to force constants."""
    if is_nac:
        ph = ph_nacl
    else:
        ph = ph_nacl_nonac

    d2f = DynmatToForceConstants(ph.primitive, ph.supercell)
    ph.run_qpoints(d2f.commensurate_points, with_dynamical_matrices=True)
    ph_dict = ph.get_qpoints_dict()
    d2f.dynamical_matrices = ph_dict["dynamical_matrices"]
    d2f.run(lang=lang)
    np.testing.assert_allclose(ph.force_constants,
                               d2f.force_constants,
                               atol=1e-5)
コード例 #4
0
 def _run_Gonze_force_constants(self):
     fc_shape = self._force_constants.shape
     d2f = DynmatToForceConstants(self._pcell,
                                  self._scell,
                                  is_full_fc=(fc_shape[0] == fc_shape[1]))
     dynmat = []
     num_q = len(d2f.commensurate_points)
     for i, q_red in enumerate(d2f.commensurate_points):
         if self._log_level > 2:
             print("%d/%d %s" % (i + 1, num_q, q_red))
         self._run(q_red)
         dm_dd = self._get_Gonze_dipole_dipole(q_red, None)
         self._dynamical_matrix -= dm_dd
         dynmat.append(self._dynamical_matrix)
     d2f.dynamical_matrices = dynmat
     d2f.run()
     self._Gonze_force_constants = d2f.force_constants