Skip to content

Roadmap: Dynamic Simulation & Chemical Reactivity Engine ​

Goal: Evolve sci-form from a static property calculator into a real-time dynamic simulation engine for molecular dynamics, chemical reactivity, and interactive molecular manipulation — all runnable in any browser via WebAssembly.

Scope: 7 implementation tasks, from WASM memory architecture through ab-initio quantum chemistry, DFT, classical MD, reactive force fields, ML potentials, and the interactive browser loop.

Relation to existing code: sci-form already ships conformer generation (ETKDGv2), static force fields (UFF, MMFF94), quantum methods (EHT, PM3, PM3(tm), GFN0/1/2-xTB, HF-3c, CISD), ANI neural potentials, a Velocity Verlet + Nosé-Hoover MD module (src/dynamics.rs), and WASM bindings (crates/wasm/). This roadmap builds on that foundation.


Existing Foundation (already implemented) ​

CapabilityModuleStatus
UFF / MMFF94 force fieldssrc/forcefield/Production
EHT + orbital gridssrc/eht/Production
PM3 / PM3(tm) SCFsrc/pm3/Production
GFN0/1/2-xTBsrc/xtb/Production
HF-3c + CISDsrc/hf/, src/scf/Production
ANI-2x / ANI-TMsrc/ani/Production
Velocity Verlet MD (UFF/PM3/xTB)src/dynamics.rsProduction
Nosé-Hoover NVT thermostatsrc/dynamics.rsProduction
NEB path searchsrc/dynamics.rsProduction
WASM MD trajectory exportcrates/wasm/src/dynamics.rsProduction
Gasteiger chargessrc/charges/Production
EEQ chargessrc/charges_eeq/Production
Materials / space groupssrc/materials/Production
SCF integral engine (STO-3G, 3-21G, 6-31G)src/scf/Production
DIIS convergence acceleratorsrc/scf/diis.rsProduction

Task 1: Zero-Copy WASM Memory Architecture for Dynamic State ​

Priority: High — prerequisite for real-time interactive simulation at 60 FPS.

Current state: The WASM bridge serializes molecular state as JSON strings on every call. This works for single-shot calculations but creates millisecond-scale overhead per frame, incompatible with 60 FPS rendering.

Target: Expose the simulation state (positions, velocities, forces) as a contiguous flat buffer in Rust's linear memory, accessible from JavaScript via Float64Array views — zero serialization cost per frame.

1.1 Dynamic atom structure ​

Extend the existing Atom struct to carry velocity and force vectors for time-stepping:

rust
// src/dynamics/state.rs (new)
pub struct DynamicAtom {
    pub element: u8,
    pub mass: f64,
    pub charge: f64,
    pub position: [f64; 3],
    pub velocity: [f64; 3],
    pub force: [f64; 3],
}

pub struct MolecularSystem {
    pub atoms: Vec<DynamicAtom>,
    pub potential_energy: f64,
    pub kinetic_energy: f64,
    pub time_fs: f64,
    /// Flat buffer: [x0, y0, z0, x1, y1, z1, ...] — exposed to JS via pointer
    pub positions_flat: Vec<f64>,
}

1.2 Direct pointer FFI via wasm-bindgen ​

rust
// crates/wasm/src/dynamics_live.rs (new)
#[wasm_bindgen]
pub struct LiveSimulation {
    system: MolecularSystem,
}

#[wasm_bindgen]
impl LiveSimulation {
    /// Returns a raw pointer to the flat positions buffer in WASM linear memory.
    /// JS reads this via: new Float64Array(wasm.memory.buffer, ptr, len)
    pub fn positions_ptr(&self) -> *const f64 {
        self.system.positions_flat.as_ptr()
    }

    pub fn positions_len(&self) -> usize {
        self.system.positions_flat.len()
    }

    /// Run N integration steps, then sync the flat buffer for rendering.
    pub fn step(&mut self, dt_fs: f64, substeps: usize) {
        for _ in 0..substeps {
            self.system.integrate(dt_fs);
        }
        self.system.sync_flat_buffer();
    }
}

1.3 Implementation steps ​

StepActionFiles affectedDepends on
1.1aCreate DynamicAtom and MolecularSystem structs with flat buffer syncsrc/dynamics/state.rs (new)—
1.1bAdd From<ConformerResult> conversion to initialize dynamics from embeddingsrc/dynamics/state.rs1.1a
1.2aCreate LiveSimulation WASM wrapper with pointer-based exportcrates/wasm/src/dynamics_live.rs (new)1.1a
1.2bAdd TypeScript helper to wrap Float64Array view from WASM memorycrates/wasm/ts/live_simulation.ts (new)1.2a
1.3Benchmark: measure frame latency (JSON vs pointer path) on 1000-atom systemtests/benchmarks/1.2a
1.4Integration test: verify pointer stability across multiple step() callstests/wasm/1.2a

Performance target: < 100 μs per-frame overhead for a 500-atom system (current JSON path: ~2–5 ms).


Task 2: Ab-Initio Hartree-Fock Engine (Obara-Saika Integrals + DIIS SCF) ​

Priority: High — provides the exact-exchange foundation for DFT hybrids and excited-state chemistry.

Current state: sci-form already has:

  • A complete SCF infrastructure in src/scf/ (overlap, kinetic, nuclear matrices, Fock construction, DIIS, density matrix, Mulliken analysis)
  • Gaussian integral evaluation in src/scf/gaussian_integrals.rs
  • HF-3c with D3/gCP/SRB corrections in src/hf/
  • Basis sets: STO-3G, 3-21G, 6-31G in src/scf/extended_basis.rs
  • CISD excited states in src/hf/cisd.rs

Remaining work: The current integral engine is functional for small molecules but needs optimization for interactive use on larger systems (50–100 atoms).

2.1 Obara-Saika recurrence optimization ​

Replace or supplement the current ERI evaluation with a fully vectorized Obara-Saika recurrence engine:

StepActionFiles affectedDepends on
2.1aImplement OS vertical recurrence relation for primitive ERI with SIMD-friendly layoutsrc/scf/obara_saika.rs (new)—
2.1bImplement OS horizontal recurrence for contracted shellssrc/scf/obara_saika.rs2.1a
2.1cAdd Schwarz pre-screening to skip negligible ERI shells (QijQkl<τ)src/scf/screening.rs (new)2.1a
2.1dBenchmark: ERI evaluation speed vs current gaussian_integrals.rs on benzene/caffeinetests/benchmarks/2.1b, 2.1c

2.2 SCF convergence hardening ​

The existing DIIS in src/scf/diis.rs works. The target here is to harden it for difficult cases:

StepActionFiles affectedDepends on
2.2aAdd level-shifting fallback when DIIS stagnates (> 30 iterations without < 10× error reduction)src/scf/scf_loop.rs, src/scf/diis.rs—
2.2bAdd fractional occupation number (FON) option for near-degenerate systemssrc/scf/density_matrix.rs—
2.2cValidate convergence on transition-metal test set (Fe, Cu, Zn complexes)tests/regression/2.2a

Performance target: < 5 s for benzene/STO-3G SCF in WASM; < 200 ms for ethanol.


Task 3: Kohn-Sham DFT (LDA and GGA Functionals) ​

Priority: Medium-high — DFT with correlation captures chemistry that HF misses (bond energies, hydrogen bonding, reaction barriers).

Current state: No DFT implementation exists yet. The SCF loop in src/scf/ handles the one-electron + Coulomb/Exchange terms. Adding DFT requires:

  1. A numerical integration grid
  2. XC functional kernels (LDA, GGA)
  3. Modification of the Fock matrix construction to include VXC

3.1 Molecular integration grid ​

StepActionFiles affectedDepends on
3.1aImplement Euler-Maclaurin radial quadrature with Treutler-Ahlrichs radial mappingsrc/dft/grid.rs (new)—
3.1bImplement Lebedev angular quadrature (6–590 point grids, precomputed tables)src/dft/lebedev.rs (new)—
3.1cImplement Becke partitioning scheme for multi-center weightssrc/dft/becke.rs (new)3.1a, 3.1b
3.1dGrid pruning: reduce angular points near nuclei where density is smoothsrc/dft/grid.rs3.1c

3.2 Exchange-correlation functional kernels ​

StepActionFiles affectedDepends on
3.2aImplement SVWN (Slater exchange + VWN-5 correlation) for LDAsrc/dft/functionals/svwn.rs (new)—
3.2bImplement PBE exchange-correlation for GGA (requires density gradient on grid)src/dft/functionals/pbe.rs (new)3.1c
3.2cBuild the VXC matrix assembly: evaluate basis functions + gradients on grid, contract with XC kernelsrc/dft/vxc_matrix.rs (new)3.2a or 3.2b, 3.1c

3.3 Kohn-Sham SCF loop ​

StepActionFiles affectedDepends on
3.3aCreate KS-DFT Fock matrix builder: FKS=Hcore+J+VXC (no exact exchange for pure DFT)src/dft/ks_fock.rs (new)3.2c
3.3bWire KS-DFT into the existing SCF loop (reuse DIIS, density matrix, convergence logic)src/scf/scf_loop.rs3.3a
3.3cValidate: atomization energies of H₂, H₂O, CH₄ within 5 kcal/mol of referencetests/regression/3.3b
3.3dWASM export: compute_dft(elements, coords, functional)crates/wasm/src/electronic.rs3.3b

Performance target: < 30 s for benzene/STO-3G/PBE in WASM; < 2 s for water.


Task 4: Classical Molecular Dynamics (Integrators & Ensembles) ​

Priority: Medium — extends the existing src/dynamics.rs with PBC and production-grade thermostats.

Current state: sci-form already implements:

  • Velocity Verlet integrator (simulate_velocity_verlet)
  • Nosé-Hoover NVT thermostat (simulate_nose_hoover)
  • Multi-backend support (UFF, PM3, xTB)
  • NEB path search (compute_simplified_neb_path)
  • WASM trajectory export (compute_md_trajectory, compute_md_trajectory_nvt)

Remaining work:

4.1 Periodic boundary conditions ​

StepActionFiles affectedDepends on
4.1aAdd SimulationBox struct with minimum-image conventionsrc/dynamics/pbc.rs (new)—
4.1bImplement coordinate wrapping and minimum-image distance in the Verlet loopsrc/dynamics.rs4.1a
4.1cAdd neighbor list (Verlet list) to avoid O(N²) force evaluation with PBCsrc/dynamics/neighbor_list.rs (new)4.1a
4.1dWire PBC into UFF force evaluation for non-bonded termssrc/forcefield/4.1b, 4.1c

4.2 Ensemble extensions ​

StepActionFiles affectedDepends on
4.2aAdd Berendsen barostat for NPT ensemble (pressure coupling)src/dynamics/barostat.rs (new)4.1a
4.2bAdd Langevin thermostat as alternative to Nosé-Hoover (better for implicit solvent)src/dynamics.rs—
4.2cAdd energy/temperature/pressure trajectory logging per stepsrc/dynamics.rs—
4.2dWASM export: compute_md_trajectory_nptcrates/wasm/src/dynamics.rs4.2a

4.3 Validation ​

StepActionFiles affectedDepends on
4.3aEnergy conservation test: NVE drift < 0.1% over 10,000 steps for argon/LJ systemtests/regression/4.1b
4.3bTemperature stability test: NVT at 300K ± 5K over 50,000 stepstests/regression/4.2a

Task 5: Reactive Force Fields (ReaxFF) ​

Priority: Medium — enables bond-breaking/formation dynamics without quantum cost.

Current state (2026-10-13): simplified reactive FF implemented in src/forcefield/reaxff/ (bond orders σ/π/ππ + overcoordination penalty, EEM charges, shielded vdW/Coulomb, numerical gradients) and validated against LAMMPS reaxff (F78: σ bond orders to 0.0085 on C–H/O–H pulls, CH₄ dissociation shape; fixture reaxff_lammps.json). Per-pair σ data (r0/p_bo/De/p_be for C/H/O) transcribed from ffield.reax.cho; bonded-pair vdW excluded (LJ diverges at bond lengths — ReaxFF uses Morse+f13 instead). Gaps: no BO overcoordination corrections, no Morse+f13, EEM polarity inverts at short range, no full ffield file parser, UFF/MMFF94 still require fixed topology.

5.1 Continuous bond orders ​

StepActionFiles affectedDepends on
5.1a✅ Continuous bond-order calculation (σ + π + ππ exponentials) + per-pair ffield σ tablesrc/forcefield/reaxff/bond_order.rs—
5.1b✅ Over-coordination correction (simplified 1/(1+e^Δ) penalties in BO + energy)src/forcefield/reaxff/bond_order.rs, energy.rs5.1a
5.1c✅ Tapering polynomial for smooth cutoffsrc/forcefield/reaxff/taper.rs—
5.1d✅ Bonded energy terms (bond/angle/torsion + per-pair De/p_be)src/forcefield/reaxff/energy.rs5.1a, 5.1c

5.2 Charge equilibration ​

StepActionFiles affectedDepends on
5.2a✅ EEM with Lagrange-constrained neutrality (polarity inverts at short range — needs stronger shielding)src/forcefield/reaxff/eem.rs—
5.2b✅ EEM wired into the energy pathsrc/forcefield/reaxff/gradients.rs5.2a, 5.1d
5.2c✅ Shielded vdW/Coulomb; bonded-pair vdW excluded (LJ diverges; ReaxFF uses Morse+f13)src/forcefield/reaxff/nonbonded.rs5.2a

5.3 ReaxFF parametrization & validation ​

StepActionFiles affectedDepends on
5.3a🔶 Per-pair σ table transcribed from ffield.reax.cho (C/H/O); full file parser pendingsrc/forcefield/reaxff/params.rs—
5.3b✅ Validated vs LAMMPS reaxff (F78): BO ≤0.0085, CH₄ shape; gate f78 in tests/alpha_reaxff_validation.rstests/alpha_reaxff_validation.rs5.1d, 5.2c
5.3c✅ Analytical gradients (BO scaling, bond/angle, over/under, vdW, Coulomb, EEM charge response)src/forcefield/reaxff/analytic.rs5.1d, 5.2c
5.3dWire into Velocity Verlet loop: reactive MD simulationsrc/dynamics.rs5.3c, Task 4
5.3eWASM export: compute_reaxff_energy, simulate_reactive_mdcrates/wasm/src/5.3d

Task 6: ML Force Field Inference (ONNX / Burn in WASM) ​

Priority: Medium — bridges DFT-level accuracy with classical MD speed.

Current state: sci-form already has ANI-2x and ANI-TM potentials in src/ani/ with AEV descriptors, cutoff functions, and gradient computation. The existing implementation uses hand-coded neural network inference in Rust (no external ML runtime).

Remaining work: Generalize to ONNX model loading for user-trained potentials.

6.1 Behler-Parrinello symmetry functions (generalized) ​

StepActionFiles affectedDepends on
6.1aExtract and generalize the AEV computation from src/ani/aev.rs into a standalone descriptor modulesrc/ml/symmetry_functions.rs (new)—
6.1bAdd configurable radial/angular function parameter sets (beyond ANI defaults)src/ml/symmetry_functions.rs6.1a

6.2 ONNX inference via tract or burn ​

StepActionFiles affectedDepends on
6.2aAdd tract-onnx as optional dependency; implement model loading and single-atom inferencesrc/ml/onnx_inference.rs (new), Cargo.toml—
6.2bImplement batch inference: compute descriptors → run model → extract per-atom energiessrc/ml/onnx_inference.rs6.1a, 6.2a
6.2cImplement analytical forces via chain rule (backprop through descriptors)src/ml/onnx_forces.rs (new)6.2b
6.2dVerify WASM compatibility: compile tract with wasm32-unknown-unknown target, measure binary sizecrates/wasm/6.2a

6.3 Integration with dynamics loop ​

StepActionFiles affectedDepends on
6.3aAdd MdBackend::Mlff variant to the dynamics enginesrc/dynamics.rs6.2c
6.3bWASM export: simulate_mlff_mdcrates/wasm/src/dynamics.rs6.3a
6.3cBenchmark: inference latency per atom per step (target: < 0.1 ms/atom in WASM)tests/benchmarks/6.3b

Binary size target: < 5 MB additional WASM payload for the ML inference runtime.


Task 7: Interactive Molecular Dynamics (IMD) Browser Loop ​

Priority: High (after core MD is stable) — the user-facing goal of the project.

Current state: The existing WASM bindings export compute_md_trajectory and compute_md_trajectory_nvt which run a full trajectory and return results. These are batch APIs, not frame-by-frame.

Target: A persistent simulation object that advances one rendering frame at a time, synchronized with requestAnimationFrame, with IMD steering forces.

7.1 Frame-by-frame simulation API ​

StepActionFiles affectedDepends on
7.1aCreate LiveSimulation WASM struct (from Task 1) with per-frame step() methodcrates/wasm/src/dynamics_live.rs (new)Task 1
7.1bAdd force backend selector: UFF, PM3, xTB, ReaxFF, MLFFcrates/wasm/src/dynamics_live.rsTasks 4–6
7.1cAdd configurable substeps-per-frame (decouple physics timestep from render rate)crates/wasm/src/dynamics_live.rs7.1a

7.2 Interactive steering (IMD forces) ​

StepActionFiles affectedDepends on
7.2aAdd apply_steering_force(atom_index, target_xyz, spring_k) API to inject harmonic IMD potentialscrates/wasm/src/dynamics_live.rs7.1a
7.2bAdd clear_steering_force(atom_index) to release IMD anchorscrates/wasm/src/dynamics_live.rs7.2a
7.2cImplement force accumulation: IMD forces are added linearly to the evaluated force fieldsrc/dynamics/7.2a

7.3 requestAnimationFrame integration ​

StepActionFiles affectedDepends on
7.3aCreate TypeScript/JS helper: startSimulationLoop(sim, renderer, options) using requestAnimationFramecrates/wasm/ts/simulation_loop.ts (new)7.1a
7.3bImplement pointer-based position read (no JSON): new Float64Array(memory.buffer, sim.positions_ptr(), sim.positions_len())crates/wasm/ts/simulation_loop.tsTask 1
7.3cAdd pause/resume/reset controlscrates/wasm/ts/simulation_loop.ts7.3a

7.4 Integration with 3d-orbitals-simulations viewer ​

StepActionFiles affectedDepends on
7.4aAdd useSimulation React hook wrapping LiveSimulation + rAF loop3d-orbitals-simulations/src/hooks/useSimulation.ts (new)7.3a
7.4bAdd simulation controls panel: play/pause, temperature, timestep, backend selector3d-orbitals-simulations/src/components/7.4a
7.4cWire atom picking (raycaster) → IMD steering force injection3d-orbitals-simulations/src/components/viewer/7.2a, 7.4a

FPS target: Sustained 60 FPS for systems up to 500 atoms with UFF backend; 30 FPS with xTB backend.


Dependency Map ​

Task 1 (WASM Memory) ──────────────────────────────────────────┐
                                                                │
Task 2 (HF/Obara-Saika) ─────┐                                 │
                              ├─► Task 3 (DFT)                  │
                              │                                 │
Task 4 (Classical MD + PBC) ──┼─► Task 5 (ReaxFF) ──┐          │
                              │                      ├──► Task 7 (IMD Browser Loop)
                              └─► Task 6 (MLFF) ─────┘          │
                                                                │
                                                   ◄────────────┘

Critical path: Task 1 → Task 4 → Task 7 (for the fastest path to interactive visualization)

Parallel tracks:

  • Task 2 + Task 3 can proceed independently (quantum accuracy)
  • Task 5 + Task 6 can proceed after Task 4 (reactive/ML backends)

Implementation Phases ​

Phase A: Interactive MVP (Tasks 1, 4 partial, 7) ​

Goal: Real-time Velocity Verlet + UFF in the browser at 60 FPS with atom steering.

  • Pointer-based WASM export
  • Existing Verlet + Nosé-Hoover
  • IMD force injection
  • rAF loop integration

Phase B: Quantum Backends (Tasks 2, 3) ​

Goal: DFT single-point calculations and SCF optimization accessible from the browser.

  • Obara-Saika integral speedup
  • LDA/GGA functionals
  • KS-DFT SCF loop

Phase C: Reactive Chemistry (Tasks 4 complete, 5, 6) ​

Goal: Bond breaking and formation in real time.

  • PBC + neighbor lists
  • ReaxFF continuous bond orders + EEM charges
  • ONNX ML potential inference in WASM

Phase D: Production (all tasks) ​

Goal: Full interactive molecular dynamics studio in the browser.

  • All force backends wired to the IMD loop
  • Simulation controls + analysis tools in the viewer
  • Educational scenario presets (water boiling, bond breaking, protein folding)

File Structure (new modules) ​

src/
├── dynamics/              # Refactored from dynamics.rs
│   ├── mod.rs
│   ├── state.rs           # DynamicAtom, MolecularSystem (Task 1)
│   ├── verlet.rs          # Existing Velocity Verlet (split from dynamics.rs)
│   ├── nose_hoover.rs     # Existing NVT (split from dynamics.rs)
│   ├── pbc.rs             # Periodic boundary conditions (Task 4)
│   ├── neighbor_list.rs   # Verlet neighbor list (Task 4)
│   └── barostat.rs        # NPT ensemble (Task 4)
├── dft/                   # New (Task 3)
│   ├── mod.rs
│   ├── grid.rs            # Molecular integration grid
│   ├── lebedev.rs         # Angular quadrature tables
│   ├── becke.rs           # Atomic partitioning weights
│   ├── vxc_matrix.rs      # XC potential matrix assembly
│   ├── ks_fock.rs         # Kohn-Sham Fock matrix builder
│   └── functionals/
│       ├── svwn.rs         # LDA
│       └── pbe.rs          # GGA
├── forcefield/
│   └── reaxff/            # New (Task 5)
│       ├── mod.rs
│       ├── bond_order.rs   # Continuous bond orders
│       ├── taper.rs        # Hermite tapering
│       ├── energy.rs       # Bonded energy terms
│       ├── nonbonded.rs    # vdW + Coulomb with shielding
│       ├── eem.rs          # Charge equilibration
│       ├── params.rs       # Parameter file parser
│       └── gradients.rs    # Analytical gradients
├── scf/
│   ├── obara_saika.rs     # New (Task 2) — optimized ERI recurrence
│   └── screening.rs       # New (Task 2) — Schwarz pre-screening
└── ml/
    ├── symmetry_functions.rs  # New (Task 6) — generalized Behler-Parrinello
    ├── onnx_inference.rs      # New (Task 6) — tract runtime
    └── onnx_forces.rs         # New (Task 6) — backprop forces

crates/wasm/
├── src/
│   └── dynamics_live.rs   # New (Task 7) — frame-by-frame simulation API
└── ts/
    ├── live_simulation.ts # New (Task 1) — Float64Array view helper
    └── simulation_loop.ts # New (Task 7) — rAF integration

Released under the MIT License.