opt¶
Overview¶
Summary: Optimizes a single structure toward a local minimum using L-BFGS (
--opt-mode grad, default) or RFO (--opt-mode hess). Optional imaginary-frequency flattening can be enabled with--flatten.
At a glance¶
Use when: You need to relax a single structure (PDB/XYZ/GJF/
_trj.xyz) to a local minimum, optionally with distance restraints or imaginary-mode flattening.Method: pysisyphus L-BFGS (
--opt-mode grad, default) or RFOptimizer (--opt-mode hess) driven by an MLIP backend (UMA by default; ORB/MACE/AIMNet2 via-b); link-hydrogen parents on PDB inputs are auto-frozen with--freeze-links.Outputs:
final_geometry.xyz(always), plusfinal_geometry.pdb(PDB inputs) andfinal_geometry.gjf(Gaussian templates) when--convert-filesis enabled;optimization_trj.xyz/optimization.pdbwhen--dumpis on; optional restart YAML.Defaults: Backend
uma,--opt-mode grad,--thresh gau,--max-cycles 10000,--bias-k 300,--freeze-links True,--convert-files True,--flatten False,--dump False,--out-dir ./result_opt/.Next step: Confirm the minimum with
freq, or proceed totsoptfor saddle points andpath-search/allfor full reaction pathways.
pdb2reaction opt optimizes a single structure to a local minimum using L-BFGS (--opt-mode grad, default) or RFO (--opt-mode hess). For PDB inputs, link-hydrogen parents are automatically frozen.
The command uses pysisyphus LBFGS (lbfgs) or RFOptimizer (rfo) while an MLIP backend (UMA by default; ORB, MACE, and AIMNet2 also available via -b/--backend) provides energies, gradients, and Hessians. Input structures can be .pdb, .xyz, _trj.xyz, or any format supported by geom_loader. Settings follow precedence: defaults < config < explicit CLI.
When the starting structure is a PDB or Gaussian template, the command also writes .pdb (PDB inputs) and .gjf (Gaussian templates) companions, controlled by --convert-files/--no-convert-files (enabled by default). PDB-specific conveniences include:
With
--freeze-links(defaultTrue), parent atoms of link hydrogens are detected and merged intogeom.freeze_atoms(1-based indices).Output conversion produces
final_geometry.pdb(andoptimization.pdbwhen dumping trajectories) using the input PDB as the topology reference. For XYZ/GJF inputs,--ref-pdbsupplies a reference PDB topology while keeping XYZ coordinates, enabling format-aware PDB/GJF output conversion.
A Gaussian .gjf template seeds the charge/spin defaults and enables automatic export of the optimized structure as .gjf when conversion is enabled.
Minimal example¶
pdb2reaction opt -i input.pdb -q 0 -m 1 --out-dir ./result_opt
Output checklist¶
result_opt/final_geometry.xyzresult_opt/final_geometry.pdb(for PDB input with conversion enabled)result_opt/optimization_trj.xyz(when--dumpis enabled)
Common examples¶
Optimize with a tighter threshold and keep trajectory dumps.
pdb2reaction opt -i input.pdb -q 0 -m 1 --thresh gau_tight --dump \
--out-dir ./result_opt_tight
Add a harmonic distance restraint.
# Restrain atoms 1 and 5 to 2.0 Å. The example uses --bias-k 20.0 (a loose restraint
# suitable for a light guide near the target distance); the default `bias.k` is 300
# eV·Å⁻² and is better when you want the restraint to dominate during optimization.
pdb2reaction opt -i input.pdb -q 0 -m 1 \
--dist-freeze '[(1,5,2.0)]' --bias-k 20.0 --out-dir ./result_opt_rest
# 2-tuple form: restrain atoms 1 and 5 to their current distance
pdb2reaction opt -i input.pdb -q 0 -m 1 \
--dist-freeze '[(1,5)]' --out-dir ./result_opt_freeze
Switch explicitly to RFO mode.
pdb2reaction opt -i input.pdb -q 0 -m 1 --opt-mode hess \
--out-dir ./result_opt_hess
Run LBFGS mode and flatten imaginary modes after optimization.
pdb2reaction opt -i input.pdb -q 0 -m 1 --opt-mode grad --flatten \
--out-dir ./result_opt_grad_flat
Usage¶
pdb2reaction opt -i INPUT.{pdb|xyz|trj|...} [-q CHARGE] [-l, --ligand-charge <number|'RES:Q,...'>] [-m MULT] \
[-b/--backend uma|orb|mace|aimnet2] [--solvent SOLVENT] [--solvent-model alpb|cpcmx] \
[--opt-mode grad|hess|lbfgs|rfo] [--flatten/--no-flatten] [--freeze-links/--no-freeze-links] \
[--dist-freeze '[(i,j,target_Å),...]'] [--one-based|--zero-based] \
[--bias-k K_eV_per_Ų] [--dump/--no-dump] [-o/--out-dir DIR] \
[--convert-files/--no-convert-files] [--ref-pdb FILE]
Workflow¶
Optimizers:
--opt-mode grad(alias:lbfgs, default) → L-BFGS;--opt-mode hess(alias:rfo) → RFOptimizer.Naming note: The CLI accepts
grad|lbfgsandhess|rfo. In YAML, uselbfgsorrfodirectly.Flatten loop:
--flattenenables post-optimization flattening of imaginary vibrational modes. Inopt, all detected imaginary modes are flattened each iteration until none remain or the internal loop cap is reached.Restraints:
--dist-freezeconsumes Python-literal tuples(i, j, target_Å)wheretarget_Åis the target distance in Å; omitting the third element restrains the starting distance.--bias-ksets a global harmonic strength (eV·Å⁻²). Indices default to 1-based but can be flipped to 0-based with--zero-based.Charge/spin resolution: Charge is resolved via the standard priority chain (see CLI Conventions: Charge specification for details).
Freeze atoms: When
--freeze-linksis active, link-hydrogen parent atoms are automatically frozen (see Link hydrogen and frozen atoms).Dumping & conversion:
--dumpmirrorsopt.dump=Trueand writesoptimization_trj.xyz; when conversion is enabled, trajectories are mirrored to.pdbfor PDB inputs.opt.dump_restartcan emit restart YAML snapshots.Exit codes: See Exit codes in CLI Conventions.
CLI options¶
Note: Default values shown are used when the option is not specified.
Option |
Description |
Default |
|---|---|---|
|
Input structure accepted by |
Required |
|
Net charge. Required unless a |
Required unless template/derivation applies |
|
Per-residue charge mapping (e.g., |
None |
|
MLIP predictor parallelism (workers > 1 disables analytic Hessians). See workers > 1 silent FD downgrade for diagnostic notes. |
|
|
Workers per node, forwarded to the parallel predictor. |
|
|
Spin multiplicity (2S+1). Falls back to |
Template/ |
|
Repeatable string parsed as Python literal describing |
None |
|
Interpret |
|
|
Harmonic bias strength applied to every |
|
|
Toggle link-hydrogen parent freezing (PDB inputs only). See extract for link-hydrogen details. |
|
|
Comma-separated 1-based atom indices to freeze explicitly (e.g., |
None |
|
Hard limit on optimization iterations ( |
|
|
Optimizer preset: |
|
|
Enable/disable the post-optimization imaginary-mode flattening loop. |
|
|
Emit trajectory dumps ( |
|
|
Enable or disable XYZ/TRJ → PDB companions for PDB inputs and XYZ → GJF companions for Gaussian templates. |
|
|
Reference PDB topology to use when the input is XYZ/GJF (keeps XYZ coordinates). |
None |
|
Output directory for all files. |
|
|
Override convergence preset ( |
|
|
Base YAML configuration file. |
None |
|
Print resolved YAML layer information before execution. |
|
|
Write a machine-readable |
|
|
Validate options and print execution plan without running optimization. |
|
|
MLIP backend. |
|
|
Implicit solvent name for xTB correction (e.g. |
|
|
xTB solvent model. |
|
Outputs¶
out_dir/
├─ final_geometry.xyz # Always written
├─ final_geometry.pdb # Only when the input was a PDB and conversion is enabled
├─ final_geometry.gjf # When a Gaussian template was detected and conversion is enabled
├─ optimization_trj.xyz # Only if dumping is enabled
├─ optimization.pdb # PDB conversion of the trajectory (PDB inputs, conversion enabled)
└─ restart*.yml # Optional restarts when opt.dump_restart is set
The console prints the resolved geom, calc, opt, lbfgs/rfo blocks plus cycle-by-cycle progress and total runtime.
See CLI Conventions: Configuration precedence for the full resolution order.
geom¶
coord_type("cart"): Cartesian vs."dlc"delocalized internal coordinates.freeze_atoms([]): 1-based frozen indices; automatically merged with CLI link detection.
calc¶
MLIP backend configuration (
model,task_name, device selection, neighbor radii, Hessian format, etc.).charge/spinmirror the CLI options; defaults come from.gjfwhen present.
opt¶
Shared optimizer controls used by both LBFGS and RFO:
threshpresets (Gaussian-like or Baker rule). Presets translate to the force/step thresholds documented inpdb2reaction/opt.py.max_cycles,print_every(100),min_step_norm(1e-8),assert_min_step, convergence toggles (rms_force, etc.), RMSD-basedconverge_to_geom_rms_thresh,overachieve_factor,check_eigval_structure,line_search.Energy plateau fallback (
energy_plateau,energy_plateau_thresh,energy_plateau_window) — declares convergence when the recent energy range flattens (useful when MLIP force noise prevents force-based convergence; see note below).Dumping/bookkeeping fields (
dump,dump_restart,prefix,out_dir).
lbfgs¶
Extends opt with L-BFGS specifics: keep_last, beta, gamma_mult, max_step, control_step, double_damp, and the optional regularization parameters mu_reg/max_mu_reg_adaptions.
rfo¶
Extends opt with RFOptimizer fields: trust-region sizing (trust_radius, trust_min, trust_max, trust_update), max_energy_incr, Hessian management (hessian_update, hessian_init, hessian_recalc, hessian_recalc_adapt, small_eigval_thresh), micro-iteration controls (alpha0, max_micro_cycles, rfo_overlaps), DIIS helpers (gdiis, gediis, thresholds, gdiis_test_direction), and adapt_step_func.
Opt-specific defaults¶
The opt subcommand sets opt.out_dir (and lbfgs.out_dir / rfo.out_dir) to ./result_opt/.
For the full YAML schema of geom, calc, opt, lbfgs, and rfo, see YAML Reference.
Note
Energy plateau fallback (new in v0.3.5). When energy_plateau: true, the optimizer
is declared converged if the energy range (max − min) over the last
energy_plateau_window steps falls below energy_plateau_thresh
(default 1×10⁻⁴ au ≈ 0.06 kcal/mol over 50 steps). This prevents wasted cycles when
the MLIP force noise floor (~4×10⁻⁴ au) exceeds the force-based convergence threshold
(e.g. baker max_force = 3×10⁻⁴ au). The fallback is skipped for chain-of-states
optimizers, which store per-image energy arrays.
See Also¶
Common Error Recipes – Symptom-first failure routing
Troubleshooting – Detailed troubleshooting guide
tsopt — Optimize transition states (saddle points) instead of minima
freq — Vibrational analysis to confirm optimization reached a minimum
extract — Generate active site model (binding pocket) PDBs before optimization
all — End-to-end workflow that pre-optimizes endpoints
YAML Reference — Full
opt,lbfgs,rfoconfiguration optionsGlossary — Definitions of L-BFGS, RFO