Skip to content

Commit c5a3398

Browse files
Cleanup: dtypes, elastic tensors, citations (#1442)
* add major refs * dtype for matgl * make default_dtype an explicit calculator kwarg * lobster citation description Co-authored-by: J. George <JaGeo@users.noreply.github.com> * ensure mace dtype gets passed as kwarg --------- Co-authored-by: J. George <JaGeo@users.noreply.github.com>
1 parent 50fcffa commit c5a3398

13 files changed

Lines changed: 62 additions & 10 deletions

File tree

docs/dev/forcefields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ There is both an `ase` module in `atomate2`, based around general `ase` `Calcula
1010

1111
The `ase` module should be used to manage high-level tasks, such as geometry optimization, molecular dynamics, and nudged elastic band. Any further developments to these tools in `ase` should also warrant updates in this module in `atomate2`. For example, when `ase` rolled out the `MTKNPT` NPT MD barostat as a replacement for the default barostat, this was also made the default in `atomate2`.
1212

13-
The `forcefields` library should be used to develop concrete implementations of workflows, e.g., harmonic phonon, Grüneisen parameter, ApproxNEB.
13+
The `forcefields` library should be used to develop concrete implementations of workflows, e.g., harmonic phonon, Grüneisen parameter, [ApproxNEB](https://doi.org/10.1063/1.4960790).
1414

1515
## Dependency Chaos
1616

src/atomate2/abinit/jobs/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import jobflow
1313
from jobflow import Maker, Response, job
14+
from pymatgen.util.due import Doi, due
1415

1516
from atomate2 import SETTINGS
1617
from atomate2.abinit.files import write_abinit_input_set
@@ -98,6 +99,7 @@ def setup_job(
9899
)
99100

100101

102+
@due.dcite(Doi("10.1063/5.028827"), description="Most recent Abinit paper")
101103
@dataclass
102104
class BaseAbinitMaker(Maker):
103105
"""

src/atomate2/aims/jobs/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from jobflow import Maker, Response, job
1111
from monty.serialization import dumpfn
1212
from pymatgen.io.aims.sets.base import AimsInputGenerator
13+
from pymatgen.util.due import Doi, due
1314

1415
from atomate2 import SETTINGS
1516
from atomate2.aims.files import (
@@ -40,6 +41,7 @@
4041
_FILES_TO_ZIP = _INPUT_FILES + _OUTPUT_FILES
4142

4243

44+
@due.dcite(Doi("10.1016/j.cpc.2009.06.022"), description="FHI-AIMS")
4345
@dataclass
4446
class BaseAimsMaker(Maker):
4547
"""

src/atomate2/ase/jobs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from jobflow import Maker, job
1313
from pymatgen.core import Molecule, Structure
1414
from pymatgen.io.ase import AseAtomsAdaptor
15+
from pymatgen.util.due import Doi, due
1516

1617
from atomate2.ase.schemas import AseResult, AseTaskDoc
1718
from atomate2.ase.utils import AseRelaxer
@@ -28,6 +29,9 @@
2829
_ASE_DATA_OBJECTS = ["trajectory"]
2930

3031

32+
@due.dcite(
33+
Doi("10.1088/1361-648X/aa680e"), description="Atomic simulation environment."
34+
)
3135
@dataclass
3236
class AseMaker(Maker, ABC):
3337
"""

src/atomate2/common/flows/approx_neb.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from emmet.core.mobility.migrationgraph import MigrationGraphDoc
99
from jobflow import Flow, Maker, OnMissing
10+
from pymatgen.util.due import Doi, due
1011

1112
from atomate2.common.jobs.approx_neb import (
1213
collate_images_single_hop,
@@ -25,6 +26,7 @@
2526
from pymatgen.util.typing import CompositionLike
2627

2728

29+
@due.dcite(Doi("https://doi.org/10.1063/1.4960790"), description="ApproxNEB")
2830
@dataclass
2931
class CommonApproxNebMaker(Maker):
3032
"""Run an ApproxNEB workflow.

src/atomate2/cp2k/jobs/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
)
1818
from pymatgen.electronic_structure.dos import DOS, CompleteDos, Dos
1919
from pymatgen.io.common import VolumetricData
20+
from pymatgen.util.due import Doi, due
2021

2122
from atomate2 import SETTINGS
2223
from atomate2.common.files import gzip_files, gzip_output_folder
@@ -85,6 +86,13 @@ def make(structure):
8586
return job(method, data=_DATA_OBJECTS, output_schema=TaskDocument)
8687

8788

89+
@due.dcite(
90+
Doi("10.1063/5.0007045"),
91+
description=(
92+
"CP2K review - ensure you cite all references "
93+
'in the "R E F E R E N C E S" section of the CP2K output'
94+
),
95+
)
8896
@dataclass
8997
class BaseCp2kMaker(Maker):
9098
"""

src/atomate2/forcefields/utils.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
from collections.abc import Callable, Generator
2121
from typing import Any
2222

23+
try:
24+
from torch import dtype as torch_dtype
25+
except ImportError:
26+
torch_dtype = str
27+
2328
from ase.calculators.calculator import Calculator
2429

2530
from atomate2.ase.schemas import AseResult
@@ -229,7 +234,9 @@ def ase_calculator_name(self) -> str:
229234

230235

231236
def ase_calculator(
232-
calculator_meta: str | MLFF | dict, **kwargs: Any
237+
calculator_meta: str | MLFF | dict,
238+
default_dtype: str | torch_dtype | None = None,
239+
**kwargs: Any,
233240
) -> Calculator | None:
234241
"""
235242
Create an ASE calculator from a given set of metadata.
@@ -246,7 +253,7 @@ def ase_calculator(
246253
"@callable": "CHGNetCalculator"
247254
}
248255
```
249-
args : optional args to pass to a calculator
256+
default_dtype (str or pytorch dtype) : optional pytorch dtype to use if applicable
250257
kwargs : optional kwargs to pass to a calculator
251258
252259
Returns
@@ -310,6 +317,9 @@ def ase_calculator(
310317
)
311318
matgl.config.BACKEND = "PYG"
312319

320+
if default_dtype is not None:
321+
matgl.set_default_dtype(default_dtype)
322+
313323
matgl_calc = getattr(
314324
import_module(f"matgl.ext._ase_{matgl.config.BACKEND.lower()}"),
315325
"PESCalculator",
@@ -328,6 +338,7 @@ def ase_calculator(
328338
calculator = MACECalculator(
329339
model_paths=model_path,
330340
device=device,
341+
default_dtype=default_dtype or "",
331342
**kwargs,
332343
)
333344

@@ -345,18 +356,20 @@ def ase_calculator(
345356
"damping": "bj",
346357
"xc": "pbe",
347358
"cutoff": 40.0 * Bohr,
348-
"dtype": kwargs.get(
349-
"default_dtype", torch.get_default_dtype()
350-
),
359+
"dtype": default_dtype or torch.get_default_dtype(),
351360
}
352-
for k, v in default_d3_kwargs.items():
353-
if k not in kwargs:
354-
kwargs[k] = v
361+
kwargs.update(
362+
{
363+
k: v
364+
for k, v in default_d3_kwargs.items()
365+
if k not in kwargs
366+
}
367+
)
355368

356369
d3_calc = TorchDFTD3Calculator(device=device, **kwargs)
357370
calculator = SumCalculator([calculator, d3_calc])
358371
else:
359-
calculator = mace_mp(**kwargs)
372+
calculator = mace_mp(default_dtype=default_dtype or "", **kwargs)
360373

361374
case MLFF.Nequip | MLFF.Allegro:
362375
from nequip.integrations.ase import NequIPCalculator

src/atomate2/jdftx/jobs/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
BandStructure,
1414
BandStructureSymmLine,
1515
)
16+
from pymatgen.util.due import Doi, due
1617

1718
from atomate2.jdftx.files import write_jdftx_input_set
1819
from atomate2.jdftx.run import run_jdftx, should_stop_children
@@ -73,6 +74,7 @@ def jdftx_job(method: Callable) -> job:
7374
return job(method, data=_DATA_OBJECTS, output_schema=TaskDoc)
7475

7576

77+
@due.dcite(Doi("10.1016/j.softx.2017.10.006"), description="JDFTx")
7678
@dataclass
7779
class BaseJdftxMaker(Maker):
7880
"""

src/atomate2/lobster/jobs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pymatgen.electronic_structure.cohp import CompleteCohp
1111
from pymatgen.electronic_structure.dos import LobsterCompleteDos
1212
from pymatgen.io.lobster import Bandoverlaps, Icohplist, Lobsterin
13+
from pymatgen.util.due import Doi, due
1314

1415
from atomate2 import SETTINGS
1516
from atomate2.common.files import gzip_output_folder
@@ -27,6 +28,13 @@
2728
_FILES_TO_ZIP = [*LOBSTEROUTPUT_FILES, "lobsterin", *VASP_OUTPUT_FILES]
2829

2930

31+
@due.dcite(
32+
Doi("https://doi.org/10.1002/jcc.26353"),
33+
description=(
34+
"Most recent LOBSTER paper. "
35+
"Please cite the publications mentioned in the LOBSTER Terms of Use."
36+
),
37+
)
3038
@dataclass
3139
class LobsterMaker(Maker):
3240
"""

src/atomate2/openff/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from openff.interchange.components._packmol import pack_box
1414
from openff.toolkit import ForceField
1515
from openff.units import unit
16+
from pymatgen.util.due import Doi, due
1617

1718
from atomate2.openff.utils import create_mol_spec_list, merge_specs_by_name_and_smiles
1819

@@ -56,6 +57,7 @@ def make(structure):
5657
)
5758

5859

60+
@due.dcite(Doi("10.1021/acs.jpcb.4c01558"), description="Open forcefield initiative")
5961
@openff_job
6062
def generate_interchange(
6163
input_mol_specs: list[MoleculeSpec | dict],

0 commit comments

Comments
 (0)