Skip to content

Commit 4da9dc3

Browse files
fixing unit test
1 parent 60b37ae commit 4da9dc3

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

autoplex/data/phonons/utils.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,29 @@ def ml_phonon_maker_preparation(
3838
Keyword arguments that can be passed to the StaticMaker.
3939
"""
4040
if bulk_relax_maker is not None:
41-
br = bulk_relax_maker
42-
bulk_relax_maker = br.update_kwargs(
41+
bulk_relax_maker = bulk_relax_maker.update_kwargs(
4342
update={"calculator_kwargs": calculator_kwargs}
4443
)
4544
if relax_maker_kwargs is not None:
46-
bulk_relax_maker = br.update_kwargs(update={**relax_maker_kwargs})
45+
bulk_relax_maker = bulk_relax_maker.update_kwargs(
46+
update={**relax_maker_kwargs}
47+
)
48+
4749
if phonon_displacement_maker is not None:
48-
ph_disp = phonon_displacement_maker
49-
phonon_displacement_maker = ph_disp.update_kwargs(
50+
phonon_displacement_maker = phonon_displacement_maker.update_kwargs(
5051
update={"calculator_kwargs": calculator_kwargs}
5152
)
5253
if static_maker_kwargs is not None:
53-
phonon_displacement_maker = ph_disp.update_kwargs({**static_maker_kwargs})
54+
phonon_displacement_maker = phonon_displacement_maker.update_kwargs(
55+
{**static_maker_kwargs}
56+
)
5457
if static_energy_maker is not None:
55-
stat_en = static_energy_maker
56-
static_energy_maker = stat_en.update_kwargs(
58+
static_energy_maker = static_energy_maker.update_kwargs(
5759
update={"calculator_kwargs": calculator_kwargs}
5860
)
5961
if static_maker_kwargs is not None:
60-
static_energy_maker = stat_en.update_kwargs(update={**static_maker_kwargs})
62+
static_energy_maker = static_energy_maker.update_kwargs(
63+
update={**static_maker_kwargs}
64+
)
6165

6266
return bulk_relax_maker, phonon_displacement_maker, static_energy_maker

tests/auto/test_auto_flows.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ def test_complete_dft_vs_ml_benchmark_workflow_gap(
169169
store=memory_jobstore,
170170
)
171171

172+
print("RMSE: ", responses[complete_workflow.jobs[-1].output.uuid][1].output[0][0]["benchmark_phonon_rmse"])
173+
172174
assert complete_workflow.jobs[4].name == "complete_benchmark"
173175
assert responses[complete_workflow.jobs[-1].output.uuid][1].output[0][0]["benchmark_phonon_rmse"] == pytest.approx(
174176
2.002641337594289, abs=1.0 # it's kinda fluctuating because of the little data

tests/data/test_datagen_flows.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
from atomate2.vasp.powerups import update_user_incar_settings
66
from atomate2.common.schemas.phonons import PhononBSDOSDoc
77
from pymatgen.core.structure import Structure
8+
from atomate2.forcefields.jobs import (
9+
GAPRelaxMaker,
10+
GAPStaticMaker,
11+
12+
)
813

914
from autoplex.data.common.flows import GenerateTrainingDataForTesting
1015
from autoplex.data.phonons.flows import IsoAtomMaker, RandomStructuresDataGenerator, MLPhononMaker
@@ -16,12 +21,17 @@
1621
def test_ml_phonon_maker(test_dir, clean_dir, memory_jobstore):
1722
from jobflow import run_locally
1823

19-
potential_file_dir = test_dir / "fitting" / "ref_files"
24+
potential_file = test_dir / "fitting" / "ref_files" / "gap_file.xml"
2025
path_to_struct = test_dir / "fitting" / "ref_files" / "POSCAR"
2126
structure = Structure.from_file(path_to_struct)
2227

23-
gap_phonon_jobs = MLPhononMaker(min_length=20).make_from_ml_model(
24-
structure=structure, potential_file=str(potential_file_dir),
28+
gap_phonon_jobs = MLPhononMaker(
29+
min_length=20,
30+
bulk_relax_maker=GAPRelaxMaker(relax_cell=True, relax_kwargs={"interval": 500}),
31+
phonon_displacement_maker=GAPStaticMaker(name="gap phonon static"),
32+
static_energy_maker=GAPStaticMaker(),
33+
).make_from_ml_model(
34+
structure=structure, potential_file=potential_file,
2535
)
2636

2737
responses = run_locally(

0 commit comments

Comments
 (0)