Skip to content

Framework geometry optimization ​

optimize-framework minimizes a molecular geometry with the shared BFGS or steepest-descent engine. The energy and forces come from the UFF force field built from the SMILES; UFF evaluates in kcal/mol and the command reports eV and eV/Å.

flowchart LR
    A[SMILES + coordinates] --> B[UFF energy and gradients]
    B --> C{Max force < force_tol?}
    C -- yes --> D[Converged]
    C -- no --> E[BFGS or steepest-descent step]
    E --> F[Cap at max_step]
    F --> G[Optional minimum-image wrap]
    G --> B

Optimizers ​

BFGS ​

The BFGS path keeps an approximate inverse Hessian (initialized to the identity), forms the search direction p = -H⁻¹g, and applies Armijo backtracking. If the direction is not a descent direction, the Hessian is reset to the identity and a steepest-descent step is taken. Steps are capped at max_step. Rows and columns belonging to fixed atoms are zeroed.

Convergence is declared when the maximum force component falls below force_tol. A stalled energy only counts as convergence when the forces also satisfy force_tol.

Steepest descent ​

The steepest-descent path moves along the force direction with an adaptive step: multiplied by 1.2 after an accepted step (up to max_step) and halved after a rejected step. It stops when the force criterion is met, when the energy change is below energy_tol (only counted as converged if the forces agree), or when the step shrinks below 1e-10.

Periodic systems ​

Supplying --a, --b and --c (plus the three angles) enables the minimum-image convention: after every step the Cartesian positions are wrapped into the cell. This is position wrapping only; the cell is not relaxed and the UFF energy does not sum over periodic images. For cell relaxation use the variable-cell path.

Output ​

json
{
  "positions": [[...]],
  "energy": 0.06718227655173616,
  "forces": [[...]],
  "max_force": 0.04905923800286457,
  "n_iterations": 21,
  "converged": true,
  "energy_history": [0.3032479101885856, 0.2589600738340934, "..."]
}

energy and energy_history are in eV, forces and max_force in eV/Å. n_iterations counts attempted optimizer iterations; energy_history records accepted energies plus the initial one. The command exits 0 for a completed run even when converged is false, so always check that field.

Validation and limits ​

  • The geometry must contain at least one atom; coords must hold exactly 3N finite values, and initial_positions must match elements one-to-one.
  • max_iter >= 1; force_tol, energy_tol and max_step must be finite and strictly positive.
  • fixed-atom indices must be non-negative integers in 0..n_atoms.
  • Every energy/force evaluation is checked: the energy must be finite, the force count must equal the atom count and every force component must be finite. A non-finite surface aborts with an error instead of being reported as a converged minimum.
  • Python/WASM accept max_iter as a floating value and require a finite non-negative integer; negative or fractional counts raise ValueError / return {"error": ...} instead of being converted to an unsigned integer or truncated. Values below 1 are then rejected by the core (max_iter >= 1).
  • all three lattice lengths are required together; lengths must be > 0, angles in (0°, 180°), and the angles must produce a positive cell volume.
  • UFF energy parity with RDKit is tracked by F16 and the force path by F84; these are force-field gates, not an experimental validation of the optimizer.
  • The optimizer is a local minimizer; it does not perform global search or conformer generation. Use ETKDG/embedding for that.

Surfaces ​

SurfaceEntry point
CLIsci-form optimize-framework "<smiles>" "<coords>"
Rustmaterials::geometry_opt::optimize_framework
Pythonsci_form.optimize_framework(...)
WASMoptimize_framework(...)

Released under the MIT License.