Skip to main content

Gauss-Legendre 6th-order implicit integrator and finite-difference helpers built on JAX.

Project description

Gauss6

Gauss6 bundles a sixth-order implicit Gauss–Legendre time integrator together with high-order finite-difference helpers, all implemented with JAX. The method is A-stable and therefore useful for stiff systems. It is also symplectic, and therefore useful for solving Hamiltonian systems such as the KdV equation.

The systems are solved based on methods described in Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems by Hairer and Wanner (Springer, 1996), section IV.8 Implementation of Implicit Runge-Kutta Methods: The Linear System. The implicit steps are solved using a Newton-GMRES solver with backtracking, as explained in Choosing the Forcing Terms in an Inexact Newton Method by Stanley C. Eisenstat and Homer F. Walker (SIAM, 1996). We further use jax to automatically compute the Jacobian-vector products needed in the GMRES solver.

Installation

The package targets Python 3.9+ and relies on JAX. Install the right jax/jaxlib wheel for your platform (CPU-only shown below) and then install Gauss6:

pip install --upgrade pip
pip install --upgrade "jax[cpu]"
pip install gauss6

Quick start

import jax.numpy as jnp
from gauss6 import Gauss6

def f(t, u, args):
    alpha = args["alpha"]
    return alpha * u

t = jnp.linspace(0.0, 2.0, 201)
params = {"alpha": -1.0}
u0 = jnp.array([1.0])  # initial condition

solver = Gauss6(t, args=params, size=u0.size)
solve = solver.make_solve(f)
trajectory = solve(u0)

We currently do not support adaptive timestepping and assume a constant step size.

The package also exposes high-order central-difference helpers:

from gauss6 import dx_order_6

x = jnp.linspace(0, 2*jnp.pi, 512, endpoint=False)
dx = x[1]-x[0]
values = jnp.sin(x)
first_derivative = dx_order_6(values, dx)

We assume that the function is periodic and that the grid is equidistant.

License

Gauss6 is released under the 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

gauss6-0.1.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

gauss6-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file gauss6-0.1.1.tar.gz.

File metadata

  • Download URL: gauss6-0.1.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for gauss6-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0c3c2e05a106e2ddbf09450c730254446a269374a41668684404af8f61d36be7
MD5 00207ab15c2546caccb42483db8147eb
BLAKE2b-256 0ed8dfbf8eea6ad25284a28456566b1e3d8f3e19e483ad0a4e54aed3eed988a3

See more details on using hashes here.

File details

Details for the file gauss6-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gauss6-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for gauss6-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f6a79b0e5fe313efdcb0b547cd5a69857449ea7b2be99effb0ee1ba1a52b8c3
MD5 cb14bc07b10956bf813dd0de4fbfc0f7
BLAKE2b-256 69ab6c8079047351f48754bc5e68d72be1f60efeefbd1b6b7ec33bd27554997f

See more details on using hashes here.

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