Skip to content

Getting started

  • Python 3.8 or newer
  • pip
  • numpy
  • scipy

Create a virtual environment and install the project in editable mode:

Terminal window
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

If you also want the notebook tooling:

Terminal window
python -m pip install -e ".[dev,notebooks]"

Confirm the solver imports cleanly:

Terminal window
python -c "from desolve.DESolver import DESolver; DESolver(); print('ok')"

The example below advances the scalar ODE u' = -u using RK4.

import numpy as np
from desolve.DESolver import DESolver
def rhs(t, u, ctx):
f = -u
jac = -np.eye(u.size, dtype=ctx["data-type"])
return f, jac
solver = DESolver()
solver.set_function_context({"data-type": np.float64})
solver.setup(keep_history=True)
solver.set_rhs(rhs)
solver.set_initial_solution(np.array([1.0], dtype=np.float64))
solver.set_duration(t_start=0.0, t_end=1.0, dt=1e-2)
solver.set_method("RK4")
solver.solve()
t, u = solver.get_trajectory()
print(t[-1], u[:, -1])

Once the basic example works, move to the solver workflow page to understand the typical call sequence and where method selection and problem setup fit together.