This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/ode/core

What the ODE integrators share

The pieces every method of lib/ode uses: the solver's state and settings as records, the weighted RMS norm the error tests are written in, the starting step, the finite-difference Jacobian, the dense output of an accepted step, and the root finder that locates an event inside a step.

A problem is three defs of the same shape, passed as function values:

rhs(t: Num, y: Arr, p: Arr) -> Arr        dy/dt, length n
jac(t: Num, y: Arr, p: Arr) -> Arr        d rhs / dy, n by n
events(t: Num, y: Arr, p: Arr) -> Arr     one g per event; a root is an event

p carries the problem's parameters, so one def serves a whole sweep of them (lib/ode/solve.viv, ode_batch). The compiled engines specialize each integrator for the defs it is given, so a call of rhs costs a direct call.

Used with from ode.core import ....

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

This program declares a record type (OdeCfg), and records run only in compiled C for now, so the Run buttons here are off. Open it in the workbench and use its C tab to compile it.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 23–352