TypeScript/JavaScript bindings for the diffsol ODE solver with WebAssembly. See https://github.com/martinjrobins/diffsol for more details.
https://diffsol-js.fly.dev/docs
npm install @martinjrobins/diffsol-js
This package bundles the diffsol runtime WASM. It requires a hosted diffsol backend that exposes:
POST /compileThe examples below use the public backend at https://diffsol-js.fly.dev.
import {
compile,
MatrixType,
LinearSolverType,
OdeSolverType,
} from '@martinjrobins/diffsol-js';
const model = `
in_i { k = 1 }
u_i { y = 1 }
F_i { -k * y }
out_i { y }
`;
const ode = await compile(
model,
{
backendUrl: 'https://diffsol-js.fly.dev',
},
MatrixType.FaerDense,
LinearSolverType.Lu,
OdeSolverType.Bdf
);
const params = new Float64Array([1.0]);
const y0 = ode.getY0(params);
const tEval = new Float64Array([0.0, 0.5, 1.0, 2.0]);
const solution = ode.solveDense(params, tEval);
const ys = solution.ys;
console.log('Initial conditions:', y0);
console.log('Solution:', ys);
solution.dispose();
ode.dispose();
The package also ships the interactive solver stylesheet:
import '@martinjrobins/diffsol-js/interactive-solver.css';
If you are using the interactive UI components, your app must be able to bundle CSS and resolve the plotly.js dependency.
The build still produces dist/diffsol.min.js for CDN-style usage:
<script src="https://diffsol-js.fly.dev/diffsol.min.js"></script>
In that mode the API is available at window.diffsol.
npm install
npm run test:offline
npm test
npm run build
npm run docs
From the js/ directory:
npm publish
prepublishOnly runs the full test suite and rebuilds the package before publishing. Tests default to https://diffsol-js.fly.dev and can be overridden with DIFFSOL_BACKEND_URL if needed. Replace the placeholder repository metadata in package.json before the first real release from the new repo.