Skip to content

Commit

Permalink
add tests for M3GNetRelaxMaker and M3GNetStaticMaker
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkuner committed Jun 15, 2023
1 parent 7b34dfe commit d1d15e8
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions tests/forcefields/test_jobs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pytest import approx


def test_static_maker(si_structure):
def test_chgnet_static_maker(si_structure):
from jobflow import run_locally

from atomate2.forcefields.jobs import CHGNetStaticMaker
Expand All @@ -23,7 +23,7 @@ def test_static_maker(si_structure):
assert output1.output.n_steps == 1


def test_relax_maker(si_structure):
def test_chgnet_relax_maker(si_structure):
from jobflow import run_locally

from atomate2.forcefields.jobs import CHGNetRelaxMaker
Expand All @@ -46,3 +46,46 @@ def test_relax_maker(si_structure):
0.002112872898578644, rel=1e-4
)
assert output1.output.n_steps == 12


def test_m3gnet_static_maker(si_structure):
from jobflow import run_locally

from atomate2.forcefields.jobs import M3GNetStaticMaker
from atomate2.forcefields.schemas import ForceFieldTaskDocument

task_doc_kwargs = {"ionic_step_data": ("structure", "energy")}

# generate job
job = M3GNetStaticMaker(task_document_kwargs=task_doc_kwargs).make(si_structure)

# run the flow or job and ensure that it finished running successfully
responses = run_locally(job, ensure_success=True)

# validation the outputs of the job
output1 = responses[job.uuid][1].output
assert isinstance(output1, ForceFieldTaskDocument)
assert output1.output.energy == approx(-10.711267471313477, rel=1e-4)
assert output1.output.n_steps == 1


def test_m3gnet_relax_maker(si_structure):
from jobflow import run_locally

from atomate2.forcefields.jobs import M3GNetRelaxMaker
from atomate2.forcefields.schemas import ForceFieldTaskDocument

# translate one atom to ensure a small number of relaxation steps are taken
si_structure.translate_sites(0, [0, 0, 0.1])

# generate job
job = M3GNetRelaxMaker(steps=25).make(si_structure)

# run the flow or job and ensure that it finished running successfully
responses = run_locally(job, ensure_success=True)

# validating the outputs of the job
output1 = responses[job.uuid][1].output
assert isinstance(output1, ForceFieldTaskDocument)
assert output1.output.energy == approx(-10.710836410522461, rel=1e-4)
assert output1.output.n_steps == 14

0 comments on commit d1d15e8

Please sign in to comment.