calypso.plugins.run_mlp module

Project Name: run_mlp

Description: Crystal structure optimization interface for machine learning potentials (MLP)

This module loading MLP reading crystal structure cif file, then performing geometric optimization by ase LBFGS/BFGS/FIRE algorithems.

Authors:

Zhenyu Wang <wangzy@calypso.cn> Xiaoshan Luo <luoxs@calypso.cn>

Created Date: 2024-08-30 Last Modified:

(2024-08-30)

Feature: use commandline argument author: Xiaoshan Luo

Copyright (c) 2022 CALYPSO Developers Group

Usage:
usage: run_mlp.py [-h] [-m {chgnet@0.3.0,dp,m3gnet,mace_mp,mace_off,eqv2,7net,orb}] [–model-args MODEL_ARGS] [–calculator-args CALCULATOR_ARGS] [-a {lbfgs,bfgs,fire}]

[-P PRESSURE] [-F FMAX] [-N OPTSTEPS] [–traj-suffix TRAJ_SUFFIX] [–opt-suffix OPT_SUFFIX] [–optinfo-suffix OPTINFO_SUFFIX] [–verbose] cif [cif …]

example:

python run_mlp.py *.vasp -m chgnet@0.3.0 -v -P 40 -F 0.01 -N 600 python run_mlp.py *.vasp -m m3gnet -v -P 40 -F 0.01 -N 600 python run_mlp.py *.vasp -m eqv2 -v -P 40 -F 0.01 -N 600 –model-args ‘{“checkpoint_path”: “eqV2_86M_omat_mp_salex.pt”, “model_name”: None, “local_cache”: None}’ python run_mlp.py *.vasp -m 7net -v -P 40 -F 0.01 -N 600 python run_mlp.py *.vasp -m mace_off -v -P 40 -F 0.01 -N 600 python run_mlp.py *.vasp -m mace_mp -v -P 40 -F 0.01 -N 600

positional arguments:

cif Structure cif file to be optimized.

options:
-h, --help

show this help message and exit

-m {chgnet@0.3.0,dp,m3gnet,mace}, –model {chgnet@0.3.0,dp,m3gnet,mace}

Machine learning potential to use. (default: chgnet@0.3.0)

--model-args MODEL_ARGS

Other model arguments as dict string. (default: {})

--calculator-args CALCULATOR_ARGS

Other calculator arguments as dict string. (default: {})

-a {lbfgs,bfgs,fire}, –algo {lbfgs,bfgs,fire}

Optimization algorithem. (default: lbfgs)

-P PRESSURE, --pressure PRESSURE

External pressure, in GPa. (default: 50.0)

-F FMAX, --fmax FMAX

Max force for optimizations, in eV/A. (default: 0.1)

-N OPTSTEPS, --optsteps OPTSTEPS

Number of optimizer steps to be run. (default: 200)

--traj-suffix TRAJ_SUFFIX

Trajectory filename suffix. (default: .opt.traj)

--opt-suffix OPT_SUFFIX

Optimized structure filename suffix. (default: .opt.cif)

--optinfo-suffix OPTINFO_SUFFIX

Settings and info of optimized structure pickle filename suffix. (default: .opt.pkl)

--verbose

Verbose output. (default: False)

Dependencies:

python>=3.9, ase Optional, chgnet, deepmd-kit (for DP), matgl (for m3gnet), mace

calypso.plugins.run_mlp.MODEL

alias of model

calypso.plugins.run_mlp.OPTALGO

alias of algo

calypso.plugins.run_mlp.get_calculator(modelname: str, model_args: str = '{}', calculator_args: str = '{}') Calculator
calypso.plugins.run_mlp.get_calculator_chgnet030(model_args: dict, calculator_args: dict) Calculator

Get CHGNet calculator 0.2.0, 0.3.0

Raises:

ModuleNotFoundError – If chgnet python package not installed.

References

https://github.com/CederGroupHub/chgnet/blob/main/chgnet/model/dynamics.py#L51 https://github.com/CederGroupHub/chgnet

calypso.plugins.run_mlp.get_calculator_dp(model_args: dict, calculator_args: dict) Calculator

Get DP calculator

Raises:
  • ModuleNotFoundError – If deepmd python package not installed.

  • ValueError – If model pt path not specified, eg --calculator-args="{'model': '/path/to/pb/file'}"

References

https://github.com/deepmodeling/deepmd-kit/blob/r2/deepmd/calculator.py#L34 https://docs.deepmodeling.com/projects/deepmd/en/stable/getting-started/install.html

calypso.plugins.run_mlp.get_calculator_eqv2(model_args: dict, calculator_args: dict) Calculator

Get EquiformerV2 pretrained model calculator

Raises:

ModuleNotFoundError – If equiv2 or fair-chem python package not installed.

References

https://huggingface.co/fairchem/OMAT24 https://github.com/FAIR-Chem/fairchem https://github.com/FAIR-Chem/fairchem/blob/main/src/fairchem/core/common/relaxation/ase_utils.py#L69 https://github.com/FAIR-Chem/fairchem/blob/main/src/fairchem/core/models/pretrained_models.yml

calypso.plugins.run_mlp.get_calculator_m3gnet(model_args: dict, calculator_args: dict) Calculator

Get M3GNet calculator

Raises:

ModuleNotFoundError – If matgl python package not installed.

References

https://github.com/materialsvirtuallab/matgl/blob/main/src/matgl/ext/ase.py#L124 https://github.com/materialsvirtuallab/matgl

calypso.plugins.run_mlp.get_calculator_mace_mp(model_args: dict, calculator_args: dict) Calculator

Get MACE(mace_mp) calculator

Raises:

ModuleNotFoundError – If mace python package not installed.

References

https://github.com/ACEsuit/mace/blob/main/mace/calculators/foundations_models.py#L18 https://github.com/ACEsuit/mace

calypso.plugins.run_mlp.get_calculator_mace_off(model_args: dict, calculator_args: dict) Calculator

Get MACE calculator

Raises:

ModuleNotFoundError – If mace python package not installed.

References

https://github.com/ACEsuit/mace/blob/main/mace/calculators/foundations_models.py#L18 https://github.com/ACEsuit/mace

calypso.plugins.run_mlp.get_calculator_orb(model_args: dict, calculator_args: dict) Calculator

Get orb pretrained model calculator

Raises:

ModuleNotFoundError – If orb python package not installed.

References

https://github.com/orbital-materials/orb-models

calypso.plugins.run_mlp.get_calculator_sevenn(model_args: dict, calculator_args: dict) Calculator

Get sevenNet pretrained model calculator

Raises:

ModuleNotFoundError – If sevenNet python package not installed.

References

https://github.com/MDIL-SNU/SevenNet?tab=readme-ov-file#sevennet-calculator-for-ase

calypso.plugins.run_mlp.get_optimizer_algo(optimizername: str)
calypso.plugins.run_mlp.main(args)
calypso.plugins.run_mlp.run_opt(cif: str | Path, modelname: str, calculator: Calculator, opt_algo, pstress: float, fmax: float, optsteps: int, traj_suffix: str, opt_suffix: str, optinfo_suffix: str, verbose=True)