def test_spin_unpolarized(): """Test the function for a non spin-polarized calculation meaning there will be a single spin channel.""" from aiida.orm import BandsData occupations = numpy.array([ [2., 2., 2., 2., 0.], [2., 2., 2., 2., 0.], [2., 2., 2., 2., 0.], [2., 2., 2., 2., 0.], ]) bands = BandsData() bands.set_array('occupations', occupations) bands.store() h**o = get_highest_occupied_band(bands) assert h**o == 4
def test_spin_polarized(self, fixture_database): """Test the function for a spin-polarized calculation meaning there will be two spin channels.""" from aiida.orm import BandsData occupations = numpy.array([ [ [2., 2., 2., 2., 0.], [2., 2., 2., 2., 0.], ], [ [2., 2., 2., 2., 0.], [2., 2., 2., 2., 0.], ] ]) bands = BandsData() bands.set_array('occupations', occupations) bands.store() h**o = get_highest_occupied_band(bands) assert h**o == 4
def test_threshold(self, fixture_database): """Test the `threshold` parameter.""" from aiida.orm import BandsData threshold = 0.002 bands = BandsData() bands.set_array('occupations', numpy.array([[2., 2., 2., 2., 0.001, 0.0015]])) bands.store() # All bands above the LUMO (occupation of 0.001) are below `2 * threshold` h**o = get_highest_occupied_band(bands, threshold=threshold) assert h**o == 4 bands = BandsData() bands.set_array('occupations', numpy.array([[2., 2., 2., 2., 0.001, 0.003]])) bands.store() # A band above the LUMO (occupation of 0.001) has an occupation above `2 * threshold` with pytest.raises(ValueError): get_highest_occupied_band(bands, threshold=threshold)