コード例 #1
0
ファイル: test_dos.py プロジェクト: ExpHP/pymatgen
class FermiDosTest(unittest.TestCase):
    def setUp(self):
        with open(os.path.join(test_dir, "complete_dos.json"), "r") as f:
            self.dos = CompleteDos.from_dict(json.load(f))
        self.dos = FermiDos(self.dos)

    def test_doping_fermi(self):
        T = 300
        fermi0 = self.dos.efermi
        frange = [fermi0 - 0.5, fermi0, fermi0 + 2.0, fermi0 + 2.2]
        dopings = [self.dos.get_doping(fermi=f, T=T) for f in frange]
        ref_dopings = [3.48077e+21, 1.9235e+18, -2.6909e+16, -4.8723e+19]
        for i, c_ref in enumerate(ref_dopings):
            self.assertLessEqual(abs(dopings[i] / c_ref - 1.0), 0.01)

        calc_fermis = [self.dos.get_fermi(c=c, T=T) for c in ref_dopings]
        for j, f_ref in enumerate(frange):
            self.assertAlmostEqual(calc_fermis[j], f_ref, 4)

        sci_dos = FermiDos(self.dos, bandgap=3.0)
        for i, c_ref in enumerate(ref_dopings):
            if c_ref < 0:
                self.assertAlmostEqual(
                    sci_dos.get_fermi(c_ref, T=T) - frange[i], 0.47, places=2)
            else:
                self.assertAlmostEqual(
                    sci_dos.get_fermi(c_ref, T=T) - frange[i], -0.47, places=2)

        self.assertAlmostEqual(sci_dos.get_fermi_interextrapolated(-1e26, 300),
                               7.5108, 4)
        self.assertAlmostEqual(sci_dos.get_fermi_interextrapolated(1e26, 300),
                               -1.6884, 4)
        self.assertAlmostEqual(sci_dos.get_fermi_interextrapolated(0.0, 300),
                               3.2382, 4)
コード例 #2
0
ファイル: test_dos.py プロジェクト: zbwang/pymatgen
class FermiDosTest(unittest.TestCase):
    def setUp(self):
        with open(os.path.join(test_dir, "complete_dos.json"), "r") as f:
            self.dos = CompleteDos.from_dict(json.load(f))
        self.dos = FermiDos(self.dos)

    def test_doping_fermi(self):
        T = 300
        fermi0 = self.dos.efermi
        frange = [fermi0 - 0.5, fermi0, fermi0 + 2.0, fermi0 + 2.2]
        dopings = [self.dos.get_doping(fermi=f, T=T) for f in frange]
        ref_dopings = [3.48077e+21, 1.9235e+18, -2.6909e+16, -4.8723e+19]
        for i, c_ref in enumerate(ref_dopings):
            self.assertLessEqual(abs(dopings[i] / c_ref - 1.0), 0.01)

        calc_fermis = [self.dos.get_fermi(c=c, T=T) for c in ref_dopings]
        for j, f_ref in enumerate(frange):
            self.assertAlmostEqual(calc_fermis[j], f_ref, 4)

        sci_dos = FermiDos(self.dos, bandgap=3.0)
        for i, c_ref in enumerate(ref_dopings):
            if c_ref < 0:
                self.assertAlmostEqual(sci_dos.get_fermi(c_ref, T=T) -
                                       frange[i],
                                       0.47,
                                       places=2)
            else:
                self.assertAlmostEqual(sci_dos.get_fermi(c_ref, T=T) -
                                       frange[i],
                                       -0.47,
                                       places=2)
コード例 #3
0
class FermiDosTest(unittest.TestCase):
    def setUp(self):
        with open(
                os.path.join(PymatgenTest.TEST_FILES_DIR, "complete_dos.json"),
                "r") as f:
            self.dos = CompleteDos.from_dict(json.load(f))
        self.dos = FermiDos(self.dos)

    def test_doping_fermi(self):
        T = 300
        fermi0 = self.dos.efermi
        frange = [fermi0 - 0.5, fermi0, fermi0 + 2.0, fermi0 + 2.2]
        dopings = [
            self.dos.get_doping(fermi_level=f, temperature=T) for f in frange
        ]
        ref_dopings = [3.48077e21, 1.9235e18, -2.6909e16, -4.8723e19]
        for i, c_ref in enumerate(ref_dopings):
            self.assertLessEqual(abs(dopings[i] / c_ref - 1.0), 0.01)

        calc_fermis = [
            self.dos.get_fermi(concentration=c, temperature=T)
            for c in ref_dopings
        ]
        for j, f_ref in enumerate(frange):
            self.assertAlmostEqual(calc_fermis[j], f_ref, 4)

        sci_dos = FermiDos(self.dos, bandgap=3.0)
        self.assertEqual(sci_dos.get_gap(), 3.0)
        old_cbm, old_vbm = self.dos.get_cbm_vbm()
        old_gap = old_cbm - old_vbm
        new_cbm, new_vbm = sci_dos.get_cbm_vbm()
        self.assertAlmostEqual(new_cbm - old_cbm, (3.0 - old_gap) / 2.0)
        self.assertAlmostEqual(old_vbm - new_vbm, (3.0 - old_gap) / 2.0)
        for i, c_ref in enumerate(ref_dopings):
            if c_ref < 0:
                self.assertAlmostEqual(
                    sci_dos.get_fermi(c_ref, temperature=T) - frange[i],
                    0.47,
                    places=2)
            else:
                self.assertAlmostEqual(
                    sci_dos.get_fermi(c_ref, temperature=T) - frange[i],
                    -0.47,
                    places=2)

        self.assertAlmostEqual(sci_dos.get_fermi_interextrapolated(-1e26, 300),
                               7.5108, 4)
        self.assertAlmostEqual(sci_dos.get_fermi_interextrapolated(1e26, 300),
                               -1.4182, 4)
        self.assertAlmostEqual(sci_dos.get_fermi_interextrapolated(0.0, 300),
                               2.5226, 4)