mlff.py: Batch MLFF Calculations
machine learning force field, MPNICE, QRNN, UMA, GPU
The script mlff.py runs batches of machine learning force field (MLFF) single point energy and geometry optimization calculations. It enables processing of multiple structures without needing to launch a separate Jaguar job per structure. Input structures are automatically split into batches and distributed across the available CPUs. For information on the available MLFF models, see Machine Learning Force Fields.
The workflow performs the following steps:
-
If preopt is enabled, a pre-optimization with OPLS is performed on each input structure.
-
The input structures are split into batches, determined by the batches keyword, and submitted as separate subjobs.
-
Each subjob runs a single point energy calculation or geometry optimization (if geopt is set) for each structure in the batch, using the specified MLFF model.
-
Output structures with computed energies are collected in
jobname-out.mae(or.maegz, matching the input file extension).
Using the mlff.py script
The mlff.py script uses an input file that contains keywords to specify the parameters of the calculation. The command syntax is:
jaguar run mlff.py inputfile.in
See Table 1 for a full list of the available mlff.py keywords and their descriptions.
Here is an example .in file that runs a geometry optimization with the Organic_MPNICE model:
infile = molecules.mae model = organic_mpnice geopt = True preopt = False
Here is an example that runs single point energies with a delta-learned model and implicit solvation. Implicit solvation is only available with delta-learned models (QRNN2, QRNN3, Organic_MPNICE_TB).
infile = molecules.mae model = organic_mpnice_tb implicit_solvent = True solvent = water solvent_model = alpb
GPU acceleration
GPU acceleration can be enabled for MLFF calculations by setting gpu to True. GPU acceleration is available for MPNICE and UMA models. QRNN models are not supported. Delta-learned models such as Organic_MPNICE_TB do not benefit significantly because the xTB portions of the calculation remain on the CPU.
To use GPU acceleration, the job must be submitted to a host with an available GPU:
infile = molecules.mae model = uma_sm_omol geopt = True gpu = True
To use an MLFF with GPU acceleration through Jaguar, set gpu=1 in the &gen section of the Jaguar input file. See External Methods Keywords in the Jaguar Input File (Machine learning methods and xTB).
Custom MLFF models
Custom MLFF models can be used by specifying the model type as the model keyword value and passing the model directory with the -MLFF_DATA command-line flag. The model type name is case-insensitive. For example:
jaguar run mlff.py -MLFF_DATA /path/to/model_directory inputfile.in
The model directory is automatically transferred to the remote host when running on a remote machine.
| Keyword | Type | Allowed Values | Default Values | Description |
|---|---|---|---|---|
| batches | real number | Any | None | Split the input molecules into this many batchesto be submitted as separate subjobs. If not set, the number of batches will be automatically determined to best utilize requested CPUs resources. |
| charge | real number | Any | None | Total charge of each molecule. If not specified, the charge will be calculated. |
| flexible_convergence | boolean | Any | True | Use flexible convergence criteria for the geometry optimization. Convergence is determined via a point system: A point is awarded for each of the convergence criteria below the threshold. For gradient/displacement criteria, an extra point is awarded for reaching 1/5 the threshold. For the energy difference, an extra point is awarded for reaching 1/20 and 1/200 the threshold. The optimization is considered converged when the total points reaches 5 (3 with `ignore_displacement`). |
| geopt | boolean | Any | False | Perform a geometry optimization on the input structures. |
| gpu | boolean | Any | False | Whether to use GPU acceleration for the MLFF calculation. Only available for some models (QRNN is not supported). Delta-learned models will not benefit significantly from GPU acceleration as the xTB portions of the calculation are still performed on the CPU. |
| ignore_displacement | boolean | Any | True | Ignore the displacement convergence criteria in the geometry optimization. |
| implicit_solvent | boolean | Any | False | Add implicit solvation. Can only be used with the Delta-Learned models: (<QRNNModels.DELTA: 2>, <QRNNModels.DELTA_TRANSFER: 3>, 'qrnn_2', 'qrnn_3'). |
| infile | string | Any | None | Input .mae file containing one or more structures. |
| model | Any | qrnn_3 | Model to use for the MLFF calculation. Commonly used models include: Organic_MPNICE: Message Passing model for organic molecules. Organic_MPNICE_TB: Delta-Learned Message Passing model for organic molecules. UMA_sm_omol: Universal Model for Atoms, trained on OMol25. For the full list of available models, see the Machine Learning Force Field documentation. | |
| multiplicity | real number | Any | None | Multiplicity of each molecule. If not specified, the multiplicity will be calculated. Only the UMA_* models support `multiplicity>1`. |
| opt_steps | integer | Any | 1000 | Perform at most this many geometry optimizations steps |
| preopt | real number | Any | None | Perform a pre-optimization with OPLS before the MLFF calculation. Default is False for single-point calculations and True for geometry optimizations. |
| return_failed | boolean | Any | True | Return structures for which the geometry optimization or xTB iterations failed. |
| solvent | string | Any | water | Solvent to use for implicit solvation. Valid solvents include: water, acetonitrile, aniline, benzene, dcm, chloroform, cs2, dmf, dmso, diethyl ether, ethanol, ethyl acetate, hexadecane, hexane, nitromethane, 1-octanol, toluene, thf. |
| solvent_model | string | alpb gbsa cosmo cpcmx |
alpb | Solvent model to use for implicit solvation. Note: `cpcmx` is not supported for optimizations. |
| use_base_energies | boolean | Any | True | Determines whether base atomic energies should be included in MLFF predictions. Note that for some models (e.g. QRNN, uma_sm_omol), base energies are always included in the model (un-toggleable). |
| verbose | boolean | Any | False | Print additional information to the output file (e.g. convergence progress for each structure). |
| prepare_input_structures | boolean | Any | False | Preprocess input structures, converting coordinates from 2D to 3D and adding any missing hydrogens. |