Skip to content

Optimization

Structure relaxation and energy calculations using multiple computational backends, with real-time progress streaming.

Source: src/lib/api/compute.ts, src/lib/structure/OptimizationPane.svelte, server/routers/

Available Calculators

CalculatorMethodDescriptionUse Case
EMTEffective Medium TheoryFast empirical potentialMetals (Al, Cu, Ag, Au, Ni, Pd, Pt)
xTB GFN2Semi-empirical DFTTight-binding with dispersionOrganic molecules, molecular crystals
xTB GFN1Semi-empirical DFTFaster, less accurate than GFN2Large organic systems
xTB GFN0Semi-empiricalFastest xTB variantScreening, pre-optimization
xTB GFN-FFForce fieldxTB-parameterized force fieldVery fast pre-relaxation
MACEMachine learningEquivariant neural network potentialGeneral-purpose, high accuracy
CHGNetMachine learningCrystal Hamiltonian Graph NetworkInorganic materials
M3GNetMachine learningMaterials 3-body Graph NetworkInorganic materials
UFFForce field (WASM)Universal Force FieldQuick in-browser optimization

Key Functions

Client-Side (TypeScript)

typescript
// List available calculators and their status
fetchCalculators(): Promise<Calculator[]>

// Check if server is running
check_server_available(): Promise<boolean>

// HTTP-based optimization (returns final result)
optimize_structure(structure, calculator, options): Promise<OptimizationResult>

// WebSocket streaming (real-time step-by-step updates)
optimize_structure_ws(structure, calculator, options, onStep): Promise<OptimizationResult>

// In-browser UFF optimization via WASM (no server needed)
wasm_optimize_structure(structure): Structure

Server-Side (Python)

The FastAPI server exposes:

  • GET /api/optimize/calculators — list available calculators
  • POST /api/optimize/structure — optimize structure (HTTP)
  • GET /api/optimize/ws — WebSocket streaming optimization
  • GET /api/optimize/energy — single-point energy calculation

Optimizer Methods

In addition to choosing a calculator (energy/force engine), you can choose the optimizer algorithm that drives the search:

OptimizerTypeDescriptionUse Case
BFGSMinimizerQuasi-Newton local minimizer (ASE default)Finding stable structures (local minima)
Sella MinimizeMinimizerTrust-radius minimizer (Sella order=0)Alternative to BFGS, sometimes more robust
Sella TS SearchSaddle pointTransition state finder (Sella order=1)Finding reaction barriers and transition states
IRCReaction pathIntrinsic Reaction Coordinate (Sella)Tracing the minimum energy path from a TS

What is a transition state?

A transition state (TS) is the highest-energy point along the lowest-energy path between a reactant and product. It tells you the activation energy — the energy barrier the system must overcome for a reaction to occur. Sella's TS Search finds these saddle points on the potential energy surface.

Sella Parameters

When using Sella Minimize or Sella TS Search:

ParameterDescriptionDefault
delta0 (Trust radius)Initial trust radius for step size controlAuto (Sella default)

When using IRC:

ParameterDescriptionDefault
dx (Step size)IRC step size in AngstromAuto (Sella default)

Installing Sella

Sella is an optional dependency. The server works without it — BFGS is always available. To enable Sella optimizers:

bash
# Python 3.13+ requires setuptools-scm first
pip install setuptools-scm

# Install Sella (use --no-build-isolation on Python 3.13+)
pip install --no-build-isolation sella

If Sella is not installed and you select a Sella optimizer, the server returns a clear error message with install instructions.

For more details, see the Sella GitHub repository.

Optimization Options

OptionTypeDescription
calculatorstringCalculator name (e.g., "mace", "xtb_gfn2")
optimizerstringOptimizer algorithm: bfgs, sella_min, sella_ts, irc
fmaxnumberForce convergence criterion (eV/A)
max_stepsnumberMaximum optimization steps
optimize_cellbooleanAlso relax cell shape/volume
frozen_atomsnumber[]Atom indices to keep fixed

Real-Time Progress

WebSocket optimization streams per-step updates:

typescript
interface OptimizationStep {
  step: number          // Current step number
  energy: number        // Total energy (eV)
  fmax: number          // Maximum force (eV/A)
  structure: Structure  // Current atomic positions
  converged: boolean    // Whether fmax < threshold
}

The UI displays:

  • Energy convergence plot
  • Maximum force (fmax) convergence plot
  • Live 3D structure update at each step
  • Step counter and status

Frozen Atoms

Atoms can be marked as "fixed" to exclude them from optimization:

  • Ring indicator — circular ring around frozen atoms
  • Crosshatch — patterned overlay
  • Dimmed — reduced opacity

Frozen atoms are passed as index arrays to the optimizer.

Components

ComponentDescription
OptimizationPane.svelteCalculator selection, options, run/stop controls
Energy/force convergence plotsReal-time line plots during optimization

Architecture

Browser                          Server
┌──────────────┐    HTTP/WS     ┌───────────────────────────┐
│ Optimization │ ──────────────→│ FastAPI Server             │
│ Pane         │                │  ├── Calculators (energy)  │
│              │←────────────── │  │   ├── EMT               │
│ (real-time   │   step data    │  │   ├── xTB               │
│  updates)    │                │  │   ├── MACE              │
└──────────────┘                │  │   ├── CHGNet            │
                                │  │   └── M3GNet            │
                                │  └── Optimizers (search)   │
                                │      ├── BFGS (default)    │
                                │      ├── Sella Minimize    │
                                │      ├── Sella TS Search   │
                                │      └── IRC               │
┌──────────────┐                └───────────────────────────┘
│ WASM (UFF)   │ ← no server needed
└──────────────┘

Released under the MIT License.