def test_max_y_range(): pdos = [ PDos( s=np.array([[0, 10, 20, 30, 40]], dtype=float), px=np.array([[0, 10, 20, 30, 40]], dtype=float), py=np.array([[0, 10, 20, 30, 40]], dtype=float), pz=np.array([[0, 10, 20, 30, 40]], dtype=float), dxy=np.array([[0, 10, 20, 30, 40]], dtype=float), dyz=np.array([[0, 10, 20, 30, 40]], dtype=float), dxz=np.array([[0, 10, 20, 30, 40]], dtype=float), dx2=np.array([[0, 10, 20, 30, 40]], dtype=float), dz2=np.array([[0, 10, 20, 30, 40]], dtype=float), f_3=np.array([[0, 10, 20, 30, 40]], dtype=float), f_2=np.array([[0, 10, 20, 30, 40]], dtype=float), f_1=np.array([[0, 10, 20, 30, 40]], dtype=float), f0=np.array([[0, 10, 20, 30, 40]], dtype=float), f1=np.array([[0, 10, 20, 30, 40]], dtype=float), f2=np.array([[0, 10, 20, 30, 40]], dtype=float), f3=np.array([[0, 10, 20, 30, 40]], dtype=float), ) ] dos_data = DosData(energies=list(range(-2, 3)), total=np.array([[0, 1, 2, 3, 4]]), pdos=pdos, vertical_lines=[0.0]) dos_plot_data = dos_data.dos_plot_data(grouped_atom_indices={"H": [0]}, xlim=[-1.1, 1.1]) assert dos_plot_data.dos_ranges == [[0, 3.3], [0, 231.0]]
def test_pdos_only_s_p_d_doses(orbitals): d = {"s": 1.0, "p": 2.0, "d": 3.0, "f": 4.0} pdos = PDos.from_dict(d) assert pdos.s == pytest.approx(1.0) assert pdos.p == pytest.approx(2.0) assert pdos.d == pytest.approx(3.0) assert pdos.f == pytest.approx(4.0)
def test_pdos_s_p_d(orbitals): p = sum([orbitals[orb] for orb in ["px", "py", "pz"]]) d = sum([orbitals[orb] for orb in ["dxy", "dyz", "dxz", "dx2", "dz2"]]) f = sum([ orbitals[orb] for orb in ["f_3", "f_2", "f_1", "f0", "f1", "f2", "f3"] ]) pdos = PDos(**orbitals) assert_array_equal(pdos.p, p) assert_array_equal(pdos.d, d) assert_array_equal(pdos.f, f)
def _pdos(self): result = [] for dos_by_site in self.complete_dos.pdos.values(): pdos_kwargs = {} for orbital, dos_by_orbital in dos_by_site.items(): pdos = np.array([ dos_by_orbital[s] for s in [Spin.up, Spin.down] if s in dos_by_orbital ]) pdos_kwargs[str( orbital)] = pdos[:, self.min_energy_idx:self.max_energy_idx + 1] try: result.append(PDos(**pdos_kwargs)) except TypeError: logger.warning("Orbital DOSes are required. SET LORBIT = 11.") raise return result
def test_pdos_msonable(orbitals): pdos = PDos(**orbitals) assert_msonable(pdos)
def pdos_list(orbitals, orbitals_2, orbitals_3): return [PDos(**orbitals), PDos(**orbitals_2), PDos(**orbitals_3)]
def test_pdos_add(orbitals): for pop_orb in ["f_3", "f_2", "f_1", "f0", "f1", "f2", "f3"]: orbitals.pop(pop_orb) pdos = PDos(**orbitals) pdos_sum = pdos + pdos assert_array_equal(pdos_sum.s, pdos.s * 2)
def test_pdos_wo_f_orbital(orbitals): orbitals.pop("f_3") assert PDos(**orbitals).f is None