Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up test files: VASP outputs #3653

Merged
merged 44 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c68d5c3
move vasprun to dedicated dir
DanielYang59 Feb 24, 2024
1fff2d4
Merge branch 'materialsproject:master' into clean-up-tests
DanielYang59 Feb 24, 2024
ee6df80
move OUTCAR to dedicated dir
DanielYang59 Feb 24, 2024
2c8eba7
fix vasp output file paths
DanielYang59 Feb 24, 2024
37868ce
move CHGCAR to dedicated dir
DanielYang59 Feb 24, 2024
649152a
relocate DOSCAR
DanielYang59 Feb 24, 2024
1bba1bf
relocate EIGENVAL
DanielYang59 Feb 24, 2024
099c205
relocate PROCAR
DanielYang59 Feb 24, 2024
428c326
relocate WAVECAR
DanielYang59 Feb 24, 2024
0044e49
relocate XDATCAR
DanielYang59 Feb 24, 2024
897fa39
relocate LOCPOT
DanielYang59 Feb 24, 2024
8c69192
relocate DYNMAT
DanielYang59 Feb 24, 2024
71964ad
relocate ELFCAR
DanielYang59 Feb 24, 2024
cb9fd86
relocate CONTCAR
DanielYang59 Feb 24, 2024
eb33d40
relocate IBZKPT
DanielYang59 Feb 24, 2024
002225f
relocate WAVEDER and WAVEDERF
DanielYang59 Feb 24, 2024
bd07afd
relocate trajectory XDATCAR
DanielYang59 Feb 24, 2024
b2d9040
relocate OSZICAR
DanielYang59 Feb 24, 2024
28c784c
temp fix: borg
DanielYang59 Feb 24, 2024
a1c25f7
rename trajectory test files
DanielYang59 Feb 24, 2024
a7301ba
remove duplicate OUTCARs
DanielYang59 Feb 24, 2024
f2a6fef
compress some CHGCAR OUTCAR PROCAR
DanielYang59 Feb 24, 2024
97891c1
compress formatted WAVEDER
DanielYang59 Feb 24, 2024
db3cd17
pre-commit auto-fixes
pre-commit-ci[bot] Feb 24, 2024
5cc1612
sort import
DanielYang59 Feb 24, 2024
af47eb7
Merge branch 'clean-up-tests' of https://github.com/DanielYang59/pyma…
DanielYang59 Feb 24, 2024
82c3729
compress OUTCAR and remove duplicate
DanielYang59 Feb 24, 2024
7951ded
compress more vasp output files
DanielYang59 Feb 24, 2024
270619c
add missing gz extension
DanielYang59 Feb 24, 2024
c4d7e6a
rename some vasprun to respect extension name
DanielYang59 Feb 28, 2024
32b1844
Merge branch 'master' into clean-up-tests
DanielYang59 Feb 28, 2024
0fa962d
rename more vasprun to respect file extension
DanielYang59 Feb 28, 2024
f2e0526
remove remaining vasprun to respect file extension
DanielYang59 Feb 28, 2024
733adf2
fix some paths after rename
DanielYang59 Feb 28, 2024
a0cabad
redirect borg to output dir for efermi search
DanielYang59 Feb 28, 2024
42cf743
Merge branch 'master' into clean-up-tests
DanielYang59 Mar 2, 2024
4a0ac92
pre-commit auto-fixes
pre-commit-ci[bot] Mar 2, 2024
59fd2b1
fix borg error
DanielYang59 Mar 5, 2024
7194a99
add test note
DanielYang59 Mar 5, 2024
a2576cd
Merge branch 'master' into clean-up-tests
DanielYang59 Mar 5, 2024
a670e9e
fix test_xe
DanielYang59 Mar 5, 2024
7eb1205
Merge branch 'clean-up-tests' of github.com:DanielYang59/pymatgen int…
DanielYang59 Mar 5, 2024
bd87dea
rename vasprun.xe and use ScratchDir
DanielYang59 Mar 7, 2024
8cc0f39
define VASP_OUT_DIR = f"{TEST_FILES_DIR}/vasp/outputs" for shorter fi…
janosh Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ def get_vasprun_outcar(path: str | Path, parse_dos: bool = True, parse_eigen: bo
if len(vruns) == 0 or len(outcars) == 0:
raise ValueError(f"Unable to get vasprun.xml/OUTCAR from prev calculation in {path}")
vsfile_fullpath = str(path / "vasprun.xml")
outcarfile_fullpath = str(path / "OUTCAR")
outcarfile_fullpath = str(path / "OUTCAR.gz")
vsfile = vsfile_fullpath if vsfile_fullpath in vruns else sorted(vruns)[-1]
outcarfile = outcarfile_fullpath if outcarfile_fullpath in outcars else sorted(outcars)[-1]
return (
Expand Down
1 change: 1 addition & 0 deletions pymatgen/util/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
MODULE_DIR = Path(__file__).absolute().parent
STRUCTURES_DIR = MODULE_DIR / ".." / "structures"
TEST_FILES_DIR = Path(SETTINGS.get("PMG_TEST_FILES_DIR", f"{ROOT}/tests/files"))
VASP_OUT_DIR = f"{TEST_FILES_DIR}/vasp/outputs"
# fake POTCARs have original header information, meaning properties like number of electrons,
# nuclear charge, core radii, etc. are unchanged (important for testing) while values of the and
# pseudopotential kinetic energy corrections are scrambled to avoid VASP copyright infringement
Expand Down
8 changes: 4 additions & 4 deletions tests/analysis/test_structure_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
)
from pymatgen.core import Element, Lattice, Structure
from pymatgen.io.vasp.outputs import Xdatcar
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR, PymatgenTest


class TestVoronoiAnalyzer(PymatgenTest):
def setUp(self):
self.ss = Xdatcar(f"{TEST_FILES_DIR}/XDATCAR.MD").structures
self.ss = Xdatcar(f"{VASP_OUT_DIR}/XDATCAR.MD").structures
self.s = self.ss[1]
self.va = VoronoiAnalyzer(cutoff=4)

Expand All @@ -40,7 +40,7 @@ def test_analyze(self):
class TestRelaxationAnalyzer(unittest.TestCase):
def setUp(self):
s1 = Structure.from_file(f"{TEST_FILES_DIR}/POSCAR.Li2O")
s2 = Structure.from_file(f"{TEST_FILES_DIR}/CONTCAR.Li2O")
s2 = Structure.from_file(f"{VASP_OUT_DIR}/CONTCAR.Li2O")
self.analyzer = RelaxationAnalyzer(s1, s2)

def test_vol_and_para_changes(self):
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_connectivity_array(self):

class TestMiscFunction(PymatgenTest):
def test_average_coordination_number(self):
xdatcar = Xdatcar(f"{TEST_FILES_DIR}/XDATCAR.MD")
xdatcar = Xdatcar(f"{VASP_OUT_DIR}/XDATCAR.MD")
coordination_numbers = average_coordination_number(xdatcar.structures, freq=1)
assert coordination_numbers["Fe"] == approx(
4.771903318390836, 5
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/test_xps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from pymatgen.analysis.xps import XPS
from pymatgen.io.vasp import Vasprun
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import VASP_OUT_DIR, PymatgenTest


class XPSTestCase(PymatgenTest):
def test_from_dos(self):
vasp_run = Vasprun(f"{TEST_FILES_DIR}/vasprun.xml.LiF.gz")
vasp_run = Vasprun(f"{VASP_OUT_DIR}/vasprun.LiF.xml.gz")
dos = vasp_run.complete_dos
xps = XPS.from_dos(dos)
assert len(xps) == 301
Expand Down
42 changes: 25 additions & 17 deletions tests/apps/borg/test_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import unittest

from monty.tempfile import ScratchDir
from pytest import approx

from pymatgen.apps.borg.hive import (
Expand All @@ -11,7 +12,7 @@
VaspToComputedEntryDrone,
)
from pymatgen.entries.computed_entries import ComputedStructureEntry
from pymatgen.util.testing import TEST_FILES_DIR
from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR


class TestVaspToComputedEntryDrone(unittest.TestCase):
Expand All @@ -20,23 +21,30 @@ def setUp(self):
self.structure_drone = VaspToComputedEntryDrone(inc_structure=True)

def test_get_valid_paths(self):
for path in os.walk(TEST_FILES_DIR):
if path[0] == TEST_FILES_DIR:
for path in os.walk(VASP_OUT_DIR):
if path[0] == VASP_OUT_DIR:
assert len(self.drone.get_valid_paths(path)) > 0

def test_assimilate(self):
entry = self.drone.assimilate(TEST_FILES_DIR)
for param in ("hubbards", "is_hubbard", "potcar_spec", "run_type"):
assert param in entry.parameters
assert entry.data["efermi"] == approx(-6.62148548)
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)
entry = self.structure_drone.assimilate(TEST_FILES_DIR)
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)
assert isinstance(entry, ComputedStructureEntry)
assert entry.structure is not None
# assert len(entry.parameters["history"]) == 2
"""Test assimilate data from "vasprun.xe.xml.gz" file."""

with ScratchDir("."):
# Need to rename the test file to "vasprun.xml.xe.gz" as
# hive is looking for pattern "vasprun.xml*"
os.symlink(f"{VASP_OUT_DIR}/vasprun.xe.xml.gz", "vasprun.xml.xe.gz")
entry = self.drone.assimilate(".")

for param in ("hubbards", "is_hubbard", "potcar_spec", "run_type"):
assert param in entry.parameters
assert entry.data["efermi"] == approx(-6.62148548)
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)

entry = self.structure_drone.assimilate(".")
assert entry.reduced_formula == "Xe"
assert entry.energy == approx(0.5559329)
assert isinstance(entry, ComputedStructureEntry)
assert entry.structure is not None

def test_as_from_dict(self):
dct = self.structure_drone.as_dict()
Expand All @@ -50,8 +58,8 @@ def setUp(self):
self.structure_drone = SimpleVaspToComputedEntryDrone(inc_structure=True)

def test_get_valid_paths(self):
for path in os.walk(TEST_FILES_DIR):
if path[0] == TEST_FILES_DIR:
for path in os.walk(VASP_OUT_DIR):
if path[0] == VASP_OUT_DIR:
assert len(self.drone.get_valid_paths(path)) > 0

def test_as_from_dict(self):
Expand Down
14 changes: 7 additions & 7 deletions tests/command_line/test_bader_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pytest import approx

from pymatgen.command_line.bader_caller import BaderAnalysis, bader_analysis_from_path
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR, PymatgenTest


@unittest.skipIf(not which("bader"), "bader executable not present")
Expand All @@ -23,9 +23,9 @@ def setUp(self):
def test_init(self):
# test with reference file
analysis = BaderAnalysis(
chgcar_filename=f"{TEST_FILES_DIR}/CHGCAR.Fe3O4",
chgcar_filename=f"{VASP_OUT_DIR}/CHGCAR.Fe3O4.gz",
potcar_filename=f"{TEST_FILES_DIR}/POTCAR.Fe3O4",
chgref_filename=f"{TEST_FILES_DIR}/CHGCAR.Fe3O4_ref",
chgref_filename=f"{VASP_OUT_DIR}/CHGCAR.Fe3O4_ref.gz",
)
assert len(analysis.data) == 14
assert analysis.data[0]["charge"] == approx(6.6136782, abs=1e-3)
Expand Down Expand Up @@ -55,7 +55,7 @@ def test_init(self):
assert struct[0].specie.oxi_state == approx(1.3863218, abs=1e-3)

# make sure bader still runs without reference file
analysis = BaderAnalysis(chgcar_filename=f"{TEST_FILES_DIR}/CHGCAR.Fe3O4")
analysis = BaderAnalysis(chgcar_filename=f"{VASP_OUT_DIR}/CHGCAR.Fe3O4.gz")
assert len(analysis.data) == 14

# Test Cube file format parsing
Expand Down Expand Up @@ -118,9 +118,9 @@ def test_bader_analysis_from_path(self):
def test_atom_parsing(self):
# test with reference file
analysis = BaderAnalysis(
chgcar_filename=f"{TEST_FILES_DIR}/CHGCAR.Fe3O4",
chgcar_filename=f"{VASP_OUT_DIR}/CHGCAR.Fe3O4.gz",
potcar_filename=f"{TEST_FILES_DIR}/POTCAR.Fe3O4",
chgref_filename=f"{TEST_FILES_DIR}/CHGCAR.Fe3O4_ref",
chgref_filename=f"{VASP_OUT_DIR}/CHGCAR.Fe3O4_ref.gz",
parse_atomic_densities=True,
)

Expand All @@ -139,4 +139,4 @@ def test_missing_file_bader_exe_path(self):
RuntimeError, match="BaderAnalysis requires the executable bader be in the PATH or the full path "
),
):
BaderAnalysis(chgcar_filename=f"{TEST_FILES_DIR}/CHGCAR.Fe3O4", bader_path="")
BaderAnalysis(chgcar_filename=f"{VASP_OUT_DIR}/CHGCAR.Fe3O4.gz", bader_exe_path="")
12 changes: 6 additions & 6 deletions tests/core/test_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from pymatgen.core.trajectory import Trajectory
from pymatgen.io.qchem.outputs import QCOutput
from pymatgen.io.vasp.outputs import Xdatcar
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR, PymatgenTest


class TestTrajectory(PymatgenTest):
def setUp(self):
xdatcar = Xdatcar(f"{TEST_FILES_DIR}/Traj_XDATCAR")
self.traj = Trajectory.from_file(f"{TEST_FILES_DIR}/Traj_XDATCAR")
xdatcar = Xdatcar(f"{VASP_OUT_DIR}/XDATCAR_traj")
self.traj = Trajectory.from_file(f"{VASP_OUT_DIR}/XDATCAR_traj")
self.structures = xdatcar.structures

out = QCOutput(f"{TEST_FILES_DIR}/molecules/new_qchem_files/ts.out")
Expand Down Expand Up @@ -221,15 +221,15 @@ def test_extend(self):
traj = copy.deepcopy(self.traj)

# Case of compatible trajectories
compatible_traj = Trajectory.from_file(f"{TEST_FILES_DIR}/Traj_Combine_Test_XDATCAR_1")
compatible_traj = Trajectory.from_file(f"{VASP_OUT_DIR}/XDATCAR_traj_combine_test_1")
traj.extend(compatible_traj)

full_traj = Trajectory.from_file(f"{TEST_FILES_DIR}/Traj_Combine_Test_XDATCAR_Full")
full_traj = Trajectory.from_file(f"{VASP_OUT_DIR}/XDATCAR_traj_combine_test_full")
compatible_success = self._check_traj_equality(self.traj, full_traj)

# Case of incompatible trajectories
traj = copy.deepcopy(self.traj)
incompatible_traj = Trajectory.from_file(f"{TEST_FILES_DIR}/Traj_Combine_Test_XDATCAR_2")
incompatible_traj = Trajectory.from_file(f"{VASP_OUT_DIR}/XDATCAR_traj_combine_test_2")
incompatible_test_success = False
try:
traj.extend(incompatible_traj)
Expand Down
4 changes: 2 additions & 2 deletions tests/electronic_structure/test_bandstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pymatgen.electronic_structure.core import Orbital, Spin
from pymatgen.electronic_structure.plotter import BSPlotterProjected
from pymatgen.io.vasp import BSVasprun
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR, PymatgenTest


class TestKpoint(unittest.TestCase):
Expand Down Expand Up @@ -264,7 +264,7 @@ def test_reconstruct_band_structure(self):

def test_vasprun_bs(self):
bsv = BSVasprun(
f"{TEST_FILES_DIR}/vasprun.xml.gz",
f"{VASP_OUT_DIR}/vasprun.xml.gz",
parse_projected_eigen=True,
parse_potcar_file=True,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/electronic_structure/test_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
plot_ellipsoid,
)
from pymatgen.io.vasp import Vasprun
from pymatgen.util.testing import TEST_FILES_DIR, PymatgenTest
from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR, PymatgenTest

rc("text", usetex=False) # Disabling latex is needed for this test to work.

Expand Down Expand Up @@ -212,7 +212,7 @@ class TestBSDOSPlotter(unittest.TestCase):
# Minimal baseline testing for get_plot. not a true test. Just checks that
# it can actually execute.
def test_methods(self):
vasp_run = Vasprun(f"{TEST_FILES_DIR}/vasprun_Si_bands.xml.gz")
vasp_run = Vasprun(f"{VASP_OUT_DIR}/vasprun_Si_bands.xml.gz")
plotter = BSDOSPlotter()
band_struct = vasp_run.get_band_structure(kpoints_filename=f"{TEST_FILES_DIR}/KPOINTS_Si_bands")
ax = plotter.get_plot(band_struct)
Expand Down
5 changes: 2 additions & 3 deletions tests/entries/test_computed_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
TemperatureEnergyAdjustment,
)
from pymatgen.io.vasp.outputs import Vasprun
from pymatgen.util.testing import TEST_FILES_DIR
from pymatgen.util.testing import TEST_FILES_DIR, VASP_OUT_DIR

filepath = f"{TEST_FILES_DIR}/vasprun.xml.gz"
vasp_run = Vasprun(filepath)
vasp_run = Vasprun(f"{VASP_OUT_DIR}/vasprun.xml.gz")


def test_energy_adjustment():
Expand Down
Loading
Loading