Vibrational AnalysisΒΆ
mlipx provides a command line interface to vibrational analysis.
You can run the following command to instantiate a test directory:
(.venv) $ mlipx recipes vibrational-analysis --models mace-mpa-0,7net-0,7net-mf-ompa-mpa,orb-v2,orb-v3,mattersim,grace-2l-omat --smiles=CO,CCO,CCCO,CCCCO
(.venv) $ vim main.py # set system="molecule"
(.venv) $ python main.py
(.venv) $ dvc repro
(.venv) $ mlipx compare --glob "*VibrationalAnalysis"
The vibrational analysis method needs additional information to run.
Please edit the main.py file and set the system parameter on the VibrationalAnalysis node.
For the given list of SMILES, you should set it to "molecule".
Then run the following commands to reproduce and inspect the results:
(.venv) $ python main.py
(.venv) $ dvc repro
(.venv) $ mlipx compare --glob "*VibrationalAnalysis"
This test uses the following Nodes together with your provided model in the models.py file:
Content of main.py
import mlipx
import zntrack
from models import MODELS
project = zntrack.Project()
frames = []
with project.group("initialize"):
for smiles in ['CO', 'CCO', 'CCCO', 'CCCCO']:
frames.append(mlipx.Smiles2Conformers(smiles=smiles, num_confs=1))
for model_name, model in MODELS.items():
with project.group(model_name):
phon = mlipx.VibrationalAnalysis(
data=sum([x.frames for x in frames], []),
model=model,
temperature=298.15,
displacement=0.015,
nfree=4,
lower_freq_threshold=12,
system="molecule",
)
project.build()
Content of models.py
import dataclasses
import mlipx
from mlipx.nodes.generic_ase import Device
ALL_MODELS = {}
# https://github.com/ACEsuit/mace
ALL_MODELS["mace-mpa-0"] = mlipx.GenericASECalculator(
module="mace.calculators",
class_name="mace_mp",
device="auto",
kwargs={"model": "../../models/mace-mpa-0-medium.model"}
# MLIPX-hub model path, adjust as needed
)
# https://github.com/MDIL-SNU/SevenNet
ALL_MODELS["7net-0"] = mlipx.GenericASECalculator(
module="sevenn.sevennet_calculator",
class_name="SevenNetCalculator",
device="auto",
kwargs={"model": "7net-0"}
)
ALL_MODELS["7net-mf-ompa-mpa"] = mlipx.GenericASECalculator(
module="sevenn.sevennet_calculator",
class_name="SevenNetCalculator",
device="auto",
kwargs={"model": "7net-mf-ompa", "modal": "mpa"}
)
# https://github.com/orbital-materials/orb-models
@dataclasses.dataclass
class OrbCalc:
name: str
device: Device | None = None
kwargs: dict = dataclasses.field(default_factory=dict)
def get_calculator(self, **kwargs):
from orb_models.forcefield import pretrained
from orb_models.forcefield.calculator import ORBCalculator
method = getattr(pretrained, self.name)
if self.device is None:
orbff = method(**self.kwargs)
calc = ORBCalculator(orbff, **self.kwargs)
elif self.device == Device.AUTO:
orbff = method(device=Device.resolve_auto(), **self.kwargs)
calc = ORBCalculator(orbff, device=Device.resolve_auto(), **self.kwargs)
else:
orbff = method(device=self.device, **self.kwargs)
calc = ORBCalculator(orbff, device=self.device, **self.kwargs)
return calc
@property
def available(self) -> bool:
try:
from orb_models.forcefield import pretrained
from orb_models.forcefield.calculator import ORBCalculator
return True
except ImportError:
return False
ALL_MODELS["orb-v2"] = OrbCalc(
name="orb_v2",
device="auto"
)
ALL_MODELS["orb-v3"] = OrbCalc(
name="orb_v3_conservative_inf_omat",
device="auto"
)
# https://github.com/CederGroupHub/chgnet
ALL_MODELS["chgnet"] = mlipx.GenericASECalculator(
module="chgnet.model",
class_name="CHGNetCalculator",
)
# https://github.com/microsoft/mattersim
ALL_MODELS["mattersim"] = mlipx.GenericASECalculator(
module="mattersim.forcefield",
class_name="MatterSimCalculator",
device="auto",
)
# https://www.faccts.de/orca/
ALL_MODELS["orca"] = mlipx.OrcaSinglePoint(
orcasimpleinput= "PBE def2-TZVP TightSCF EnGrad",
orcablocks ="%pal nprocs 8 end",
orca_shell="",
)
# https://gracemaker.readthedocs.io/en/latest/gracemaker/foundation/
ALL_MODELS["grace-2l-omat"] = mlipx.GenericASECalculator(
module="tensorpotential.calculator",
class_name="TPCalculator",
device=None,
kwargs={
"model": "../../models/GRACE-2L-OMAT",
},
# MLIPX-hub model path, adjust as needed
)
# OPTIONAL
# ========
# If you have custom property names you can use the UpdatedFramesCalc
# to set the energy, force and isolated_energies keys mlipx expects.
# REFERENCE = mlipx.UpdateFramesCalc(
# results_mapping={"energy": "DFT_ENERGY", "forces": "DFT_FORCES"},
# info_mapping={mlipx.abc.ASEKeys.isolated_energies.value: "isol_ene"},
# )
# ============================================================
# THE SELECTED MODELS!
# ONLY THESE MODELS WILL BE USED IN THE RECIPE
# ============================================================
MODELS = {
"mace-mpa-0": ALL_MODELS["mace-mpa-0"],
"7net-0": ALL_MODELS["7net-0"],
"7net-mf-ompa-mpa": ALL_MODELS["7net-mf-ompa-mpa"],
"orb-v2": ALL_MODELS["orb-v2"],
"orb-v3": ALL_MODELS["orb-v3"],
"mattersim": ALL_MODELS["mattersim"],
"grace-2l-omat": ALL_MODELS["grace-2l-omat"],
}