Skip to content

Commit

Permalink
Add test_get_vbm_cbm_doping
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Jan 3, 2025
1 parent f7aa77a commit 83b988d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/electronic_structure/test_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from pymatgen.core import Element, Structure
from pymatgen.electronic_structure.core import Orbital, OrbitalType, Spin
from pymatgen.electronic_structure.dos import DOS, CompleteDos, FermiDos, LobsterCompleteDos
from pymatgen.electronic_structure.dos import DOS, CompleteDos, FermiDos, LobsterCompleteDos, Dos
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest

TEST_DIR = f"{TEST_FILES_DIR}/electronic_structure/dos"
Expand Down Expand Up @@ -103,6 +103,23 @@ def test_as_dict(self):
assert isinstance(dos_dict["densities"]["1"][0], float)
assert not isinstance(dos_dict["densities"]["1"][0], np.float64)

def test_get_vbm_cbm_doping(self):
dos = Dos(
energies=np.array([0.0, 0.5, 1.0, 1.5, 2.0]),
densities={
Spin.up: np.array([1.0, 2.0, 0.0, 3.0, 4.0]),
Spin.down: np.array([0.5, 1.0, 0.0, 1.5, 2.0]),
},
efermi=0.8,
)
fermi_dos = FermiDos(dos, structure=self.dos.structure,)
assert fermi_dos.get_cbm_vbm() == (1.5, 0.5)
assert np.isclose(
fermi_dos.get_doping(fermi_level=1.0, temperature=300),
-1385561583858093.5, # <0 because e doping; greater DOS in CBM than VBM here, and efermi set to mid-gap
rtol=1e-3
)


class TestCompleteDos(TestCase):
def setUp(self):
Expand Down

0 comments on commit 83b988d

Please sign in to comment.