Skip to content

Commit

Permalink
add one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
JaGeo committed Dec 26, 2024
1 parent 512cad7 commit 1163b83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/autoplex/auto/phonons/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ def get_output(
# TODO: potentially evaluation of imaginary modes

rms_max_values = [] # get the largest rms in each fit

for i in range(len(metrics[0])):
rms_max_value = max(sublist[i]["benchmark_phonon_rmse"] for sublist in metrics)
rms_max_values.append(rms_max_value)
Expand Down
52 changes: 16 additions & 36 deletions tests/auto/phonons/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,50 +122,30 @@ def test_get_output(clean_dir,test_dir,memory_jobstore):
from jobflow import run_locally

input_dict={"metrics": [[{"benchmark_phonon_rmse": 0.12230662063050536, "dft_imaginary_modes": True,
"ml_imaginary_modes": False, "ml_model": "GAP", "mp_id": "test",
"structure": {"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0, "lattice": {
"matrix": [[5.527464055912056, 0.0, 3.3845955817373727e-16],
[8.888840143585662e-16, 5.527464055912056, 3.3845955817373727e-16],
[0.0, 0.0, 3.006687739088837]], "pbc": [True, True, True], "a": 5.527464055912056,
"b": 5.527464055912056, "c": 3.006687739088837, "alpha": 90.0, "beta": 90.0,
"gamma": 89.99999999999999, "volume": 91.86290621686962}, "properties": {}, "sites": [
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.5, 0.0, 0.25], "properties": {},
"label": "Sn", "xyz": [2.763732027956028, 0.0, 0.7516719347722095]},
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.0, 0.0, 0.0], "properties": {},
"label": "Sn", "xyz": [0.0, 0.0, 0.0]},
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.0, 0.5, 0.75], "properties": {},
"label": "Sn", "xyz": [4.444420071792831e-16, 2.763732027956028, 2.255015804316628]},
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.5, 0.5, 0.5], "properties": {},
"label": "Sn", "xyz": [2.7637320279560282, 2.763732027956028, 1.503343869544419]}]},
"displacement": 0.01, "atomwise_regularization_parameter": 0.1,
"soap_dict": {"delta": 1.0, "n_sparse": 6000}, "suffix": "full"}], [
"ml_imaginary_modes": False}], [
{"benchmark_phonon_rmse": 0.08305510558730159, "dft_imaginary_modes": False,
"ml_imaginary_modes": False, "ml_model": "GAP", "mp_id": "test2",
"structure": {"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0,
"lattice": {"matrix": [[5.586266865017504, 0.0, 3.4206019177133026e-16],
[8.983402272772745e-16, 5.586266865017504,
3.4206019177133026e-16], [0.0, 0.0, 3.0386737788663782]],
"pbc": [True, True, True], "a": 5.586266865017504,
"b": 5.586266865017504, "c": 3.0386737788663782, "alpha": 90.0,
"beta": 90.0, "gamma": 89.99999999999999, "volume": 94.82600100373789},
"properties": {}, "sites": [
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.5, 0.0, 0.25], "properties": {},
"label": "Sn", "xyz": [2.793133432508752, 0.0, 0.7596684447165948]},
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.0, 0.0, 0.0], "properties": {},
"label": "Sn", "xyz": [0.0, 0.0, 0.0]},
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.0, 0.5, 0.75], "properties": {},
"label": "Sn", "xyz": [4.491701136386372e-16, 2.793133432508752, 2.279005334149784]},
{"species": [{"element": "Sn", "occu": 1}], "abc": [0.5, 0.5, 0.5], "properties": {},
"label": "Sn", "xyz": [2.7931334325087525, 2.793133432508752, 1.5193368894331896]}]},
"displacement": 0.01, "atomwise_regularization_parameter": 0.1,
"soap_dict": {"delta": 1.0, "n_sparse": 6000}, "suffix": "full"}]]}
"ml_imaginary_modes": False}]]}

job_here=get_output(metrics=input_dict["metrics"])

responses=run_locally(job_here)

responses[job_here.uuid][1].output["rms"] == pytest.approx(0.1223)

input_dict = {"metrics": [[{"benchmark_phonon_rmse": 0.12230662063050536, "dft_imaginary_modes": True,
"ml_imaginary_modes": False}, {"benchmark_phonon_rmse": 0.15230662063050536, "dft_imaginary_modes": True,
"ml_imaginary_modes": False}], [
{"benchmark_phonon_rmse": 0.08305510558730159, "dft_imaginary_modes": False,
"ml_imaginary_modes": False}, {"benchmark_phonon_rmse": 0.12230662063050536, "dft_imaginary_modes": True,
"ml_imaginary_modes": False}]]}

job_here=get_output(metrics=input_dict["metrics"])

responses=run_locally(job_here)

responses[job_here.uuid][1].output["rms"] == pytest.approx(0.1223)


def test_complete_benchmark(clean_dir, test_dir, memory_jobstore):
from monty.serialization import loadfn
from atomate2.common.schemas.phonons import PhononBSDOSDoc
Expand Down

0 comments on commit 1163b83

Please sign in to comment.