Skip to main content

State Translation Adaptive Runge Kutta

Project description

stark-ode

State Translation Adaptive Runge-Kutta for structured ordinary differential equations.

stark-ode is an initial-value ODE solver that works with ordinary Python values, NumPy arrays, and structured simulation state.

Unlike most Python ODE libraries, STARK does not assume that every model state is a single flat vector. Instead it separates the mathematical problem, the state representation, the numerical method, and the execution backend into independent concepts:

System -> Frame -> Method -> Engine
  • System describes the differential equations.
  • Frame describes the structure of the state.
  • Method chooses the numerical integration algorithm.
  • Engine chooses where state is stored and where algebra is performed.

That separation allows the same numerical methods to work with simple array problems, structured state, and more specialised simulation models without changing the solver architecture.

Why STARK?

Most ODE libraries start by flattening state into one vector.

STARK instead keeps the distinction between:

  • the state of the model;
  • the translation or increment applied by the solver;
  • the numerical method;
  • the execution backend.

This makes several things possible without changing the solver architecture:

  • named and structured state fields;
  • existing object-oriented simulation models;
  • explicit, implicit, and IMEX methods under one API;
  • alternative storage backends including NumPy, JAX, and CuPy;
  • extensible algebra for specialised state representations.

If your model is naturally a single dense vector, STARK still works well. If it is not naturally a vector, STARK is designed specifically for that use case.

Installation

Until the beta release is published on PyPI:

python -m pip install git+https://github.com/stark-numerics/stark-ode.git

Once a beta is published on PyPI:

python -m pip install --pre stark-ode

For development:

git clone https://github.com/stark-numerics/stark-ode.git
cd stark-ode
python -m pip install -e .

Optional extras are available for documentation, examples, benchmarking, accelerators, and comparison reports:

python -m pip install -e ".[accelerators]"
python -m pip install -e ".[examples]"
python -m pip install -e ".[docs]"
python -m pip install -e ".[comparison]"
python -m pip install -e ".[asv]"

Quick Start

import numpy as np

from stark import Frame, Interval, Method, System
from stark.engines import EngineNumpy
from stark.methods import SchemeCashKarp


def exponential_decay(t, state, out):
    del t
    out.dy[0] = -0.5 * state.y[0]


system = System(
    dynamics=exponential_decay,
    frame=Frame.scalar("y", translation="dy"),
)

ivp = system.ivp(
    initial={"y": np.array([2.0])},
    interval=Interval(present=0.0, step=0.1, stop=1.0),
    method=Method(SchemeCashKarp),
    engine=EngineNumpy,
)

for interval, state in ivp.stable_trajectory():
    print(interval.present, state.y[0])

Documentation

The documentation is organised by learning path.

If you want to... Read
Learn the design docs/concepts.md
Solve your first problem docs/getting-started.md
Build and configure systems docs/problem.md
Choose numerical methods docs/methods.md
Use implicit and IMEX methods docs/implicit.md
Understand execution backends docs/engines.md
Monitor integrations docs/diagnostics.md
Browse runnable examples docs/examples.md

For contributors, design notes begin in docs/contributing/README.md.

Examples

Examples are executable documentation. Recommended starting points are:

python -m examples.getting_started.scalar_decay
python -m examples.getting_started.numpy_oscillator
python -m examples.problem.dynamics_styles
python -m examples.methods.choose_scheme
python -m examples.diagnostics.compare_custom_scheme

Each example demonstrates one aspect of the library and can be run directly after installing the examples extra.

Features

STARK includes:

  • explicit Runge-Kutta methods;
  • adaptive embedded Runge-Kutta methods;
  • implicit DIRK, SDIRK, Gauss, Radau, and BDF methods;
  • IMEX methods;
  • Newton, Picard, Anderson, Broyden, and related nonlinear resolvents;
  • dense and iterative linear inversion strategies;
  • native Python, NumPy, JAX, and CuPy execution engines;
  • diagnostics, comparison tooling, and benchmarking support;
  • extension points for custom state representations and numerical algorithms.

See the documentation for the complete method catalogue.

Who Is STARK For?

STARK is intended for users who:

  • want to preserve the structure of simulation state;
  • work with dataclasses or object-oriented models;
  • need explicit, implicit, and IMEX methods within one framework;
  • want to experiment with numerical algorithms or extend solver components.

If every problem you solve is already naturally represented as a single dense NumPy vector, SciPy's solve_ivp may be the simpler choice.

Development

python -m pip install -e ".[dev]"
python -m pytest -q

Citation

If you use STARK in published work, please cite the repository. Citation metadata is provided in CITATION.cff.

License

MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stark_ode-0.1.0b1.tar.gz (264.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stark_ode-0.1.0b1-py3-none-any.whl (470.6 kB view details)

Uploaded Python 3

File details

Details for the file stark_ode-0.1.0b1.tar.gz.

File metadata

  • Download URL: stark_ode-0.1.0b1.tar.gz
  • Upload date:
  • Size: 264.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stark_ode-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 51f0a88ee7755d8996b38fc738454ff5f23a12fd1a95bc0ebdefad2988e67935
MD5 f3abcf5059a523ad09b086f04afc2b3d
BLAKE2b-256 fc615713cc2257074f9c3c3ea5287fdcab9c2d74a1e21203ef726c1837eb32fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for stark_ode-0.1.0b1.tar.gz:

Publisher: release.yml on stark-numerics/stark-ode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stark_ode-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: stark_ode-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 470.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stark_ode-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7ce04e89bb91e1a112f3fecfa4898d1b9effd822be489e5eaa0102ce6f2585d
MD5 c90589276b753035350fc759a2ac10d7
BLAKE2b-256 8b964b387d33085dd5cd7257207b56bc2e28729b0b070e50eab97a728a1bb3f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for stark_ode-0.1.0b1-py3-none-any.whl:

Publisher: release.yml on stark-numerics/stark-ode

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page