optimizer¶
Optimizers for refining TS-constrained conformers.
Constructor parameters:
conf_id_ref: int = -1: reference conformer ID on the TS moleculeforce_constant: float = 1e6: force constant of distance constraints to TS reference points
MMFFOptimizer¶
Optimizes each conformer with MMFF94:
- Align to the TS reference conformer (on
align_indices)- Create RDKit force-field extra points at the TS coordinates for each
align_indicesatom and add distance constraints withforce_constant- Minimize and set the conformer
energyproperty fromff.CalcEnergy()in kcal/mol- Re-align to the TS reference
UFFOptimizer¶
Same flow as MMFF_optimizer using the RDKit implementation of UFF.
Note
- MMFF: Good general-purpose performance, if MMFF parameters are available.
- UFF: Use if no MMFF parameters available or as fallback.
ASEOptimizer (optional dependency)¶
ASEOptimizer uses the Atomic Simulation Environment (ASE):
- Align to the TS reference conformer on
align_indices- Convert each RDKit conformer to ASE
Atoms- Apply
FixAtoms(indices=align_indices)to freeze these atoms- Optimize with an ASE optimizer (
BFGSby default) and the provided ASE calculator (calculator=..., instance or callable)- Write positions back to RDKit and set conformer
energyin kcal/mol (eV * 23.06054783061903)- Re-align to the TS reference
Charge and multiplicity are the charge and multiplicity arguments, else the values stored on the molecule by generate_conformers, else the sum of the formal charges and the lowest multiplicity for the number of electrons. They reach the calculator in two forms: in atoms.info (charge, spin = multiplicity, as read by UMA/fairchem) and as initial charges and magnetic moments (whose sums tblite and xtb-python read). Calculators that take charge and multiplicity as their own arguments (e.g. ASE's ORCA(charge=..., mult=...), PySCF) need them passed there.
A conformer whose calculation fails (e.g. SCF not converged) is left without an energy and is dropped when pruning; if all conformers fail, an error is raised.
Note
align_indices follow standard Python indexing (0-based), consistent with RDKit and ASE atom indices.
Install ASE support with:
pip install racerts[ase]
Example with a calculator instance:
from ase.calculators.lj import LennardJones
from racerts.optimizer import ASEOptimizer
optimizer = ASEOptimizer(
calculator=LennardJones(),
fmax=0.05,
max_steps=100,
)
Example with a calculator callable:
from ase.calculators.lj import LennardJones
from racerts.optimizer import ASEOptimizer
optimizer = ASEOptimizer(
calculator=LennardJones,
num_workers=4,
)