From 57d1e7253adc1a9c00c1f383e408262475776ce2 Mon Sep 17 00:00:00 2001 From: JosePizarro3 Date: Mon, 29 Apr 2024 15:37:19 +0200 Subject: [PATCH] Added tests from old parser Fix pipeline --- pyproject.toml | 2 +- tests/test_parser.py | 59 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f356917..0a4bb38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", ] dependencies = [ - "nomad-lab>=1.2.2dev578", + "nomad-lab@git+https://github.com/nomad-coe/nomad.git@develop", "nomad-schema-plugin-simulation-workflow@git+https://github.com/nomad-coe/nomad-schema-plugin-simulation-workflow.git@develop", "nomad-schema-plugin-run@git+https://github.com/nomad-coe/nomad-schema-plugin-run.git@develop", "nomad-schema-plugin-simulation-data@git+https://github.com/nomad-coe/nomad-schema-plugin-simulation-data.git@develop", diff --git a/tests/test_parser.py b/tests/test_parser.py index b7e177a..c1f9273 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -40,4 +40,61 @@ def test_single_point_La2CuO4(parser): archive, None, ) - sec_run = archive.run[-1] \ No newline at end of file + sec_run = archive.run[-1] + sec_program = sec_run.program + assert sec_program.name == 'Wannier90' + assert sec_program.version == '3.1.0' + + assert len(sec_run.system) == 1 + sec_system = sec_run.system[-1] + assert sec_system.atoms.labels[-1] == 'O' + assert (sec_system.atoms.positions[2].magnitude == np.array([0.0, 0.0, 0.0])).all() + assert sec_system.atoms.lattice_vectors[0][0].magnitude == approx(-1.909145e-10) + assert sec_system.atoms.periodic == [True, True, True] + assert sec_system.m_xpath('atoms_group') + assert len(sec_system.atoms_group) == 1 + assert sec_system.atoms_group[-1].label == 'projection' + assert sec_system.atoms_group[-1].type == 'active_orbitals' + assert sec_system.atoms_group[-1].index == 0 + assert sec_system.atoms_group[-1].atom_indices[0] == 2 + + assert len(sec_run.method) == 1 + sec_method = sec_run.method[-1] + assert sec_method.k_mesh.n_points == 343 + assert ( + sec_method.k_mesh.points[303] == np.array([0.85714, 0.14286, 0.28571]) + ).all() + assert (sec_method.k_mesh.grid == np.array([7, 7, 7])).all() + sec_wannier = sec_method.tb.wannier + assert sec_wannier.n_projected_orbitals == 1 + assert sec_wannier.n_bands == 5 + assert sec_wannier.is_maximally_localized is True + assert sec_method.atom_parameters[-1].n_orbitals == 1 + assert sec_method.atom_parameters[-1].orbitals[0] == 'dx2-y2' + + # Band tests + assert len(sec_run.calculation) == 1 + sec_scc = sec_run.calculation[-1] + assert len(sec_scc.band_structure_electronic[0].segment) == 4 + assert sec_scc.band_structure_electronic[0].segment[0].n_kpoints == 100 + assert sec_scc.band_structure_electronic[0].segment[0].n_kpoints == len( + sec_scc.band_structure_electronic[0].segment[0].energies[0] + ) + assert sec_scc.energy.fermi == sec_scc.band_structure_electronic[0].energy_fermi + assert sec_scc.band_structure_electronic[0].energy_fermi.to( + 'eV' + ).magnitude == approx(12.895622) + # DOS tests + sec_dos = sec_scc.dos_electronic + assert len(sec_dos) == 1 + assert sec_dos[0].n_energies == 692 + assert sec_dos[0].n_energies == len(sec_dos[0].energies) + assert len(sec_dos[0].total[0].value) == sec_dos[0].n_energies + # x_wannier90 tests + sec_hoppings = sec_scc.hopping_matrix[0] + assert sec_hoppings.n_wigner_seitz_points == 397 + assert sec_hoppings.n_wigner_seitz_points == len(sec_hoppings.degeneracy_factors) + assert sec_hoppings.n_orbitals == sec_wannier.n_projected_orbitals + assert sec_hoppings.value.shape[0] == sec_hoppings.n_wigner_seitz_points + assert sec_hoppings.value.shape[1] == sec_hoppings.n_orbitals + assert sec_hoppings.value.shape[2] == 7