-
Notifications
You must be signed in to change notification settings - Fork 124
Description
Describe the bug
This is probably a minor issue, since most of the ase calculators are managed through subclasses of the ForceFieldMDMaker
, however the ase_calculator
does not work as expected from the definition of the API, since passing an MLFF
instance is not properly recognized.
The reason is this check:
if isinstance(calculator_meta, str | MLFF) and calculator_meta in map(str, MLFF): |
Since str(MLFF.MACE)
gives 'MLFF.MACE'
, this check translates in something like MLFF.MACE in ["MLFF.FACE", ...]
which resolves to False.
Overall the ForceFieldMDMaker
works because it always converts MLFF to a string:
atomate2/src/atomate2/forcefields/md.py
Line 160 in 0e50e07
str(self.force_field_name), # make mypy happy |
I am not opening a PR because I am not sure how you would rather address this. In principle changing the code so that it accepts the string "MACE"
instead of "MLFF.MACE"
may be a backward incompatible change.
To Reproduce
from atomate2.forcefields import MLFF
from atomate2.forcefields.utils import ase_calculator
ase_calculator(MLFF.MACE) # raises an error: ValueError: Could not create ASE calculator for MLFF.MACE.
ase_calculator("MACE") # raises an error: ValueError: Could not create ASE calculator for MLFF.MACE.
ase_calculator(str(MLFF.MACE)) # works
ase_calculator("MLFF.MACE") # works