Skip to content

TypeScript / JavaScript API Reference ​

The npm package is published as sci-form-wasm.

bash
npm install sci-form-wasm

It is a dual package: import resolves to the ESM (browser/bundler) build and require resolves to the CommonJS (Node.js) build. Both halves expose the same API.

Every entry point returns a JSON string, except the typed-array variants (embed_coords_typed, embed_coords_typed_seed64, compute_esp_grid_typed, eht_orbital_grid_typed, eht_orbital_grid_from_coefficients_typed), which return a typed array, and estimate_workers, which returns a number.


Initialisation ​

Browser / bundler (ESM):

typescript
import init, { embed, solve_eht } from 'sci-form-wasm';
await init();

Node.js (CommonJS) needs no async initialisation:

javascript
const sci = require('sci-form-wasm');

Both entry points come from the same tarball: the require condition of the package points at the CommonJS half in cjs/, which loads its own .wasm file from disk.

The alpha and beta research modules are published under the sci-form-wasm/alpha and sci-form-wasm/beta sub-paths.


Conventions ​

Error payload ​

On failure every entry point returns the canonical payload

json
{ "error": "<message>" }

and nothing else. The payload is always valid JSON — a NaN or a bare Rust message is never emitted. So a caller can always write:

typescript
const parsed = JSON.parse(sci.compute_something(...));
if (parsed.error) { /* handle */ }

Seeds are 64-bit ​

wasm-bindgen maps a Rust u64 to a JavaScript BigInt, so every seed-taking entry point has a *_seed64 variant that takes the full 64-bit range. The older 32-bit variants accept a JavaScript number and require an exact integer in 0..=4294967295; a seed above 2³², a negative/fractional value, NaN or Infinity returns {"error": ...} (or an empty Float64Array for the typed-array variants) instead of wrapping through >>> 0.

The *_seed64 variants use all 64 bits: two seeds that differ only above 2³² produce different conformers. For backward compatibility, seeds below 2³² keep their previous output. BigInt seeds are interpreted as unsigned 64-bit values.

The *_seed64 variants are:

64-bit variant32-bit counterpart
embed_seed64embed
embed_coords_seed64embed_coords
embed_coords_typed_seed64embed_coords_typed
embed_batch_seed64embed_batch
compute_md_trajectory_seed64compute_md_trajectory
compute_md_trajectory_nvt_seed64compute_md_trajectory_nvt
compute_md_trajectory_with_method_seed64compute_md_trajectory_with_method
search_conformers_with_uff_seed64search_conformers_with_uff
split_worker_tasks_seed64split_worker_tasks

embed_diverse, train_random_forest and train_gradient_boosting only exist in the 64-bit form.

Units ​

QuantityUnit
Geometry (coordinates, bond lengths, cell parameters)Å (cell angles in degrees)
UFF / MMFF94 energieskcal/mol
EHT, PM3, xTB orbital energies and HOMO–LUMO gapseV
PM3 / xTB total, electronic, repulsive, dispersion energieseV
PM3 heat of formationkcal/mol
HF-3c energy, HF energy, nuclear repulsion, D3/gCP/SRBHartree
HF-3c orbital energies, HOMO/LUMO, gapHartree
ANI energy, per-atom energiesHartree (forces Hartree/Å)
CISD energy, correlation_energyHartree (energy_ev is eV)
EHT gradients, optimize_geometry_eht energyeV, eV/Å
optimize_framework energy and forceseV, eV/Å
Vibrational frequencies, IR wavenumberscm⁻¹
NMR chemical shifts and shieldingsppm
NMR J-couplingsHz
Dipole momentDebye
Partial chargeselementary charge (e)
Electrostatic potentialHartree/e
DOS / PDOS1/eV
Surface areaŲ
MD energieskcal/mol; times in fs; temperatures in K

Energies are always total system energies unless the field name says otherwise.

Naming ​

The exported names match the Rust root function names, so the same capability has the same name in Rust, Python, WASM and (where exposed) the CLI. A handful of names are kept as aliases for the older spelling: eht_calculate (alias of solve_eht), eht_or_uff_fallback (alias of compute_eht_or_uff_fallback), get_eht_support / get_system_capabilities / get_system_method_plan (aliases of the get_-less names), pack_batch_arrow (alias of pack_conformers), compute_ml_properties and compute_molecular_descriptors (deprecated aliases of predict_ml_properties and compute_ml_descriptors). The historical *_wasm spellings remain as byte-identical aliases of the canonical names: validate_electron_count_wasm, validate_kmesh_weights_wasm, chart_to_json_wasm, chart_from_json_wasm, validate_chart_schema_wasm, pack_chart_payload_wasm, bloch_phase_wasm, build_bloch_hamiltonian_wasm, assemble_periodic_operators_wasm, compute_periodic_dos_wasm, solve_periodic_randnla_wasm, bz_integrate_scalar_wasm, bz_integrate_vector_wasm, extract_kinetics_diagnostics_wasm, solve_microkinetic_network_wasm, solve_microkinetic_steady_state_wasm and analyze_gsm_mbh_htst_step_wasm.


Metadata ​

version ​

typescript
function version(): string

Returns "sci-form 2.2.0".

alpha_modules_info / beta_modules_info ​

typescript
function alpha_modules_info(): string
function beta_modules_info(): string

Returns JSON {"alpha_modules": [...], "stability": "...", "version": "..."} and the beta_ equivalent. The lists are derived from the active Cargo features (MBH/Riemannian are omitted from beta_modules when their features are not built), so they describe the binary rather than a fixed catalogue.


Conformer generation ​

embed ​

typescript
function embed(smiles: string, seed: number): string

JSON payload:

typescript
interface ConformerResult {
  smiles: string;
  num_atoms: number;
  coords: number[];            // flat [x0,y0,z0,...], Å
  elements: number[];          // atomic numbers
  bonds: [number, number, string][];
  error: string | null;
  time_ms: number;   // always 0 in the WASM build (no wall-clock timer)
}
typescript
const result = JSON.parse(embed('CCO', 42));
console.log(result.num_atoms, result.coords.length);

embed_seed64 ​

typescript
function embed_seed64(smiles: string, seed: bigint): string

Same payload; seed is a BigInt (e.g. 42n). Numbers are also accepted below 2⁵³.

embed_coords ​

typescript
function embed_coords(smiles: string, seed: number): string

Compact JSON: {"coords": number[], "num_atoms": number}.

embed_coords_seed64 ​

typescript
function embed_coords_seed64(smiles: string, seed: bigint): string

embed_coords_typed ​

typescript
function embed_coords_typed(smiles: string, seed: number): Float64Array

The coordinates as a Float64Array — no JSON parsing overhead. Preferred for high-throughput use. Empty on failure.

typescript
const coords: Float64Array = embed_coords_typed('CCO', 42);

embed_coords_typed_seed64 ​

typescript
function embed_coords_typed_seed64(smiles: string, seed: bigint): Float64Array

embed_batch ​

typescript
function embed_batch(smiles_list: string, seed: number): string

Batch-embed from a newline-separated SMILES string. Returns a JSON array of ConformerResult. A batch-level failure returns a JSON array holding a single {"error": "..."} object, so the array shape is preserved.

embed_batch_seed64 ​

typescript
function embed_batch_seed64(smiles_list: string, seed: bigint): string

embed_diverse ​

typescript
function embed_diverse(smiles: string, n_conformers: number, rmsd_cutoff: number, base_seed: bigint): string

Embeds n_conformers times with consecutive seeds and keeps the Butina RMSD cluster centroids (cutoff in Å, finite and > 0). Returns a JSON array of ConformerResult records (smiles, num_atoms, coords, elements, bonds, error, time_ms); an invalid cutoff returns {"error": "..."}.

parse_smiles ​

typescript
function parse_smiles(smiles: string): string

Returns JSON:

typescript
interface ParseResult {
  num_atoms: number;
  num_bonds: number;
  atoms: { element: number; hybridization: string; formal_charge: number }[];
}

An empty string parses as an empty molecule (num_atoms=0), matching Python's parse(""); whitespace-only or malformed SMILES return {"error": ...}.

The atoms array matches the payload of Python's parse().

to_canonical_smiles ​

typescript
function to_canonical_smiles(smiles: string): string

Returns a JSON-quoted canonical SMILES string (e.g. "\"FC(Cl)(Br)I\""). All disconnected fragments are preserved and joined with . in lexicographic order, e.g. "[Cl-].[Na+]". Empty or malformed SMILES return {"error": ...}.


Charges, surface and electrostatics ​

compute_charges ​

typescript
function compute_charges(smiles: string): string
typescript
interface ChargeResult {
  charges: number[];        // e
  iterations: number;
  total_charge: number;     // e
  converged: boolean;
}

compute_charges_configured ​

typescript
function compute_charges_configured(
  smiles: string,
  max_iter: number,
  initial_damping: number,
  convergence_threshold: number,
): string

Same ChargeResult payload with an explicit convergence configuration. max_iter must be an integer >= 1; empty/whitespace or malformed SMILES and negative/fractional/non-finite max_iter return {"error": ...}.

compute_sasa ​

typescript
function compute_sasa(elements: string, coords_flat: string, probe_radius: number): string
typescript
interface SasaResult {
  total_sasa: number;    // Ų
  atom_sasa: number[];   // Ų
  probe_radius: number;  // Å
  num_points: number;
}

Electrical double layer ​

typescript
function compute_helmholtz_profile(
  surface_potential_v: number,
  ionic_strength_m: number,
  temperature_k?: number,
): string
function compute_gouy_chapman_profile(
  surface_potential_v: number,
  ionic_strength_m: number,
  temperature_k?: number,
): string
function compute_gcs_profile(
  surface_potential_v: number,
  ionic_strength_m: number,
  stern_thickness_a: number,
  temperature_k?: number,
): string

Potential-based Helmholtz, Gouy-Chapman and Gouy-Chapman-Stern profiles. The optional temperature_k defaults to 298.15 K and keeps existing two-/three-argument calls working. The payload contains distance_axis_angstrom, electrostatic_potential_v, field_strength_v_per_m, charge_density_c_per_m3, compact_layer_drop_v, diffuse_layer_drop_v, total_interfacial_drop_v, capacitance_total_f_per_m2, model_name and converged. Invalid or extreme finite input returns {"error": ...}; all three models expose the field series.

compute_population ​

typescript
function compute_population(elements: string, coords_flat: string): string
typescript
interface PopulationResult {
  mulliken_charges: number[];      // e
  lowdin_charges: number[];        // e
  mulliken_populations: number[];
  num_atoms: number;
  total_charge_mulliken: number;
  total_charge_lowdin: number;
  charge_conservation_error: number;
  homo_energy: number;             // eV
  lumo_energy: number;             // eV
  gap: number;                     // eV
  warnings: string[];
}

compute_dipole ​

typescript
function compute_dipole(elements: string, coords_flat: string): string

coords_flat must contain exactly 3 × len(elements) finite values and atomic numbers must lie in 1..=118; otherwise the result is {"error": "..."}. Valid elements without EHT parameters (for example Z=104) are also errors.

typescript
interface DipoleResult {
  vector: [number, number, number];  // Debye
  magnitude: number;                 // Debye
  unit: 'Debye';
  nuclear_dipole: [number, number, number];
  electronic_dipole: [number, number, number];
}

compute_esp_grid ​

typescript
function compute_esp_grid(elements: string, coords_flat: string, spacing: number, padding: number): string

Electrostatic potential on a 3D grid, in Hartree/e. compute_esp_grid is an alias of compute_esp.

compute_esp_grid_info ​

typescript
function compute_esp_grid_info(elements: string, coords_flat: string, spacing: number, padding: number): string

Returns {"dims": [...], "origin": [...], "spacing": ...} — the grid metadata without the values. The same spacing/padding/geometry and 1..=118 element validation as compute_esp_grid applies; an invalid configuration returns {"error": "..."} instead of a degenerate dims array.

compute_esp_grid_typed ​

typescript
function compute_esp_grid_typed(elements: string, coords_flat: string, spacing: number, padding: number): Float64Array

The grid values as a Float64Array of length dims[0] * dims[1] * dims[2] (Hartree/e). Pair with compute_esp_grid_info for the metadata. On invalid arguments it returns an empty Float64Array, because the typed-array ABI cannot carry an error object.


Density of states and alignment ​

compute_dos ​

typescript
function compute_dos(elements: string, coords_flat: string, sigma: number, e_min: number, e_max: number, n_points: number): string

n_points must be an integer >= 2; negative, fractional and non-finite values return {"error": ...}. Empty/non-finite geometry, atomic numbers outside 1..=118 and EHT-unsupported elements are also errors.

typescript
interface DosResult {
  sigma: number;        // eV
  energies: number[];   // eV
  total_dos: number[];  // 1/eV
  n_atoms_pdos: number;
}

compute_dos_multimethod ​

typescript
function compute_dos_multimethod(elements: string, coords_flat: string, method: string, sigma: number, e_min: number, e_max: number, n_points: number): string

method is eht, pm3, xtb (GFN2), gfn1, gfn2 or hf3c.

typescript
interface MultiMethodDosResult {
  energies: number[];         // eV
  total_dos: number[];        // 1/eV
  method: string;
  homo_energy: number;        // eV
  lumo_energy: number;        // eV
  gap: number;                // eV
  orbital_energies: number[]; // eV
  sigma: number;              // eV
}

compute_rmsd ​

typescript
function compute_rmsd(coords: string, reference: string): string

Returns {"rmsd": 0.034281} (Å). Mismatched lengths, partial triplets and non-finite coordinates return {"error": ...}; a NaN RMSD is never emitted.

compute_rmsd_matrix ​

typescript
function compute_rmsd_matrix(conformers_json: string): string

Returns a JSON 2-D array of pairwise RMSD values (Å). Ragged, empty or non-finite conformers return {"error": "..."} instead of the legacy -1.0 sentinel.


Extended Hückel theory ​

eht_calculate ​

typescript
function eht_calculate(elements: string, coords_flat: string, k: number): string

k is the Wolfsberg-Helmholtz constant; 0.0 selects the default 1.75. Negative, non-finite or otherwise non-positive constants are rejected with {"error": "..."} instead of being replaced by the default.

typescript
interface EhtResult {
  energies: number[];      // eV, all MO energies
  coefficients: number[][];
  n_electrons: number;
  homo_index: number;
  lumo_index: number;
  homo_energy: number;     // eV
  lumo_energy: number;     // eV
  gap: number;             // eV
  support: EhtSupport;
}

interface EhtSupport {
  level: string;
  has_transition_metals: boolean;
  supported_elements: number[];
  provisional_elements: number[];
  unsupported_elements: number[];
  warnings: string[];
}

solve_eht ​

typescript
function solve_eht(elements: string, coords_flat: string, k: number): string

The canonical name of the same calculation (sci_form::eht::solve_eht); eht_calculate is kept as an alias.

eht_support / get_eht_support ​

typescript
function eht_support(elements: string): string
function get_eht_support(elements: string): string

Returns the EhtSupport payload. get_eht_support is the Rust-root spelling, kept as an alias.

compute_eht_or_uff_fallback / eht_or_uff_fallback ​

typescript
function compute_eht_or_uff_fallback(smiles: string, elements: string, coords_flat: string, allow_experimental_eht: boolean): string
function eht_or_uff_fallback(smiles: string, elements: string, coords_flat: string, allow_experimental_eht: boolean): string

Returns {"mode": "eht" | "uff_fallback", "result": {...}} for EHT plus the flattened energies, n_electrons, homo_index, lumo_index, homo_energy, lumo_energy, gap, support_level and warnings. The fallback payload has energy_kcal_mol, reason, support_level and warnings.

compute_eht_gradient ​

typescript
function compute_eht_gradient(elements: string, coords_flat: string): string
typescript
interface EhtGradient {
  gradients: [number, number, number][];  // eV/Å
  rms_gradient: number;                   // eV/Å
  max_gradient: number;                   // eV/Å
  energy: number;                         // eV
}

optimize_geometry_eht ​

typescript
function optimize_geometry_eht(elements: string, coords_flat: string, max_steps: number, grad_threshold: number, energy_threshold: number, step_size: number): string

elements must be in 1..=118, coords_flat must hold exactly 3N finite values, max_steps must be a finite non-negative integer and the thresholds must be finite and positive; invalid input returns {"error": ...}.

typescript
interface EhtOptResult {
  positions: [number, number, number][];  // Å
  energy: number;                         // eV
  n_steps: number;
  converged: boolean;
  rms_gradient: number;                   // eV/Å
  energies: number[];                     // eV
}

Electronic structure ​

compute_pm3 ​

typescript
function compute_pm3(elements_json: string, coords_flat_json: string): string
typescript
interface Pm3Result {
  orbital_energies: number[];   // eV
  electronic_energy: number;    // eV
  nuclear_repulsion: number;    // eV
  total_energy: number;         // eV
  heat_of_formation: number;    // kcal/mol
  n_basis: number;
  n_electrons: number;
  homo_energy: number;          // eV
  lumo_energy: number;          // eV
  gap: number;                  // eV
  mulliken_charges: number[];   // e
  scf_iterations: number;
  converged: boolean;
  notes: string[];
}

compute_xtb ​

typescript
function compute_xtb(elements_json: string, coords_flat_json: string): string

GFN2-xTB (the same numbers as compute_gfn2): {orbital_energies, electronic_energy, repulsive_energy, total_energy, n_basis, n_electrons, homo_energy, lumo_energy, gap, mulliken_charges, scc_iterations, converged, notes} — all energies in eV.

compute_gfn1 ​

typescript
function compute_gfn1(elements_json: string, coords_flat_json: string): string

GFN1-xTB: as compute_xtb plus dispersion_energy (eV), dispersion_e6, dispersion_e8, halogen_bond_energy and shell_charges (e, per atom and shell). Elements must be in 1..=118 and coordinates exactly 3N finite values; invalid input returns {"error": ...}.

compute_gfn2 ​

typescript
function compute_gfn2(elements_json: string, coords_flat_json: string): string

GFN2-xTB: as compute_xtb plus dispersion_energy (eV), dispersion_2_body_energy (eV), halogen_bond_energy (eV), atomic_dipoles (Debye) and atomic_quadrupoles. Elements must be in 1..=118 and coordinates exactly 3N finite values; invalid input returns {"error": ...}.

compute_hf3c / compute_hf3c_custom ​

typescript
function compute_hf3c(elements_json: string, coords_flat_json: string): string
function compute_hf3c_custom(elements_json: string, coords_flat_json: string, max_scf_iter: number, n_cis_states: number, corrections: boolean): string

compute_hf3c_custom requires an integer max_scf_iter >= 1 and an integer n_cis_states >= 0 (0 skips CIS); fractional, negative or non-finite values return {"error": ...}. The backend is closed-shell and accepts H, C, N, O, F, P, S and Cl; odd electron counts, elements without an STO-3G basis and invalid geometries are errors. A non-finite SCF/CIS result is never returned.

typescript
interface Hf3cResult {
  energy: number;             // Hartree
  hf_energy: number;          // Hartree
  nuclear_repulsion: number;  // Hartree
  d3_energy: number;          // Hartree
  gcp_energy: number;         // Hartree
  srb_energy: number;         // Hartree
  orbital_energies: number[]; // Hartree
  scf_iterations: number;
  converged: boolean;
  cis: { excitations: unknown[]; error: string | null };
  n_basis: number;
  n_electrons: number;
  homo_energy: number;        // Hartree
  lumo_energy: number;        // Hartree
  gap: number;                // Hartree
  mulliken_charges: number[]; // e
}

compute_ani ​

typescript
function compute_ani(elements_json: string, coords_flat_json: string): string

The geometry must be a non-empty finite 3N array with atomic numbers in 1..=118; elements outside the ANI species set (H, C, N, O, F, S, Cl) return {"error": ...}.

typescript
interface AniResult {
  energy: number;             // Hartree
  forces: [number, number, number][];  // Hartree/Å
  species: number[];
  atomic_energies: number[];  // Hartree
  aevs: number[][] | null;
}

compute_cisd ​

typescript
function compute_cisd(elements_json: string, coords_flat_json: string, n_states: number): string

n_states must be an integer at least 1; zero, negative, fractional, NaN and infinite values return {"error": ...}. This payload contains the CISD result; Python additionally exposes the SCF reference metadata.

typescript
interface CisdResult {
  excitations: CisdExcitation[];
  correlation_energy: number;  // Hartree
  n_csfs: number;
  approximation: string;       // "full" or "perturbative"
}

interface CisdExcitation {
  energy: number;             // Hartree
  energy_ev: number;          // eV
  wavelength_nm: number;
  oscillator_strength: number;
  dominant_transition: [number, number][];
  character: string;
  singles_weight: number;
}

compute_aevs_tm ​

typescript
function compute_aevs_tm(elements_json: string, coords_flat_json: string): string

{"aev_length": number, "aevs": number[][], "n_atoms": number}, with aev_length == 176256 for the default ANI-TM parameters. Empty/non-finite or mismatched 3N geometry and elements outside the ANI-TM set return {"error": ...}.


compute_uhf / compute_rohf ​

typescript
function compute_uhf(elements: string, coords_flat: string, charge: number, multiplicity: number): string
function compute_rohf(elements: string, coords_flat: string, charge: number, multiplicity: number): string

Unrestricted and restricted open-shell Hartree-Fock. The energies are in Hartree, the gap in eV. For ROHF the HOMO is the SOMO and the LUMO is the next spatial orbital. The dense matrices of the result are not part of the payload; the scalar results, the orbital energies and the Mulliken charges are.

compute_pm3_gradient / compute_xtb_gradient ​

typescript
function compute_pm3_gradient(elements: string, coords_flat: string): string
function compute_xtb_gradient(elements: string, coords_flat: string): string

Energy gradients in eV/Å per atom. PM3 uses the stationary-density (Pulay-free) form: fixed-density integral rebuilds, no SCF per displaced coordinate. xTB uses warm-started central differences (5·10⁻⁴ Å) of the GFN2-xTB energy. compute_pm3_gradient returns {gradients: [[x, y, z], ...], energy, heat_of_formation} (energy in eV, heat_of_formation in kcal/mol); compute_xtb_gradient returns {gradients, energy} (eV). Atomic numbers must be in 1..=118; malformed geometry, unsupported elements and non-finite output return {"error": "..."}.

Force fields ​

compute_uff_energy ​

typescript
function compute_uff_energy(smiles: string, coords: string): string

{"energy": 6.993048, "unit": "kcal/mol"}.

compute_uff_energy_with_aromatic_heuristics ​

typescript
function compute_uff_energy_with_aromatic_heuristics(smiles: string, coords: string): string

Returns the raw energy, the aromatic correction and the corrected energy, all in kcal/mol. See UFF energy and the aromatic heuristic for the formula, measured benzene values and validation contract.

compute_mmff94_energy ​

typescript
function compute_mmff94_energy(smiles: string, coords: string): string

{"energy": 3.058318, "unit": "kcal/mol"} — complete MMFF94 energy (bond, angle, stretch-bend, out-of-plane, torsion, vdW, electrostatics). See MMFF94 for the measured ethanol total and validation contract.

compute_empirical_pka ​

typescript
function compute_empirical_pka(smiles: string): string

{"acidic_sites": [...], "basic_sites": [...], "notes": [...]} — coarse screening hints, not publication-grade predictions. See empirical pKa sites for the rule table, measured examples and limits.


compute_uff_energy_breakdown / compute_mmff94_energy_breakdown ​

typescript
function compute_uff_energy_breakdown(smiles: string, coords_flat: string): string
function compute_mmff94_energy_breakdown(smiles: string, coords_flat: string): string

The force-field energy split by term type, in kcal/mol (MMFF94 terms are bond, angle, stretch_bend, oop, torsion, vdw, electrostatic):

json
{ "terms": [{ "term": "bond", "energy": -12.3 }, { "term": "vdw", "energy": 4.1 }],
  "unit": "kcal/mol" }

Spectroscopy ​

compute_stda_uvvis ​

typescript
function compute_stda_uvvis(elements_json: string, coords_flat_json: string, sigma: number, e_min: number, e_max: number, n_points: number, broadening: string): string
typescript
interface StdaUvVisSpectrum {
  energies_ev: number[];      // eV
  wavelengths_nm: number[];   // nm
  absorptivity: number[];
  excitations: {
    energy_ev: number;
    wavelength_nm: number;
    oscillator_strength: number;
    from_mo: number;
    to_mo: number;
    transition_dipole: number; // Debye
  }[];
  sigma: number;               // eV
  broadening: string;          // "Gaussian" | "Lorentzian"
  notes: string[];
}

compute_fluorescence ​

typescript
function compute_fluorescence(elements_json: string, coords_flat_json: string, sigma: number, e_min: number, e_max: number, n_points: number, stokes_ev: number, refractive_index: number, dark_threshold: number, broadening: string): string
typescript
interface FluorescenceSpectrum {
  energies_ev: number[];          // eV
  wavelengths_nm: number[];       // nm
  intensity: number[];
  absorption_energy_ev: number;   // eV
  emission_energy_ev: number;     // eV
  emission_wavelength_nm: number; // nm
  oscillator_strength: number;
  radiative_rate_hz: number;      // Hz
  radiative_lifetime_ns: number;  // ns
  kasha: boolean;
  from_mo: number;
  to_mo: number;
  notes: string[];
}

compute_vibrational_analysis ​

typescript
function compute_vibrational_analysis(elements_json: string, coords_flat_json: string, method: string, step_size: number): string
typescript
interface VibrationalAnalysis {
  n_atoms: number;
  elements: number[];
  modes: {
    frequency_cm1: number;    // cm⁻¹
    ir_intensity: number;     // km/mol
    displacement: number[];
    is_real: boolean;
  }[];
  n_real_modes: number;
  n_imaginary_modes: number;
  zpve_ev: number;            // eV
  thermochemistry: {
    temperature_k: number;
    zpve_kcal: number;        // kcal/mol
    thermal_energy_kcal: number;
    enthalpy_correction_kcal: number;
    entropy_vib_cal: number;  // cal/mol/K
    gibbs_correction_kcal: number;
  };
  method: string;
  notes: string[];
}

WARNING

The EHT Hessian is a one-electron model with no electron-electron repulsion, so the surface has no minimum and imaginary (negative) frequencies are expected. Use pm3 or xtb.

compute_vibrational_analysis_uff ​

typescript
function compute_vibrational_analysis_uff(smiles: string, elements_json: string, coords_flat_json: string, step_size: number): string

The same payload with method: "UFF" — the fast analytical-Hessian path, useful for interactive IR previews. elements must match the SMILES atom order, coords must contain exactly 3N finite values, and step_size must be finite and > 0 (0.0 selects the engine default). Invalid SMILES or mismatched elements/geometry return {"error": ...}.

compute_ir_spectrum ​

typescript
function compute_ir_spectrum(analysis_json: string, gamma: number, wn_min: number, wn_max: number, n_points: number): string

Broadens an existing vibrational-analysis JSON string (the output of compute_vibrational_analysis or compute_vibrational_analysis_uff).

typescript
interface IrSpectrum {
  wavenumbers: number[];   // cm⁻¹
  intensities: number[];   // km/mol
  peaks: { frequency_cm1: number; ir_intensity: number; mode_index: number }[];
  gamma: number;           // cm⁻¹
  notes: string[];
}
typescript
const analysis = compute_vibrational_analysis(elements, coords, 'xtb', 0.005);
const ir = JSON.parse(compute_ir_spectrum(analysis, 15.0, 400.0, 4000.0, 1000));

compute_ir_spectrum_broadened ​

typescript
function compute_ir_spectrum_broadened(elements_json: string, coords_flat_json: string, method: string, gamma: number, wn_min: number, wn_max: number, n_points: number, broadening: string, step_size: number, smiles: string): string

Runs the vibrational analysis internally and broadens the result. broadening is gaussian or lorentzian; step_size is the finite-difference step in Å (0.0 uses the engine default); smiles is required when method is uff and ignored otherwise. n_points must be an integer ≥ 2; negative, fractional or non-finite values return {"error": ...}.

assign_peaks ​

typescript
function assign_peaks(frequencies_json: string, intensities_json: string, elements_json: string, mode_displacements_json: string): string

frequencies_json and intensities_json are JSON arrays of numbers; elements_json is a JSON array of atomic numbers; mode_displacements_json is a JSON array of modes (each an array of [x,y,z] triples) — pass "" to skip the normal-mode refinement.

Returns {"assignments": [...], "functional_groups": [...]}.


NMR ​

predict_nmr_shifts ​

typescript
function predict_nmr_shifts(smiles: string): string

Empty/whitespace or malformed SMILES return {"error": ...}; non-finite shifts or confidences outside 0..1 are rejected.

typescript
interface NmrShiftResult {
  h_shifts: ChemicalShift[];
  c_shifts: ChemicalShift[];
  f_shifts: ChemicalShift[];
  p_shifts: ChemicalShift[];
  n_shifts: ChemicalShift[];
  b_shifts: ChemicalShift[];
  si_shifts: ChemicalShift[];
  se_shifts: ChemicalShift[];
  o_shifts: ChemicalShift[];
  s_shifts: ChemicalShift[];
  other_shifts: unknown[];
  notes: string[];
}

interface ChemicalShift {
  atom_index: number;
  element: number;
  shift_ppm: number;   // ppm
  environment: string;
  confidence: number;
}

predict_nmr_shifts_for_nucleus ​

typescript
function predict_nmr_shifts_for_nucleus(smiles: string, nucleus: string): string

Returns a JSON array of ChemicalShift for the requested nucleus — 2H, 35Cl, 79Br, 195Pt, 207Pb, …. Labels are case-insensitive and accept either order (13C/C13), element names (carbon) and aliases (proton). A valid nucleus with no matching atom returns []; empty/malformed SMILES or an unknown nucleus returns {"error": ...}. Isotope abundances are not modeled, so 2H reports a relative shift for every hydrogen position.

predict_nmr_couplings ​

typescript
function predict_nmr_couplings(smiles: string, coords_flat_json: string): string

Returns a JSON array of {h1_index, h2_index, j_hz, n_bonds, coupling_type} — couplings in Hz. Pass "[]" for the topology-only free-rotation average. A non-empty coordinate array must contain exactly 3N finite values; empty/malformed SMILES, mismatched lengths and non-finite coordinates return {"error": ...}.

compute_ensemble_j_couplings ​

typescript
function compute_ensemble_j_couplings(smiles: string, conformer_coords_json: string, energies_kcal_json: string, temperature_k: number): string

J-couplings averaged over a conformer ensemble with Boltzmann weighting. conformer_coords_json is a JSON array of conformers (each a flat xyz array) and energies_kcal_json the matching energies in kcal/mol.

compute_nmr_spectrum ​

typescript
function compute_nmr_spectrum(smiles: string, nucleus: string, gamma: number, ppm_min: number, ppm_max: number, n_points: number): string

gamma must be finite and >= 0 (0 selects the nucleus default), ppm_max > ppm_min, n_points must be an integer >= 2 (negative, fractional and non-finite values are errors), and the nucleus must be supported; empty/whitespace SMILES also returns {"error": "..."}.

typescript
interface NmrSpectrum {
  ppm_axis: number[];    // ppm
  intensities: number[];
  peaks: { shift_ppm: number; intensity: number; atom_index: number; atom_indices: number[]; multiplicity: string; environment: string }[];
  nucleus: string;
  gamma: number;         // ppm
  integrations: unknown[];
  notes: string[];
}

compute_nmr_spectrum_with_coords ​

typescript
function compute_nmr_spectrum_with_coords(smiles: string, coords_flat_json: string, nucleus: string, gamma: number, ppm_min: number, ppm_max: number, n_points: number): string

Coordinate-aware variant: with 3D coordinates the vicinal ³J couplings use the Karplus relation instead of the topology-only fallback. The flat coordinate array must be a finite multiple of three; a trailing partial triplet used to panic inside chunks(3) and now returns {"error": "..."}.

compute_giao_nmr ​

typescript
function compute_giao_nmr(elements_json: string, coords_flat_json: string, nucleus: string, charge: number, multiplicity: number, max_scf_iter: number, allow_basis_fallback: boolean, use_parallel_eri: boolean): string

The flat coordinate array must be exactly 3N finite values; otherwise the result is {"error": "..."}. charge may be negative for a closed-shell anion; multiplicity and max_scf_iter must be integers ≥ 1. Impossible charges, zero multiplicity and fractional or negative iteration counts return {"error": ...} instead of being clamped/truncated.

typescript
interface GiaoNmrResult {
  nucleus: string;
  target_atomic_number: number;
  method: string;             // "RHF/GIAO"
  basis_set: string;          // "STO-3G"
  charge: number;
  multiplicity: number;
  scf_converged: boolean;
  scf_iterations: number;
  total_energy_hartree: number;   // Hartree
  n_basis: number;
  n_target_atoms: number;
  chemical_shifts: number[];      // ppm
  shieldings: { atom_index: number; element: number; isotropic: number; anisotropy: number; tensor: number[]; chemical_shift: number }[];
  fallback_elements: number[];
  notes: string[];
}

The public path is restricted to singlet closed-shell systems.

compute_hose_codes ​

typescript
function compute_hose_codes(smiles: string, max_radius: number): string

Returns a JSON array of {atom_index, element, spheres: string[], full_code}. max_radius must be an integer in 1..=100; empty SMILES and invalid radii return {"error": ...}.


Solvation ​

compute_nonpolar_solvation ​

typescript
function compute_nonpolar_solvation(elements: string, coords_flat: string, probe_radius: number): string
typescript
interface NonPolarSolvation {
  energy_kcal_mol: number;      // kcal/mol
  atom_contributions: number[]; // kcal/mol
  atom_sasa: number[];          // Ų
  total_sasa: number;           // Ų
}

compute_gb_solvation ​

typescript
function compute_gb_solvation(elements: string, coords_flat: string, charges: string, solvent_dielectric: number, solute_dielectric: number, probe_radius: number): string

Returns a JSON string. On invalid input the result is {"error": "<message>"}: the coordinate array must hold 3 * atoms values, the charge array must hold one value per atom, a dielectric constant must be finite and >= 1.0 (1.0 is the vacuum limit), and the probe radius must be finite and >= 0.

typescript
interface GbSolvation {
  electrostatic_energy_kcal_mol: number;  // kcal/mol
  nonpolar_energy_kcal_mol: number;       // kcal/mol
  total_energy_kcal_mol: number;          // kcal/mol
  born_radii: number[];                   // Å
  charges: number[];                      // e
  solvent_dielectric: number;
  solute_dielectric: number;
}

Kinetics ​

extract_kinetics_diagnostics ​

typescript
function extract_kinetics_diagnostics(network_json: string, n_steps: number): string
function extract_kinetics_diagnostics_wasm(network_json: string, n_steps: number): string

network_json is a MicrokineticNetworkConfig document; pass "" for the built-in A ⇌ B demo. n_steps must be a finite integer >= 2 and overrides the network's n_frames; negative/fractional/NaN/infinite values return {"error": ...}. The _wasm suffix is a byte-identical alias. Returns:

json
{
  "is_steady_state": false,
  "mass_conservation_error": 2.220446049250313e-16,
  "max_population": 0.9800069400037741,
  "max_rate_of_change": 7.94623340044654e-6,
  "total_population": 1.0000000000000002
}

solve_microkinetic_network / solve_microkinetic_steady_state ​

typescript
function solve_microkinetic_network(network_json: string, n_steps: number): string
function solve_microkinetic_steady_state(
  network_json: string,
  n_steps: number,
  tol: number,
): string

Both apply the same n_steps >= 2 contract and override n_frames. The steady-state solver also requires tol to be finite and strictly positive. Returns {n_steps, n_rates, converged, final_time_s, final_populations, diagnostics} and {n_steps, converged, residual, tol, final_time_s, final_populations, diagnostics} respectively.

Rings, fingerprints and clustering ​

compute_sssr ​

typescript
function compute_sssr(smiles: string): string

Empty or malformed SMILES return {"error": ...}; acyclic molecules return an empty rings array.

typescript
interface SssrResult {
  rings: { atoms: number[]; size: number; is_aromatic: boolean }[];
  atom_ring_count: number[];
  atom_ring_sizes: number[][];
  ring_size_histogram: number[];
}

compute_ecfp ​

typescript
function compute_ecfp(smiles: string, radius: number, n_bits: number): string

radius must be an integer in 0..=100 and n_bits an integer in 64..=1,048,576; empty/whitespace SMILES and invalid controls return {"error": ...}.

typescript
interface ECFPFingerprint {
  n_bits: number;
  on_bits: number[];
  radius: number;          // 2 = ECFP4, 3 = ECFP6
  raw_features: number[];
}

compute_ecfp_batch ​

typescript
function compute_ecfp_batch(smiles_list_json: string, radius: number, n_bits: number): string

Returns a JSON array of ECFPFingerprint, in input order. The same radius and n_bits range applies; an empty list returns [] and empty/invalid SMILES return an error object.

compute_tanimoto ​

typescript
function compute_tanimoto(fp1_json: string, fp2_json: string): string

Returns {"tanimoto": 0.333333}. Both fingerprints must use the same radius and n_bits; mismatched or malformed fingerprints return {"error": ...}.

butina_cluster ​

typescript
function butina_cluster(conformers_json: string, rmsd_cutoff: number): string

Every conformer must be a non-empty finite 3N array with the same atom count, and rmsd_cutoff must be finite and > 0; otherwise the result is {"error": "..."}.

typescript
interface ClusterResult {
  n_clusters: number;
  assignments: number[];
  centroid_indices: number[];
  cluster_sizes: number[];
  rmsd_cutoff: number;   // Å
}

filter_diverse ​

typescript
function filter_diverse(conformers_json: string, rmsd_cutoff: number): string

Returns a JSON array of the retained (cluster centroid) conformer indices. The same conformer/cutoff validation as butina_cluster applies.


Descriptors and machine learning ​

compute_ml_descriptors ​

typescript
function compute_ml_descriptors(smiles: string): string
typescript
interface MolecularDescriptors {
  molecular_weight: number;
  n_heavy_atoms: number;
  n_hydrogens: number;
  n_bonds: number;
  n_rotatable_bonds: number;
  n_hbd: number;
  n_hba: number;
  fsp3: number;
  total_abs_charge: number;
  max_charge: number;
  min_charge: number;
  wiener_index: number;
  n_rings: number;
  n_aromatic: number;
  balaban_j: number;
  sum_electronegativity: number;
  sum_polarizability: number;
}

Deprecated alias: compute_molecular_descriptors → compute_ml_descriptors. See ML descriptors and proxy properties for the field table and measured examples.

predict_ml_properties ​

typescript
function predict_ml_properties(smiles: string): string

{"logp", "molar_refractivity", "log_solubility", "lipinski_violations", "lipinski_passes", "druglikeness"}.

Deprecated alias: compute_ml_properties → predict_ml_properties.

compute_tpsa ​

typescript
function compute_tpsa(smiles: string): string

Topological polar surface area in Ų (Ertl fragment contributions over N, O, P and S). It is a topological property: no 3D geometry is needed. Empty or malformed SMILES return {"error": ...}.

predict_ensemble ​

typescript
function predict_ensemble(smiles: string): string

Ensemble property prediction: the consensus LogP with its uncertainty, the solubility, the TPSA, the pKa estimates, the Veber rules, the BBB permeability and an overall confidence score (0–1).

compute_whim ​

typescript
function compute_whim(elements_json: string, coords_flat_json: string, weighting: string): string

The coordinate array must be exactly 3N and finite; otherwise the result is {"error": "..."}.

weighting is unit, mass, volume, electronegativity or polarizability. Returns {eigenvalues, lambda, nu, gamma, eta, total_spread, anisotropy, directional, kurtosis}.

compute_rdf ​

typescript
function compute_rdf(elements_json: string, coords_flat_json: string, charges_json: string, beta: number, r_max: number, n_points: number): string

At least two atoms, beta > 0, r_max > 0, n_points >= 2 and a finite charge array of the correct length are required; pass "" for Gasteiger charges.

charges_json is a JSON array of partial charges; pass "" to derive them internally with Gasteiger. Returns {radii (Å), rdf_unweighted, rdf_mass, rdf_electronegativity, rdf_charge, beta (Å⁻²), n_pairs}.

compute_getaway ​

typescript
function compute_getaway(elements_json: string, coords_flat_json: string, bonds_json: string, max_lag: number): string

bonds_json is a JSON array of [i, j] pairs; pass "" to perceive the bonds from the geometry. max_lag must be an integer in 1..=10000. Returns {leverages, hat_autocorrelation, r_autocorrelation, hat_total, r_total, h_information, h_max, h_mean, max_lag}.

train_random_forest ​

typescript
function train_random_forest(features_json: string, targets_json: string, n_trees: number, max_depth: number, min_samples_split: number, min_samples_leaf: number, sample_fraction: number, seed: bigint): string

{"model_type": "random_forest", "n_estimators", "n_samples", "predictions", "train_rmse"}.

train_gradient_boosting ​

typescript
function train_gradient_boosting(features_json: string, targets_json: string, n_estimators: number, learning_rate: number, max_depth: number, min_samples_split: number, min_samples_leaf: number, subsample: number, seed: bigint): string

{"model_type": "gradient_boosting", "n_estimators", "n_samples", "predictions", "train_rmse"}.

For both trainers, counts must be finite non-negative integers; fractional/negative/NaN/infinite values return {"error": ...}. seed is a JavaScript bigint.


Reactivity and topology ​

compute_bond_orders ​

typescript
function compute_bond_orders(elements: string, coords_flat: string): string

{bonds: [{atom_i, atom_j, distance (Å), wiberg, mayer}], num_atoms, wiberg_valence, mayer_valence}. Invalid geometry, atomic numbers outside 1..=118 or elements without EHT parameters return {"error": ...}.

compute_frontier_descriptors ​

typescript
function compute_frontier_descriptors(elements: string, coords_flat: string): string

coords_flat must be exactly 3N finite values and atomic numbers must lie in 1..=118; otherwise the result is {"error": "..."}.

{num_atoms, homo_atom_contributions, lumo_atom_contributions, dual_descriptor, homo_energy (eV), lumo_energy (eV), gap (eV)}.

compute_fukui_descriptors ​

typescript
function compute_fukui_descriptors(elements: string, coords_flat: string): string

Same exact-3N finite-coordinate and 1..=118 element contract as compute_frontier_descriptors.

{num_atoms, f_plus, f_minus, f_radical, dual_descriptor, condensed, homo_energy, lumo_energy, gap, validity_notes}.

compute_reactivity_ranking ​

typescript
function compute_reactivity_ranking(elements: string, coords_flat: string): string

Same exact-3N finite coordinate contract as compute_frontier_descriptors.

{nucleophilic_attack_sites, electrophilic_attack_sites, radical_attack_sites, notes} — the scores are empirical composites, not calibrated kinetic barriers.

compute_uv_vis_spectrum ​

typescript
function compute_uv_vis_spectrum(elements: string, coords_flat: string, sigma: number, e_min: number, e_max: number, n_points: number): string

{energies_ev (eV), intensities, peaks, sigma (eV), notes}.

compute_topology ​

typescript
function compute_topology(elements: string, coords_flat: string): string

Invalid geometry, non-finite coordinates or atomic numbers outside 1..=118 return {"error": "..."}. See metal coordination topology.

{metal_centers, warnings}.

analyze_graph_features ​

typescript
function analyze_graph_features(smiles: string): string

{aromaticity: {aromatic_atoms, aromatic_bonds}, stereocenters: {tagged_tetrahedral_centers, inferred_tetrahedral_centers}}. Inferred centres use CIP substituent trees; see graph feature analysis.

analyze_stereo ​

typescript
function analyze_stereo(smiles: string, coords_flat: string): string

A non-empty coords_flat must contain exactly 3N finite values; truncated, extra or non-finite arrays return {"error": ...}. An empty array gives the topology-only result.

typescript
interface StereoAnalysis {
  stereocenters: {
    atom_index: number;
    element: number;
    substituent_indices: number[];
    priorities: number[];
    configuration: 'R' | 'S' | null;
  }[];
  double_bonds: {
    atom1: number;
    atom2: number;
    configuration: 'E' | 'Z' | null;
    high_priority_sub1: number | null;
    high_priority_sub2: number | null;
  }[];
  n_stereocenters: number;
  n_double_bonds: number;
  atropisomeric_axes: unknown[];
  prochiral_centers: unknown[];
  helical_chirality: unknown[];
}

Pass "[]" for the topology-only analysis.


Orbital meshes and grids ​

compute_orbital_mesh ​

typescript
function compute_orbital_mesh(elements_json: string, coords_flat_json: string, method: string, mo_index: number, spacing: number, padding: number, isovalue: number): string

method is eht, pm3, xtb or hf3c; spacing and padding are in Å. spacing > 0, padding >= 0, isovalue finite and mo_index in range are required; invalid values return an error object.

typescript
interface OrbitalMeshResult {
  mesh: { vertices: number[]; normals: number[]; indices: number[]; num_triangles: number; isovalue: number };
  grid: { origin: [number, number, number]; spacing: number; dims: [number, number, number]; values: number[] };
  method: string;
  mo_index: number;
  homo_index: number;
  orbital_energies: number[];  // eV
  gap: number;                 // eV
}

eht_orbital_mesh ​

typescript
function eht_orbital_mesh(elements: string, coords_flat: string, mo_index: number, spacing: number, isovalue: number): string

The flat EHT mesh payload: {vertices, normals, indices, num_triangles, isovalue}. Elements must be in 1..=118, coordinates exactly 3N finite values, mo_index a finite non-negative integer inside the orbital range, spacing finite and positive, and isovalue finite; invalid input returns {"error": ...}.

eht_orbital_grid_typed ​

typescript
function eht_orbital_grid_typed(elements: string, coords_flat: string, mo_index: number, spacing: number): Float32Array

The raw volumetric orbital grid as a Float32Array. Use eht_volumetric_grid_info for the grid dimensions.

eht_orbital_grid_from_coefficients_typed ​

typescript
function eht_orbital_grid_from_coefficients_typed(elements: string, coords_flat: string, coefficients_json: string, mo_index: number, spacing: number): Float32Array

The same grid, computed from supplied MO coefficients.

eht_volumetric_grid_info ​

typescript
function eht_volumetric_grid_info(elements: string, coords_flat: string, spacing: number, padding: number): string

{"dims": [...], "origin": [...], "spacing": ...}.


Materials and periodic systems ​

parse_cif / write_cif ​

typescript
function parse_cif(cif_text: string): string
function write_cif(cif_json: string): string

Read a CIF file into a crystal structure (as JSON) and write it back. The cell lengths are in Å, the cell angles in degrees and the atom-site coordinates are fractional.

create_unit_cell ​

typescript
function create_unit_cell(a: number, b: number, c: number, alpha: number, beta: number, gamma: number): string

{"a", "b", "c" (Å), "alpha", "beta", "gamma" (degrees), "volume" (ų)}. Lengths must be finite and positive, angles in (0°, 180°), and the angle combination must produce a positive volume; otherwise the result is {"error": ...}.

assemble_framework ​

typescript
function assemble_framework(topology: string, metal: number, geometry: string, lattice_a: number, supercell: number): string

topology is any name accepted by Topology::from_name (pcu, dia, sql, bcu, fcu, acs, afw, sod, pts, xah, tfy); geometry is linear, trigonal, tetrahedral, square_planar or octahedral. metal must be an atomic number in 1..=118, lattice_a finite and positive, and supercell an integer >= 1; the replicated structure is capped at 1,000,000 atoms. Invalid inputs return {"error": ...}. Returns {cell: {lattice}, atoms: [{element, frac_coords}], labels}. This wrapper uses one carboxylate linker; per-edge-type linker selection is Rust-only (assemble_framework_with_linkers).

space_group_by_number / space_group_by_symbol ​

typescript
function space_group_by_number(number: number): string
function space_group_by_symbol(symbol: string): string
typescript
interface SpaceGroup {
  number: number;
  symbol: string;
  crystal_system: string;
  lattice_type: string;
  point_group: string;
  operations: { rotation: number[][]; translation: number[] }[];
}

number must be a finite integer; fractional/NaN/infinite values return {"error": ...}. An integer outside 1..=230 and an unknown symbol return JSON null (matching Python's None). Symbol matching ignores spaces and is case-sensitive.

all_space_groups ​

typescript
function all_space_groups(): string

Returns a JSON array of [number, symbol] pairs — all 230 groups, with unique numbers and unique symbols.

build_periodic_molecule ​

typescript
function build_periodic_molecule(elements_json: string, frac_coords_json: string, cell_json: string, bond_tolerance: number): string

frac_coords_json is a JSON array of [x, y, z] triples and cell_json the JSON array [a, b, c, alpha, beta, gamma] (Å, degrees). bond_tolerance is the extra bonding tolerance in Å and is required on this surface: 0.0 disables the extra tolerance, while the Rust/Python default of 0.3 Å is passed explicitly. Every element must be in 1..=118, every coordinate a finite triple, and the cell finite with a non-degenerate volume; invalid input returns {"error": ...}. Returns {elements, frac_coords, cart_coords, bonds, cell, n_atoms}.

detect_hapticity ​

typescript
function detect_hapticity(elements_json: string, coords_flat_json: string, bonds_json: string): string

bonds_json is a JSON array of [i, j] pairs; pass "" to perceive the bonds from the geometry. Returns {interactions, is_metallocene, n_interactions}. The coordinate array must be exactly 3N finite values; otherwise the result is {"error": "..."}.

optimize_framework ​

typescript
function optimize_framework(smiles: string, coords_flat_json: string, method: string, max_iter: number, force_tol: number, energy_tol: number, max_step: number, fixed_atoms_json: string, cell_json: string): string

cell_json optionally enables periodic (minimum-image) optimisation and is the JSON array [a, b, c, alpha, beta, gamma]. Energies are reported in eV and forces in eV/Å. coords_flat_json must hold exactly 3N finite values, max_iter must be a finite non-negative integer and fixed_atoms_json indices must be non-negative and in range; invalid input returns {"error": ...}. The core also rejects non-finite energy/force evaluations and force/atom count mismatches.

typescript
interface FrameworkOptResult {
  positions: [number, number, number][];  // Å
  energy: number;                        // eV
  forces: [number, number, number][];    // eV/Å
  max_force: number;                     // eV/Å
  n_iterations: number;
  converged: boolean;
  energy_history: number[];              // eV
}

Dynamics, NEB and reaction paths ​

compute_md_trajectory ​

typescript
function compute_md_trajectory(smiles: string, coords_json: string, n_steps: number, dt_fs: number, seed: number): string

Short NVE molecular dynamics with the UFF force field. dt_fs in fs; energies in kcal/mol.

typescript
interface MdTrajectory {
  frames: { step: number; time_fs: number; coords: number[]; potential_energy_kcal_mol: number; kinetic_energy_kcal_mol: number; temperature_k: number }[];
  dt_fs: number;
  notes: string[];
  energy_drift_percent: number | null;
}

compute_md_trajectory_seed64 ​

typescript
function compute_md_trajectory_seed64(smiles: string, coords_json: string, n_steps: number, dt_fs: number, seed: bigint): string

compute_md_trajectory_nvt ​

typescript
function compute_md_trajectory_nvt(smiles: string, coords_json: string, n_steps: number, dt_fs: number, seed: number, target_temp_k: number, thermostat_tau_fs: number): string

NVT with the Berendsen thermostat; target_temp_k in K, thermostat_tau_fs in fs. See molecular dynamics.

compute_md_trajectory_nvt_seed64 ​

typescript
function compute_md_trajectory_nvt_seed64(smiles: string, coords_json: string, n_steps: number, dt_fs: number, seed: bigint, target_temp_k: number, thermostat_tau_fs: number): string

compute_md_trajectory_with_method ​

typescript
function compute_md_trajectory_with_method(smiles: string, coords_json: string, elements_json: string, n_steps: number, dt_fs: number, seed: number, target_temp_k: number, backend: string): string

backend is uff, pm3 or xtb; target_temp_k > 0 enables the 100 fs Berendsen thermostat and 0 disables it. The elements must match the SMILES. See multi-backend MD.

backend is uff, pm3 or xtb; target_temp_k > 0 enables the Berendsen thermostat with a 100 fs coupling.

compute_md_trajectory_with_method_seed64 ​

typescript
function compute_md_trajectory_with_method_seed64(smiles: string, coords_json: string, elements_json: string, n_steps: number, dt_fs: number, seed: bigint, target_temp_k: number, backend: string): string

compute_simplified_neb_path ​

typescript
function compute_simplified_neb_path(smiles: string, start_coords_json: string, end_coords_json: string, n_images: number, n_iter: number, spring_k: number, step_size: number): string

{"images": [...], "notes": [...]} — a low-cost exploratory path, not a full climbing-image / tangent-projected NEB. n_images must be an integer in 2..=1000, n_iter an integer ≥ 1; invalid counts, empty SMILES or non-finite/mismatched coordinates return {"error": ...}.

compute_neb_path_with_method ​

typescript
function compute_neb_path_with_method(smiles: string, start_coords_json: string, end_coords_json: string, n_images: number, n_iter: number, spring_k: number, step_size: number, method: string): string

method is uff, mmff94, pm3, xtb, gfn1, gfn2 or hf3c. n_images must be an integer in 2..=1000; n_iter must be an integer ≥ 1; empty SMILES and invalid counts return {"error": ...}.

neb_single_point_energy / neb_energy_and_gradient ​

typescript
function neb_single_point_energy(method: string, smiles: string, coords_json: string): string
function neb_energy_and_gradient(method: string, smiles: string, coords_json: string): string

{"energy": <f64> (kcal/mol), "method": "<str>"} and {"energy": <f64> (kcal/mol), "gradient": [<f64>...], "method": "<str>"}. Empty/malformed SMILES, unknown backends and coordinates whose length is not 3 × n_atoms return {"error": ...}; the gradient has one triple per atom in input order.

list_neb_backends ​

typescript
function list_neb_backends(elements_json: string): string

Returns a JSON array of {"method": string, "available": bool, "note": string}. available is true only when every requested element has parameters for that backend (UFF types; MMFF94 H/C/N/O/F/Si/P/S/Cl/Br/I/Fe; the PM3, GFN1 and GFN2 tables; HF-3c H/C/N/O/F/P/S/Cl). An empty array, an atomic number outside 1..=118, or malformed JSON returns {"error": ...}. Availability is parameter coverage, not an SCF convergence guarantee.

search_conformers_with_uff ​

typescript
function search_conformers_with_uff(smiles: string, n_samples: number, seed: number, rmsd_threshold: number): string

{"generated", "unique", "rotatable_bonds", "conformers", "clusters", "notes"} — energies in kcal/mol, RMSD threshold in Å.

search_conformers_with_uff_seed64 ​

typescript
function search_conformers_with_uff_seed64(smiles: string, n_samples: number, seed: bigint, rmsd_threshold: number): string

compute_reaction_dynamics ​

typescript
function compute_reaction_dynamics(reactant_smiles_json: string, product_smiles_json: string, method: string, config_json: string): string

Embeds one reactant and one product molecule, builds oriented complexes, runs NEB for the reactive zone and generates approach/departure frames. method is uff, mmff94, pm3, xtb, gfn1, gfn2 or hf3c; config_json is an optional JSON configuration (pass "" or "{}" for the defaults). The atom mapping enumerates element/connectivity/bond-order graph isomorphisms and keeps the lowest-Kabsch-RMSD mapping, so product SMILES order does not create a spurious barrier (CCO → OCC: 1.1165 kcal/mol). Multi-fragment input and reactions that change connectivity or bond orders (for example CC=O → C=C-O) are rejected explicitly with a not isomorphic error; use the Rust-only 3D reaction dynamics for those. Frame energies remain exploratory. See 1D reaction dynamics.


SMIRKS ​

parse_smirks ​

typescript
function parse_smirks(smirks: string): string
typescript
interface SmirksTransform {
  reactant_smarts: string[];
  product_smarts: string[];
  atom_map: Record<string, number>;
  bond_changes: {
    atom1_map: number;
    atom2_map: number;
    old_order: string | null;
    new_order: string | null;
  }[];
  smirks: string;
}

apply_smirks ​

typescript
function apply_smirks(smirks: string, smiles: string): string
typescript
interface SmirksResult {
  products: string[];
  atom_mapping: Record<string, number>;
  n_transforms: number;
  success: boolean;
  messages: string[];
}

parse_smirks requires a non-empty transform with at least one atom map in 1..=255 on both sides. apply_smirks returns applied canonical product SMILES in products, not the product template. It applies mapped element, charge, hydrogen-count and bond-order changes, creates product-only mapped atoms and removes reactant-only mapped atoms. Empty/whitespace smiles, a multi-fragment smiles with a one-component transform, and an unmapped SMIRKS are rejected with {"error": ...}. A valid transform that does not match returns success: false and products: []. Multi-component transforms accept dot-separated reactants and return the combined product.


Transport and worker helpers ​

pack_conformers / pack_batch_arrow ​

typescript
function pack_conformers(results_json: string): string
function pack_batch_arrow(results_json: string): string

Pack a JSON array of conformer results into sci-form's columnar (Arrow-like) format. This is not the Apache Arrow IPC format — it is a JSON serialisation of sci-form's own columnar layout.

num_rows is the number of conformers (failed results keep a row with success: 0), not the total atom count. The columns are success (Int32), num_atoms (Int32), time_ms (Float64), coords (Float64, shape [total_atoms, 3]) and elements (Uint8, shape [total_atoms]). A result whose num_atoms does not match its coordinate or element array returns {"error": ...} instead of silently dropping the row.

typescript
interface RecordBatch {
  num_rows: number;
  schema: { name: string; dtype: 'Float64' | 'Int32' | 'Uint8'; shape: number[] }[];
  float_columns: { name: string; values: number[]; shape: number[] }[];
  int_columns: { name: string; values: number[]; shape: number[] }[];
  uint8_columns: { name: string; values: number[]; shape: number[] }[];
}

split_worker_tasks ​

typescript
function split_worker_tasks(smiles_json: string, n_workers: number, seed: number): string

Returns a JSON array of worker tasks: {id: number, kind: string, smiles: string[], params: unknown[]}. Empty input returns []; n_workers must be an integer >= 1, otherwise the result is {"error": ...}.

split_worker_tasks_seed64 ​

typescript
function split_worker_tasks_seed64(smiles_json: string, n_workers: number, seed: bigint): string

estimate_workers ​

typescript
function estimate_workers(n_items: number, max_workers: number): number

Heuristic to pick the optimal worker count. Negative, fractional or non-finite arguments return 0.


System planning ​

system_capabilities / get_system_capabilities ​

Empty element arrays and atomic numbers outside 1..=118 mark the affected methods unavailable; unsupported_elements is a number array.

typescript
function system_capabilities(elements: string): string
function get_system_capabilities(elements: string): string
typescript
interface MethodCapability {
  available: boolean;
  confidence: string;   // "supported" | "experimental" | "unsupported"
  unsupported_elements: number[];
  warnings: string[];
}

interface SystemCapabilities {
  embed: MethodCapability;
  uff: MethodCapability;
  eht: MethodCapability;
  population: MethodCapability;
  orbital_grid: MethodCapability;
}

system_method_plan / get_system_method_plan ​

For an empty or invalid element set, recommendations are null and every capability is unavailable.

typescript
function system_method_plan(elements: string): string
function get_system_method_plan(elements: string): string
typescript
interface PropertyMethodPlan {
  property: string;
  recommended: string | null;
  fallback: string | null;
  rationale: string[];
  methods: MethodMetadata[];
}

interface SystemMethodPlan {
  capabilities: SystemCapabilities;
  geometry: PropertyMethodPlan;
  force_field_energy: PropertyMethodPlan;
  orbitals: PropertyMethodPlan;
  population: PropertyMethodPlan;
  orbital_grid: PropertyMethodPlan;
}

compare_methods ​

typescript
function compare_methods(smiles: string, elements: string, coords_flat: string, allow_experimental_eht: boolean): string

{"plan": SystemMethodPlan, "comparisons": MethodComparisonEntry[]}. Per-method failures are rows; empty or non-finite geometry returns {"error": ...}.


Experimental (feature-gated) ​

State note (2.2.0). The Rust implementations of CGA, SDR, EDL, GSM, KPM, CPM, RandNLA, Riemannian, kinetics, the periodic adapters and the render bridge are core. Some Python/WASM/CLI wrappers still carry the historical experimental-*, alpha-* or beta-* feature flag; the flag is a build choice, not a stability claim. MBH, DFT, MLFF and reaction dynamics remain gated.

These exports are exposed when the corresponding Cargo feature is enabled on the sci-form-wasm build. The entry points are:

FunctionFeature
compute_eeq_charges, compute_eeq_energyexperimental-eeq
compute_alpb_solvation, compute_alpb_born_radiiexperimental-alpb
compute_d4_energyexperimental-d4
compute_cpm_charges, compute_cpm_surfaceexperimental-cpm
compute_kmesh, compute_periodic_dos, solve_periodic_randnla, bloch_phase, build_bloch_hamiltonian, assemble_periodic_operators, validate_electron_count, validate_kmesh_weights, alpha_periodic_kpath_standard, alpha_periodic_fermi_surface_from_bandsalpha-periodic-linear
bz_integrate_scalar, bz_integrate_vectoralpha-periodic-linear
compute_edl_profile, compute_edl_capacitance_scan, compute_helmholtz_profile, compute_gouy_chapman_profile, compute_gcs_profilealpha-edl
compute_htst_rate, compute_htst_sweep, extract_kinetics_diagnostics, solve_microkinetic_network, solve_microkinetic_steady_state, analyze_gsm_mbh_htst_stepalpha-kinetics
chart_to_json, chart_from_json, validate_chart_schema, pack_chart_payload, compute_edl_chart, compute_capacitance_chart, compute_arrhenius_chart, compute_thermal_prop_chart, compute_phase_portrait_chart, compute_band_structure_chart, compute_dos_chart, compute_kpoint_path_chart, compute_fermi_surface_chart, compute_trajectory_chart, compute_reaction_coordinate_chartalpha-render-bridge
compute_pka, compute_pka_relative, compute_redox_potential, compute_redox_potential_relativealpha-redox-pka
compute_epr_hyperfinealpha-epr
compute_mp2_energyalpha-mp2
compute_xps_binding_energiesalpha-core-spectroscopy
compute_qmmm_energyalpha-qmmm
compute_raman_spectrum, compute_vcd_spectrum, compute_roa_spectrumalpha-raman
estimate_free_energyalpha-free-energy
run_uff_metadynamics, run_uff_opes, reweight_free_energy, reweight_free_energy_correlated, reweight_free_energy_2dalpha-enhanced-sampling
solve_3d_rismalpha-rism
compute_gcmc_isothermalways built
run_kinetic_monte_carloalways built
discover_reaction_network, discover_template_network, refine_barrier_with_gsmalways built
conformal_calibrate, active_learning_proposealways built
compute_pbe0_energyalpha-dft-hybrid
active_nmr_isotopes, compute_all_nmralpha-nmr-all
compute_dftalpha-dft
webgpu_status, init_webgpuexperimental-gpu
alpha_*, beta_* research functionsthe matching alpha-* / beta-* features

Enhanced-sampling reweighting ​

reweight_free_energy, reweight_free_energy_correlated and reweight_free_energy_2d take JSON trace/config strings and return a JSON result string. Invalid configs, empty traces, non-finite CV/bias values and weight overflow/underflow return {"error": ...}. reweight_free_energy_correlated needs at least two blocks (block_size < trace length); it reports standard_error per bin (kcal/mol), n_blocks and block_size.

webgpu_status / init_webgpu ​

typescript
function webgpu_status(): string
function init_webgpu(): Promise<string>

Both return JSON. init_webgpu() probes navigator.gpu; without it (Node, older browsers, blocked GPU) it returns the CPU-fallback status with an error string instead of throwing or aborting. webgpu_status() is synchronous and retains the last initialisation error.

typescript
interface WebGpuStatus {
  initialized: boolean;
  backend: string;             // "CPU-fallback" or the adapter backend
  gpu_available: boolean;      // current runtime, not a hardware probe
  max_storage_buffer_size?: number;
  max_workgroup_size_x?: number;
  max_workgroup_size_y?: number;
  max_workgroup_invocations?: number;
  error: string | null;
}

This export is WASM-only; Python and the Rust root API have no equivalent.

compute_pka / compute_pka_relative ​

typescript
function compute_pka(acid_smiles: string, base_smiles: string, method_name: string): string
function compute_pka_relative(acid_smiles: string, base_smiles: string,
  reference_acid: string, reference_base: string,
  reference_pka: number, method_name: string): string

compute_pka_relative returns the relative cycle with a reference summary. Empty/whitespace SMILES, a non-finite reference_pka and unknown methods return {"error": ...}. The self-reference invariant is pka == reference_pka; adding ΔpKa to the reference shifts the result by exactly ΔpKa. compute_pka returns the absolute cycle (relative: false).

typescript
function compute_redox_potential(oxidized_smiles: string, reduced_smiles: string,
  n_electrons: number, method_name: string): string
function compute_redox_potential_relative(oxidized_smiles: string, reduced_smiles: string,
  n_electrons: number, reference_oxidized: string, reference_reduced: string,
  reference_potential_v: number, method_name: string): string

n_electrons must be an integer in 1..=4; fractional, negative and non-finite values return {"error": ...} instead of being truncated. The reference couple must transfer the same number of electrons, its potential must be finite and both reference SMILES non-empty. A self-reference returns exactly the supplied reference potential. See pKa and redox.

validate_electron_count / validate_kmesh_weights ​

typescript
function validate_electron_count(n_electrons: number, n_bands: number, n_kpoints: number): string
function validate_kmesh_weights(weights_json: string, tolerance: number): string

validate_electron_count returns {"valid": bool} after checking that all three counts are finite, non-negative integers; the capacity 2 * n_bands * n_kpoints saturates instead of wrapping on overflow. Zero bands or k-points reports valid: false. Fractional, negative or non-finite counts return {"error": ...}. validate_kmesh_weights accepts finite, non-negative weights and a finite non-negative tolerance.


Usage patterns ​

High-throughput conformer generation ​

typescript
import init, { embed_coords_typed, estimate_workers, split_worker_tasks } from 'sci-form-wasm';

await init();

const coords = embed_coords_typed('c1ccccc1', 42);
const nWorkers = estimate_workers(1000, navigator.hardwareConcurrency ?? 4);
const tasks = JSON.parse(split_worker_tasks(JSON.stringify(smilesList), nWorkers, 42));

Three.js molecule viewer ​

typescript
import init, { embed, solve_eht, eht_orbital_mesh } from 'sci-form-wasm';
import * as THREE from 'three';

await init();

const result = JSON.parse(embed('c1ccccc1', 42));
const elements = JSON.stringify(result.elements);
const coordsJson = JSON.stringify(result.coords);

const scene = new THREE.Scene();
for (let i = 0; i < result.num_atoms; i++) {
  const sphere = new THREE.Mesh(
    new THREE.SphereGeometry(0.3),
    new THREE.MeshPhongMaterial({ color: 0x336699 })
  );
  sphere.position.set(result.coords[i*3], result.coords[i*3+1], result.coords[i*3+2]);
  scene.add(sphere);
}

const eht = JSON.parse(solve_eht(elements, coordsJson, 1.75));
const mesh = JSON.parse(eht_orbital_mesh(elements, coordsJson, eht.homo_index, 0.2, 0.02));

const orbGeom = new THREE.BufferGeometry();
orbGeom.setAttribute('position', new THREE.Float32BufferAttribute(mesh.vertices, 3));
orbGeom.setAttribute('normal', new THREE.Float32BufferAttribute(mesh.normals, 3));
orbGeom.setIndex(mesh.indices);
scene.add(new THREE.Mesh(orbGeom, new THREE.MeshPhongMaterial({
  color: 0x0077ff, transparent: true, opacity: 0.5, side: THREE.DoubleSide
})));

React hook ​

tsx
import { useEffect, useState } from 'react';
import init, { embed } from 'sci-form-wasm';

export function useConformer(smiles: string) {
  const [result, setResult] = useState<any>(null);

  useEffect(() => {
    (async () => {
      await init();
      setResult(JSON.parse(embed(smiles, 42)));
    })();
  }, [smiles]);

  return result;
}

See also ​

Released under the MIT License.