Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump chgnet from 0.3.8 to 0.4.0 #990

Merged
merged 16 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ strict = [
]
strict-forcefields = [
"calorine==2.2.1",
"chgnet==0.3.8",
"chgnet==0.4.0",
"mace-torch>=0.3.3",
"matgl==1.1.3",
"quippy-ase==0.9.14; python_version < '3.12'",
"sevenn==0.9.3.post1",
"torch==2.2.1",
"torch==2.4.1",
"torchdata==0.7.1", # TODO: remove when issue fixed
]

Expand Down
16 changes: 8 additions & 8 deletions src/atomate2/qchem/drones.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Drones for parsing VASP calculations and realtd outputs."""
"""Drones for parsing VASP calculations and related outputs."""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Drones for parsing VASP calculations and related outputs."""
"""Drones for parsing QChem calculations and related outputs."""

from __future__ import annotations

Expand Down Expand Up @@ -69,15 +69,15 @@ def get_valid_paths(self, path: tuple[str, list[str], list[str]]) -> list[str]:
parent, subdirs, _ = path
task_names = ["mol.qout.*"]
combined_paths = [parent + os.sep + sdir for sdir in subdirs]
rpath = []
for cpath in combined_paths:
fnames = os.listdir(cpath)
if any(name.startswith("mol.qout.") for name in fnames):
rpath.append(parent)
valid_paths = []
for sub_dir in combined_paths:
file_names = os.listdir(sub_dir)
if any(name.startswith("mol.qout.") for name in file_names):
valid_paths.append(parent)

if (
not any(parent.endswith(os.sep + r) for r in task_names)
and len(list(Path(parent).glob("mol.qout*"))) > 0
):
rpath.append(parent)
return rpath
valid_paths.append(parent)
return valid_paths
18 changes: 5 additions & 13 deletions tests/aims/test_flows/test_anharmonic_quantification.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ def test_anharmonic_quantification_oneshot(si, clean_dir, mock_aims, species_dir
phonon_maker=phonon_maker,
)
maker.name = "anharmonicity"
flow = maker.make(
si,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
)
flow = maker.make(si, supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3))

# run the flow or job and ensure that it finished running successfully
responses = run_locally(flow, create_folders=True, ensure_success=True)
Expand Down Expand Up @@ -120,7 +117,7 @@ def test_anharmonic_quantification_full(si, clean_dir, mock_aims, species_dir):
maker.name = "anharmonicity"
flow = maker.make(
si,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3),
one_shot_approx=False,
seed=1234,
)
Expand Down Expand Up @@ -254,9 +251,7 @@ def test_site_resolved_anharmonic_quantification(
)
maker.name = "anharmonicity"
flow = maker.make(
nacl,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
site_resolved=True,
nacl, supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3), site_resolved=True
)

# run the flow or job and ensure that it finished running successfully
Expand Down Expand Up @@ -323,7 +318,7 @@ def test_element_resolved_anharmonic_quantification(
maker.name = "anharmonicity"
flow = maker.make(
nacl,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3),
element_resolved=True,
)

Expand Down Expand Up @@ -372,10 +367,7 @@ def test_anharmonic_quantification_socket_oneshot(si, clean_dir, species_dir):
phonon_maker=phonon_maker,
)
maker.name = "anharmonicity"
flow = maker.make(
si,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
)
flow = maker.make(si, supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3))

# run the flow or job and ensure that it finished running successfully
responses = run_locally(flow, create_folders=True, ensure_success=True)
Expand Down
21 changes: 5 additions & 16 deletions tests/aims/test_flows/test_phonon_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ def test_phonon_flow(si, clean_dir, mock_aims, species_dir):
),
)
maker.name = "phonons"
flow = maker.make(
si,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
)
flow = maker.make(si, supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3))

# run the flow or job and ensure that it finished running successfully
responses = run_locally(flow, create_folders=True, ensure_success=True)
Expand Down Expand Up @@ -142,10 +139,7 @@ def test_phonon_socket_flow(si, clean_dir, mock_aims, species_dir):
),
)
maker.name = "phonons"
flow = maker.make(
si,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
)
flow = maker.make(si, supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3))

# run the flow or job and ensure that it finished running successfully
responses = run_locally(flow, create_folders=True, ensure_success=True)
Expand Down Expand Up @@ -212,10 +206,8 @@ def test_phonon_default_flow(si, clean_dir, mock_aims, species_dir):

maker = PhononMaker()
maker.name = "phonons"
flow = maker.make(
si,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
)
supercell_matrix = np.ones((3, 3)) - 2 * np.eye(3)
flow = maker.make(si, supercell_matrix=supercell_matrix)

# run the flow or job and ensure that it finished running successfully
responses = run_locally(flow, create_folders=True, ensure_success=True)
Expand Down Expand Up @@ -288,10 +280,7 @@ def test_phonon_default_socket_flow(si, clean_dir, mock_aims, species_dir):

maker = PhononMaker(socket=True)
maker.name = "phonons"
flow = maker.make(
si,
supercell_matrix=np.array([-1, 1, 1, 1, -1, 1, 1, 1, -1]).reshape((3, 3)),
)
flow = maker.make(si, supercell_matrix=np.ones((3, 3)) - 2 * np.eye(3))

# run the flow or job and ensure that it finished running successfully
responses = run_locally(flow, create_folders=True, ensure_success=True)
Expand Down
15 changes: 11 additions & 4 deletions tests/ase/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def test_lennard_jones_relax_maker(lj_fcc_ne_pars, fcc_ne_structure):
assert output.structure.volume == pytest.approx(22.304245)
assert output.output.energy == pytest.approx(-0.018494767)
assert isinstance(output, AseStructureTaskDoc)
assert fcc_ne_structure.matches(
output.structure
), f"{output.structure} != {fcc_ne_structure}"


def test_lennard_jones_static_maker(lj_fcc_ne_pars, fcc_ne_structure):
Expand All @@ -46,8 +49,12 @@ def test_lennard_jones_static_maker(lj_fcc_ne_pars, fcc_ne_structure):
assert output.structure.volume == pytest.approx(24.334)
assert isinstance(output, AseStructureTaskDoc)

# Structure.__eq__ checks properties which contains 'energy', 'forces', 'stress'
# so need to reset properties to ensure equality
output.structure.properties = fcc_ne_structure.properties
assert output.structure == fcc_ne_structure
assert (
output.structure == fcc_ne_structure
), f"{output.structure} != {fcc_ne_structure}"


@pytest.mark.skipif(condition=TBLite is None, reason="TBLite must be installed.")
Expand Down Expand Up @@ -94,9 +101,7 @@ def test_gfn_xtb_relax_maker(h2o_3uud_trimer):
def test_gfn_xtb_static_maker(h2o_3uud_trimer):
os.environ["OMP_NUM_THREADS"] = "1"
job = GFNxTBStaticMaker(
calculator_kwargs={
"method": "GFN2-xTB",
},
calculator_kwargs={"method": "GFN2-xTB"},
).make(h2o_3uud_trimer)

response = run_locally(job)
Expand All @@ -105,5 +110,7 @@ def test_gfn_xtb_static_maker(h2o_3uud_trimer):
assert output.output.energy_per_atom == pytest.approx(-46.05920227158222)
assert isinstance(output, AseMoleculeTaskDoc)

# Molecule.__eq__ checks properties which contains 'energy', 'forces', 'stress'
# so need to reset properties to ensure equality
output.molecule.properties = h2o_3uud_trimer.properties
assert output.molecule == h2o_3uud_trimer
6 changes: 4 additions & 2 deletions tests/forcefields/flows/test_eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
from atomate2.forcefields.flows.eos import (
CHGNetEosMaker,
ForceFieldEosMaker,
M3GNetEosMaker,
# M3GNetEosMaker,
MACEEosMaker,
)

ff_maker_map = {
MLFF.CHGNet.value: CHGNetEosMaker,
MLFF.M3GNet.value: M3GNetEosMaker,
# skip m3gnet due to DGL issues FileNotFoundError: Cannot find DGL C++ graphbolt
# libgraphbolt_pytorch_2.4.1.so
# MLFF.M3GNet.value: M3GNetEosMaker,
MLFF.MACE.value: MACEEosMaker,
}

Expand Down
5 changes: 5 additions & 0 deletions tests/forcefields/test_phonon.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def test_phonon_maker_initialization_with_all_mlff(
if mlff in {MLFF.GAP, MLFF.Forcefield}:
continue # TODO fix GAP, currently fails with RuntimeError, see
# https://github.com/materialsproject/atomate2/pull/918#issuecomment-2253659694
# skip m3gnet due to DGL issues FileNotFoundError: Cannot find DGL C++ graphbolt
# libgraphbolt_pytorch_2.4.1.so
if mlff == MLFF.M3GNet:
continue

calc_kwargs = {
MLFF.Nequip: {"model_path": f"{chk_pt_dir}/nequip/nequip_ff_sr_ti_o3.pth"},
MLFF.NEP: {"model_filename": f"{test_dir}/forcefields/nep/nep.txt"},
Expand Down
Loading