Install
Browser
Section titled “Browser”Nothing to install. Open the playground.
Python
Section titled “Python”The soliton package wraps the Rust engine with NumPy arrays in and out. Until it is published on PyPI, build it
from source:
git clone https://github.com/soliton-physics/solitoncd soliton/crates/soliton-pyuv venv && source .venv/bin/activateuv pip install maturin numpymaturin develop --releasefrom soliton import mechanics
scene = mechanics.scenario("atwood", m1=2, m2=3)print(scene.answers())run = scene.run(until=2.0)print(run.body("m2")["velocity"][-1])The wave solvers live beside it:
from soliton import Simulation, kdv_soliton
sim = Simulation("kdv", points=512, length=60.0, dt=1e-3)sim.state = kdv_soliton(sim.x, 0.0, speed=4.0, center=-10.0)sim.step(5000)print(sim.time, sim.invariants())cargo add soliton-core --git https://github.com/soliton-physics/solitonuse soliton_core::exact::kdv_soliton;use soliton_core::{Complex64, Kdv, PeriodicGrid, Simulation};
let mut sim = Simulation::new(PeriodicGrid::new(512, 60.0), Kdv, 1e-3);sim.set_profile(|x| Complex64::new(kdv_soliton(x, 0.0, 4.0, -10.0), 0.0));sim.advance(5000);Running the tests
Section titled “Running the tests”cargo test --releaseThe tests compare every solver against closed-form solutions. See Validation for the current numbers.