diff --git a/tests/conftest.py b/tests/conftest.py index 7def0a690..20bcacf68 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,7 +12,7 @@ from jobflow.settings import JobflowSettings from maggma.stores import MemoryStore from monty.serialization import loadfn -from pymatgen.core import Structure +from pymatgen.core import Molecule, Structure from atomate2.utils.log import initialize_logger @@ -117,6 +117,11 @@ def ba_ti_o3_structure(test_dir): return Structure.from_file(test_dir / "structures" / "BaTiO3.cif") +@pytest.fixture +def water_molecule(test_dir): + return Molecule.from_file(test_dir / "molecules" / "water.xyz") + + @pytest.fixture(autouse=True) def mock_jobflow_settings(memory_jobstore): """Mock the jobflow settings to use our specific jobstore (with data store).""" diff --git a/tests/forcefields/test_jobs.py b/tests/forcefields/test_jobs.py index 4b8350bdb..74c1ee1ac 100644 --- a/tests/forcefields/test_jobs.py +++ b/tests/forcefields/test_jobs.py @@ -3,7 +3,7 @@ import pytest from jobflow import run_locally -from pymatgen.core import Structure +from pymatgen.core import Molecule, Structure from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pytest import approx, importorskip @@ -319,9 +319,7 @@ def test_mace_relax_maker( assert output1.output.n_steps == 7 -def test_mace_mpa_0_relax_maker( - si_structure: Structure, -): +def test_mace_mpa_0_relax_maker(si_structure: Structure, water_molecule: Molecule): job = ForceFieldRelaxMaker( force_field_name="MACE_MPA_0", steps=25, @@ -333,12 +331,27 @@ def test_mace_mpa_0_relax_maker( # validating the outputs of the job output = responses[job.uuid][1].output + job_mol = ForceFieldRelaxMaker( + force_field_name="MACE_MPA_0", + steps=25, + relax_kwargs={"fmax": 0.005}, + ).make(water_molecule) + # run the flow or job and ensure that it finished running successfully + responses_mol = run_locally(job_mol, ensure_success=True) + + # validating the outputs of the job + output_mol = responses_mol[job_mol.uuid][1].output + assert output.ase_calculator_name == "MLFF.MACE_MPA_0" assert output.output.energy == pytest.approx(-10.829493522644043) assert output.output.structure.volume == pytest.approx(40.87471552602735) assert len(output.output.ionic_steps) == 4 assert output.structure.volume == output.output.structure.volume + assert output_mol.ase_calculator_name == "MLFF.MACE_MPA_0" + assert output_mol.output.energy == pytest.approx(-13.786081314086914) + assert len(output_mol.output.ionic_steps) == 20 + def test_gap_static_maker(si_structure: Structure, test_dir): importorskip("quippy") diff --git a/tests/test_data/molecules/water.xyz b/tests/test_data/molecules/water.xyz new file mode 100644 index 000000000..c067ca4f1 --- /dev/null +++ b/tests/test_data/molecules/water.xyz @@ -0,0 +1,5 @@ +3 +Water molecule +O 0.00000 0.00000 0.11779 +H 0.00000 0.75545 -0.47116 +H 0.00000 -0.75545 -0.47116