Esempio n. 1
0
def two_band_set():
    first_branch_energies = [[[-3.0, -2, -1, -1, -1, -2, -3],
                               [7.0, 6, 5, 4, 3, 2, 3]],
                              [[-2.0, -1, 0, 0, 0, -1, -2],
                               [6.0, 5, 4, 3, 2, 1, 2]]]
    second_branch_energies = [[[-4, -5, -6, -7],
                               [5, 2, 7, 8]],
                              [[-3, -4, -5, -6],
                               [4, 1, 6, 7]]]
    first_band_energies = [first_branch_energies, second_branch_energies]

    band_edge_1 = BandEdge(vbm=0, cbm=1,
                           vbm_distances=[2, 3, 4], cbm_distances=[5, 7])
    band_info_1 = BandInfo(band_energies=first_band_energies,
                           band_edge=band_edge_1,
                           fermi_level=None)

    first_branch_energies = [[[-5, -5, -5, -5, -4, -5, -5],
                              [ 5,  5,  5,  5,  4,  5,  5]],
                             [[-6, -6, -6, -6, -5, -6, -6],
                              [6, 6, 6, 6, 5, 6, 6]]]
    second_branch_energies = [[[-5, -5, -5, -5],
                               [5, 5, 5, 5]],
                              [[-6, -6, -6, -6],
                               [6, 6, 6, 6]]]
    second_band_energies = [first_branch_energies, second_branch_energies]

    band_edge_2 = BandEdge(vbm=-4, cbm=4,
                           vbm_distances=[4], cbm_distances=[4])
    band_info_2 = BandInfo(band_energies=second_band_energies,
                           band_edge=band_edge_2,
                           fermi_level=None)

    return [band_info_1, band_info_2]
Esempio n. 2
0
def test_band_info_slide_energies(band_info):
    band_info.slide_energies(base_energy=base_energy)
    expected_band_edge = BandEdge(vbm=0, cbm=3,
                                  vbm_distances=[2, 3, 4], cbm_distances=[5, 7])

    assert band_info.band_energies == shifted_band_energies
    assert band_info.band_edge == expected_band_edge
    assert band_info.fermi_level == fermi_level - base_energy
Esempio n. 3
0
 def _band_edge(self, bs, plot_data):
     if bs.is_metal():
         return None
     else:
         return BandEdge(
             vbm=plot_data["vbm"][0][1],
             cbm=plot_data["cbm"][0][1],
             vbm_distances=[i[0] for i in plot_data["vbm"]],
             cbm_distances=[i[0] for i in plot_data["cbm"]])
Esempio n. 4
0
def test_band_plot_info_band_energy_region():
    band_info = BandInfo(band_energies=[[[[-1.01, -1.008, -1.003, -1.0]]],
                                        [[[1.01, 1.0]]]],
                         band_edge=BandEdge(vbm=-1.0,
                                            cbm=1.0,
                                            vbm_distances=[1],
                                            cbm_distances=[1]),
                         fermi_level=0.0)
    assert band_info.band_energy_region() == [[-1.01, -1.0], [1.0, 1.01]]
    assert band_info.band_energy_region(decision_width=0.0031) \
           == [[-1.01, -1.008], [-1.003, -1.0], [1.0, 1.0], [1.01, 1.01]]
    assert band_info.band_energy_region(bottom=0.0) == [[1.0, 1.01]]
    assert band_info.band_energy_region(top=0.0) == [[-1.01, -1.0]]
    assert band_info.band_energy_region(offset=0.1) == [[-1.11, -1.1],
                                                        [0.9, 0.91]]
Esempio n. 5
0

def test_greek_to_unicode():
    assert greek_to_unicode("GAMMA") == "Γ"
    assert greek_to_unicode("SIGMA") == "Σ"
    assert greek_to_unicode("DELTA") == "Δ"


def test_italic_to_roman():
    assert italic_to_roman(r"S$\mid$$S_0$") == "S$\mid$${\\rm S}_0$"


test_data = [(True, None),
             (False,
              BandEdge(vbm=-100,
                       cbm=100,
                       vbm_distances=[0],
                       cbm_distances=[1, 2]))]


@pytest.mark.parametrize("is_metal,expected_band_edge", test_data)
def test_vasp_band_plotter(is_metal, expected_band_edge, mocker):
    mock_bs = mocker.MagicMock()
    mock_bs.efermi = 10
    mock_bs.is_metal.return_value = is_metal

    stub_vasprun = mocker.MagicMock()
    stub_vasprun.final_structure.composition = Composition("MgO2")
    stub_vasprun.get_band_structure.return_value = mock_bs

    energy = {"1": [np.array([[0.1], [0.2], [0.3]])]}
    distances = [np.array([0.0, 0.1, 0.2])]
Esempio n. 6
0
+ Add spin info to band edge 

DONE:
"""

distances = [[0, 1, 2, 3, 4, 5, 6], [6, 7, 8, 9]]
x_ticks = XTicks(["A", "B", "C$\\mid$D", "E"], [0.0, 5.0, 6.0, 9.0])
y_range = [-10, 10]
title = "Title"
base_energy = -1.0
# [by branch][by spin][by band idx][by k-path idx]
band_energies = [[[[-3.0, -2, -1, -1, -1, -2, -3], [7.0, 6, 5, 4, 3, 2, 3]]],
                 [[[-4.0, -5, -6, -7], [5, 2, 7, 8]]]]
shifted_band_energies = [(np.array(e) + 1.0).tolist() for e in band_energies]

band_edge = BandEdge(vbm=-1, cbm=2, vbm_distances=[2, 3, 4], cbm_distances=[5, 7])
fermi_level = 1.5

band_info_fermi = BandInfo(band_energies=band_energies, fermi_level=fermi_level)
band_info_edge = BandInfo(band_energies=band_energies, band_edge=band_edge)

colors = ['#E15759', '#4E79A7', '#F28E2B', '#76B7B2']


@pytest.fixture
def band_info():
    return BandInfo(band_energies=deepcopy(band_energies), band_edge=band_edge,
                    fermi_level=fermi_level)


@pytest.fixture