Beispiel #1
0
    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.9071, 4)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
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)
Beispiel #7
0
    def featurize(self, dos, bandgap=None):
        """
        Args:
            dos (pymatgen Dos, CompleteDos or FermiDos):
            bandgap (float): for example the experimentally measured band gap
                or one that is calculated via more accurate methods than the
                one used to generate dos. dos will be scissored to have the
                same electronic band gap as bandgap.

        Returns ([float]): features are fermi levels in eV at the given
            concentrations and temperature + eref in eV if return_eref
        """
        dos = FermiDos(dos, bandgap=bandgap)
        feats = []
        eref = 0.0
        for c in self.dopings:
            fermi = dos.get_fermi(concentration=c,
                                  temperature=self.T,
                                  nstep=50)
            if isinstance(self.eref, str):
                if self.eref == "dos_fermi":
                    eref = dos.efermi
                elif self.eref in ["midgap", "vbm", "cbm"]:
                    ecbm, evbm = dos.get_cbm_vbm()
                    if self.eref == "midgap":
                        eref = (evbm + ecbm) / 2.0
                    elif self.eref == "vbm":
                        eref = evbm
                    elif self.eref == "cbm":
                        eref = ecbm
                elif self.eref == "band center":
                    eref = self.BC.featurize(dos.structure.composition)[0]
                else:
                    raise ValueError('Unsupported "eref": {}'.format(
                        self.eref))
            else:
                eref = self.eref
            if not self.return_eref:
                fermi -= eref
            feats.append(fermi)
        if self.return_eref:
            feats.append(eref)
        return feats
Beispiel #8
0
    def featurize(self, dos, bandgap=None):
        """
        Args:
            dos (pymatgen Dos, CompleteDos or FermiDos):
            bandgap (float): for example the experimentally measured band gap
                or one that is calculated via more accurate methods than the
                one used to generate dos. dos will be scissored to have the
                same electronic band gap as bandgap.

        Returns ([float]): features are fermi levels in eV at the given
            concentrations and temperature + eref in eV if return_eref
        """
        dos = FermiDos(dos, bandgap=bandgap)
        feats = []
        eref = 0.0
        for c in self.dopings:
            fermi = dos.get_fermi(c=c, T=self.T, nstep=50)
            if isinstance(self.eref, str):
                if self.eref == "dos_fermi":
                    eref = dos.efermi
                elif self.eref in ["midgap", "vbm", "cbm"]:
                    ecbm, evbm = dos.get_cbm_vbm()
                    if self.eref == "midgap":
                        eref = (evbm + ecbm) / 2.0
                    elif self.eref == "vbm":
                        eref = evbm
                    elif self.eref == "cbm":
                        eref = ecbm
                elif self.eref == "band center":
                    eref = self.BC.featurize(dos.structure.composition)[0]
                else:
                    raise ValueError('Unsupported "eref": {}'.format(self.eref))
            else:
                eref = self.eref
            if not self.return_eref:
                fermi -= eref
            feats.append(fermi)
        if self.return_eref:
            feats.append(eref)
        return feats