Python API Reference
The Python package is published as sciforma on PyPI; the import name is sci_form.
pip install sciformaimport sci_form
print(sci_form.__version__) # "2.2.0"
print(sci_form.version()) # "sci-form 2.2.0"Naming convention
The canonical name of every capability is the name of the Rust root function, and every action carries an explicit verb (compute_*, analyze_*, predict_*). The old Python names — bare nouns such as charges, sasa, population, dipole, dos, and the *_calculate forms such as pm3_calculate, xtb_calculate, gfn1_calculate, gfn2_calculate, hf3c_calculate, ani_calculate — are deprecated aliases. They still work, but they emit a DeprecationWarning and will be removed in a future major release:
>>> import warnings, sci_form
>>> with warnings.catch_warnings(record=True) as w:
... warnings.simplefilter("always")
... sci_form.charges("CCO")
... print(w[0].category.__name__, w[0].message)
DeprecationWarning sci_form.charges is deprecated and will be removed in a future major release; use sci_form.compute_charges instead.Every deprecated alias is listed next to its canonical function below, and the complete table is in crates/python/src/naming.rs.
The module also exposes sci_form.__all__ — the grouped public surface — so dir(sci_form) and help(sci_form) are meaningful:
>>> len(sci_form.__all__)
247The list holds 145 callables (93 canonical functions plus 52 deprecated aliases), 98 result classes, the three submodules alpha, beta and potentials, and the __version__ string.
The count depends on the features the wheel was built with: 265 for the default build and 327 for the wheel the release pipeline publishes (it adds every alpha and beta module). The names are always the same; only the feature-gated ones come and go.
Units
Units are not uniform across the library. Check the unit of every returned number:
| Quantity | Unit |
|---|---|
| Geometry (coordinates, bond lengths, cell parameters) | Å (cell angles in degrees) |
| UFF / MMFF94 energies | kcal/mol |
| UFF / MMFF94 gradients | kcal/mol/Å |
| EHT, PM3, xTB orbital energies and HOMO–LUMO gaps | eV |
| PM3 / xTB total, electronic, repulsive, dispersion energies | eV |
| PM3 heat of formation | kcal/mol |
| HF-3c energy, HF energy, nuclear repulsion, D3/gCP/SRB corrections | Hartree |
| HF-3c orbital energies, HOMO/LUMO, gap | Hartree |
| ANI energy and per-atom energies | Hartree |
| ANI forces | Hartree/Å |
CISD excitation energy, correlation_energy | Hartree (energy_ev is eV) |
EHT gradients, optimize_geometry_eht energy | eV, eV/Å |
optimize_framework energy and forces | eV, eV/Å |
| Vibrational frequencies, IR wavenumbers | cm⁻¹ |
| NMR chemical shifts and shieldings | ppm |
| NMR J-couplings | Hz |
| Dipole moment | Debye |
| Partial charges | elementary charge (e) |
| Electrostatic potential | Hartree/e |
| DOS / PDOS | 1/eV |
| Surface area | Ų |
| MD energies | kcal/mol; times in fs; temperatures in K |
| Pressure | bar |
Energies are always total system energies, not per-atom normalised, unless the field name says otherwise. Gradients are dE/dR with R in Å, so they carry the sign convention "force = −gradient".
Errors
| Situation | Exception |
|---|---|
| The caller's input is malformed (bad SMILES, wrong coordinate count, unknown method) | ValueError |
| The engine ran but failed (SCF blew up, optimisation failed) | RuntimeError |
| The engine ran but did not converge in the allowed number of iterations | NotConvergedError |
NotConvergedError is a subclass of RuntimeError, so except RuntimeError still catches it while except NotConvergedError lets you separate "the physics did not settle" from "you passed nonsense".
import sci_form
try:
sci_form.parse("C(")
except ValueError as e:
print(e)
# Invalid 'smiles' 'C('. Expected ')' at position 2 (found 'end of input') in "C("Messages follow one template everywhere:
<What failed> '<actual value>'. Supported: 'a', 'b', 'c'.Rust internal names (positions, unwrap, None, a file:line) never leak into a Python message, and a NaN is never returned.
Package metadata
| Name | Type | Description |
|---|---|---|
sci_form.__version__ | str | Crate version, e.g. "2.2.0" |
version | str | "sci-form 2.2.0" (also available as sci_form.version()) |
sci_form.NotConvergedError | exception | Subclass of RuntimeError |
Conformer generation
embed
def embed(smiles: str, seed: int = 42) -> ConformerResultGenerate a 3D conformer for one molecule with ETKDGv2. Coordinates are flat and in Å.
from sci_form import embed
result = embed("CCO", seed=42)
print(result) # ConformerResult(smiles='CCO', atoms=9, time=1.4ms)
print(result.num_atoms) # 9
print(result.get_positions() # [(x, y, z), ...] in Å
print(result.is_ok()) # Trueembed_batch
def embed_batch(smiles_list: list[str], seed: int = 42, num_threads: int = 0) -> list[ConformerResult]Batch-generate conformers. num_threads=0 auto-detects the CPU count.
results = embed_batch(["CCO", "c1ccccc1", "CC(=O)O"], seed=42)
for r in results:
if r.is_ok():
print(f"{r.smiles}: {r.num_atoms} atoms, {r.time_ms:.1f}ms")embed_diverse
def embed_diverse(
smiles: str,
n_conformers: int = 10,
rmsd_cutoff: float = 1.0,
base_seed: int = 42,
) -> list[ConformerResult]Embed n_conformers times with consecutive seeds and keep only the Butina RMSD cluster centroids (cutoff in Å). The cutoff must be finite and > 0; otherwise ValueError is raised. This is the cheap diversity ensemble, not the UFF-ranked search (search_conformers_with_uff).
conformers = sci_form.embed_diverse("CCCC", n_conformers=10, rmsd_cutoff=1.0)
for member in conformers:
print(member.smiles, member.num_atoms, member.error)embed_coords_into — zero copy
def embed_coords_into(smiles: str, coords: "numpy.ndarray", seed: int = 42) -> intEmbed a SMILES and write the coordinates straight into a caller-owned buffer instead of copying them across the Python boundary. coords must be a writable, C-contiguous float64 buffer (NumPy array, array('d') or memoryview) of length 3 * num_atoms; read-only, non-contiguous, integer, float32 and wrong-length buffers raise ValueError. The buffer is left untouched on any error. seed is an unsigned 64-bit seed. Returns the number of atoms written.
import numpy as np, sci_form
buf = np.zeros(3 * sci_form.parse("CCO").num_atoms, dtype=np.float64)
n_atoms = sci_form.embed_coords_into("CCO", buf, seed=42)
print(n_atoms, buf[:3])
# 9 [-0.89306372 0.06926389 0.06360101]parse
def parse(smiles: str) -> ParseResultParse a SMILES string into a molecular graph without generating 3D coordinates. Returns a ParseResult object (it used to return a plain dict).
mol = sci_form.parse("c1ccccc1")
print(mol.num_atoms, mol.num_bonds) # 12 12
for atom in mol.atoms:
print(atom.element, atom.hybridization, atom.formal_charge, atom.explicit_h)An empty string parses as an empty molecule (num_atoms=0); whitespace-only or malformed SMILES raise ValueError.
### `to_canonical_smiles`
```python
def to_canonical_smiles(smiles: str) -> strprint(sci_form.to_canonical_smiles("C(F)(Cl)(Br)I")) # FC(Cl)(Br)I
print(sci_form.to_canonical_smiles("[Na+].[Cl-]")) # [Cl-].[Na+]Return types
ConformerResult
| Attribute | Type | Description |
|---|---|---|
smiles | str | Input SMILES |
num_atoms | int | Atom count (implicit H included) |
coords | list[float] | Flat coordinates [x₀,y₀,z₀,…] in Å |
elements | list[int] | Atomic numbers |
bonds | list[tuple] | (a, b, order_str) with order ∈ SINGLE/DOUBLE/TRIPLE/AROMATIC |
error | str | None | Error message or None |
time_ms | float | Generation time in ms |
Methods: get_positions() -> list[tuple[float, float, float]], is_ok() -> bool.
ParseResult
| Attribute | Type | Description |
|---|---|---|
num_atoms | int | Atom count |
num_bonds | int | Bond count |
atoms | list[ParsedAtom] | Per-atom records |
ParsedAtom
| Attribute | Type | Description |
|---|---|---|
element | int | Atomic number |
hybridization | str | SP3, SP2, SP, Unknown |
formal_charge | int | Formal charge |
explicit_h | int | Explicitly attached hydrogens |
Charges, surface and electrostatics
compute_charges
def compute_charges(smiles: str) -> ChargeResultGasteiger-Marsili partial charges using the core default of up to 100 sweeps (the earlier text said 6). Charges are in elementary charge (e). For CCO it converges in 30 sweeps; use compute_charges_configured to cap the iteration count.
result = sci_form.compute_charges("CCO")
print(result.charges) # [-0.04184, 0.04020, -0.39669, 0.02538, ...]
print(result.total_charge) # -2.8e-17 e
print(result.iterations, result.converged) # 30 TrueEmpty/whitespace or malformed SMILES ("", Q, C(, C1CC) raise ValueError with the offending fragment and position.
Deprecated alias:
charges→compute_charges.
compute_charges_configured
def compute_charges_configured(
smiles: str,
max_iter: int = 6,
initial_damping: float = 0.5,
convergence_threshold: float = 1e-10,
) -> ChargeResultThe same solver with an explicit convergence configuration: max_iter electronegativity equalisation sweeps (integer ≥ 1), initial_damping the first damping factor (halved every iteration) and convergence_threshold the maximum charge-transfer convergence criterion. Empty/whitespace or malformed SMILES and negative/zero max_iter raise ValueError.
result = sci_form.compute_charges_configured("CCO", max_iter=12, initial_damping=0.7)
print(result.iterations) # 12compute_sasa
def compute_sasa(elements: list[int], coords: list[float], probe_radius: float = 1.4) -> SasaResultSolvent-accessible surface area (Shrake-Rupley) in Ų.
conf = sci_form.embed("CCO")
sasa = sci_form.compute_sasa(conf.elements, conf.coords, probe_radius=1.4)
print(sasa.total_sasa) # 198.45192083308308 Ų
print(sasa.num_points) # 960Deprecated alias:
sasa→compute_sasa.
Electrical double layer
def compute_helmholtz_profile(
surface_potential_v: float,
ionic_strength_m: float = 0.1,
temperature_k: float = 298.15,
) -> EdlProfileResult
def compute_gouy_chapman_profile(
surface_potential_v: float,
ionic_strength_m: float = 0.1,
temperature_k: float = 298.15,
) -> EdlProfileResult
def compute_gcs_profile(
surface_potential_v: float,
ionic_strength_m: float = 0.1,
temperature_k: float = 298.15,
stern_thickness_a: float = 3.0,
) -> EdlProfileResultPotential-based Helmholtz, Gouy-Chapman and Gouy-Chapman-Stern profiles (the argument is always a surface potential in V). EdlProfileResult exposes distance_axis_angstrom, electrostatic_potential_v, field_strength_v_per_m, charge_density_c_per_m3, the compact/diffuse/total drops, the total capacitance and the model name. The potential, ionic strength, temperature and Stern thickness must be finite and positive; every returned series and capacitance must be finite, otherwise ValueError is raised. For 0.2 V, 0.1 M, 298.15 K the Gouy-Chapman profile returns total_interfacial_drop_v=0.2 and capacitance_total_f_per_m2=17.71542571824761.
compute_population
def compute_population(elements: list[int], coords: list[float]) -> PopulationResultMulliken and Löwdin population analysis from the EHT density matrix. Charges in e, orbital energies in eV.
pop = sci_form.compute_population(conf.elements, conf.coords)
print(pop.mulliken_charges, pop.lowdin_charges) # per atom
print(pop.mulliken_populations) # per AO (n_basis entries)
print(pop.total_charge_mulliken, pop.charge_conservation_error)
print(pop.homo_energy, pop.lumo_energy, pop.gap) # eVDeprecated alias:
population→compute_population.
compute_dipole
def compute_dipole(elements: list[int], coords: list[float]) -> DipoleResultcoords must contain exactly 3 × len(elements) finite values and atomic numbers must lie in 1..=118; otherwise ValueError is raised. Valid elements without EHT parameters (for example Z=104) are also ValueError.
Molecular dipole moment in Debye.
d = sci_form.compute_dipole(conf.elements, conf.coords)
print(d.magnitude) # Debye
print(d.vector) # [x, y, z] in Debye
print(d.nuclear_dipole) # optional decomposition
print(d.electronic_dipole) # optional decomposition
print(d.unit) # "Debye"Deprecated alias:
dipole→compute_dipole.
compute_esp_grid
def compute_esp_grid(elements: list[int], coords: list[float], spacing: float = 0.5, padding: float = 3.0) -> EspGridElectrostatic potential on a 3D grid, in Hartree/e. spacing and padding are in Å. spacing must be finite and > 0, padding finite and >= 0, and the geometry must be a non-empty finite 3N array with atomic numbers in 1..=118; invalid values raise ValueError.
esp = sci_form.compute_esp_grid(conf.elements, conf.coords, spacing=1.0, padding=2.0)
print(esp.dims, esp.spacing, esp.origin)
print(len(esp.values))Deprecated aliases:
compute_espandesp→compute_esp_grid.
compute_esp_grid_into — zero copy
def compute_esp_grid_into(
elements: list[int],
coords: list[float],
out: "numpy.ndarray",
spacing: float = 0.5,
padding: float = 3.0,
) -> intCompute the ESP grid and write the values straight into a caller-owned buffer. out must be a writable, C-contiguous float64 array of length dims[0] * dims[1] * dims[2]; a ValueError is raised if the length does not match.
import numpy as np, sci_form
info = sci_form.compute_esp([6, 6, 8], [0.0, 0.0, 0.0, 1.5, 0, 0, 3.0, 0, 0], 1.0, 1.0)
n = info.dims[0] * info.dims[1] * info.dims[2]
buf = np.zeros(n, dtype=np.float64)
sci_form.compute_esp_grid_into([6, 6, 8], [0.0, 0.0, 0.0, 1.5, 0, 0, 3.0, 0, 0], buf, 1.0, 1.0)
print(buf[:4])compute_dos
def compute_dos(
elements: list[int],
coords: list[float],
sigma: float = 0.3,
e_min: float = -30.0,
e_max: float = 5.0,
n_points: int = 500,
) -> DosResultTotal DOS from the EHT orbital energies with Gaussian smearing. Energy axis in eV, DOS in 1/eV. n_points must be an integer >= 2; negative values raise ValueError. Empty/non-finite geometry, atomic numbers outside 1..=118 and EHT-unsupported elements also raise ValueError.
dos = sci_form.compute_dos(conf.elements, conf.coords, sigma=0.3, e_min=-30.0, e_max=5.0)
print(dos.energies[0], dos.energies[-1], dos.sigma)Deprecated alias:
dos→compute_dos.
compute_dos_multimethod
def compute_dos_multimethod(
elements: list[int],
coords: list[float],
method: str = "eht",
sigma: float = 0.3,
e_min: float = -30.0,
e_max: float = 5.0,
n_points: int = 500,
) -> MultiMethodDosResultThe same DOS, but the orbital energies come from the chosen electronic-structure method. method is one of eht, pm3, xtb, gfn1, gfn2, hf3c.
dos = sci_form.compute_dos_multimethod(conf.elements, conf.coords, method="eht")
print(dos.method, dos.gap) # 'eht', 6.3626366667205545 eVcompute_rmsd
def compute_rmsd(coords: list[float], reference: list[float]) -> AlignmentResultKabsch optimal alignment and RMSD. RMSD in Å. Both coordinate arrays must have the same length, a multiple of three, and finite values; mismatched, partial-triplet or non-finite input raises ValueError.
a = sci_form.embed("CCO", seed=42)
b = sci_form.embed("CCO", seed=123)
result = sci_form.compute_rmsd(a.coords, b.coords)
print(result.rmsd) # Å
print(result.aligned_coords) # `coords` after the optimal rotation
print(result.rotation, result.translation)Deprecated alias:
rmsd→compute_rmsd.
compute_rmsd_matrix
def compute_rmsd_matrix(conformers: list[list[float]]) -> list[list[float]]All-pairs RMSD matrix (Å) with Kabsch alignment. Every conformer must be a non-empty finite 3N array with the same atom count; ragged, empty or non-finite conformers raise ValueError instead of producing the legacy -1.0 sentinel.
Deprecated alias:
rmsd_matrix→compute_rmsd_matrix.
Return types
| Class | Attributes |
|---|---|
ChargeResult | charges (e), iterations, total_charge (e), converged |
SasaResult | total_sasa (Ų), atom_sasa (Ų), probe_radius (Å), num_points |
DipoleResult | vector (Debye), magnitude (Debye), unit, nuclear_dipole, electronic_dipole |
DosResult | energies (eV), total_dos (1/eV), sigma (eV) |
MultiMethodDosResult | energies (eV), total_dos (1/eV), method, homo_energy, lumo_energy, gap, orbital_energies, sigma |
AlignmentResult | rmsd (Å), aligned_coords (Å), rotation, translation |
EspGrid | dims, spacing (Å), origin (Å), values (Hartree/e) |
PopulationResult | mulliken_charges (e), lowdin_charges (e), mulliken_populations, num_atoms, total_charge_mulliken (e), total_charge_lowdin (e), charge_conservation_error, homo_energy (eV), lumo_energy (eV), gap (eV), warnings |
Electronic structure
solve_eht
def solve_eht(elements: list[int], coords: list[float], k: float = 1.75) -> EhtResultExtended-Hückel calculation. k is the Wolfsberg-Helmholtz constant; it must be finite and
0, and
0.0selects the default 1.75. Orbital energies and the HOMO-LUMO gap are in eV. Coordinates must be exactly3Nfinite values.
eht = sci_form.solve_eht(conf.elements, conf.coords)
print(eht.homo_energy, eht.lumo_energy, eht.gap) # eV
print(eht.energies) # all MO energies, eV
print(eht.homo_index, eht.lumo_index, eht.n_electrons)Deprecated alias:
eht_calculate→solve_eht.
eht_support
def eht_support(elements: list[int]) -> EhtSupportReport whether an element set is inside the EHT domain and with which confidence.
support = sci_form.eht_support(conf.elements)
print(support.level, support.has_transition_metals)
print(support.supported_elements, support.provisional_elements, support.unsupported_elements)compute_eht_or_uff_fallback
def compute_eht_or_uff_fallback(
smiles: str,
elements: list[int],
coords: list[float],
allow_experimental_eht: bool = False,
) -> dictRun EHT when the element set is supported, otherwise fall back to UFF. The returned mapping has a mode key ("eht" or "uff_fallback") plus the method payload; for the EHT path the payload carries the orbital energies in eV, homo_energy, lumo_energy, gap, n_electrons, homo_index, lumo_index, support_level and warnings. The fallback path carries energy_kcal_mol, reason, support_level and warnings.
out = sci_form.compute_eht_or_uff_fallback("CCO", conf.elements, conf.coords)
print(out["mode"], out.get("gap"))Deprecated alias:
eht_or_uff_fallback→compute_eht_or_uff_fallback.
compute_eht_gradient
def compute_eht_gradient(elements: list[int], coords: list[float]) -> EhtGradientCentral-finite-difference gradients on the EHT energy surface, in eV/Å.
g = sci_form.compute_eht_gradient(conf.elements, conf.coords)
print(g.rms_gradient, g.max_gradient) # eV/Å
print(g.energy) # eVoptimize_geometry_eht
def optimize_geometry_eht(
elements: list[int],
coords: list[float],
max_steps: int = 200,
grad_threshold: float = 0.01,
energy_threshold: float = 1e-6,
step_size: float = 0.2,
) -> EhtOptResultOptimise a geometry on the EHT surface with the shared BFGS engine. Energies in eV, gradients in eV/Å. elements must be in 1..=118, coords must contain exactly 3N finite values, and max_steps must be a finite non-negative integer; invalid input raises ValueError. step_size is the maximum BFGS step in Å (default 0.2); max_steps, grad_threshold and energy_threshold must be positive. A completed run can return converged=False.
For elements=[6,6,8], coords=[0,0,0, 1.2,0.6,0, 2.4,0.6,0] and max_steps=3, the measured result is energy=752.5049338566063 eV, rms_gradient=186.4590465586736 eV/Å, n_steps=3, converged=False.
opt = sci_form.optimize_geometry_eht(conf.elements, conf.coords)
print(opt.converged, opt.n_steps, opt.energy, opt.rms_gradient)eht_orbital_mesh
def eht_orbital_mesh(
elements: list[int],
coords: list[float],
mo_index: int,
spacing: float = 0.2,
isovalue: float = 0.02,
) -> OrbitalMeshResultIsosurface mesh for one EHT molecular orbital. Vertices and normals in Å. elements must be in 1..=118, coords exactly 3N finite values, mo_index a finite non-negative integer inside the calculated orbital range, spacing finite and positive, and isovalue finite; invalid input raises ValueError.
compute_pm3
def compute_pm3(elements: list[int], coords: list[float]) -> Pm3ResultPM3 NDDO semi-empirical SCF. Supports transition metals via PM3(tm). Total, electronic and nuclear-repulsion energies are in eV; heat_of_formation is in kcal/mol; orbital energies and the gap are in eV.
pm3 = sci_form.compute_pm3(conf.elements, conf.coords)
print(pm3.total_energy, pm3.electronic_energy, pm3.nuclear_repulsion) # eV
print(pm3.heat_of_formation) # kcal/mol
print(pm3.homo_energy, pm3.lumo_energy, pm3.gap) # eV
print(pm3.converged, pm3.scf_iterations)Deprecated alias:
pm3_calculate→compute_pm3.
compute_xtb
def compute_xtb(elements: list[int], coords: list[float]) -> XtbResultGFN2-xTB tight binding with self-consistent charges (25 elements, including transition metals); the numbers are identical to compute_gfn2. All energies in eV, orbital energies and gap in eV.
xtb = sci_form.compute_xtb(conf.elements, conf.coords)
print(xtb.total_energy, xtb.electronic_energy, xtb.repulsion_energy) # eV
print(xtb.homo_energy, xtb.lumo_energy, xtb.gap) # eVDeprecated alias:
xtb_calculate→compute_xtb.
compute_gfn1
def compute_gfn1(elements: list[int], coords: list[float]) -> Gfn1ResultGFN1-xTB with shell-resolved charges and D3-style dispersion. All energies in eV. Elements must be in 1..=118 and coordinates must be 3N finite values; invalid input raises ValueError before the solver.
gfn1 = sci_form.compute_gfn1(conf.elements, conf.coords)
print(gfn1.total_energy, gfn1.dispersion_energy) # eV
print(gfn1.shell_charges) # per-atom s/p/d shell charges, eDeprecated alias:
gfn1_calculate→compute_gfn1.
compute_gfn2
def compute_gfn2(elements: list[int], coords: list[float]) -> Gfn2ResultGFN2-xTB with multipole electrostatics, D4-style dispersion and halogen-bond corrections. All energies in eV; atomic_dipoles in Debye. Elements must be in 1..=118 and coordinates must be 3N finite values; invalid input raises ValueError before the solver.
gfn2 = sci_form.compute_gfn2(conf.elements, conf.coords)
print(gfn2.total_energy, gfn2.dispersion_energy, gfn2.halogen_bond_energy) # eV
print(gfn2.atomic_dipoles) # DebyeDeprecated alias:
gfn2_calculate→compute_gfn2.
compute_hf3c
def compute_hf3c(
elements: list[int],
coords: list[float],
max_scf_iter: int = 300,
n_cis_states: int = 5,
corrections: bool = True,
) -> Hf3cResultMinimal-basis Hartree-Fock with D3, gCP and SRB corrections. All energies and orbital energies are in Hartree.
The backend is closed-shell and supports H, C, N, O, F, P, S and Cl. Elements outside 1..=118 and odd electron counts raise ValueError; elements inside 1..=118 without an STO-3G basis (for example He) also raise ValueError. max_scf_iter must be at least 1 and n_cis_states at least 0 (0 skips CIS). Invalid coordinates raise ValueError. Non-finite SCF/CIS output is a RuntimeError, never a result with NaN/null.
hf = sci_form.compute_hf3c(conf.elements, conf.coords)
print(hf.energy, hf.hf_energy, hf.nuclear_repulsion) # Hartree
print(hf.d3_energy, hf.gcp_energy, hf.srb_energy) # Hartree
print(hf.homo_energy, hf.lumo_energy, hf.gap) # Hartree
print(hf.cis.excitations) # optional CIS statesDeprecated alias:
hf3c_calculate→compute_hf3c.
compute_ani
def compute_ani(elements: list[int], coords: list[float]) -> AniResultANI neural-network potential for H, C, N, O, F, S, Cl. energy and atomic_energies are in Hartree, forces in Hartree/Å. The bundled weights are test weights, so the energies are not physically meaningful ANI-2x energies. The geometry must be a non-empty finite 3N array with atomic numbers in 1..=118; elements outside the ANI species set are rejected with ValueError.
Deprecated alias:
ani_calculate→compute_ani.
compute_aevs_tm
def compute_aevs_tm(elements: list[int], coords: list[float]) -> AniTmAevsANI-TM atomic environment vectors over the 24-element set (H, C, N, O, F, Si, P, S, Cl, Ti, Cr, Mn, Fe, Co, Ni, Cu, Zn, Br, Ru, Pd, Ag, I, Pt, Au). Each atom gets 176256 floats. Empty/non-finite/mismatched 3N geometry and elements outside the ANI-TM set raise ValueError.
compute_cisd
def compute_cisd(elements: list[int], coords: list[float], n_states: int = 5) -> CisdResultCISD excited states from an internal STO-3G RHF calculation. The reference must be closed-shell (even electron count) and use an element with an STO-3G contraction (H, C, N, O, F, P, S, Cl); n_states must be an integer at least 1, and zero/negative values raise ValueError. correlation_energy and each excitation's energy are in Hartree; energy_ev is the same excitation in eV. The geometry entry point returns the reference values as well, so scf_energy, scf_converged, n_basis and n_occupied are available on the result.
cisd = sci_form.compute_cisd(conf.elements, conf.coords, n_states=2)
print(cisd.approximation, cisd.n_csfs, cisd.correlation_energy)
for ex in cisd.excitations:
print(ex.energy_ev, ex.wavelength_nm, ex.oscillator_strength)compute_uhf
def compute_uhf(elements: list[int], coords: list[float], charge: int = 0, multiplicity: int = 1) -> UhfResultUnrestricted Hartree-Fock for open-shell systems. The energies are in Hartree, the HOMO-LUMO gap in eV and the Mulliken charges in e. charge is the total molecular charge and multiplicity the spin multiplicity (1 = singlet, 2 = doublet, 3 = triplet); a multiplicity that does not match the electron count is an error.
uhf = sci_form.compute_uhf([6, 1, 1, 1], coords, 0, 2) # a methyl radical
print(uhf.converged, uhf.total_energy, uhf.s2_expectation)compute_rohf
def compute_rohf(elements: list[int], coords: list[float], charge: int = 0, multiplicity: int = 1) -> UhfResultRestricted open-shell Hartree-Fock: the same spatial orbitals for both spins, so the spin contamination is zero by construction. The HOMO is the singly occupied orbital and the LUMO is the next spatial orbital, so gap_ev is the SOMO–LUMO gap; invalid charge/multiplicity combinations raise ValueError.
compute_pm3_gradient
def compute_pm3_gradient(elements: list[int], coords: list[float]) -> Pm3GradientResultPM3 energy gradient: stationary-density (Pulay-free) differentiation of the energy compute_pm3 returns (fixed-density integral rebuild, no SCF per displacement), so the two are consistent by construction. Pm3GradientResult.gradients is in eV/Å (one [x, y, z] per atom), .energy in eV and .heat_of_formation in kcal/mol. Cost: 6·N integral rebuilds plus one SCF. Raises ValueError for a malformed geometry or atomic numbers outside 1..=118, NotConvergedError / RuntimeError when the SCF fails at the reference or at any displaced geometry, and a numerical error for non-finite output.
compute_xtb_gradient
def compute_xtb_gradient(elements: list[int], coords: list[float]) -> XtbGradientResultxTB energy gradient: warm-started central differences (step 5·10⁻⁴ Å) of the GFN2-xTB energy, the one compute_xtb returns. Each displaced geometry is warm-started from the reference charges/multipoles. XtbGradientResult.gradients is in eV/Å per atom and .energy in eV. Raises ValueError for malformed geometry, atomic numbers outside 1..=118 or elements without GFN2 parameters; non-finite output is a numerical error.
compute_aevs_tm
def compute_aevs_tm(elements: list[int], coords: list[float]) -> AniTmAevsANI-TM atomic environment vectors over the extended element set (24 elements). Dimensionless.
Return types
| Class | Attributes (unit) |
|---|---|
EhtResult | energies (eV), n_electrons, homo_index, lumo_index, homo_energy (eV), lumo_energy (eV), gap (eV), support_level, has_transition_metals, supported_elements, provisional_elements, unsupported_elements, warnings |
UhfResult | alpha_orbital_energies, beta_orbital_energies (Hartree), electronic_energy, nuclear_repulsion, total_energy (Hartree), homo_energy (Hartree), lumo_energy (Hartree), gap_ev (eV), mulliken_charges (e), scf_iterations, converged, n_basis, n_alpha, n_beta, s2_expectation, spin_contamination, alpha_coefficients, beta_coefficients |
Pm3GradientResult | gradients (eV/Å), energy (eV), heat_of_formation (kcal/mol) |
XtbGradientResult | gradients (eV/Å), energy (eV) |
EhtSupport | level, has_transition_metals, supported_elements, provisional_elements, unsupported_elements, warnings |
EhtGradient | gradients (eV/Å), rms_gradient (eV/Å), max_gradient (eV/Å), energy (eV) |
EhtOptResult | positions (Å), energy (eV), n_steps, converged, rms_gradient (eV/Å), energies (eV) |
Pm3Result | orbital_energies (eV), electronic_energy (eV), nuclear_repulsion (eV), total_energy (eV), heat_of_formation (kcal/mol), n_basis, n_electrons, homo_energy (eV), lumo_energy (eV), gap (eV), mulliken_charges (e), scf_iterations, converged |
XtbResult | orbital_energies (eV), electronic_energy (eV), repulsion_energy (eV), total_energy (eV), n_basis, n_electrons, homo_energy (eV), lumo_energy (eV), gap (eV), mulliken_charges (e), scf_iterations, converged |
Gfn1Result | as XtbResult plus dispersion_energy (eV), shell_charges (e) |
Gfn2Result | as XtbResult plus dispersion_energy (eV), dispersion_2_body_energy (eV), halogen_bond_energy (eV), atomic_dipoles (Debye), atomic_quadrupoles |
Hf3cResult | energy, hf_energy, nuclear_repulsion, d3_energy, gcp_energy, srb_energy, orbital_energies (Hartree), scf_iterations, converged, cis, n_basis, n_electrons, homo_energy, lumo_energy, gap (Hartree), mulliken_charges (e) |
Hf3cCis | excitations, error |
Hf3cExcitation | energy (Hartree), energy_ev (eV), wavelength_nm, oscillator_strength, dominant_transition |
AniResult | energy (Hartree), forces (Hartree/Å), species, atomic_energies (Hartree) |
CisdResult | excitations, correlation_energy (Hartree), n_csfs, approximation, scf_energy (Hartree), scf_converged, n_basis, n_occupied |
CisdExcitation | energy (Hartree), energy_ev (eV), wavelength_nm, oscillator_strength, dominant_transition, character, singles_weight |
AniTmAevs | aev_length, aevs, n_atoms |
Force fields
compute_uff_energy
def compute_uff_energy(smiles: str, coords: list[float]) -> floatUFF force-field energy in kcal/mol.
print(sci_form.compute_uff_energy("CCO", conf.coords)) # 6.993048...Deprecated alias:
uff_energy→compute_uff_energy.
compute_uff_gradient
def compute_uff_gradient(smiles: str, coords: list[float]) -> tuple[float, list[float]]Returns (energy, gradient) for the same UFF surface: energy in kcal/mol and the Cartesian gradient in kcal/mol/Å (gradient[3*i + k] is dE/dx for atom i). The wrapper validates the SMILES, the exact 3N coordinate length and finiteness; invalid input raises ValueError. The analytic gradient matches central differences of compute_uff_energy (used by the ASE NEB reference for the 3D reaction path).
compute_uff_energy_with_aromatic_heuristics
def compute_uff_energy_with_aromatic_heuristics(smiles: str, coords: list[float]) -> UffHeuristicEnergyUFF energy with an aromaticity-informed correction. All energies in kcal/mol. See UFF energy and the aromatic heuristic for the formula, measured benzene values and validation contract.
Deprecated alias:
uff_energy_with_aromatic_heuristics→compute_uff_energy_with_aromatic_heuristics.
compute_mmff94_energy
def compute_mmff94_energy(smiles: str, coords: list[float]) -> floatComplete MMFF94 force-field energy in kcal/mol: bond, angle, stretch-bend, out-of-plane, torsion, buffered 14-7 van der Waals and buffered Coulomb electrostatics with PBCI/BCI partial charges. See MMFF94 for the measured ethanol total and validation contract.
Deprecated alias:
mmff94_energy→compute_mmff94_energy.
compute_uff_energy_breakdown
def compute_uff_energy_breakdown(smiles: str, coords: list[float]) -> list[tuple[str, float]]The UFF energy split by term type (bond, angle, torsion, inversion, vdw). Only non-zero terms are emitted. The values are in kcal/mol and sum to compute_uff_energy.
compute_mmff94_energy_breakdown
def compute_mmff94_energy_breakdown(smiles: str, coords: list[float]) -> list[tuple[str, float]]The same split for MMFF94 (bond, angle, stretch_bend, oop, torsion, vdw, electrostatic); only non-zero terms are emitted and the values sum to compute_mmff94_energy.
compute_pka
def compute_pka(
acid_smiles: str,
base_smiles: str,
reference_acid: str | None = None,
reference_base: str | None = None,
reference_pka: float | None = None,
method_name: str = "uhf",
n_conformers: int = 1,
) -> PkaResultSolution pKa from an explicit acid/conjugate-base pair. Supplying all three reference arguments selects the relative cycle; supplying none selects the absolute cycle. Empty/whitespace SMILES, a non-finite reference_pka, n_conformers < 1 and unknown methods raise ValueError. The reference summary is exposed as result.reference (PkaReferenceResult). See pKa and redox for the cycle, measured TFA value and limitations.
result = sci_form.compute_pka(
"FC(F)(F)C(=O)O",
"FC(F)(F)C(=O)[O-]",
reference_acid="CC(=O)O",
reference_base="CC(=O)[O-]",
reference_pka=4.76,
)
print(result.pka, result.relative, result.reference.pka)compute_redox_potential
def compute_redox_potential(
oxidized_smiles: str,
reduced_smiles: str,
n_electrons: int = 1,
reference_oxidized: str | None = None,
reference_reduced: str | None = None,
reference_potential: float | None = None,
method_name: str = "uhf",
n_conformers: int = 1,
) -> RedoxResultRedox potential from an explicit oxidised/reduced pair. Supplying the three reference arguments selects the relative cycle; n_electrons must be an integer in 1..=4, the reference must transfer the same number of electrons, its potential must be finite and its SMILES non-empty. Empty SMILES, fractional/negative electron counts and n_conformers < 1 raise ValueError. See pKa and redox.
result = sci_form.compute_redox_potential(
"CC(=O)O", "CC(=O)[O-]", 1,
reference_oxidized="CC(=O)O", reference_reduced="CC(=O)[O-]",
reference_potential=0.0,
)
print(result.potential_vs_reference_v) # 0.0 for the same couple
print(result.reference.potential_v, result.reference.delta_g_kcal_mol)compute_empirical_pka
def compute_empirical_pka(smiles: str) -> EmpiricalPkaResultGraph-heuristic pKa estimation. The pKa values are coarse screening hints, not publication-grade predictions. See empirical pKa sites for the rule table, measured examples and limits.
Deprecated alias:
empirical_pka→compute_empirical_pka.
Return types
| Class | Attributes |
|---|---|
UffHeuristicEnergy | raw_energy_kcal_mol, aromatic_stabilization_kcal_mol, corrected_energy_kcal_mol (kcal/mol), aromatic_bond_count, notes |
PkaResult | pka, delta_g_kcal_mol (kcal/mol), relative, reference, acid_smiles, base_smiles, temperature_k (K), proton_solvation_kcal_mol (kcal/mol), acid_energy_kcal_mol, base_energy_kcal_mol, acid_spread_kcal_mol, base_spread_kcal_mol, notes |
PkaReferenceResult | acid_smiles, base_smiles, pka, delta_g_kcal_mol (kcal/mol), acid_energy_kcal_mol, base_energy_kcal_mol, acid_spread_kcal_mol, base_spread_kcal_mol |
RedoxResult | potential_vs_reference_v, absolute_potential_v (V), delta_g_kcal_mol (kcal/mol), n_electrons, relative, reference, oxidized_smiles, reduced_smiles, reference_absolute_potential_v (V), oxidized_energy_kcal_mol, reduced_energy_kcal_mol, notes |
RedoxReferenceResult | oxidized_smiles, reduced_smiles, potential_v (V), delta_g_kcal_mol (kcal/mol), oxidized_energy_kcal_mol, reduced_energy_kcal_mol, oxidized_spread_kcal_mol, reduced_spread_kcal_mol |
EmpiricalPkaResult | acidic_sites, basic_sites, notes |
EmpiricalPkaSite | atom_index, estimated_pka, site_type, environment, confidence |
Molecular descriptors and machine learning
compute_ml_descriptors
def compute_ml_descriptors(smiles: str) -> MolecularDescriptorsTopology-derived descriptors. No 3D geometry needed. Charges are Gasteiger–Marsili and aromatic atoms come from aromatic bonds, so total_abs_charge, max_charge, min_charge and n_aromatic are populated from the SMILES. See ML descriptors and proxy properties for the field table and measured examples.
Deprecated alias:
ml_descriptors→compute_ml_descriptors.
predict_ml_properties
def predict_ml_properties(smiles: str) -> MlPropertyResultLipinski / ADME proxy prediction.
Deprecated alias:
ml_predict→predict_ml_properties.
compute_tpsa
def compute_tpsa(smiles: str) -> floatTopological 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 raise ValueError.
predict_ensemble
def predict_ensemble(smiles: str) -> EnsembleResultEnsemble 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). Empty/whitespace or malformed SMILES raise ValueError; non-finite predictions are a numerical error. The values are deterministic proxy models, not calibrated neural predictions.
compute_whim
def compute_whim(elements: list[int], coords: list[float], weighting: str = "mass") -> WhimDescriptorsWHIM 3D molecular descriptors. weighting is one of unit, mass, volume, electronegativity, polarizability. The coordinate array must be exactly 3N and finite.
compute_rdf
def compute_rdf(
elements: list[int],
coords: list[float],
charges: list[float] | None = None,
beta: float = 100.0,
r_max: float = 12.0,
n_points: int = 128,
) -> RdfDescriptorsRadial distribution function descriptors. radii are in Å, beta in Å⁻². When charges is None the charges are derived internally with Gasteiger. At least two atoms are required; beta > 0, r_max > 0, n_points >= 2 and a finite charge array of the correct length are enforced with ValueError.
compute_getaway
def compute_getaway(
elements: list[int],
coords: list[float],
bonds: list[tuple[int, int]] | None = None,
max_lag: int = 8,
) -> GetawayDescriptorsGETAWAY 3D molecular descriptors. When bonds is None the bonds are perceived from the geometry. max_lag must be an integer in 1..=10000; invalid geometry, bonds or max_lag values raise ValueError.
train_random_forest
def train_random_forest(
features: list[list[float]],
targets: list[float],
n_trees: int = 100,
max_depth: int = 10,
min_samples_split: int = 5,
min_samples_leaf: int = 2,
sample_fraction: float = 1.0,
seed: int = 42,
options: dict | None = None,
) -> RegressionModelTrain a Random Forest regressor and return its training-set predictions. Counts must be non-negative integers; fractional/negative values raise ValueError. The default four-sample example returns constant predictions [1.505, …] with RMSE 1.118045169033881.
train_gradient_boosting
def train_gradient_boosting(
features: list[list[float]],
targets: list[float],
n_estimators: int = 100,
learning_rate: float = 0.1,
max_depth: int = 5,
min_samples_split: int = 5,
min_samples_leaf: int = 2,
subsample: float = 0.8,
seed: int = 42,
options: dict | None = None,
) -> RegressionModelTrain a Gradient Boosting regressor and return its training-set predictions. Counts must be non-negative integers; fractional/negative values raise ValueError. The default four-sample example returns [1.510925865628068, …] with RMSE 1.1180873733924923.
Return types
| Class | Attributes |
|---|---|
MolecularDescriptors | molecular_weight, n_heavy_atoms, n_hydrogens, n_bonds, n_rotatable_bonds, n_hbd, n_hba, fsp3, wiener_index, n_rings, n_aromatic, sum_electronegativity, sum_polarizability |
MlPropertyResult | logp, molar_refractivity, log_solubility, druglikeness, lipinski_violations, lipinski_passes |
WhimDescriptors | eigenvalues, lambda_, nu, gamma, eta, total_spread, anisotropy, directional, kurtosis |
RdfDescriptors | radii (Å), rdf_unweighted, rdf_mass, rdf_electronegativity, rdf_charge, beta (Å⁻²), n_pairs |
GetawayDescriptors | leverages, hat_autocorrelation, r_autocorrelation, hat_total, r_total, h_information, h_max, h_mean, max_lag |
RegressionModel | predictions, train_rmse, model_type, n_estimators, n_samples |
EnsembleResult | logp, logp_std, log_solubility, tpsa (Ų), pka_acidic, pka_basic, veber, bbb_permeable, bbb_score (0–1), confidence (0–1) |
VeberResult | tpsa_ok, rotb_ok, passes |
Spectroscopy
compute_stda_uvvis
def compute_stda_uvvis(
elements: list[int],
coords: list[float],
sigma: float = 0.3,
e_min: float = 1.0,
e_max: float = 8.0,
n_points: int = 500,
broadening: str = "gaussian",
) -> StdaUvVisSpectrumsTDA UV-Vis spectrum on EHT MO transitions. energies_ev in eV, wavelengths_nm in nm, absorptivity in L mol⁻¹ cm⁻¹. broadening is gaussian or lorentzian.
Deprecated alias:
stda_uvvis→compute_stda_uvvis.
compute_fluorescence
def compute_fluorescence(
elements: list[int],
coords: list[float],
sigma: float = 0.25,
e_min: float = 0.5,
e_max: float = 8.0,
n_points: int = 400,
stokes_ev: float = 0.0,
refractive_index: float = 1.0,
dark_threshold: float = 1e-3,
broadening: str = "gaussian",
options: dict | None = None,
) -> FluorescenceSpectrumFluorescence from the same sTDA singlets as the absorption spectrum. radiative_rate_hz in Hz, radiative_lifetime_ns in ns, energies in eV, wavelengths in nm.
Deprecated alias:
fluorescence_spectrum→compute_fluorescence.
compute_vibrational_analysis
def compute_vibrational_analysis(
elements: list[int],
coords: list[float],
method: str = "eht",
step_size: float | None = None,
smiles: str | None = None,
) -> VibrationalAnalysisNumerical Hessian (6N energy evaluations) plus diagonalisation; translation/rotation modes are projected out. Frequencies in cm⁻¹, IR intensities in km/mol, zpve_ev in eV.
With method="uff", smiles is required; elements must match the SMILES atom order and coords must contain exactly 3N finite values. Invalid SMILES, mismatched elements/geometry and a non-positive or non-finite step_size raise ValueError.
vib = sci_form.compute_vibrational_analysis(conf.elements, conf.coords, method="xtb")
print(vib.n_real_modes, vib.zpve_ev)
for mode in vib.modes:
print(mode.frequency_cm1, mode.ir_intensity, mode.is_real)WARNING
The EHT Hessian is a one-electron model with no electron-electron repulsion: the surface has no minimum, so imaginary (negative) frequencies are expected. Use pm3 or xtb for vibrational analysis.
Deprecated alias:
vibrational_analysis→compute_vibrational_analysis.
compute_ir_spectrum
def compute_ir_spectrum(
elements: list[int],
coords: list[float],
method: str = "eht",
gamma: float = 15.0,
wn_min: float = 400.0,
wn_max: float = 4000.0,
n_points: int = 1000,
step_size: float | None = None,
smiles: str | None = None,
options: dict | None = None,
) -> IrSpectrumRuns the vibrational analysis internally and applies the default Lorentzian broadening. wavenumbers in cm⁻¹, gamma in cm⁻¹, intensities in km/mol.
Deprecated alias:
ir_spectrum→compute_ir_spectrum.
compute_ir_spectrum_broadened
def compute_ir_spectrum_broadened(
elements: list[int],
coords: list[float],
method: str = "eht",
gamma: float = 15.0,
wn_min: float = 400.0,
wn_max: float = 4000.0,
n_points: int = 1000,
broadening: str = "lorentzian",
step_size: float | None = None,
smiles: str | None = None,
options: dict | None = None,
) -> IrSpectrumAn unknown broadening raises ValueError: the value used to fall back to the Lorentzian shape, so the typo gauassian silently changed the spectrum.
Same as compute_ir_spectrum but with a selectable broadening type (gaussian or lorentzian). step_size is the finite-difference step in Å (None uses the engine default) and smiles is required when method="uff". n_points must be an integer ≥ 2; zero, one and negative values raise ValueError.
assign_peaks
def assign_peaks(
frequencies: list[float],
intensities: list[float],
elements: list[int],
mode_displacements: list[list[list[float]]] | None = None,
) -> AssignmentResultAssign IR peaks to functional groups using the standard group-frequency tables. frequencies are in cm⁻¹.
assignment = sci_form.assign_peaks([1000.0, 3000.0], [10.0, 20.0], conf.elements)
for peak in assignment.assignments:
print(peak.frequency, peak.confidence)
for match in peak.assignments:
print(" ", match.group, match.vibration_type, match.match_quality)
print(assignment.functional_groups)Return types
| Class | Attributes (unit) |
|---|---|
StdaUvVisSpectrum | energies_ev (eV), wavelengths_nm (nm), absorptivity, excitations, sigma (eV), broadening, notes |
StdaExcitation | energy_ev (eV), wavelength_nm (nm), oscillator_strength, from_mo, to_mo, transition_dipole |
FluorescenceSpectrum | energies_ev (eV), wavelengths_nm (nm), intensity, absorption_energy_ev (eV), emission_energy_ev (eV), emission_wavelength_nm (nm), oscillator_strength, radiative_rate_hz (Hz), radiative_lifetime_ns (ns), kasha, from_mo, to_mo, notes |
VibrationalAnalysis | n_atoms, elements, modes, n_real_modes, n_imaginary_modes, zpve_ev (eV), thermochemistry, method, notes |
VibrationalMode | frequency_cm1 (cm⁻¹), ir_intensity (km/mol), displacement, is_real |
IrSpectrum | wavenumbers (cm⁻¹), intensities (km/mol), peaks, gamma (cm⁻¹), notes |
IrPeak | frequency_cm1 (cm⁻¹), ir_intensity (km/mol), mode_index, assignment |
PeakAssignment | frequency (cm⁻¹), intensity, assignments, confidence |
AssignmentResult | assignments, functional_groups |
FunctionalGroupMatch | group, vibration_type, match_quality |
NMR
predict_nmr_shifts
def predict_nmr_shifts(smiles: str) -> NmrShiftResultRepresentative chemical shifts for the default nucleus of each element. Shifts in ppm, no 3D geometry needed. The legacy per-element fields (h_shifts, c_shifts, f_shifts, p_shifts, n_shifts, b_shifts, si_shifts, se_shifts, o_shifts, s_shifts) plus other_shifts cover the whole registry. Empty/whitespace or malformed SMILES raise ValueError; non-finite shifts or confidences outside 0..1 are numerical errors.
Deprecated alias:
nmr_shifts→predict_nmr_shifts.
predict_nmr_shifts_for_nucleus
def predict_nmr_shifts_for_nucleus(smiles: str, nucleus: str) -> list[ChemicalShift]Shifts for one requested nucleus, including the expanded registry (2H, 35Cl, 79Br, 195Pt, 207Pb, …). The nucleus label is case-insensitive and accepts either mass-number order (13C, C13), element names (carbon) and aliases (proton). A valid nucleus with no matching atom returns an empty list; an empty/malformed SMILES or an unknown nucleus raises ValueError. Isotope abundances are not modeled: 2H reports a relative shift for every hydrogen position.
Deprecated alias:
nmr_shifts_for_nucleus→predict_nmr_shifts_for_nucleus.
predict_nmr_couplings
def predict_nmr_couplings(smiles: str, coords: list[float] = []) -> list[JCoupling]J-coupling constants in Hz. With 3D coordinates the Karplus relation is used for ³J; topology only gives free-rotation averages. Parameterised pathways: H-C-C-H (Altona-Sundaralingam), H-C-N-H (Bystrov), H-C-O-H, H-C-S-H. The coordinate array must contain exactly 3N finite values when non-empty; an empty list selects the topology-only mode. Empty/malformed SMILES and wrong or non-finite coordinates raise ValueError.
cc = sci_form.embed("CC")
for j in sci_form.predict_nmr_couplings("CC", cc.coords):
print(j.n_bonds, j.h1_index, j.h2_index, j.j_hz, j.coupling_type)Deprecated alias:
nmr_couplings→predict_nmr_couplings.
compute_ensemble_j_couplings
def compute_ensemble_j_couplings(
smiles: str,
conformer_coords: list[list[float]],
energies_kcal: list[float],
temperature_k: float = 298.15,
) -> list[JCoupling]J-couplings in Hz, averaged over a conformer ensemble with Boltzmann weighting. energies_kcal holds the matching conformer energies in kcal/mol.
compute_nmr_spectrum
def compute_nmr_spectrum(
smiles: str,
coords: list[float] = [],
nucleus: str = "1H",
gamma: float = 0.02,
ppm_min: float = 0.0,
ppm_max: float = 12.0,
n_points: int = 1000,
) -> NmrSpectrumFull NMR spectrum pipeline. ppm_axis in ppm, gamma in ppm. gamma must be finite and >= 0 (0 selects the nucleus-specific default), ppm_max > ppm_min, and n_points must be an integer >= 2; negative, zero and one raise ValueError. Malformed coordinate triplets, empty/whitespace SMILES, unknown nuclei and bad windows also raise ValueError.
Deprecated alias:
nmr_spectrum→compute_nmr_spectrum.
compute_giao_nmr
def compute_giao_nmr(
elements: list[int],
coords: list[float],
nucleus: str = "1H",
charge: int = 0,
multiplicity: int = 1,
max_scf_iter: int = 100,
allow_basis_fallback: bool = False,
use_parallel_eri: bool = False,
options: dict | None = None,
) -> GiaoNmrResultThe public SCF-backed GIAO route for one nucleus. total_energy_hartree in Hartree, chemical_shifts in ppm, shieldings in ppm. Coordinates must be exactly 3N finite values; malformed arrays raise ValueError. The current public path is restricted to singlet closed-shell systems and by default rejects elements that only have the hydrogen-like fallback basis in the SCF stack. Negative charge values are supported when they leave an even electron count (for example O²⁻); multiplicity must be ≥ 1 and max_scf_iter ≥ 1. Impossible charges, zero multiplicity and zero iterations raise ValueError instead of being silently clamped.
Deprecated alias:
giao_nmr→compute_giao_nmr.
compute_hose_codes
def compute_hose_codes(smiles: str, max_radius: int = 2) -> list[tuple[int, int, str]]HOSE code fingerprints for all atoms: one (atom_index, element, full_code) tuple per atom. max_radius must be an integer in 1..=100; empty SMILES and invalid radii raise ValueError.
Deprecated alias:
hose_codes→compute_hose_codes.
Return types
| Class | Attributes (unit) |
|---|---|
NmrShiftResult | h_shifts, c_shifts, f_shifts, p_shifts, n_shifts, b_shifts, si_shifts, se_shifts, o_shifts, s_shifts, other_shifts, notes |
ChemicalShift | atom_index, element, shift_ppm (ppm), environment, confidence |
NucleusShiftSeries | nucleus, shifts |
JCoupling | h1_index, h2_index, j_hz (Hz), n_bonds, coupling_type |
NmrPeak | atom_index, environment, intensity, multiplicity, shift_ppm (ppm) |
NmrSpectrum | ppm_axis (ppm), intensities, peaks, nucleus, gamma (ppm), notes |
GiaoNmrResult | nucleus, target_atomic_number, method, basis_set, charge, multiplicity, scf_converged, scf_iterations, total_energy_hartree (Hartree), n_basis, n_target_atoms, chemical_shifts (ppm), shieldings, fallback_elements, notes |
GiaoNmrEntry | atom_index, element, isotropic (ppm), anisotropy (ppm), tensor, chemical_shift (ppm) |
Solvation
compute_nonpolar_solvation
def compute_nonpolar_solvation(elements: list[int], coords: list[float], probe_radius: float = 1.4) -> NonPolarSolvationNon-polar solvation ΔG_np = Σ_i σ_i A_i from per-element ASP and Shrake-Rupley SASA. Energy in kcal/mol, areas in Ų.
Deprecated alias:
nonpolar_solvation→compute_nonpolar_solvation.
compute_gb_solvation
def compute_gb_solvation(
elements: list[int],
coords: list[float],
charges: list[float],
solvent_dielectric: float = 78.5,
solute_dielectric: float = 1.0,
probe_radius: float = 1.4,
) -> GbSolvationGB/SA electrostatic solvation (HCT Born radii + Still GB equation). Energies in kcal/mol, born radii in Å.
Raises ValueError when the input is malformed: coords does not have 3 * len(elements) values, charges does not have one value per atom, a charge is NaN/±Inf, a dielectric constant is not finite or < 1.0 (ε = 1.0 is the vacuum limit and is accepted), or the probe radius is negative or not finite.
Deprecated alias:
gb_solvation→compute_gb_solvation.
Return types
| Class | Attributes (unit) |
|---|---|
NonPolarSolvation | energy_kcal_mol (kcal/mol), atom_contributions (kcal/mol), atom_sasa (Ų), total_sasa (Ų) |
GbSolvation | electrostatic_energy_kcal_mol, nonpolar_energy_kcal_mol, total_energy_kcal_mol (kcal/mol), born_radii (Å), charges (e), solvent_dielectric, solute_dielectric |
Rings, fingerprints and clustering
compute_sssr
def compute_sssr(smiles: str) -> SssrResultSmallest Set of Smallest Rings (Horton) with Hückel aromaticity. Empty or malformed SMILES raise ValueError; acyclic molecules return rings == [].
r = sci_form.compute_sssr("c1ccc2ccccc2c1")
print(len(r.rings), r.ring_size_histogram)Deprecated alias:
sssr→compute_sssr.
compute_ecfp
def compute_ecfp(smiles: str, radius: int = 2, n_bits: int = 2048) -> ECFPFingerprintExtended-Connectivity Fingerprint (Morgan). radius=2 is ECFP4, radius=3 is ECFP6. radius must be in 0..=100 and n_bits in 64..=1,048,576; empty/whitespace SMILES and invalid controls raise ValueError.
Deprecated alias:
ecfp→compute_ecfp.
compute_ecfp_batch
def compute_ecfp_batch(smiles_list: list[str], radius: int = 2, n_bits: int = 2048) -> list[ECFPFingerprint]Batch ECFP generation, in input order. radius and n_bits follow the same 0..=100 / 64..=1,048,576 contract; an empty list returns an empty list and any empty or invalid SMILES rejects the batch with ValueError.
compute_tanimoto
def compute_tanimoto(fp1: ECFPFingerprint, fp2: ECFPFingerprint) -> floatJaccard-Tanimoto similarity T = |A ∩ B| / |A ∪ B|, dimensionless in [0, 1]. Both fingerprints must use the same radius and n_bits; mismatched or malformed fingerprints raise ValueError.
Deprecated alias:
tanimoto→compute_tanimoto.
butina_cluster
def butina_cluster(conformers: list[list[float]], rmsd_cutoff: float = 1.0) -> ClusterResultTaylor-Butina single-linkage RMSD clustering. Cutoff in Å, finite and > 0; ragged, empty or non-finite conformers and invalid cutoffs raise ValueError.
filter_diverse
def filter_diverse(conformers: list[list[float]], rmsd_cutoff: float = 1.0) -> list[int]Indices of the cluster centroid (diverse representative) conformers. It applies the same conformer and cutoff validation as butina_cluster.
Return types
| Class | Attributes |
|---|---|
SssrResult | rings, atom_ring_count, atom_ring_sizes, ring_size_histogram |
RingInfo | atoms, size, is_aromatic |
ECFPFingerprint | n_bits, on_bits, radius, density |
ClusterResult | n_clusters, assignments, centroid_indices, cluster_sizes, rmsd_cutoff (Å) |
Stereochemistry, topology and reactivity
analyze_stereo
def analyze_stereo(smiles: str, coords: list[float] = []) -> StereoAnalysisAssign CIP priorities and determine R/S at stereocenters and E/Z at double bonds. With an empty coords the analysis is topology-only and configuration stays None. A non-empty coords must contain exactly 3N finite values; truncated, extra or non-finite arrays raise ValueError.
Deprecated alias:
stereo_analysis→analyze_stereo.
analyze_graph_features
def analyze_graph_features(smiles: str) -> GraphFeatureAnalysisAromaticity and graph-level stereocentre analysis. inferred_tetrahedral_centers uses CIP substituent trees, so duplicate substituents are not reported as centres. See graph feature analysis.
Deprecated alias:
graph_features→analyze_graph_features.
compute_topology
def compute_topology(elements: list[int], coords: list[float]) -> TopologyAnalysisResultMismatched lengths, empty geometry, non-finite coordinates and atomic numbers outside 1..=118 raise ValueError. See metal coordination topology.
Metal coordination environments from 3D coordinates: ligand spheres, coordination numbers and a geometric guess of the coordination polyhedron.
Deprecated alias:
topology_analysis→compute_topology.
compute_uv_vis_spectrum
def compute_uv_vis_spectrum(
elements: list[int],
coords: list[float],
sigma: float = 0.25,
e_min: float = 0.5,
e_max: float = 8.0,
n_points: int = 600,
) -> UvVisSpectrumExploratory UV-Vis-like spectrum from EHT MO energy differences. energies_ev in eV; each peak has energy_ev (eV) and wavelength_nm (nm). sigma is in eV. There is no top-level wavelengths_nm field.
Deprecated alias:
uvvis_spectrum→compute_uv_vis_spectrum.
compute_frontier_descriptors
def compute_frontier_descriptors(elements: list[int], coords: list[float]) -> FrontierDescriptorsHOMO/LUMO atom contributions and the dual descriptor. Energies in eV. coords must be exactly 3 × len(elements) finite values and atomic numbers must lie in 1..=118; otherwise ValueError is raised.
Deprecated alias:
frontier_descriptors→compute_frontier_descriptors.
compute_fukui_descriptors
def compute_fukui_descriptors(elements: list[int], coords: list[float]) -> FukuiDescriptorsCondensed Fukui functions f⁺, f⁻, f⁰. Energies in eV. The same exact-3N finite-coordinate and 1..=118 element contract as compute_frontier_descriptors applies.
Deprecated alias:
fukui_descriptors→compute_fukui_descriptors.
compute_reactivity_ranking
def compute_reactivity_ranking(elements: list[int], coords: list[float]) -> ReactivityRankingRanked atomic sites for nucleophilic, electrophilic and radical attack. The scores are empirical composites, not calibrated kinetic barriers. Invalid coordinate arrays, atomic numbers outside 1..=118 and EHT-unsupported elements raise ValueError.
Deprecated alias:
reactivity_ranking→compute_reactivity_ranking.
compute_bond_orders
def compute_bond_orders(elements: list[int], coords: list[float]) -> BondOrderResultWiberg and Mayer bond orders from the EHT density matrix. Distances in Å. Mismatched/empty/non-finite geometry, atomic numbers outside 1..=118 and elements without EHT parameters raise ValueError.
Deprecated alias:
bond_orders→compute_bond_orders.
Return types
| Class | Attributes (unit) |
|---|---|
StereoAnalysis | stereocenters, double_bonds, n_stereocenters, n_double_bonds |
Stereocenter | atom_index, element, substituent_indices, priorities, configuration ("R"/"S"/None) |
DoubleBondStereo | atom1, atom2, configuration ("E"/"Z"/None), high_priority_sub1, high_priority_sub2 |
GraphFeatureAnalysis | aromatic_atoms, aromatic_bonds, tagged_tetrahedral_centers, inferred_tetrahedral_centers |
MetalCoordinationCenter | atom_index, element, ligand_indices, coordination_number, geometry, geometry_score |
TopologyAnalysisResult | metal_centers, warnings |
UvVisSpectrum | energies_ev (eV), intensities, peaks, sigma (eV), notes |
UvVisPeak | energy_ev (eV), wavelength_nm (nm), intensity, from_mo, to_mo |
FrontierDescriptors | homo_atom_contributions, lumo_atom_contributions, dual_descriptor, homo_energy (eV), lumo_energy (eV), gap (eV), num_atoms |
BondOrderResult | atom_pairs, distances (Å), wiberg, mayer, wiberg_valence, mayer_valence, num_atoms |
FukuiDescriptors | f_plus, f_minus, f_radical, dual_descriptor, condensed_atom_indices, condensed_f_plus, condensed_f_minus, condensed_f_radical, condensed_dual_descriptor, homo_energy (eV), lumo_energy (eV), gap (eV), num_atoms, validity_notes |
ReactivityRanking | nucleophilic_attack_sites, electrophilic_attack_sites, radical_attack_sites, notes |
ReactivitySiteScore | atom_index, score |
Orbital meshes
compute_orbital_mesh
def compute_orbital_mesh(
elements: list[int],
coords: list[float],
method: str = "eht",
mo_index: int = 0,
spacing: float = 0.2,
padding: float = 3.0,
isovalue: float = 0.02,
) -> OrbitalMeshResultIsosurface mesh for any supported method (eht, pm3, xtb, hf3c). spacing and padding in Å. spacing > 0, padding >= 0, isovalue finite and mo_index in range are required.
Deprecated alias:
orbital_mesh→compute_orbital_mesh.
OrbitalMeshResult
| Attribute | Type | Description |
|---|---|---|
vertices | list[float] | Flat mesh vertices in Å |
normals | list[float] | Flat normals |
indices | list[int] | Flat triangle indices |
num_triangles | int | Triangle count |
method | str | Method used |
mo_index | int | Requested orbital index |
homo_index | int | HOMO index |
orbital_energies | list[float] | Orbital energies (eV) |
gap | float | HOMO-LUMO gap (eV) |
Materials and periodic systems
create_unit_cell
def create_unit_cell(a: float, b: float, c: float, alpha: float = 90.0, beta: float = 90.0, gamma: float = 90.0) -> UnitCellPeriodic unit cell from crystallographic parameters. Lengths in Å, angles in degrees, volume in ų. Lengths must be finite and positive, angles in (0°, 180°), and the angle combination must produce a positive volume; otherwise ValueError is raised.
Deprecated alias:
unit_cell→create_unit_cell.
assemble_framework
def assemble_framework(
topology: str = "pcu",
metal: int = 30,
geometry: str = "octahedral",
lattice_a: float = 10.0,
supercell: int = 1,
) -> CrystalStructureAssemble a MOF-type framework. topology is any name accepted by Topology::from_name (pcu, dia, sql, bcu, fcu, acs, afw, sod, pts, xah, tfy); metal is an atomic number in 1..=118 and geometry ∈ {linear, trigonal, tetrahedral, square_planar, octahedral}. lattice_a must be finite and positive, and supercell an integer >= 1; the replicated structure is capped at 1,000,000 atoms. Invalid input raises ValueError and non-integer counts are rejected instead of truncated. This wrapper uses one carboxylate linker; the per-edge-type linker selection is available from Rust (assemble_framework_with_linkers).
space_group_by_number
def space_group_by_number(number: int) -> SpaceGroup | NoneLook up a crystallographic space group by its ITC number (1–230). Out-of-range integers return None; fractional, NaN or infinite numbers raise ValueError.
space_group_by_symbol
def space_group_by_symbol(symbol: str) -> SpaceGroup | NoneLook up a space group by Hermann-Mauguin symbol, e.g. "P 21/c". Spaces in the symbol are ignored ("P21/c" also works); matching is case-sensitive and an unknown symbol returns None.
all_space_groups
def all_space_groups() -> list[SpaceGroupEntry]All 230 space groups as (number, symbol) records; both numbers and symbols are unique.
build_periodic_molecule
def build_periodic_molecule(
elements: list[int],
frac_coords: list[list[float]],
a: float,
b: float,
c: float,
alpha: float = 90.0,
beta: float = 90.0,
gamma: float = 90.0,
bond_tolerance: float | None = None,
options: dict | None = None,
) -> PeriodicMoleculeBuild a periodic molecular graph from fractional coordinates and a unit cell. frac_coords is a list of [x, y, z] triples; the lattice lengths are in Å. bond_tolerance is the extra bonding tolerance in Å: omitted/None uses the engine default of 0.3 Å, while 0.0 disables the extra tolerance. Every element must be in 1..=118, every coordinate must be a finite triple, and the cell must be finite with a non-degenerate volume; otherwise ValueError is raised.
detect_hapticity
def detect_hapticity(elements: list[int], coords: list[float], bonds: list[tuple[int, int]] | None = None) -> HapticityAnalysisDetect haptic (η) metal–ring interactions and metallocene motifs. When bonds is None the bonds are perceived from the geometry. coords must be exactly 3N finite values; malformed arrays raise ValueError.
optimize_framework
def optimize_framework(
smiles: str,
coords: list[float],
method: str = "bfgs",
max_iter: int = 200,
force_tol: float = 0.05,
energy_tol: float = 1e-6,
max_step: float = 0.2,
fixed_atoms: list[int] | None = None,
cell_a: float | None = None,
cell_b: float | None = None,
cell_c: float | None = None,
cell_alpha: float = 90.0,
cell_beta: float = 90.0,
cell_gamma: float = 90.0,
options: dict | None = None,
) -> FrameworkOptResultOptimise a geometry with the shared BFGS engine (UFF backend). energy is reported in eV and forces in eV/Å; cell_a/cell_b/cell_c enable periodic (minimum-image) optimisation. method is bfgs or steepest_descent. coords must contain exactly 3N finite values, max_iter must be a finite non-negative integer, and fixed_atoms indices must be non-negative and in range; otherwise ValueError is raised. The core also rejects an empty geometry, a non-finite energy/force evaluation, or a force count that does not match the atom count, so a NaN surface cannot be reported as converged.
parse_cif and write_cif
def parse_cif(cif_text: str) -> CifStructure
def write_cif(structure: CifStructure) -> strRead a CIF file into a crystal structure and write it back. The cell lengths are in Å, the cell angles in degrees and the atom-site coordinates are fractional (dimensionless).
structure = sci_form.parse_cif(open("NaCl.cif").read())
print(structure.data_block, structure.a, len(structure.atom_sites))
text = sci_form.write_cif(structure)A CifStructure can also be built directly:
structure = sci_form.CifStructure(
data_block="test",
lattice=[[5.0, 0.0, 0.0], [0.0, 5.0, 0.0], [0.0, 0.0, 5.0]],
a=5.0, b=5.0, c=5.0, alpha=90.0, beta=90.0, gamma=90.0,
)Return types
| Class | Attributes (unit) |
|---|---|
UnitCell | a, b, c (Å), alpha, beta, gamma (degrees), volume (ų), lattice |
CifStructure | data_block, lattice (Å), a, b, c (Å), alpha, beta, gamma (degrees), space_group_hm, space_group_number, atom_sites |
CifAtomSite | label, type_symbol, atomic_number, frac_x, frac_y, frac_z, occupancy |
CrystalStructure | elements, cart_coords (Å), frac_coords, labels, lattice, num_atoms |
SpaceGroup | number, symbol, crystal_system, lattice_type, point_group, operations |
SymmetryOp | rotation, translation |
SpaceGroupEntry | number, symbol |
PeriodicMolecule | elements, frac_coords, cart_coords (Å), bonds, cell, n_atoms |
PeriodicBond | atom_i, atom_j, order, image, distance (Å) |
HapticityAnalysis | interactions, is_metallocene, n_interactions |
HapticInteraction | metal_index, metal_element, ring_atoms, hapticity, centroid (Å), metal_centroid_distance (Å) |
FrameworkOptResult | positions (Å), energy (eV), forces (eV/Å), max_force (eV/Å), n_iterations, converged, energy_history (eV) |
Dynamics, reactions and transport
extract_kinetics_diagnostics and microkinetic solvers
def extract_kinetics_diagnostics(
network_json: str | None = None, n_steps: int = 20
) -> str
def solve_microkinetic_network(
network_json: str | None = None, n_steps: int = 20
) -> str
def solve_microkinetic_steady_state(
network_json: str | None = None, n_steps: int = 20, tol: float = 1e-10
) -> strAll three return a JSON string. network_json is a MicrokineticNetworkConfig document; omit it (or pass None) for the built-in A ⇌ B demo. n_steps must be a finite integer >= 2 and is the number of output/integration frames: it overrides the network document's n_frames on this surface. Negative, fractional, NaN or infinite counts raise ValueError. tol must be finite and strictly positive.
extract_kinetics_diagnostics returns:
{
"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
}is_steady_state is max_rate_of_change < 1e-10. solve_microkinetic_network adds n_steps, n_rates, converged, final_time_s, final_populations and a diagnostics object; solve_microkinetic_steady_state reports residual, tol and the same shape.
compute_md_trajectory
def compute_md_trajectory(smiles: str, coords: list[float], n_steps: int = 100, dt_fs: float = 1.0, seed: int = 42) -> MdTrajectoryShort exploratory NVE molecular dynamics (velocity Verlet + UFF). Times in fs, energies in kcal/mol, temperatures in K.
Deprecated alias:
md_trajectory→compute_md_trajectory.
compute_md_trajectory_nvt
def compute_md_trajectory_nvt(
smiles: str,
coords: list[float],
n_steps: int = 100,
dt_fs: float = 1.0,
seed: int = 42,
target_temp_k: float = 300.0,
thermostat_tau_fs: float = 100.0,
) -> MdTrajectoryNVT molecular dynamics with the Berendsen thermostat. target_temp_k in K, thermostat_tau_fs in fs. See molecular dynamics for the equations and limits.
Deprecated alias:
md_trajectory_nvt→compute_md_trajectory_nvt.
compute_simplified_neb_path
def compute_simplified_neb_path(
smiles: str,
start_coords: list[float],
end_coords: list[float],
n_images: int = 8,
n_iter: int = 50,
spring_k: float = 0.1,
step_size: float = 0.01,
) -> NebPathResultSimplified NEB-like path between two geometries: linear interpolation plus spring-coupled UFF gradient relaxation. The configurable-backend variant (compute_neb_path_with_method) is Rust/WASM only. This is a low-cost exploratory path tool, not a full climbing-image / tangent-projected NEB. n_images must be an integer in 2..=1000, n_iter an integer ≥ 1; empty SMILES, wrong coordinate lengths and non-finite coordinates raise ValueError.
Deprecated alias:
simplified_neb_path→compute_simplified_neb_path.
search_conformers_with_uff
def search_conformers_with_uff(smiles: str, n_samples: int = 10, seed: int = 42, rmsd_threshold: float = 0.5) -> ConformerSearchResultMulti-seed conformer exploration ranked by UFF energy and deduplicated by Kabsch-aligned RMSD (threshold in Å). Energies in kcal/mol.
Deprecated alias:
search_conformers→search_conformers_with_uff.
parse_smirks and apply_smirks
def parse_smirks(smirks: str) -> SmirksTransform
def apply_smirks(smirks: str, smiles: str) -> SmirksResultParse a SMIRKS reaction string and apply it to a molecule.
parse_smirks requires exactly one >>, a non-empty reactant and product and at least one atom map number in 1..=255 present on both sides. transform.atom_map is a dict[int, int] (the map number is the identity key) and transform.bond_changes is a list of BondChange objects with atom1_map, atom2_map, old_order and new_order.
apply_smirks matches the reactant SMARTS and returns applied canonical product SMILES in result.products, not the product template. It applies mapped element, formal-charge, hydrogen-count and bond-order changes, creates product-only mapped atoms and removes reactant-only mapped atoms; atom_mapping maps each map number to the input molecule atom index. Empty/whitespace SMILES, multiple fragments with a one-component SMIRKS and unmapped SMIRKS raise ValueError; a valid SMIRKS that does not match returns success=False with products=[]. Multi-component transforms accept dot-separated reactant components and return the combined canonical product.
pack_conformers
def pack_conformers(results: list[ConformerResult]) -> RecordBatchPack conformer results into sci-form's columnar (Arrow-like) format for efficient transfer. This is not the Apache Arrow IPC format.
num_rows is the number of conformers (one row per result, including failed ones with success = 0), not the total atom count. The columns are success (int), num_atoms (int), time_ms (float), coords (flat 3 * total_atoms floats, shape [total_atoms, 3]) and elements (flat atomic numbers, shape [total_atoms]). A result whose num_atoms does not match len(coords) / 3 or len(elements) raises ValueError instead of being silently dropped.
split_worker_tasks
def split_worker_tasks(smiles: list[str], n_workers: int = 4, seed: int = 42) -> list[dict]Split a SMILES list into balanced worker tasks for multi-process / web-worker dispatch. n_workers must be an integer >= 1; empty lists return [] and invalid counts raise ValueError. The SMILES JSON in each task is escaped with serde_json.
estimate_workers
def estimate_workers(n_items: int, max_workers: int = 8) -> intEstimate the optimal number of workers for a given batch size. n_items and max_workers must be non-negative; negative values raise ValueError.
Return types
| Class | Attributes (unit) |
|---|---|
MdTrajectory | frames, dt_fs (fs), notes |
MdFrame | step, time_fs (fs), coords (Å), potential_energy_kcal_mol, kinetic_energy_kcal_mol (kcal/mol), temperature_k (K) |
NebPathResult | images, notes |
NebImage | index, coords (Å), potential_energy_kcal_mol (kcal/mol) |
ConformerSearchResult | generated, unique, rotatable_bonds, conformers, clusters, notes |
ConformerEnsembleMember | seed, cluster_id, coords (Å), energy_kcal_mol (kcal/mol) |
ConformerClusterSummary | cluster_id, size, representative_seed, member_seeds |
SmirksTransform | reactant_smarts, product_smarts, atom_map, bond_changes, smirks |
BondChange | atom1_map, atom2_map, old_order, new_order |
SmirksResult | products, atom_mapping, n_transforms, success, messages, is_ok |
RecordBatch | num_rows, num_columns, byte_size, column_names, float_data, int_data, uint8_data |
System planning
system_capabilities
def system_capabilities(elements: list[int]) -> SystemCapabilitiesReport which core workflows are usable for an element set. Empty element lists and atomic numbers outside 1..=118 mark the relevant methods unavailable; unsupported_elements is a list[int].
system_method_plan
def system_method_plan(elements: list[int]) -> SystemMethodPlanRecommend a method (and a fallback) per property domain. For an empty or invalid element set the recommendations are None and every capability is unavailable.
compare_methods
def compare_methods(smiles: str, elements: list[int], coords: list[float], allow_experimental_eht: bool = False) -> MethodComparisonResultCompare the available methods on the same system and geometry. Per-method failures are reported in each row; empty or non-finite geometry raises ValueError.
Return types
| Class | Attributes |
|---|---|
SystemCapabilities | embed, uff, eht, population, orbital_grid (each a MethodCapability) |
MethodCapability | available, confidence, unsupported_elements, warnings |
SystemMethodPlan | capabilities, geometry, force_field_energy, orbitals, population, orbital_grid (each a PropertyMethodPlan) |
PropertyMethodPlan | property, recommended, fallback, rationale, methods |
MethodMetadata | method, available, confidence, confidence_score, warnings, limitations |
MethodComparisonResult | plan, comparisons |
MethodComparisonEntry | method, status, available, confidence, confidence_score, warnings, limitations, error, support_level, homo_energy (eV), lumo_energy (eV), gap (eV), energy_kcal_mol (kcal/mol) |
Options mappings
Eight over-argumented functions accept an optional trailing options mapping. The positional form keeps working exactly as before; a key present in the mapping overrides the positional value. An unknown key is an error, not a silent no-op.
| Function | Accepted option keys |
|---|---|
compute_fluorescence | sigma, e_min, e_max, n_points, stokes_ev, refractive_index, dark_threshold, broadening |
compute_ir_spectrum | method, gamma, wn_min, wn_max, n_points, step_size, smiles |
compute_ir_spectrum_broadened | method, gamma, wn_min, wn_max, n_points, broadening, step_size, smiles |
compute_giao_nmr | nucleus, charge, multiplicity, max_scf_iter, allow_basis_fallback, use_parallel_eri |
build_periodic_molecule | a, b, c, alpha, beta, gamma, bond_tolerance |
optimize_framework | method, max_iter, force_tol, energy_tol, max_step, fixed_atoms, cell_a, cell_b, cell_c, cell_alpha, cell_beta, cell_gamma |
train_random_forest | n_trees, max_depth, min_samples_split, min_samples_leaf, sample_fraction, seed |
train_gradient_boosting | n_estimators, learning_rate, max_depth, min_samples_split, min_samples_leaf, subsample, seed |
result = sci_form.optimize_framework("CCO", coords, options={"max_iter": 5})
print(result.n_iterations) # 5
sci_form.optimize_framework("CCO", coords, options={"nope": 1})
# ValueError: Invalid 'options' key 'nope'. Supported: 'method', 'max_iter', 'force_tol',
# 'energy_tol', 'max_step', 'fixed_atoms', 'cell_a', 'cell_b', 'cell_c',
# 'cell_alpha', 'cell_beta', 'cell_gamma'.Experimental surface
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-*orbeta-*feature flag; the flag is a build choice, not a stability claim. MBH, DFT, MLFF and reaction dynamics remain gated.
These functions are exposed by the Python package when the matching Cargo feature is enabled on the sci-form-python build. They are listed in sci_form.__all__ when present.
| Capability | Feature | Canonical functions | Deprecated aliases |
|---|---|---|---|
| EEQ charges | experimental-eeq | compute_eeq_charges, compute_eeq_energy | eeq_charges, eeq_energy |
| ALPB solvation | experimental-alpb | compute_alpb_solvation, compute_alpb_born_radii | alpb_solvation, alpb_born_radii |
| D4 dispersion | experimental-d4 | compute_d4_energy | d4_energy |
| CPM electrochemistry | experimental-cpm | compute_cpm_charges, compute_cpm_surface | cpm_charges, cpm_surface |
| Electrical double layer | alpha-edl | compute_edl_profile, compute_edl_capacitance_scan, compute_helmholtz_profile, compute_gouy_chapman_profile, compute_gcs_profile | edl_profile, edl_capacitance_scan, edl_helmholtz, edl_gouy_chapman, edl_gcs |
| Periodic linear algebra | alpha-periodic-linear | compute_kmesh, compute_periodic_dos, solve_periodic_randnla, bloch_phase, build_bloch_hamiltonian, assemble_periodic_operators, bz_integrate_scalar, bz_integrate_vector, validate_electron_count, validate_kmesh_weights | kmesh |
| Kinetics | alpha-kinetics | compute_htst_rate, compute_htst_sweep, extract_kinetics_diagnostics, solve_microkinetic_network, solve_microkinetic_steady_state, analyze_gsm_mbh_htst_step | htst_rate, htst_temperature_sweep |
| Chart utilities | alpha-render-bridge | 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_chart | edl_chart, capacitance_chart, arrhenius_chart, thermal_prop_chart, phase_portrait_chart, band_structure_chart, density_of_states_chart, kpoint_path_chart, fermi_surface_chart, trajectory_chart, reaction_coordinate_chart |
| pKa and redox | alpha-redox-pka | compute_pka, compute_redox_potential | — |
| EPR hyperfine | alpha-epr | compute_epr_hyperfine | — |
| MP2 | alpha-mp2 | compute_mp2_energy | — |
| XPS | alpha-core-spectroscopy | compute_xps_binding_energies | — |
| QM/MM | alpha-qmmm | compute_qmmm_energy | — |
| Raman/VCD/ROA | alpha-raman | compute_raman_spectrum, compute_vcd_spectrum, compute_roa_spectrum | — |
| Alchemical free energy | alpha-free-energy | estimate_free_energy | — |
| Enhanced sampling | alpha-enhanced-sampling | run_uff_metadynamics, run_uff_opes, reweight_free_energy, reweight_free_energy_correlated, reweight_free_energy_2d | — |
| 3D-RISM | alpha-rism | solve_3d_rism | — |
| GCMC | always built | compute_gcmc_isotherm | — |
| kMC | always built | run_kinetic_monte_carlo | — |
| Reaction networks | always built | discover_reaction_network, discover_template_network, refine_barrier_with_gsm | — |
| Conformal/active learning | always built | conformal_calibrate, active_learning_propose | — |
| PBE0 | alpha-dft-hybrid | compute_pbe0_energy | — |
| All-nuclide NMR | alpha-nmr-all | active_nmr_isotopes, compute_all_nmr | — |
Enhanced-sampling reweighting (JSON)
def reweight_free_energy(trace_json: str, config_json: str) -> str
def reweight_free_energy_correlated(trace_json: str, config_json: str) -> str
def reweight_free_energy_2d(trace_json: str, config_json: str) -> strThese functions take JSON-encoded MetaDynamicsPoint / MultiTracePoint traces and a ReweightConfig / MultiReweightConfig, and return the result as a JSON string. reweight_free_energy_correlated additionally returns standard_error (one value per bin, kcal/mol), n_blocks and block_size. A block_size that leaves only one block is a ValueError; empty traces, non-finite CV/bias values, invalid grids and weight overflow/underflow are also rejected. A non-finite surface is never returned.
Periodic validators
def validate_electron_count(n_electrons: int, n_bands: int, n_kpoints: int) -> bool
def validate_kmesh_weights(weights: list[float], tolerance: float) -> boolvalidate_electron_count requires three finite non-negative integers and reports whether n_electrons <= 2 * n_bands * n_kpoints (zero bands/k-points is invalid). The capacity saturates on overflow instead of wrapping. Fractional, negative or non-finite counts raise ValueError. validate_kmesh_weights rejects negative/non-finite weights and tolerances with False.
The deprecated aliases follow exactly the same rule as the stable ones: they still work, they emit a DeprecationWarning, and they will be removed in a future major release.
Submodules
sci_form.alpha and sci_form.beta
Empty in a default build; populated when the matching alpha-* / beta-* features are enabled. The alpha module covers DFT, ReaxFF, MLFF, CGA, GSM, SDR and live dynamics; beta covers KPM, MBH, RandNLA, Riemannian methods and CPM.
alpha — canonical name and deprecated alias:
| Canonical | Deprecated alias |
|---|---|
alpha_compute_dft | dft_calculate |
alpha_compute_reaxff_gradient | reaxff_gradient |
alpha_compute_reaxff_energy | reaxff_energy |
alpha_compute_eem_charges | eem_charges |
alpha_rotate_dihedral_cga | rotate_dihedral_cga |
alpha_refine_torsion_cga | refine_torsion_cga |
alpha_gsm_interpolate | gsm_interpolate |
alpha_gsm_backend_plan | gsm_backend_plan |
alpha_gsm_compare_backends | gsm_compare_backends |
alpha_gsm_find_ts | gsm_find_ts |
alpha_sdr_embed | sdr_embed_py |
beta — canonical name and deprecated alias:
| Canonical | Deprecated alias |
|---|---|
beta_compute_kpm_dos | kpm_dos |
beta_compute_kpm_mulliken | kpm_mulliken |
beta_compute_mbh_frequencies | mbh_frequencies |
beta_solve_eht_randnla | eht_randnla |
beta_compute_cpm_charges | cpm_charges |
sci_form.potentials
Analytic model potentials, useful as test targets for the reaction-dynamics code.
| Function | Signature |
|---|---|
double_well_1d | (x) -> float |
asymmetric_1d | (x) -> float |
sn2_model_1d | (x) -> float |
muller_brown_2d | (x, y) -> float |
proton_transfer_evb | (s, k, coupling) -> float |
proton_transfer_2d_morse | (r_ah, r_hb) -> float |
Integration examples
NumPy
import numpy as np
from sci_form import embed
result = embed("CCO")
coords = np.array(result.coords).reshape(-1, 3) # (9, 3), Å
elements = np.array(result.elements) # (9,)Zero-copy embedding
import numpy as np, sci_form
buf = np.zeros(3 * 9, dtype=np.float64)
sci_form.embed_coords_into("CCO", buf, 42)
print(buf.reshape(-1, 3))Pandas
import pandas as pd
from sci_form import embed_batch
results = embed_batch(["CCO", "c1ccccc1", "CC(=O)O"])
df = pd.DataFrame([
{"smiles": r.smiles, "num_atoms": r.num_atoms, "time_ms": r.time_ms, "ok": r.is_ok()}
for r in results
])RDKit interop
from rdkit import Chem
from sci_form import embed
result = embed("c1ccccc1")
mol = Chem.MolFromSmiles("c1ccccc1")
mol = Chem.AddHs(mol)
conf = Chem.Conformer(mol.GetNumAtoms())
for i in range(result.num_atoms):
conf.SetAtomPosition(i, (result.coords[i*3], result.coords[i*3+1], result.coords[i*3+2]))
mol.AddConformer(conf, assignId=True)DOS + matplotlib
import matplotlib.pyplot as plt
from sci_form import embed, compute_dos
conf = embed("c1ccccc1")
result = compute_dos(conf.elements, conf.coords, sigma=0.3)
plt.plot(result.energies, result.total_dos)
plt.xlabel("Energy (eV)")
plt.ylabel("DOS (states/eV)")
plt.show()