monkeypatch_vasp

atomate2.utils.testing.vasp.monkeypatch_vasp(monkeypatch, vasp_test_dir, nelect=12)[source]

Fake VASP calculations by copying reference files.

This is provided as a generator and can be used as by conextmanagers and pytest.fixture.

It works by monkeypatching (replacing) calls to run_vasp and VaspInputSet.write_inputs with versions that will work when the vasp executables or POTCAR files are not present.

The primary idea is that instead of running VASP to generate the output files, reference files will be copied into the directory instead. As we do not want to test whether VASP is giving the correct output rather that the calculation inputs are generated correctly and that the outputs are parsed properly, this should be sufficient for our needs. Another potential issue is that the POTCAR files distributed with VASP are not present on the testing server due to licensing constraints. Accordingly, VaspInputSet.write_inputs will fail unless the “potcar_spec” option is set to True, in which case a POTCAR.spec file will be written instead.

The pytext.fixture defined with this is stored at tests/vasp/conftest.py. For examples, see the tests in tests/vasp/makers/core.py.

Parameters:
  • monkeypatch (The a MonkeyPatch object from pytest, this is meant as a place-holder) – For the monkeypatch fixture in pytest.

  • vasp_test_dir (The root directory for the VASP tests. This is)

  • nelect (The number of electrons in a system is usually calculate using the POTCAR) – which we do not have direct access to during testing. So we have to patch it in. TODO: potcar_spec should have the nelect data somehow.

Return type:

Generator[Callable[[Any, Any], Any], None, None]