opt (geometry optimization)¶
opt optimizes one structure of a layered ML/MM enzyme model to a local minimum. It uses L-BFGS (--opt-mode grad, the default) or RFO (--opt-mode hess).
What it is for¶
Preparing R, P, and intermediates: relax the reactant, product, and intermediate structures before a path search or a frequency calculation, and confirm each minimum (n_imag = 0) with
freq.Relaxing with fixed distances: keep chosen atom pairs at a set distance while everything else relaxes.
Turning IRC endpoints into R and P: optimize the endpoints of an
ircrun to the minima they lead to.MM pre-relaxation: relax the whole system on the MM force field alone (
--mm-only) before the ML/MM optimization.
The ML region uses UMA (Meta) by default; -b/--backend also selects ORB, MACE, AIMNet2, or DFT. The MM atoms use the Amber force field of --parm7.
Examples¶
1. Basic minimization¶
Optimize the full system system_layered.pdb with its Amber topology real.parm7 and the ML region ml_region.pdb, and write a summary with --out-json.
mlmm opt -i system_layered.pdb --parm7 real.parm7 --model-pdb ml_region.pdb \
-q 0 -m 1 --out-json --out-dir ./result_opt
The run converged when the console prints [opt] Converged! and result_opt/result.json has "optimization_status": "converged".
2. Tighter threshold with trajectory¶
Use the gau_tight criteria and keep the optimization trajectory.
mlmm opt -i system_layered.pdb --parm7 real.parm7 --model-pdb ml_region.pdb \
-q 0 -m 1 --thresh gau_tight --dump --out-dir ./result_opt_tight
3. Distance restraint¶
Pull atoms 12 and 45 toward 2.20 Å with a weak harmonic restraint (20 eV·Å⁻²).
mlmm opt -i system_layered.pdb --parm7 real.parm7 --model-pdb ml_region.pdb \
-q 0 -m 1 --distance-restraint '[(12,45,2.20)]' --restraint-k 20.0 \
--out-dir ./result_opt_rest
4. RFO with microiteration¶
Switch to RFO, which starts from an exact Hessian, with --opt-mode hess; microiteration is on by default.
mlmm opt -i system_layered.pdb --parm7 real.parm7 --model-pdb ml_region.pdb \
-q 0 -m 1 --opt-mode hess --out-dir ./result_opt_rfo
How it works¶
Building the ML/MM system:
optreads the full system from-i, the Amber topology from--parm7, and the ML region from--model-pdb; the other atoms are movable or frozen MM atoms.-qand-mare the charge and the spin multiplicity of the ML region, and--freeze-atomsfreezes more atoms.Choosing the optimizer (
--opt-mode):grad(aliaslbfgs) runs L-BFGS, which uses gradients only;hess(aliasrfo) runs RFO, which starts from an exact Hessian, updates it with TS-BFGS (the default of YAMLrfo.hessian_update), and recomputes it every 500 cycles. Withhess, microiteration alternates one RFO step of the ML atoms and the MM parent atoms of the link atoms with an L-BFGS relaxation of the other movable MM atoms on MM forces only, as in Gaussian’s microiteration.Adding distance restraints (
--distance-restraint): each(i, j, target)adds a harmonic term with force constant--restraint-k(eV·Å⁻²) that pulls atoms i and j towardtargetin Å;(i, j)keeps their starting distance. Indices are 1-based unless--zero-basedis given.Minimizing: the optimizer moves the structure until the convergence criteria are met or
--max-cyclesis reached. The default--thresh gauasks for a max force below 4.5 × 10⁻⁴ and an RMS force below 3.0 × 10⁻⁴ hartree/bohr, and a max step below 1.8 × 10⁻³ and an RMS step below 1.2 × 10⁻³ bohr, the same as Gaussian’s default.Removing imaginary modes (only with
--flatten): after the optimization,optcomputes the Hessian, displaces the structure by 0.10 Å along every imaginary mode (ν < −5.00 cm⁻¹), and optimizes again, for up to 50 rounds or until no imaginary mode is left. With--flatten, the console prints n_imag in the line[Imaginary modes] n=…after each round, and[flatten] WARNING: Remaining imaginary modes after the flatten loop: Nwhen modes are left after the last round.
Checking convergence¶
How the run ended is printed on the console and recorded in result.json (--out-json):
How it ended |
|
Console line |
|
|---|---|---|---|
Converged |
|
|
|
Reached |
|
|
|
Stopped on an energy plateau ( |
|
|
|
Each of these lines is followed by [opt] Total cycles: N. A stalled run is not converged: the energy stopped changing while the force criteria were still unmet.
Convergence gives a stationary point, not necessarily a minimum. opt computes no final Hessian unless --flatten is on, so run freq on the final geometry and check that n_imag = 0.
Output files¶
When the run finishes, --out-dir (default ./result_opt/) contains:
result_opt/
├─ final_geometry.xyz # Final geometry (always written)
├─ final_geometry.pdb # Same, for PDB/mmCIF input or --ref-pdb
├─ optimization_trj.xyz # Optimization trajectory (--dump)
├─ optimization.pdb # Same trajectory as PDB (--dump)
├─ optimization_all_trj.xyz # All optimization steps in one trajectory (--dump)
├─ optimization_all.pdb # Same trajectory as PDB (--dump)
├─ restart_NNN.yaml # Optimizer state (--dump with YAML opt.dump_restart)
└─ result.json # Summary (--out-json)
mmCIF input, and PDB input too large for the PDB columns, also get .cif files that keep the original identifiers.
Final geometry:
final_geometry.*is the optimized structure to pass tofreqor to a path search.Summary: with
--out-json,result.jsonrecordsoptimization_status, the final energyenergy_hartree(without the restraint energy), and the number of cyclesn_opt_cycles; with microiteration, also the number of MM relaxation cyclesn_micro_cycles.Console: the cycle table and the elapsed time.
Main options¶
The options shared by every ML/MM calculation command are explained once in ML/MM options; the table below lists only the options specific to opt.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
path |
(required) |
Full-system structure ( |
|
integer |
|
Charge of the ML region. Required unless |
|
text |
|
Total charge of unknown ligand residues (for example |
|
integer |
|
Spin multiplicity (2S+1) of the ML region |
|
text |
|
ML-region backend ( |
|
|
|
Optimizer: L-BFGS / RFO ( |
|
flag |
|
With |
|
flag |
|
Minimize the whole system on the MM force field only ( |
|
preset |
|
Convergence criteria ( |
|
integer |
|
Maximum number of optimization cycles, shared with the |
|
|
|
Optimization coordinates; keep |
|
flag |
|
Write the trajectories |
|
text |
|
Harmonic distance restraints, inline ( |
|
float |
|
Force constant of the distance restraints (eV·Å⁻²) |
|
flag |
|
Count |
|
text |
|
Atoms to freeze (1-based, comma-separated, for example |
|
float |
|
Put only the movable MM atoms within this distance (Å) of the ML region into the Hessian; by default all movable MM atoms |
|
flag |
|
Remove imaginary modes after the optimization |
|
flag |
|
With |
|
flag |
|
Stop when the energy stops changing (range below 1e-4 hartree over 50 cycles) and report |
|
path |
|
Output directory |
See the generated CLI reference for every option.
The --thresh presets set these limits (forces in hartree/bohr, steps in bohr):
Preset |
Max force |
RMS force |
Max step |
RMS step |
|---|---|---|---|---|
|
2.5e-3 |
1.7e-3 |
1.0e-2 |
6.7e-3 |
|
4.5e-4 |
3.0e-4 |
1.8e-3 |
1.2e-3 |
|
1.5e-5 |
1.0e-5 |
6.0e-5 |
4.0e-5 |
|
2.0e-6 |
1.0e-6 |
6.0e-6 |
4.0e-6 |
|
3.0e-4 |
2.0e-4 |
3.0e-4 |
2.0e-4 |
baker also requires an energy change below 1e-6 hartree between cycles. never never reports convergence, so the run continues to --max-cycles.
Notes¶
Microiteration: with
--distance-restraintor--embedcharge,optruns RFO without microiteration (with--embedchargebecause the MM-only steps leave out the embedding forces). The MM relaxation converges to the same preset as--thresh; YAMLmicroiter.micro_threshsets another preset.--mm-onlyworks only withgrad: with--opt-mode hessit stops with an error (exit code 2). The Movable-MM and Frozen-MM layers still apply.Plateau stop:
--stop-plateausaves cycles when force noise keeps the force criteria out of reach, but a flat energy is no evidence of a stationary point.--max-cyclesremains the real limit, and the MM relaxation of microiteration is never stopped this way.--stop-plateau-threshand--stop-plateau-windowset the energy range and the number of cycles.Restraint strength: the default force constant, 300 eV·Å⁻², holds the distance firmly; the 20 eV·Å⁻² of the example guides the structure gently toward the target.
--reject-uphillworks only withhess: withgrad(L-BFGS) it is ignored.One structure per run:
-itakes a single structure, and.xyzinput needs--ref-pdbfor the atom order and the layers. Extract the frame you need from a trajectory to.xyzfirst.--flattenneeds a nearly converged structure: with more than 25 imaginary modes,optskips the flatten loop and prints a warning; optimize the structure first and rerun with--flatten.Rigid motions with frozen atoms:
--flattentreats rigid motions asfreqdoes, andresult.jsonrecords them underrigid_projection.Frozen atoms and restraints in general: how to choose frozen atoms and restraints is described in Frozen atoms and distance restraints.
Optimizer state dumps: with
--dump, set YAMLopt.dump_restartto a positive integer N to writerestart_NNN.yamlevery N cycles. mlmm-toolkit does not read this file back, so rerunoptfrom the final geometry to continue a stopped calculation.Model and precision:
--backend-modelselects the model of the backend and--precisionits precision; see the generated reference.
See also¶
freq — check that the optimized structure is a minimum (n_imag = 0)
tsopt — optimize a TS (saddle point) instead of a minimum
irc — trace the reaction path from a TS to the endpoints to optimize
define-layer — write the ML and MM layers into the B-factors before optimizing
all — the full workflow, which also optimizes the IRC endpoints
Troubleshooting — when a run fails
YAML Reference — every
opt,lbfgs,rfo, andmicroitersettingGlossary — L-BFGS, RFO, and other terms
Exit codes — what each exit status means