Skip to main content

Numerical integrators using Numba

Project description

PyPI Package latest release PyPI Wheel Supported versions Supported implementations

Numba Integrators

Numba Integrators is collection numerical integrators based on the ones in SciPy. Aim is to make them faster and much more compatible with Numba.

Table of Contents

Quick start guide

Here's how you can start

The first steps

Installing

Install Numba Integrators with pip

pip install numba-integrators

Importing

Import name is not the same as install name, numba-integrators.

import numba_integrators

Example

import numba as nb
import numba_integrators as ni
import numpy as np

@nb.njit(nb.float64[:](nb.float64, nb.float64[:]))
def f(t, y):
    '''Differential equation for sine wave'''
    return np.array((y[1], -y[0]))

y0 = np.array((0., 1.))

solver = ni.RK45(f, 0.0, y0,
                 t_bound = 1, atol = 1e-8, rtol = 1e-8)

t = []
y = []

while ni.step(solver):
    t.append(solver.t)
    y.append(solver.y)

print(t)
print(y)

Example of the advanced function

import numba as nb
import numba_integrators as ni
import numpy as np

@nb.njit
def f(t, y, parameters):
    '''Differential equation for sine wave'''
    auxiliary = parameters[0] * y[1]
    dy = np.array((auxiliary, -y[0])) + parameters[1]
    return dy, auxiliary

t0 = 0.
y0 = np.array((0., 1.))
parameters = (2., np.array((-1., 1.)))

# Numba type signatures
parameters_signature = nb.types.Tuple((nb.float64, nb.float64[:]))
auxiliary_signature = nb.float64
solver_type = ni.RK45

Solver = ni.Advanced(parameters_signature, auxiliary_signature, solver_type)
solver = Solver(f, t0, y0, parameters,
                t_bound = 1, atol = 1e-8, rtol = 1e-8)

t = []
y = []
auxiliary = []

while ni.step(solver):
    t.append(solver.t)
    y.append(solver.y)
    auxiliary.append(solver.auxiliary)

print(t)
print(y)
print(auxiliary)

Changelog

0.2.1 2023-08-10

  • Advanced mode solver to handle functions with parameters and auxiliary output

0.1.2 2023-08-06

  • Fixes

0.1.1 2023-08-05

  • Initial working version

0.0.3 2023-05-14

  • Inital working state

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

numba-integrators-0.2.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

numba_integrators-0.2.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file numba-integrators-0.2.1.tar.gz.

File metadata

  • Download URL: numba-integrators-0.2.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for numba-integrators-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d6147ab7a1c8587055c60c2d2d3179190fe0b857bc759a8f973bdd8bd9589fd5
MD5 4a5f967f9343e5e0d2f204e406a8b1af
BLAKE2b-256 f3368b23d71f12749c6282709fedf9f8eb68739820b21a928ef1ba61d71b9abe

See more details on using hashes here.

File details

Details for the file numba_integrators-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for numba_integrators-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9ba1889897588667b210d23e1cac2091822edf537fd6e3b0797b7102b5e9de4
MD5 9a22419676d1d68af7fac287db038c45
BLAKE2b-256 fb1064c521e226c9665fc9d00a402b5e507013d08cc18160a4be9f5f723ef9ba

See more details on using hashes here.

Supported by

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