Docs are under construction. Content may be incomplete or change.

tako.optimize Settings

Page type: Reference · Generated from src/script/takoScriptDocs.ts · Verified 2026-07-11T00:00:00.000Z
On this page

This page is generated from code-owned Doxygen-style metadata in src/script/takoScriptDocs.ts. Update that file first, then regenerate this page so runtime capability descriptions, docs, and agent guidance stay aligned.

tako.optimize

Relaxes atomic positions, and optionally the periodic cell, through the normal Tako calculation workspace.

Signature: await tako.optimize(structure, { calculator, properties, optimizer, maxSteps, fmaxEvPerAngstrom, maxstepAngstrom, alpha, trajectoryFrameInterval, cellRelaxation })

Theory

  • Geometry optimization searches for a local minimum on the selected model potential-energy surface by iteratively using energies and forces. Fixed-cell convergence is judged by the largest per-atom force-vector norm, reported through fmaxEvPerAngstrom; variable-cell optimization extends the optimizer array with three scaled cell rows.
  • BFGS builds an approximate Hessian and is efficient near smooth minima. FIRE is often robust for rough starts and large force relaxation. MDMin is a simple damped-dynamics fallback. For fixed cells, maxstepAngstrom limits atomic displacement; variable-cell runs apply it to the augmented atomic-and-cell optimizer array.
  • Cell relaxation adds lattice degrees of freedom. It requires stress support and changes the physical question from fixed-cell relaxation to variable-cell relaxation; do not mix fixed-cell and variable-cell energies without noting that difference.

Usage Notes

  • Start with fixed-cell atom relaxation for imported crystals unless the task explicitly asks for cell relaxation.
  • Use trajectoryFrameInterval greater than 1 for long relaxations when only coarse history is needed.
  • After optimization, use tako.analysis.finalStructure(input, result) and write it to output/final.extxyz for reproducibility.

Settings

SettingTypeDefaultValuesUnitValidationDescription
calculatorcalculatorRequired for calculator-backed operations; validate the operation, structure element coverage, and requested properties before executionCalculator object from tako.calculator.gxtb(...), gfn2(...), mlip(...), or dft(...). It controls the level of theory, charge/spin where supported, runtime assets, property availability, and the synchronous supported-element list used by TakoScript and the UI.
propertiesproperties['energy', 'forces']energy, forces, stressUnknown names are removed; energy and forces are reinserted. Stress is meaningful only for a periodic structure and a calculator that supplies it. Optimization performs no DOS, PDOS, charge, density, NCI, or WFN post-processing stage.Optimization result channels. The operation returns energy and force-derived convergence data; request stress for a supported periodic final-state stress evaluation and for variable-cell relaxation.
optimizerenumbfgsbfgs, fire, mdminGeometry optimizer. bfgs is the default quasi-Newton optimizer, fire is robust for poor starting geometries, and mdmin is a damped-dynamics fallback.
maxStepsinteger500Positive integer; the WASM execution path clamps the effective budget to 1–500 even if a larger value was suppliedRequested optimizer iteration budget. The returned settings record currently retains the requested value, while execution uses at most 500 steps; use 500 or less to keep recorded and effective budgets identical.
trajectoryFrameIntervalinteger1Write one trajectory frame every N optimization steps. Increase it to reduce output size for long relaxations.
fmaxEvPerAngstromnumber0.01Force convergence threshold in eV/A. Smaller values are stricter but can expose model noise or greatly increase runtime.
maxstepAngstromnumber0.04Fixed-cell: maximum atomic displacement per optimizer step in Å. Variable-cell: limiter on the combined N+3 generalized optimizer rows, so the trace maximum may come from a scaled cell row rather than an atom.
alphanumber70eV/ŲBFGS initial Hessian scale. Larger values make the initial BFGS steps more conservative; it mainly matters for BFGS.
cellRelaxationobject{ mode: 'fixed' }fixed, full, lengths, angles, customfixed relaxes atoms only. full relaxes lengths and angles. lengths changes lattice vector lengths while preserving angles. angles changes angles while preserving lengths. custom uses explicit relaxLengths: [a,b,c], relaxAngles: [alpha,beta,gamma], and optional cellFactor scaling for cell degrees of freedom.

Example

const input = await tako.input("input/slab.extxyz");
const calculator = tako.calculator.mlip({ levelOfTheory: "nequix-phono" });
const result = await tako.optimize(input, {
  calculator,
  properties: ["energy", "forces", "stress"],
  optimizer: "fire",
  maxSteps: 300,
  fmaxEvPerAngstrom: 0.02,
  cellRelaxation: { mode: "fixed" },
});
await tako.output("output/final.extxyz", tako.analysis.finalStructure(input, result));

Result

Returned optimization result with convergence state, final energy and force diagnostic, sampled frames, serialized trajectory text, normalized settings, final structure, optional stress, and calculator provenance. Workspace logs and persisted artifacts are separate from this object.

FieldTypeUnitAvailabilityDescription
kind”optimization”Every resolved resultRuntime result discriminator.
convergedbooleanEvery resolved resultWhether the optimizer met its gate before exhausting the effective step budget. Fixed cell uses maximum per-atom force norm; variable cell uses the maximum norm over augmented atomic and scaled cell-force rows.
stepsintegerEvery resolved resultAccepted optimization steps; may be zero for an initially converged structure.
final_energy_hartreenumberEhEvery resolved resultFinal calculator energy.
final_energy_evnumbereVEvery resolved resultFinal calculator energy converted to electronvolts.
final_fmax_hartree_per_bohrnumberEh/bohrEvery resolved resultFixed cell: final maximum per-atom force norm. Variable cell: final maximum over the augmented atomic and scaled cell-force rows.
final_fmax_ev_per_angstromnumbereV/ÅEvery resolved resultThe same final optimizer-array norm converted to eV/Å; not guaranteed to be an atomic force in a variable-cell run.
framesobject[]Every resolved resultSampled optimization frames; the first emitted frame and final frame are retained even when the interval skips intermediate steps.
frames[].stepintegerEvery stored frameOptimizer step index.
frames[].energy_hartreenumberEhEvery stored frameFrame potential energy.
frames[].energy_evnumbereVEvery stored frameFrame potential energy converted to electronvolts.
frames[].fmax_hartree_per_bohrnumberEh/bohrEvery stored frameFixed cell: frame maximum per-atom force norm. Variable cell: maximum augmented-row norm.
frames[].fmax_ev_per_angstromnumbereV/ÅEvery stored frameThe same frame optimizer-array norm converted to eV/Å.
frames[].maxstep_bohrnumberbohrEvery stored frameFixed-cell: maximum accepted atomic displacement. Variable-cell: maximum over the N+3 generalized optimizer rows, which may be a scaled cell row.
frames[].maxstep_angstromnumberÅEvery stored frameThe same optimizer-trace maximum converted with the length convention; in variable-cell runs it is not guaranteed to be an atomic displacement.
frames[].cell.vectors3×3 number arrayÅPeriodic stored frames onlyFrame lattice vectors.
frames[].atomsobject[]Every stored frameFrame atoms in input order.
frames[].atoms[].idintegerEvery frame atomStable input atom identifier.
frames[].atoms[].elementstringEvery frame atomElement symbol.
frames[].atoms[].xnumberÅEvery frame atomFrame Cartesian x coordinate.
frames[].atoms[].ynumberÅEvery frame atomFrame Cartesian y coordinate.
frames[].atoms[].znumberÅEvery frame atomFrame Cartesian z coordinate.
frames[].atoms[].selective[boolean, boolean, boolean]Frame atoms whose input carried selective-dynamics flagsPer-axis mobility flags copied from the input.
trajectory_xyzstringEvery resolved resultStored frames serialized as an XYZ trajectory.
settings.optimizer”bfgs” | “fire” | “mdmin”Every resolved resultNormalized optimizer name.
settings.max_stepsintegerEvery resolved resultRequested step budget retained in the payload. Execution clamps it to 1–500; values above 500 therefore do not describe the effective budget.
settings.trajectory_frame_intervalintegerEvery resolved resultStored-frame interval.
settings.fmax_ev_per_angstromnumbereV/ÅEvery resolved resultRequested force gate.
settings.maxstep_angstromnumberÅEvery resolved resultRequested fixed-cell atomic step limit or variable-cell augmented-row step limit.
settings.alphanumbereV/ŲEvery resolved resultBFGS initial Hessian scale retained in the normalized settings.
settings.cell_relaxation.mode”fixed” | “full” | “lengths” | “angles” | “custom”Every resolved resultNormalized cell-relaxation mode.
settings.cell_relaxation.relax_lengths[boolean, boolean, boolean]Every resolved resultEnabled a, b, and c length strain components.
settings.cell_relaxation.relax_angles[boolean, boolean, boolean]Every resolved resultEnabled α, β, and γ angle strain components.
settings.cell_relaxation.cell_factornumber | nullEvery resolved resultRequested positive cell-degree scaling factor, or null when omitted. At execution, null, zero, nonfinite, and nonpositive values use the engine default factor based on atom count; the payload records the request rather than the resolved effective factor.
settings.scfobjectEvery resolved resultNormalized GFN SCF settings record; retained with empty/default GFN fields for MLIP runs.
settings.scf.energy_thresholdnumberEhEvery resolved resultNormalized SCF energy threshold.
settings.scf.density_thresholdnumberEvery resolved resultNormalized SCF density threshold.
settings.scf.max_iterationsintegerEvery resolved resultSCF iteration limit.
settings.scf.electronic_temperature_kelvinnumberKEvery resolved resultElectronic temperature.
settings.scf.mixer_dampingnumberEvery resolved resultSCF mixer damping.
settings.scf.output_intervalintegerEvery resolved resultSCF log/output interval.
settings.scf.temperature_schedule_kelvinnumber[]KEvery resolved resultExplicit electronic-temperature schedule.
settings.scf.temperature_annealing.policystringEvery resolved resultEffective annealing policy.
settings.scf.temperature_annealing.start_kelvinnumberKEvery resolved resultAnnealing start temperature.
settings.scf.temperature_annealing.stagesintegerEvery resolved resultAnnealing stage count.
settings.scf.temperature_annealing.stage_iterationsintegerEvery resolved resultIterations allocated to each annealing stage.
settings.scf.initial_guessstringEvery resolved resultNormalized initial-guess mode.
settings.scf.mixerstringEvery resolved resultNormalized SCF mixer name.
settings.scf.allow_unconvergedbooleanEvery resolved resultWhether an unconverged electronic state was permitted by settings.
stress_ev_per_angstrom33×3 number array | nulleV/ųEvery resolved result; populated only when stress was requested and the final calculator evaluation returned itFinal stress tensor in the backend convention.
cellobject | nullEvery resolved resultFinal periodic cell or null for a nonperiodic structure.
cell.vectors3×3 number arrayÅPeriodic final structure onlyFinal lattice vectors.
atomsobject[]Every resolved resultFinal atoms in input order.
atoms[].idintegerEvery final atomStable input atom identifier.
atoms[].elementstringEvery final atomElement symbol.
atoms[].xnumberÅEvery final atomFinal Cartesian x coordinate.
atoms[].ynumberÅEvery final atomFinal Cartesian y coordinate.
atoms[].znumberÅEvery final atomFinal Cartesian z coordinate.
atoms[].selective[boolean, boolean, boolean]Final atoms whose input carried selective-dynamics flagsPer-axis mobility flags copied from the input.
level_of_theorystringEvery resolved resultNormalized level-of-theory identifier.
engine”gfn2” | “mlip”Every resolved resultCalculation engine family.
mlip_runtimestringEvery resolved result; empty for GFN2MLIP inference runtime identifier.
mlip_modelstringEvery resolved result; empty for GFN2MLIP model-weight identifier.

Errors and Promise Behavior

  • Validate calculator support before execution. Variable-cell relaxation additionally requires a periodic cell and stress-capable calculator; invalid combinations reject rather than falling back to fixed-cell optimization.
  • The promise resolves with converged: false when the step budget ends before the force gate. This is a numerical nonconvergence result, not a rejected promise and not an accepted optimized structure.
  • Validation, asset preparation, calculator execution, serialization, worker reset, done without a result, and cancellation reject the promise. Cancellation rejects with Canceled by user and exposes no restartable optimizer state.
  • Frames streamed or persisted before rejection are partial execution evidence. They must not be presented as a completed optimization result.