예제 #1
0
 def test_get_Wif_from_WSWQ(self):
     with warnings.catch_warnings():
         warnings.simplefilter('ignore')
         wswqs = [(pmg.Structure.from_file(d + '/vasprun.xml.gz'),
                   d + '/WSWQ.gz')
                  for d in glob.glob(str(TEST_FILES / 'lower' / '*'))]
         wswqs = list(
             map(
                 lambda x: (get_Q_from_struct(self.gnd_real, self.exd_real,
                                              x[0]), x[1]), wswqs))
     self.assertAlmostEqual(get_Wif_from_WSWQ(wswqs,
                                              str(TEST_FILES /
                                                  'vasprun.xml.0.gz'),
                                              192, [189],
                                              spin=1)[0][1],
                            0.081,
                            places=2)
     self.assertAlmostEqual(get_Wif_from_WSWQ(wswqs,
                                              str(TEST_FILES /
                                                  'vasprun.xml.0.gz'),
                                              192, [189],
                                              spin=1,
                                              fig=FakeFig())[0][1],
                            0.081,
                            places=2)
예제 #2
0
 def test_get_Wif_from_wavecars(self):
     with warnings.catch_warnings():
         warnings.simplefilter('ignore')
         wcrs = [(Structure.from_file(d + '/vasprun.xml.gz'),
                  d + '/WAVECAR')
                 for d in glob.glob(str(TEST_FILES / 'lower' / '*'))]
         wcrs = list(
             map(
                 lambda x: (get_Q_from_struct(self.gnd_real, self.exd_real,
                                              x[0]), x[1]), wcrs))
     self.assertAlmostEqual(get_Wif_from_wavecars(wcrs,
                                                  str(TEST_FILES /
                                                      'WAVECAR.C0'),
                                                  192, [189],
                                                  spin=1)[0][1],
                            0.087,
                            places=2)
     self.assertAlmostEqual(get_Wif_from_wavecars(wcrs,
                                                  str(TEST_FILES /
                                                      'WAVECAR.C0'),
                                                  192, [189],
                                                  spin=1,
                                                  fig=FakeFig())[0][1],
                            0.087,
                            places=2)
예제 #3
0
파일: test_ccd.py 프로젝트: wangvei/nonrad
 def test_get_Q_from_struct(self):
     q = get_Q_from_struct(self.gnd_test, self.exd_test, self.sct_test)
     self.assertAlmostEqual(q, 0.5 * 0.86945, places=4)
     q = get_Q_from_struct(self.gnd_real, self.exd_real,
                           str(TEST_FILES / 'POSCAR.C0.gz'))
     self.assertAlmostEqual(q, 0., places=4)
     gs, es = get_cc_structures(self.gnd_real,
                                self.exd_real,
                                np.linspace(-0.5, 0.5, 100),
                                remove_zero=False)
     Q = 1.68587 * np.linspace(-0.5, 0.5, 100)
     for s, q in zip(gs, Q):
         tq = get_Q_from_struct(self.gnd_real, self.exd_real, s)
         self.assertAlmostEqual(tq, q, places=4)
     for s, q in zip(es, Q + 1.68587):
         tq = get_Q_from_struct(self.gnd_real, self.exd_real, s)
         self.assertAlmostEqual(tq, q, places=4)
예제 #4
0
파일: test_ccd.py 프로젝트: tsaie79/nonrad
    def test_get_Q_from_struct(self):
        q = get_Q_from_struct(self.gnd_test, self.exd_test, self.sct_test)
        self.assertAlmostEqual(q, 0.5 * 0.86945, places=4)
        q = get_Q_from_struct(self.gnd_real, self.exd_real,
                              str(TEST_FILES / 'POSCAR.C0.gz'))
        self.assertAlmostEqual(q, 0., places=4)
        gs, es = get_cc_structures(self.gnd_real, self.exd_real,
                                   np.linspace(-0.5, 0.5, 100),
                                   remove_zero=False)
        Q = 1.68587 * np.linspace(-0.5, 0.5, 100)
        for s, q in zip(gs, Q):
            tq = get_Q_from_struct(self.gnd_real, self.exd_real, s)
            self.assertAlmostEqual(tq, q, places=4)
        for s, q in zip(es, Q + 1.68587):
            tq = get_Q_from_struct(self.gnd_real, self.exd_real, s)
            self.assertAlmostEqual(tq, q, places=4)

        # test when one of the coordinates stays the same
        sg = pmg.Structure(np.eye(3), ['H'], [[0.0, 0.0, 0.0]])
        sq = pmg.Structure(np.eye(3), ['H'], [[0.1, 0.0, 0.1]])
        se = pmg.Structure(np.eye(3), ['H'], [[0.2, 0.0, 0.2]])
        dQ = get_dQ(sg, se)
        self.assertAlmostEqual(get_Q_from_struct(sg, se, sq)/dQ, 0.5)