Python interface to goss - General ODE System Solver
Project description
GOSS - General ODE System Solver
goss
is a C++ library for solving ordinary differential equations.
The general idea is that you define your ODE in a gotran ode file
and hand the ode over to goss
.
First define the ode in a gotran ODE file
# lorentz.ode
parameters(
sigma=10.0,
rho=28.0,
beta=8/3
)
# The values of the states represent the initial conditions
states(
x=0.0,
y=1.0,
z=1.05
)
dx_dt = sigma * (y - x)
dy_dt = x * (rho - z) - y
dz_dt = x * y - beta * z
You can now solve the ode as follows
import numpy as np
import matplotlib.pyplot as plt
from gotran import load_ode
import goss
# Import the ode in gotran
lorentz = load_ode("lorentz.ode")
# Jit compile the code for the right hand side
ode = goss.ParameterizedODE(lorentz)
# Select a solver and instantiate the solver
solver = goss.solvers.RKF32(ode)
# Select the time steps you want to solve for
t = np.linspace(0, 100, 10001)
# Solve the system
u = solver.solve(t)
# Plot the solution
fig = plt.figure()
ax = fig.add_subplot(projection="3d")
ax.plot(u[:, 0], u[:, 1], u[:, 2], lw=0.5)
ax.set_xlabel("X Axis")
ax.set_ylabel("Y Axis")
ax.set_zlabel("Z Axis")
ax.set_title("Lorenz Attractor")
plt.show()
For more examples, check out the demo folder
There is also a command line interface that can be used to list the available solvers, run the solver and generate the goss code
Documentation
Documentation is hosed at https://computationalphysiology.github.io/goss
Install
You can install goss with pip
python -m pip install pygoss
Alternatively you can clone the repo, cd into it at execute
python -m pip install .
or use
python -m pip install -e .
for an editable install.
Testing
Python
The tests for the python code can be found in the folder tests and run with pytest
. To run the tests, please install the test dependencies
python -m pip install ".[test]"
and run the tests with
python -m pytest
C++
The C++ source code for goss
is found in the folder cpp. The C++ code also has a separate test suite that can be found in cpp/tests. To run the tests you need to first build goss with the BUILD_TESTS flag enabled
cmake -B build-cpp -S cpp -DBUILD_TESTS=ON
cmake --build build-cpp
and now you can run the tests
cd build-cpp
ctest
Structure
The bindings between python and C++ uses pybind11 and all the bindings are found in the file python/wrapper.cpp.
The python package is built using scikit-build which is a build system especially suited for python code with C++ extensions.
Known issues
- There is currently an issue on Apple Silicon with exceptions raised from by the jit compiled code which means the one test is not passing. An issue has been filed for this here
Contributing
Contributions are very welcomed. To contribute please fork the repo, create a branch a submit a pull request. Before the pull request can be accepted it has to pass the test suit for the python and C++ code. Also note that we try to enforce an consistent coding style. To ensure that you follow the coding style you can install the pre-commit hook in the repo
python -m pip install pre-commit
pre-commit install
For every future commit, you will now run a set of tests that will make sure that you follow the coding style.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pygoss-0.3.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33c4fe2a8d02446ae54c437db495ad687294fda841027c45f10a7e4a52bfeb23 |
|
MD5 | 336e7065907bde48d62935f7f4414b9b |
|
BLAKE2b-256 | ac90c6e3e4c0614689be55c3205a235b802fa98c9f2ed061c6711c35b0386c6e |
Hashes for pygoss-0.3.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b31a34fa66ab8d062d20491967ef2be020bed71f7ff1c22fd96f560a15380278 |
|
MD5 | 0098c67569b33f9d71e0f6bed1ac010f |
|
BLAKE2b-256 | 0621c79fd4da01435d668f7547c96463f6d9761a570503cc1565e9fef4f86271 |
Hashes for pygoss-0.3.13-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d018eca707352f8d8f88ffd1c556c085c2ee6f302198c7b6efbaf7ec881b770 |
|
MD5 | 29de009676a5c779e00f761b7d2b005a |
|
BLAKE2b-256 | a24643128cbb72adb728f030b46a50f29ff38ab99df21b7a2360ac6185717d8d |
Hashes for pygoss-0.3.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa13a6b7f860610ea17975423f4faaf4067be8c41a69a0e56320092055d7c015 |
|
MD5 | ec09069b9cb36fcfe3a11b0121be9cb7 |
|
BLAKE2b-256 | 7418e1ad08397df96a881884c806c793bebeff46977cb755bcac379d06739dd8 |
Hashes for pygoss-0.3.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07c2b5dba2717a1de7705e989372f7e30fbec6a15d86b3d9669939a444ea71b2 |
|
MD5 | 2f8734f0ba182323ed8336e31d549ca1 |
|
BLAKE2b-256 | 3b47e296fbe9b2a3ad5e6e42af2f156d6b73a9f3b6f8265d4fe7ccf1c7aefdd7 |
Hashes for pygoss-0.3.13-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c84c8dd2fe71cac604f025aeb8d6eb3a8aa50b8449c41fcc862b8de89459ceb |
|
MD5 | 8ecaa5fcfb03d589a5d3c5b5442db08c |
|
BLAKE2b-256 | 4d3bb71ea063741ecb8b157f3c57c01b8fae89958cd32061eb8a32a744a9c61d |
Hashes for pygoss-0.3.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 706304b4822296bf47746a39f0af2ba62690dd80f3ebccba57f83d3bc9856d90 |
|
MD5 | c1776a4f1a848a5b24a51bb019c58d04 |
|
BLAKE2b-256 | a854f1acda80eda34f024db1da8e232f0d5f1f0102f377e03603e7c9c7a1d0c4 |
Hashes for pygoss-0.3.13-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab073160743951234b791ee3820ca468870b66b6c26c421a9345259258f4066 |
|
MD5 | b6c7b53ca6e2015bc2cc45edc9fd0e26 |
|
BLAKE2b-256 | 722a48fbefc2a6befbf1950f96b63b43d060c62f558de67c1458c97d507efdb0 |
Hashes for pygoss-0.3.13-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bae38f83590ef90c8e60c904aea15f1cc8296e846e189313a04c9ef0aaee4954 |
|
MD5 | a46484bff4b4883d4249007a1f91e8c6 |
|
BLAKE2b-256 | 38ba593de7bbf01c41f7f1075555c1463ab5c0683323693671910cebfc39a74b |
Hashes for pygoss-0.3.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82ce155371c73099f60406e88696b1b5d3774c56cc657e14353a97f13051a7f4 |
|
MD5 | cc1892788baab6857c03af847c797b03 |
|
BLAKE2b-256 | 82d3982c00bb418125e50df3167de5ebf3f922e90a39cf69d5a344474758c6a9 |
Hashes for pygoss-0.3.13-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb2cc4428d62d61087eddc7931cd04e6381a1a1afa7d2685f0c397e01273b8c0 |
|
MD5 | f1a64978f10cde8c1cb6de21767730fe |
|
BLAKE2b-256 | fcba2d113bbb8db069f75068e3c1487f8e5b3b01777ae6f1f54037af38a7ddfc |
Hashes for pygoss-0.3.13-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f5c9a8455b7787c583212c6e677d49375b46d06b11f26de6ee871902329e489 |
|
MD5 | 32ba65cfbc0ea17704fb4db45e33ccf2 |
|
BLAKE2b-256 | 2e3d491133ee6f320897566af7937b74edfe299d6b24d91039a8c4091d906bb1 |
Hashes for pygoss-0.3.13-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2f1df21cd2d22229a6f7a625361aa75ff6a61f42e3f99cbae3ee2aa49a1a751 |
|
MD5 | 453b9553f9f91e0933f1b96d7b7bc7ad |
|
BLAKE2b-256 | a70f8f26691814f3eeaeebf6b3c1427b2b49422f389654fc30258054916bc7ae |
Hashes for pygoss-0.3.13-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f235dbc66942cba6e257d497c100490a80017ab3fa73092e9211672a98c651e |
|
MD5 | 2a416e5f2e0157105b1de3955f6c7063 |
|
BLAKE2b-256 | 6cc1f2b997494d3289123cf062a28b773dec2d488987a8bb19a507d9b8dbed2c |