mxlpy-native 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/MANIFEST.in +1 -0
- {mxlpy_native-0.3.0/src/mxlpy_native.egg-info → mxlpy_native-0.4.0}/PKG-INFO +15 -3
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/README.md +11 -1
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/mxn_solvers.c +79 -4
- mxlpy_native-0.4.0/c/vendor/SUNDIALS-LICENCE.txt +31 -0
- mxlpy_native-0.4.0/c/vendor/SUNDIALS-NOTICE.txt +21 -0
- mxlpy_native-0.4.0/c/vendor/VENDORED +92 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode.h +269 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode_diag.h +63 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode_ls.h +134 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/cvode/cvode_proj.h +60 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/nvector/nvector_serial.h +292 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/priv/sundials_context_impl.h +49 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/priv/sundials_errors_impl.h +561 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/priv/sundials_logger_macros.h +136 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_adaptcontroller.h +206 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_adjointcheckpointscheme.h +124 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_adjointstepper.h +84 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_band.h +197 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_config.h +106 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_context.h +71 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_core.h +45 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_dense.h +237 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_direct.h +369 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_domeigestimator.h +156 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_errors.h +133 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_export.h +51 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_futils.h +50 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_iterative.h +485 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_linearsolver.h +252 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_logger.h +120 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_math.h +353 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_matrix.h +169 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_memory.h +187 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_nonlinearsolver.h +248 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_nvector.h +363 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_nvector_senswrapper.h +109 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_profiler.h +105 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_stepper.h +178 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_types.h +284 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sundials/sundials_version.h +44 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sunlinsol/sunlinsol_dense.h +96 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sunmatrix/sunmatrix_band.h +138 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sunmatrix/sunmatrix_dense.h +116 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sunmatrix/sunmatrix_sparse.h +198 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sunnonlinsol/sunnonlinsol_fixedpoint.h +159 -0
- mxlpy_native-0.4.0/c/vendor/sundials/include/sunnonlinsol/sunnonlinsol_newton.h +154 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode.c +5003 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_diag_impl.h +72 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_fused_stubs.c +163 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_impl.h +800 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_io.c +1841 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_ls.c +1976 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_ls_impl.h +202 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_nls.c +490 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_proj.c +456 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/cvode/cvode_proj_impl.h +78 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/nvector/serial/nvector_serial.c +2053 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/stl/sunstl_vector.h +300 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_adiak_metadata.h +152 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_band.c +276 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_context.c +313 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_debug.h +54 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_dense.c +415 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_errors.c +164 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_futils.c +58 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_hashmap_impl.h +87 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_linearsolver.c +345 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_logger.c +625 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_logger_impl.h +167 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_macros.h +44 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_math.c +95 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_matrix.c +250 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_memory.c +262 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_nonlinearsolver.c +391 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_nvector.c +1132 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_nvector_senswrapper.c +569 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_utils.h +146 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sundials/sundials_version.c +64 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sunlinsol/dense/sunlinsol_dense.c +225 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sunmatrix/band/sunmatrix_band.c +539 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sunmatrix/dense/sunmatrix_dense.c +413 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +872 -0
- mxlpy_native-0.4.0/c/vendor/sundials/src/sunnonlinsol/newton/sunnonlinsol_newton.c +544 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/pyproject.toml +3 -3
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/setup.py +9 -2
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/src/mxlpy_native/__init__.py +1 -1
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0/src/mxlpy_native.egg-info}/PKG-INFO +15 -3
- mxlpy_native-0.4.0/src/mxlpy_native.egg-info/SOURCES.txt +107 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/tests/test_solvers.py +5 -2
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/tests/test_vendor.py +3 -3
- mxlpy_native-0.3.0/c/vendor/VENDORED +0 -13
- mxlpy_native-0.3.0/src/mxlpy_native.egg-info/SOURCES.txt +0 -28
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/LICENSE +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/HAIRER-LICENCE.txt +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/SCIPY-LICENCE.txt +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/blaslapack_declarations.h +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/dc_decsol.c +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/decsol.c +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/f2c.h +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/libf2c_stubs.c +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/lsoda.c +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/lsoda.h +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/mxs_lapack.c +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/c/vendor/radau5.c +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/setup.cfg +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/src/mxlpy_native/__main__.py +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/src/mxlpy_native.egg-info/dependency_links.txt +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/src/mxlpy_native.egg-info/requires.txt +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/src/mxlpy_native.egg-info/top_level.txt +0 -0
- {mxlpy_native-0.3.0 → mxlpy_native-0.4.0}/tests/test_build_errors.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mxlpy-native
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Compiled ODE solvers for MxlPy's Native integrator
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Compiled ODE solvers (RADAU5, LSODA, SUNDIALS CVODE) for MxlPy's Native integrator
|
|
5
5
|
Author-email: Marvin van Aalst <marvin.vanaalst@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/Computational-Biology-Aachen/mxlpy-native
|
|
@@ -17,17 +17,29 @@ Description-Content-Type: text/markdown
|
|
|
17
17
|
License-File: LICENSE
|
|
18
18
|
License-File: c/vendor/HAIRER-LICENCE.txt
|
|
19
19
|
License-File: c/vendor/SCIPY-LICENCE.txt
|
|
20
|
+
License-File: c/vendor/SUNDIALS-LICENCE.txt
|
|
21
|
+
License-File: c/vendor/SUNDIALS-NOTICE.txt
|
|
20
22
|
Requires-Dist: llvmlite>=0.45
|
|
21
23
|
Dynamic: license-file
|
|
22
24
|
|
|
23
25
|
# mxlpy-native
|
|
24
26
|
|
|
25
|
-
The compiled Radau and
|
|
27
|
+
The compiled Radau, LSODA and CVODE solvers behind [MxlPy](https://github.com/Computational-Biology-Aachen/MxlPy)'s `Native` integrator, plus `llvmlite`, which compiles models to machine code for them. Install it through MxlPy rather than on its own:
|
|
26
28
|
|
|
27
29
|
```bash
|
|
28
30
|
pip install "mxlpy[native]"
|
|
29
31
|
```
|
|
30
32
|
|
|
33
|
+
## Solvers and licences
|
|
34
|
+
|
|
35
|
+
| Solver | Origin | Licence |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| RADAU5 | E. Hairer and G. Wanner, via f2c | `c/vendor/HAIRER-LICENCE.txt` |
|
|
38
|
+
| LSODA | SciPy's C translation of ODEPACK | `c/vendor/SCIPY-LICENCE.txt` |
|
|
39
|
+
| CVODE (BDF and Adams) | [SUNDIALS](https://github.com/LLNL/sundials) v7.9.0, © Lawrence Livermore National Security and the SUNDIALS contributors | `c/vendor/SUNDIALS-LICENCE.txt` (BSD-3-Clause), `c/vendor/SUNDIALS-NOTICE.txt` |
|
|
40
|
+
|
|
41
|
+
All three are vendored from [mxl-solvers](https://github.com/Computational-Biology-Aachen/mxl-solvers), whose README lists the papers to cite for SUNDIALS. The licence files ship in every wheel.
|
|
42
|
+
|
|
31
43
|
## Platforms
|
|
32
44
|
|
|
33
45
|
Wheels are published for Linux (x86_64, aarch64; glibc 2.28+), macOS (arm64, 12+) and Windows (amd64, arm64), the platforms `llvmlite` has wheels for. On anything else, `mxlpy[native]` installs the WASM backend (`wasmtime`) instead, which runs the same solvers without a compiler, a little slower.
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# mxlpy-native
|
|
2
2
|
|
|
3
|
-
The compiled Radau and
|
|
3
|
+
The compiled Radau, LSODA and CVODE solvers behind [MxlPy](https://github.com/Computational-Biology-Aachen/MxlPy)'s `Native` integrator, plus `llvmlite`, which compiles models to machine code for them. Install it through MxlPy rather than on its own:
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
pip install "mxlpy[native]"
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
## Solvers and licences
|
|
10
|
+
|
|
11
|
+
| Solver | Origin | Licence |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| RADAU5 | E. Hairer and G. Wanner, via f2c | `c/vendor/HAIRER-LICENCE.txt` |
|
|
14
|
+
| LSODA | SciPy's C translation of ODEPACK | `c/vendor/SCIPY-LICENCE.txt` |
|
|
15
|
+
| CVODE (BDF and Adams) | [SUNDIALS](https://github.com/LLNL/sundials) v7.9.0, © Lawrence Livermore National Security and the SUNDIALS contributors | `c/vendor/SUNDIALS-LICENCE.txt` (BSD-3-Clause), `c/vendor/SUNDIALS-NOTICE.txt` |
|
|
16
|
+
|
|
17
|
+
All three are vendored from [mxl-solvers](https://github.com/Computational-Biology-Aachen/mxl-solvers), whose README lists the papers to cite for SUNDIALS. The licence files ship in every wheel.
|
|
18
|
+
|
|
9
19
|
## Platforms
|
|
10
20
|
|
|
11
21
|
Wheels are published for Linux (x86_64, aarch64; glibc 2.28+), macOS (arm64, 12+) and Windows (amd64, arm64), the platforms `llvmlite` has wheels for. On anything else, `mxlpy[native]` installs the WASM backend (`wasmtime`) instead, which runs the same solvers without a compiler, a little slower.
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
/* RADAU5 and
|
|
2
|
-
* points. The same source builds the native wheel and solvers.wasm. The solvers
|
|
3
|
-
* themselves are vendored from mxl-solvers (see vendor/VENDORED)
|
|
1
|
+
/* RADAU5, LSODA and CVODE for MxlPy's Native integrator, returning values at requested
|
|
2
|
+
* time points. The same source builds the native wheel and solvers.wasm. The solvers
|
|
3
|
+
* themselves are vendored from mxl-solvers (see vendor/VENDORED); CVODE is SUNDIALS'
|
|
4
|
+
* (vendor/sundials, BSD-3-Clause, see vendor/SUNDIALS-LICENCE.txt). RADAU5 and this
|
|
4
5
|
* file keep global state, so only one solve can run at a time in a process. */
|
|
5
6
|
#include "f2c.h"
|
|
6
7
|
#include "lsoda.h"
|
|
8
|
+
#include <cvode/cvode.h>
|
|
9
|
+
#include <nvector/nvector_serial.h>
|
|
10
|
+
#include <sunlinsol/sunlinsol_dense.h>
|
|
11
|
+
#include <sunmatrix/sunmatrix_dense.h>
|
|
12
|
+
#include <sunnonlinsol/sunnonlinsol_fixedpoint.h>
|
|
7
13
|
#include <math.h>
|
|
8
14
|
#include <stdint.h>
|
|
9
15
|
#include <stdlib.h>
|
|
@@ -17,7 +23,7 @@
|
|
|
17
23
|
|
|
18
24
|
/* Bump whenever an exported signature or its meaning changes, together with ABI_VERSION
|
|
19
25
|
* in mxlpy_native/__init__.py and the version MxlPy's Native integrator expects. */
|
|
20
|
-
#define MXN_ABI_VERSION
|
|
26
|
+
#define MXN_ABI_VERSION 2
|
|
21
27
|
MXN_API int mxn_abi_version(void) { return MXN_ABI_VERSION; }
|
|
22
28
|
|
|
23
29
|
extern int radau5_(integer *n, U_fp fcn, doublereal *x, doublereal *y, doublereal *xend, doublereal *h,
|
|
@@ -152,6 +158,75 @@ MXN_API int mxn_lsoda(int n, double *y, double *pars, double rtol, double atol,
|
|
|
152
158
|
return 2;
|
|
153
159
|
}
|
|
154
160
|
|
|
161
|
+
static int cvode_rhs(sunrealtype t, N_Vector y, N_Vector dydt, void *user_data) {
|
|
162
|
+
(void)user_data;
|
|
163
|
+
int n = (int)N_VGetLength(y);
|
|
164
|
+
double *f = N_VGetArrayPointer(dydt);
|
|
165
|
+
g_model(n, t, N_VGetArrayPointer(y), f, g_pars);
|
|
166
|
+
for (int i = 0; i < n; i++) {
|
|
167
|
+
if (!isfinite(f[i])) return 1; /* recoverable: CVODE retries with a smaller step */
|
|
168
|
+
}
|
|
169
|
+
return 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* Same contract as mxn_lsoda, with SUNDIALS' CVODE: BDF with Newton iteration and a dense
|
|
173
|
+
* difference-quotient Jacobian, or with adams != 0, Adams-Moulton with fixed-point
|
|
174
|
+
* iteration. nmax caps the total number of steps. Returns 1 on success, or CVODE's
|
|
175
|
+
* negative flag: -1 too many steps, -2 too much accuracy requested, -3 repeated error
|
|
176
|
+
* test failures, -4 repeated convergence failures, -8 the right-hand side kept failing
|
|
177
|
+
* (non-finite), -22 bad input, ... (see cvode.h). Returns -99 if allocation fails or the
|
|
178
|
+
* result isn't finite. */
|
|
179
|
+
MXN_API int mxn_cvode(int n, double *y, double *pars, double rtol, double atol, int nmax, int adams, int n_out,
|
|
180
|
+
const double *t_out, double *y_out) {
|
|
181
|
+
SUNContext ctx = NULL;
|
|
182
|
+
if (SUNContext_Create(SUN_COMM_NULL, &ctx) != 0) return -99;
|
|
183
|
+
N_Vector v = N_VMake_Serial(n, y, ctx); /* works on y in place */
|
|
184
|
+
void *mem = CVodeCreate(adams ? CV_ADAMS : CV_BDF, ctx);
|
|
185
|
+
SUNMatrix A = NULL;
|
|
186
|
+
SUNLinearSolver ls = NULL;
|
|
187
|
+
SUNNonlinearSolver nls = NULL;
|
|
188
|
+
int flag = (v && mem) ? CV_SUCCESS : -99;
|
|
189
|
+
g_pars = pars;
|
|
190
|
+
if (flag == CV_SUCCESS) flag = CVodeInit(mem, cvode_rhs, t_out[0], v);
|
|
191
|
+
if (flag == CV_SUCCESS) flag = CVodeSStolerances(mem, rtol, atol);
|
|
192
|
+
/* Never step past the last output time: models needn't be defined beyond it. */
|
|
193
|
+
if (flag == CV_SUCCESS) flag = CVodeSetStopTime(mem, t_out[n_out - 1]);
|
|
194
|
+
if (flag == CV_SUCCESS && adams) {
|
|
195
|
+
nls = SUNNonlinSol_FixedPoint(v, 0, ctx);
|
|
196
|
+
flag = nls ? CVodeSetNonlinearSolver(mem, nls) : -99;
|
|
197
|
+
} else if (flag == CV_SUCCESS) {
|
|
198
|
+
A = SUNDenseMatrix(n, n, ctx);
|
|
199
|
+
ls = A ? SUNLinSol_Dense(v, A, ctx) : NULL;
|
|
200
|
+
flag = ls ? CVodeSetLinearSolver(mem, ls, A) : -99;
|
|
201
|
+
}
|
|
202
|
+
memcpy(y_out, y, (size_t)n * sizeof(double));
|
|
203
|
+
double t = t_out[0];
|
|
204
|
+
for (int k = 1; k < n_out && flag >= 0; k++) {
|
|
205
|
+
if (t_out[k] != t_out[k - 1]) {
|
|
206
|
+
long int steps = 0;
|
|
207
|
+
CVodeGetNumSteps(mem, &steps);
|
|
208
|
+
if (steps >= nmax) {
|
|
209
|
+
flag = CV_TOO_MUCH_WORK;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
CVodeSetMaxNumSteps(mem, nmax - steps);
|
|
213
|
+
flag = CVode(mem, t_out[k], v, &t, CV_NORMAL);
|
|
214
|
+
}
|
|
215
|
+
if (flag >= 0) memcpy(y_out + (size_t)k * (size_t)n, y, (size_t)n * sizeof(double));
|
|
216
|
+
}
|
|
217
|
+
CVodeFree(&mem);
|
|
218
|
+
SUNNonlinSolFree(nls);
|
|
219
|
+
SUNLinSolFree(ls);
|
|
220
|
+
SUNMatDestroy(A);
|
|
221
|
+
N_VDestroy(v);
|
|
222
|
+
SUNContext_Free(&ctx);
|
|
223
|
+
if (flag < 0) return flag;
|
|
224
|
+
for (int i = 0; i < n; i++) {
|
|
225
|
+
if (!isfinite(y[i])) return -99;
|
|
226
|
+
}
|
|
227
|
+
return 1;
|
|
228
|
+
}
|
|
229
|
+
|
|
155
230
|
/* Evaluates fn once per row of y, writing n_out values per row into out. */
|
|
156
231
|
MXN_API void mxn_eval_rows(intptr_t fn, int n, int n_out, int rows, const double *t, double *y, double *out,
|
|
157
232
|
double *pars) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026, Lawrence Livermore National Security, University of Maryland Baltimore County, and the SUNDIALS contributors.
|
|
4
|
+
Copyright (c) 2013-2025, Lawrence Livermore National Security and Southern Methodist University.
|
|
5
|
+
Copyright (c) 2002-2013, Lawrence Livermore National Security.
|
|
6
|
+
All rights reserved.
|
|
7
|
+
|
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
|
10
|
+
|
|
11
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
12
|
+
list of conditions and the following disclaimer.
|
|
13
|
+
|
|
14
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
15
|
+
this list of conditions and the following disclaimer in the documentation
|
|
16
|
+
and/or other materials provided with the distribution.
|
|
17
|
+
|
|
18
|
+
* Neither the name of the copyright holder nor the names of its
|
|
19
|
+
contributors may be used to endorse or promote products derived from
|
|
20
|
+
this software without specific prior written permission.
|
|
21
|
+
|
|
22
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
23
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
24
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
25
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
26
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
27
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
28
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
29
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
30
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
This work was produced under the auspices of the U.S. Department of
|
|
2
|
+
Energy by Lawrence Livermore National Laboratory under Contract
|
|
3
|
+
DE-AC52-07NA27344.
|
|
4
|
+
|
|
5
|
+
This work was prepared as an account of work sponsored by an agency of
|
|
6
|
+
the United States Government. Neither the United States Government nor
|
|
7
|
+
Lawrence Livermore National Security, LLC, nor any of their employees
|
|
8
|
+
makes any warranty, expressed or implied, or assumes any legal liability
|
|
9
|
+
or responsibility for the accuracy, completeness, or usefulness of any
|
|
10
|
+
information, apparatus, product, or process disclosed, or represents that
|
|
11
|
+
its use would not infringe privately owned rights.
|
|
12
|
+
|
|
13
|
+
Reference herein to any specific commercial product, process, or service
|
|
14
|
+
by trade name, trademark, manufacturer, or otherwise does not necessarily
|
|
15
|
+
constitute or imply its endorsement, recommendation, or favoring by the
|
|
16
|
+
United States Government or Lawrence Livermore National Security, LLC.
|
|
17
|
+
|
|
18
|
+
The views and opinions of authors expressed herein do not necessarily
|
|
19
|
+
state or reflect those of the United States Government or Lawrence
|
|
20
|
+
Livermore National Security, LLC, and shall not be used for advertising
|
|
21
|
+
or product endorsement purposes.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Vendored from https://github.com/Computational-Biology-Aachen/mxl-solvers at 6f3cc88e60510bae954d20e97fe4435bba3c6a1c.
|
|
2
|
+
# Don't edit these files here: change mxl-solvers, then re-run its scripts/vendor.sh.
|
|
3
|
+
da5d9b896c422aa002b6d8fc3c7003a6e6345454afd700ae65fa3cd944ab12e5 radau5.c
|
|
4
|
+
8d2173c6ae898e77a71c2dc52e027ce2b6185d91170bd5f031b185aff6e1d354 dc_decsol.c
|
|
5
|
+
9dc2c0ede63b1511813fbde4300c23a6c1e0536e4d316c6fd5492ae0f20d8195 decsol.c
|
|
6
|
+
cf5d31866e63553809a79416b6baa957be45e3c03a5da59254fbbb317c735cfc f2c.h
|
|
7
|
+
5ab404a0cbf7e02c21105b9f8322cb65ef78e10f40937740a9cc90b36796b8b8 libf2c_stubs.c
|
|
8
|
+
2f05643511057c06ceed0d8a1d7181857f93a759a60139d7506a4b6123654ac7 lsoda.c
|
|
9
|
+
751d5aa397f303b491d78f689dbf5b779f32b2d158b58c2b861d58143702e1f9 lsoda.h
|
|
10
|
+
8076d5b1bd27484ce6214cc5f9df7d6c88225182498538c9a878ed14d1743836 blaslapack_declarations.h
|
|
11
|
+
c615cf28e6d41f150f631d0b7fa73f6b2d8b694a88818a38851f54b0efec042c mxs_lapack.c
|
|
12
|
+
0e9a5c3ba2637f05909967c3eeeac9c7b9a4a4c6e92801a408afd2aa725024e2 sundials/include/cvode/cvode.h
|
|
13
|
+
adb1e5836989c630b595b14c0fa213426ddbfd3a87d14b581a470d5272b5881b sundials/include/cvode/cvode_diag.h
|
|
14
|
+
84dfab497850c933b8020cc0b2236a2e85bfe5fceffe4b5aefc8a1b518dd68a3 sundials/include/cvode/cvode_ls.h
|
|
15
|
+
86a439a57e9fbc1990a3167592a5417806b3f0c11a33e0008ce907386ffe4634 sundials/include/cvode/cvode_proj.h
|
|
16
|
+
1d506e67d5db4438b6ef0d814c22efc99edde53ef4b37ea507d12bef2c08001f sundials/include/nvector/nvector_serial.h
|
|
17
|
+
79ed44b5c1236088bcc878e1de5084664dc4a1b3ee153094b5da81f263906fc6 sundials/include/sundials/priv/sundials_context_impl.h
|
|
18
|
+
f534d085757203cfea2da292fdc631076b96fc73dc12bb0a96d8a3b186828af4 sundials/include/sundials/priv/sundials_errors_impl.h
|
|
19
|
+
7d19b2c96f357b7f4f3a815a8f51f317af8ad87bfd4e79e87e94d37ac134a69d sundials/include/sundials/priv/sundials_logger_macros.h
|
|
20
|
+
bf5493735899a4cc63162d64a2f374474efe7febf556b2477f6799ee2560d759 sundials/include/sundials/sundials_adaptcontroller.h
|
|
21
|
+
4db307e54511800c8c1a0418ffaa85c81f1f73a6c98d10d510d1aa57686f45f0 sundials/include/sundials/sundials_adjointcheckpointscheme.h
|
|
22
|
+
37bca6199a4fa9a4f7639ff72af47284c44277b437b5074cc26b50765d4f4d6c sundials/include/sundials/sundials_adjointstepper.h
|
|
23
|
+
ed847fda53456b56ad2cf3523371281b510687739a6d2246285f78cf2ac24cb6 sundials/include/sundials/sundials_band.h
|
|
24
|
+
c191637b3470b5cf068cc527c0de5966364cdcbb9a4df7418a1cfee619906e0d sundials/include/sundials/sundials_config.h
|
|
25
|
+
20d24a8a49fa27f45d2e9f3fe89269096b5b80d9fc0c924eb3592fe6e16d6f10 sundials/include/sundials/sundials_context.h
|
|
26
|
+
b57c39d153ba0d23b26401bcdeac3fe0f123a5ee756652bb844b57d567ca4c65 sundials/include/sundials/sundials_core.h
|
|
27
|
+
3779aab4236405ffeb3df4bb91dd2c7c640d691bf67753d97f8487c17aa1775d sundials/include/sundials/sundials_dense.h
|
|
28
|
+
080a893fcf9ba48008172ac2b27e6a5a6dd07a747c3512aefb3ede3f6d0af389 sundials/include/sundials/sundials_direct.h
|
|
29
|
+
d31cbeb674e221925e7028ef4b40270075a5685d2f1708d90629090e863cdbb6 sundials/include/sundials/sundials_domeigestimator.h
|
|
30
|
+
2b7f3d812009bbc19ec47c21e2eec18a36f0b76efa55dda9c0cd331fa4559e38 sundials/include/sundials/sundials_errors.h
|
|
31
|
+
51a9fb7365677b78dbf3ff7f5737500d309217f1ea3308a6b7098866d6d56fca sundials/include/sundials/sundials_export.h
|
|
32
|
+
da1f5c38312951c2b8f3c5d8101eda2b37a8390032d85144b948aa424632df6b sundials/include/sundials/sundials_futils.h
|
|
33
|
+
9497398cc6e5b41e304374e9799efe81cd8de6e0691f96b6f7ef39c98f19e1d1 sundials/include/sundials/sundials_iterative.h
|
|
34
|
+
5014b4ac0e5ba295215cda7a8df979a87d5d9e19ee8d9d124f203091d7127fbf sundials/include/sundials/sundials_linearsolver.h
|
|
35
|
+
253a57a0f38229057c50418358788549739eed3fe465f85e179ce56a5ea6fdbc sundials/include/sundials/sundials_logger.h
|
|
36
|
+
4f1d6030e6c942bf5b8af93f82184b8931549ab60b8a16301afc7b2e98e52d20 sundials/include/sundials/sundials_math.h
|
|
37
|
+
3921cfbd55c674f56dbdd3d138cdf42df8724fbf6cdcc8dd707f03608966dd86 sundials/include/sundials/sundials_matrix.h
|
|
38
|
+
03d73b7660b6eaeb11c30ac3abc0bf9d347199f68d699e9cd47a29eb54bdc655 sundials/include/sundials/sundials_memory.h
|
|
39
|
+
0bb0f46e0430df2a43ec92a522d8a43aeb602edae9295bbbb0e78e3156d67bbb sundials/include/sundials/sundials_nonlinearsolver.h
|
|
40
|
+
ce10747b53a8e63e4e9db4dcb9d6f6c6b3ff042d8b8e8497f0e69726c851193a sundials/include/sundials/sundials_nvector.h
|
|
41
|
+
5b8ae9158c438f5272bd475514389c5793023a1d18021e8bd8da9f1952b6f08e sundials/include/sundials/sundials_nvector_senswrapper.h
|
|
42
|
+
430352c17759d4719c4e8348849eb6750b7ef3dcdef63e5c3964aa076e515269 sundials/include/sundials/sundials_profiler.h
|
|
43
|
+
e9b443699bf8a01366eb7e21e9f009c4b1510d6144626afc94a31ade35d154ec sundials/include/sundials/sundials_stepper.h
|
|
44
|
+
e0fc8e9fc04ef756f6d148a70a0b223c2fdb769a6cc67b31c3a3f0091492fff6 sundials/include/sundials/sundials_types.h
|
|
45
|
+
203a1833d06ca499575fb8038f58e98e6f5585e0fad6f3d15c910af80b345fcd sundials/include/sundials/sundials_version.h
|
|
46
|
+
018f2430dd2965a9184b20822adcd4518099278f89c367ffe1f59a6db6e5e78a sundials/include/sunlinsol/sunlinsol_dense.h
|
|
47
|
+
6f096a67d7609c6617d6ec9eed79da95b0ede921a9fe631301149c0c241eba0e sundials/include/sunmatrix/sunmatrix_band.h
|
|
48
|
+
b1835f8bd9eecc879653d78782602123ca62b12fad1861f4c1973cadae2ec492 sundials/include/sunmatrix/sunmatrix_dense.h
|
|
49
|
+
76306ea569f779f18a1a79f82a27e6422db37e9bee0953099e65ec73095d109d sundials/include/sunmatrix/sunmatrix_sparse.h
|
|
50
|
+
18afbd9ff9fd2a3ba9bbaecbb029250ec462571fa52f5562fa4f90255eba68af sundials/include/sunnonlinsol/sunnonlinsol_fixedpoint.h
|
|
51
|
+
ed507a3bb80066f07a267fdfe6e1af050b75dc896202585be69dcf8c8426761f sundials/include/sunnonlinsol/sunnonlinsol_newton.h
|
|
52
|
+
7590f4ec73215229be22479b3af8856395232191985eff364e30709aebe2322a sundials/src/cvode/cvode.c
|
|
53
|
+
8a803cbdd874d462e4f8f1bebacea3e5aebed7b8cdc02dd94eaddc8637dcdee4 sundials/src/cvode/cvode_diag_impl.h
|
|
54
|
+
33781c0673da6318a75b8577fe6d9f98800c6adcfff497ceeb15c9d8f95ef2d7 sundials/src/cvode/cvode_fused_stubs.c
|
|
55
|
+
d22ef38c930b247dfaefc1d921ad3444f629a521998f0697c0227b29841da87d sundials/src/cvode/cvode_impl.h
|
|
56
|
+
e8fbe1785079b69f42c8d8c449c800512ab3a31f3c79f3226c7580283788b789 sundials/src/cvode/cvode_io.c
|
|
57
|
+
31b16188b4257930832aeb5a4984d4fcebcb050c30cadf01603d63eb1ce07240 sundials/src/cvode/cvode_ls.c
|
|
58
|
+
1c151437138df09b3b3f6d36be2453f068bfc5e04c05cc757152d85a0ff9a026 sundials/src/cvode/cvode_ls_impl.h
|
|
59
|
+
2cbe80dfeb66adf0a10fae045ac8a1f44d161e50afe36a10de9765cfbd57b07d sundials/src/cvode/cvode_nls.c
|
|
60
|
+
2e1d255c02d8c18fd7f9f6e56070fcd199acf3ed233e485c9767c0a574ffe0f5 sundials/src/cvode/cvode_proj.c
|
|
61
|
+
084e96897f8188dbf5f8dd793865bc9a01884879f9b5e79cbfc7d75eeb7539cc sundials/src/cvode/cvode_proj_impl.h
|
|
62
|
+
73bbdef0bc605a2afd9aded688ae421f7b8deb285bfa4122040182e26c4615d9 sundials/src/nvector/serial/nvector_serial.c
|
|
63
|
+
d88e0e15aa60f7ac7379d15c869fa1a2f38d732afed89a9a448bf7a564a7a606 sundials/src/sundials/stl/sunstl_vector.h
|
|
64
|
+
2fb830b870a1d53f7f26355f20737b74e4124aaa6cb96a03137cffd84a20dc58 sundials/src/sundials/sundials_adiak_metadata.h
|
|
65
|
+
654e4100b6c9a41d7a4d69f3dfc9f858ffdeb9fb031119308555dbb625877e69 sundials/src/sundials/sundials_band.c
|
|
66
|
+
a753c7b3b862bf6f68ad7d47a6bfbf3ecd41feca645c2bca79f9d8eea646361a sundials/src/sundials/sundials_context.c
|
|
67
|
+
f8fcf707e6d875ed4c52c804374f5f31bc320d0060e20b1bfacbf768c9475ce5 sundials/src/sundials/sundials_debug.h
|
|
68
|
+
da668d7469df705811a49a5b50b24c8a8969abcd3894f554a301b7a58f8add06 sundials/src/sundials/sundials_dense.c
|
|
69
|
+
055a45d2156d36fe3976f9e1b8e53c4a22b8f5a74cd676c9cd301cef264f09d7 sundials/src/sundials/sundials_errors.c
|
|
70
|
+
beff39ff5ba7ec06613dea70833438fc98fb9f307473d6879fe004b54d9b88b2 sundials/src/sundials/sundials_futils.c
|
|
71
|
+
1e214df5bae719d5f22824484ba8324862295d9c3f773e187f38d1401b2ad5dd sundials/src/sundials/sundials_hashmap_impl.h
|
|
72
|
+
e3c74781f6faddcb3bca67cf7099aabba9d765fb6bd5880cc7f66adb0a931c9b sundials/src/sundials/sundials_linearsolver.c
|
|
73
|
+
580f6282419efdd3045af571eb17f75a15945ccb675fbc2bbf5e58481a8a3148 sundials/src/sundials/sundials_logger.c
|
|
74
|
+
a9297d70aaf8f32d96fb2a7eb5cba252d2a11434c5bf066bd089fd68761a3d16 sundials/src/sundials/sundials_logger_impl.h
|
|
75
|
+
a0aec9a25ea7ad2800b3ed8a079e4e0136179d693ee68d1beb5c5a001f5c4cba sundials/src/sundials/sundials_macros.h
|
|
76
|
+
73e9429f1f9efe7d3d59ba44b7e26b06f35b16d41b83bb04bd7a77a37cec2d26 sundials/src/sundials/sundials_math.c
|
|
77
|
+
be7d93993852c61dce7466b4849b2767400d10eaa174446482a20312f07c5f92 sundials/src/sundials/sundials_matrix.c
|
|
78
|
+
8bc7bdbcaaa5a96cb1de49ed21b9c2f83dd03f4e1f13308291171531f67d9d39 sundials/src/sundials/sundials_memory.c
|
|
79
|
+
e35bff8b6463a8300aa01053c21e2e0438bc63d23db55dfa28dcf4840db89c3a sundials/src/sundials/sundials_nonlinearsolver.c
|
|
80
|
+
289de7fa60d16e359f739a2905f854d138bead78d8d2fd5f234d8c8034f2fff5 sundials/src/sundials/sundials_nvector.c
|
|
81
|
+
bba2bb148b239b3abfdc46f165cd01dea656feb4bb4f6492d3155e598ce49639 sundials/src/sundials/sundials_nvector_senswrapper.c
|
|
82
|
+
b7c5bfbdde79abf9f9b37312d1a565799714e264d49a425ff9e843e9f644d448 sundials/src/sundials/sundials_utils.h
|
|
83
|
+
d8eb26aee21f2d370689e722eff9f65f5e6f71e23142fefafdb8ea2657657c6d sundials/src/sundials/sundials_version.c
|
|
84
|
+
3213ea349f4e64543dd66b3f20bfc7454481eabf7ad6f3ddb1d5505aeac3d10f sundials/src/sunlinsol/dense/sunlinsol_dense.c
|
|
85
|
+
280a4e54da0e3732fac6911f96d8a87c97e1183d5627338b6dd0ef46504af25f sundials/src/sunmatrix/band/sunmatrix_band.c
|
|
86
|
+
7418295ae120d40f3a139421c21b01e1fcbca74d8e717dc41088c7e9a854bcf2 sundials/src/sunmatrix/dense/sunmatrix_dense.c
|
|
87
|
+
acc17ac1685b3ef154387b62ec8fe8f2b93d634c820d59d04b6d044f5c73bd66 sundials/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c
|
|
88
|
+
6d642aea374abac22c30e718b75700aaa20e9aec818a76912ba5fdb48e8d8be6 sundials/src/sunnonlinsol/newton/sunnonlinsol_newton.c
|
|
89
|
+
49bcfad0e3bbe5c3a0428624254567f32786948332a3204fc1e35b8b2a02b0fd HAIRER-LICENCE.txt
|
|
90
|
+
221e59f5e910fd7f94e44f0dac77436a11338c285c6346232e4a850a50da0e94 SCIPY-LICENCE.txt
|
|
91
|
+
d83f244e1bef3d00a88d043d37d9cd2493c7aa19c9fbf35a837b310e867897a6 SUNDIALS-LICENCE.txt
|
|
92
|
+
5cb9c6b0ca7c09b26fe2d1f9ef45231086c9ea2cdb32eb5f9dce7012e2364bc2 SUNDIALS-NOTICE.txt
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/* -----------------------------------------------------------------
|
|
2
|
+
* Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
|
|
3
|
+
* and Dan Shumaker @ LLNL
|
|
4
|
+
* -----------------------------------------------------------------
|
|
5
|
+
* SUNDIALS Copyright Start
|
|
6
|
+
* Copyright (c) 2025-2026, Lawrence Livermore National Security,
|
|
7
|
+
* University of Maryland Baltimore County, and the SUNDIALS contributors.
|
|
8
|
+
* Copyright (c) 2013-2025, Lawrence Livermore National Security
|
|
9
|
+
* and Southern Methodist University.
|
|
10
|
+
* Copyright (c) 2002-2013, Lawrence Livermore National Security.
|
|
11
|
+
* All rights reserved.
|
|
12
|
+
*
|
|
13
|
+
* See the top-level LICENSE and NOTICE files for details.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
* SUNDIALS Copyright End
|
|
17
|
+
* -----------------------------------------------------------------
|
|
18
|
+
* This is the header file for the main CVODE integrator.
|
|
19
|
+
* -----------------------------------------------------------------*/
|
|
20
|
+
|
|
21
|
+
#ifndef _CVODE_H
|
|
22
|
+
#define _CVODE_H
|
|
23
|
+
|
|
24
|
+
#include <cvode/cvode_ls.h>
|
|
25
|
+
#include <cvode/cvode_proj.h>
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
#include <sundials/sundials_core.h>
|
|
28
|
+
|
|
29
|
+
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
|
30
|
+
extern "C" {
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
/* -----------------
|
|
34
|
+
* CVODE Constants
|
|
35
|
+
* ----------------- */
|
|
36
|
+
|
|
37
|
+
/* lmm */
|
|
38
|
+
#define CV_ADAMS 1
|
|
39
|
+
#define CV_BDF 2
|
|
40
|
+
|
|
41
|
+
/* itask */
|
|
42
|
+
#define CV_NORMAL 1
|
|
43
|
+
#define CV_ONE_STEP 2
|
|
44
|
+
|
|
45
|
+
/* return values */
|
|
46
|
+
|
|
47
|
+
#define CV_SUCCESS 0
|
|
48
|
+
#define CV_TSTOP_RETURN 1
|
|
49
|
+
#define CV_ROOT_RETURN 2
|
|
50
|
+
|
|
51
|
+
#define CV_WARNING 99
|
|
52
|
+
|
|
53
|
+
#define CV_TOO_MUCH_WORK -1
|
|
54
|
+
#define CV_TOO_MUCH_ACC -2
|
|
55
|
+
#define CV_ERR_FAILURE -3
|
|
56
|
+
#define CV_CONV_FAILURE -4
|
|
57
|
+
|
|
58
|
+
#define CV_LINIT_FAIL -5
|
|
59
|
+
#define CV_LSETUP_FAIL -6
|
|
60
|
+
#define CV_LSOLVE_FAIL -7
|
|
61
|
+
#define CV_RHSFUNC_FAIL -8
|
|
62
|
+
#define CV_FIRST_RHSFUNC_ERR -9
|
|
63
|
+
#define CV_REPTD_RHSFUNC_ERR -10
|
|
64
|
+
#define CV_UNREC_RHSFUNC_ERR -11
|
|
65
|
+
#define CV_RTFUNC_FAIL -12
|
|
66
|
+
#define CV_NLS_INIT_FAIL -13
|
|
67
|
+
#define CV_NLS_SETUP_FAIL -14
|
|
68
|
+
#define CV_CONSTR_FAIL -15
|
|
69
|
+
#define CV_NLS_FAIL -16
|
|
70
|
+
|
|
71
|
+
#define CV_MEM_FAIL -20
|
|
72
|
+
#define CV_MEM_NULL -21
|
|
73
|
+
#define CV_ILL_INPUT -22
|
|
74
|
+
#define CV_NO_MALLOC -23
|
|
75
|
+
#define CV_BAD_K -24
|
|
76
|
+
#define CV_BAD_T -25
|
|
77
|
+
#define CV_BAD_DKY -26
|
|
78
|
+
#define CV_TOO_CLOSE -27
|
|
79
|
+
#define CV_VECTOROP_ERR -28
|
|
80
|
+
|
|
81
|
+
#define CV_PROJ_MEM_NULL -29
|
|
82
|
+
#define CV_PROJFUNC_FAIL -30
|
|
83
|
+
#define CV_REPTD_PROJFUNC_ERR -31
|
|
84
|
+
|
|
85
|
+
#define CV_CONTEXT_ERR -32
|
|
86
|
+
|
|
87
|
+
#define CV_UNRECOGNIZED_ERR -99
|
|
88
|
+
|
|
89
|
+
/* ------------------------------
|
|
90
|
+
* User-Supplied Function Types
|
|
91
|
+
* ------------------------------ */
|
|
92
|
+
|
|
93
|
+
typedef int (*CVRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data);
|
|
94
|
+
|
|
95
|
+
typedef int (*CVRootFn)(sunrealtype t, N_Vector y, sunrealtype* gout_1d,
|
|
96
|
+
void* user_data);
|
|
97
|
+
|
|
98
|
+
typedef int (*CVEwtFn)(N_Vector y, N_Vector ewt, void* user_data);
|
|
99
|
+
|
|
100
|
+
/* DEPRECATION NOTICE: this will be removed in v8.0.0 */
|
|
101
|
+
typedef int (*CVMonitorFn)(void* cvode_mem, void* user_data);
|
|
102
|
+
|
|
103
|
+
/* -------------------
|
|
104
|
+
* Exported Functions
|
|
105
|
+
* ------------------- */
|
|
106
|
+
|
|
107
|
+
/* Initialization functions */
|
|
108
|
+
|
|
109
|
+
SUNDIALS_EXPORT void* CVodeCreate(int lmm, SUNContext sunctx);
|
|
110
|
+
|
|
111
|
+
SUNDIALS_EXPORT int CVodeInit(void* cvode_mem, CVRhsFn f, sunrealtype t0,
|
|
112
|
+
N_Vector y0);
|
|
113
|
+
SUNDIALS_EXPORT int CVodeReInit(void* cvode_mem, sunrealtype t0, N_Vector y0);
|
|
114
|
+
SUNDIALS_EXPORT int CVodeResizeHistory(void* cvode_mem, sunrealtype* t_hist_1d,
|
|
115
|
+
N_Vector* y_hist_1d, N_Vector* f_hist_1d,
|
|
116
|
+
int num_y_hist, int num_f_hist);
|
|
117
|
+
|
|
118
|
+
/* Tolerance input functions */
|
|
119
|
+
|
|
120
|
+
SUNDIALS_EXPORT int CVodeSStolerances(void* cvode_mem, sunrealtype reltol,
|
|
121
|
+
sunrealtype abstol);
|
|
122
|
+
SUNDIALS_EXPORT int CVodeSVtolerances(void* cvode_mem, sunrealtype reltol,
|
|
123
|
+
N_Vector abstol);
|
|
124
|
+
SUNDIALS_EXPORT int CVodeWFtolerances(void* cvode_mem, CVEwtFn efun);
|
|
125
|
+
|
|
126
|
+
/* Optional input functions */
|
|
127
|
+
|
|
128
|
+
SUNDIALS_EXPORT int CVodeSetOptions(void* cvode_mem, const char* cvid,
|
|
129
|
+
const char* file_name, int argc,
|
|
130
|
+
char* argv[]);
|
|
131
|
+
SUNDIALS_EXPORT int CVodeSetConstraints(void* cvode_mem, N_Vector constraints);
|
|
132
|
+
SUNDIALS_EXPORT int CVodeSetMaxNumConstraintFails(void* cvode_mem, int max_fails);
|
|
133
|
+
SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void* cvode_mem,
|
|
134
|
+
sunrealtype dgmax_lsetup);
|
|
135
|
+
SUNDIALS_EXPORT int CVodeSetInitStep(void* cvode_mem, sunrealtype hin);
|
|
136
|
+
SUNDIALS_EXPORT int CVodeSetLSetupFrequency(void* cvode_mem, long int msbp);
|
|
137
|
+
SUNDIALS_EXPORT int CVodeSetMaxConvFails(void* cvode_mem, int maxncf);
|
|
138
|
+
SUNDIALS_EXPORT int CVodeSetMaxErrTestFails(void* cvode_mem, int maxnef);
|
|
139
|
+
SUNDIALS_EXPORT int CVodeSetMaxHnilWarns(void* cvode_mem, int mxhnil);
|
|
140
|
+
SUNDIALS_EXPORT int CVodeSetMaxNonlinIters(void* cvode_mem, int maxcor);
|
|
141
|
+
SUNDIALS_EXPORT int CVodeSetMaxNumSteps(void* cvode_mem, long int mxsteps);
|
|
142
|
+
SUNDIALS_EXPORT int CVodeSetMaxOrd(void* cvode_mem, int maxord);
|
|
143
|
+
SUNDIALS_EXPORT int CVodeSetMaxStep(void* cvode_mem, sunrealtype hmax);
|
|
144
|
+
SUNDIALS_EXPORT int CVodeSetMinStep(void* cvode_mem, sunrealtype hmin);
|
|
145
|
+
SUNDIALS_DEPRECATED_EXPORT_MSG(
|
|
146
|
+
"Monitoring functions will be removed in version 8.0.0")
|
|
147
|
+
int CVodeSetMonitorFn(void* cvode_mem, CVMonitorFn fn);
|
|
148
|
+
SUNDIALS_DEPRECATED_EXPORT_MSG(
|
|
149
|
+
"Monitoring functions will be removed in version 8.0.0")
|
|
150
|
+
int CVodeSetMonitorFrequency(void* cvode_mem, long int nst);
|
|
151
|
+
SUNDIALS_EXPORT int CVodeSetNlsRhsFn(void* cvode_mem, CVRhsFn f);
|
|
152
|
+
SUNDIALS_EXPORT int CVodeSetNonlinConvCoef(void* cvode_mem, sunrealtype nlscoef);
|
|
153
|
+
SUNDIALS_EXPORT int CVodeSetNonlinearSolver(void* cvode_mem,
|
|
154
|
+
SUNNonlinearSolver NLS);
|
|
155
|
+
SUNDIALS_EXPORT int CVodeSetStabLimDet(void* cvode_mem, sunbooleantype stldet);
|
|
156
|
+
SUNDIALS_EXPORT int CVodeSetStopTime(void* cvode_mem, sunrealtype tstop);
|
|
157
|
+
SUNDIALS_EXPORT int CVodeSetInterpolateStopTime(void* cvode_mem,
|
|
158
|
+
sunbooleantype interp);
|
|
159
|
+
SUNDIALS_EXPORT int CVodeClearStopTime(void* cvode_mem);
|
|
160
|
+
SUNDIALS_EXPORT int CVodeSetUseIntegratorFusedKernels(void* cvode_mem,
|
|
161
|
+
sunbooleantype onoff);
|
|
162
|
+
SUNDIALS_EXPORT int CVodeSetUserData(void* cvode_mem, void* user_data);
|
|
163
|
+
|
|
164
|
+
/* Optional step adaptivity input functions */
|
|
165
|
+
|
|
166
|
+
SUNDIALS_EXPORT
|
|
167
|
+
int CVodeSetEtaFixedStepBounds(void* cvode_mem, sunrealtype eta_min_fx,
|
|
168
|
+
sunrealtype eta_max_fx);
|
|
169
|
+
SUNDIALS_EXPORT
|
|
170
|
+
int CVodeSetEtaMaxFirstStep(void* cvode_mem, sunrealtype eta_max_fs);
|
|
171
|
+
SUNDIALS_EXPORT
|
|
172
|
+
int CVodeSetEtaMaxEarlyStep(void* cvode_mem, sunrealtype eta_max_es);
|
|
173
|
+
SUNDIALS_EXPORT
|
|
174
|
+
int CVodeSetNumStepsEtaMaxEarlyStep(void* cvode_mem, long int small_nst);
|
|
175
|
+
SUNDIALS_EXPORT
|
|
176
|
+
int CVodeSetEtaMax(void* cvode_mem, sunrealtype eta_max_gs);
|
|
177
|
+
SUNDIALS_EXPORT
|
|
178
|
+
int CVodeSetEtaMin(void* cvode_mem, sunrealtype eta_min);
|
|
179
|
+
SUNDIALS_EXPORT
|
|
180
|
+
int CVodeSetEtaMinErrFail(void* cvode_mem, sunrealtype eta_min_ef);
|
|
181
|
+
SUNDIALS_EXPORT
|
|
182
|
+
int CVodeSetEtaMaxErrFail(void* cvode_mem, sunrealtype eta_max_ef);
|
|
183
|
+
SUNDIALS_EXPORT
|
|
184
|
+
int CVodeSetNumFailsEtaMaxErrFail(void* cvode_mem, int small_nef);
|
|
185
|
+
SUNDIALS_EXPORT
|
|
186
|
+
int CVodeSetEtaConvFail(void* cvode_mem, sunrealtype eta_cf);
|
|
187
|
+
|
|
188
|
+
/* Rootfinding initialization function */
|
|
189
|
+
SUNDIALS_EXPORT int CVodeRootInit(void* cvode_mem, int nrtfn, CVRootFn g);
|
|
190
|
+
|
|
191
|
+
/* Rootfinding optional input functions */
|
|
192
|
+
|
|
193
|
+
SUNDIALS_EXPORT int CVodeSetRootDirection(void* cvode_mem, int* rootdir_1d);
|
|
194
|
+
SUNDIALS_EXPORT int CVodeSetNoInactiveRootWarn(void* cvode_mem);
|
|
195
|
+
|
|
196
|
+
/* Solver function */
|
|
197
|
+
SUNDIALS_EXPORT int CVode(void* cvode_mem, sunrealtype tout, N_Vector yout,
|
|
198
|
+
sunrealtype* tret, int itask);
|
|
199
|
+
|
|
200
|
+
/* Utility functions to update/compute y based on ycor */
|
|
201
|
+
|
|
202
|
+
SUNDIALS_EXPORT int CVodeComputeState(void* cvode_mem, N_Vector ycor, N_Vector y);
|
|
203
|
+
|
|
204
|
+
/* Dense output function */
|
|
205
|
+
SUNDIALS_EXPORT int CVodeGetDky(void* cvode_mem, sunrealtype t, int k,
|
|
206
|
+
N_Vector dky);
|
|
207
|
+
|
|
208
|
+
/* Optional output functions */
|
|
209
|
+
|
|
210
|
+
SUNDIALS_DEPRECATED_EXPORT_MSG(
|
|
211
|
+
"Work space functions will be removed in version 8.0.0")
|
|
212
|
+
int CVodeGetWorkSpace(void* cvode_mem, long int* lenrw, long int* leniw);
|
|
213
|
+
SUNDIALS_EXPORT int CVodeGetNumSteps(void* cvode_mem, long int* nsteps);
|
|
214
|
+
SUNDIALS_EXPORT int CVodeGetNumRhsEvals(void* cvode_mem, long int* nfevals);
|
|
215
|
+
SUNDIALS_EXPORT int CVodeGetNumLinSolvSetups(void* cvode_mem,
|
|
216
|
+
long int* nlinsetups);
|
|
217
|
+
SUNDIALS_EXPORT int CVodeGetNumErrTestFails(void* cvode_mem, long int* netfails);
|
|
218
|
+
SUNDIALS_EXPORT int CVodeGetLastOrder(void* cvode_mem, int* qlast);
|
|
219
|
+
SUNDIALS_EXPORT int CVodeGetCurrentOrder(void* cvode_mem, int* qcur);
|
|
220
|
+
SUNDIALS_EXPORT int CVodeGetCurrentGamma(void* cvode_mem, sunrealtype* gamma);
|
|
221
|
+
SUNDIALS_EXPORT int CVodeGetNumStabLimOrderReds(void* cvode_mem,
|
|
222
|
+
long int* nslred);
|
|
223
|
+
SUNDIALS_EXPORT int CVodeGetActualInitStep(void* cvode_mem, sunrealtype* hinused);
|
|
224
|
+
SUNDIALS_EXPORT int CVodeGetLastStep(void* cvode_mem, sunrealtype* hlast);
|
|
225
|
+
SUNDIALS_EXPORT int CVodeGetCurrentStep(void* cvode_mem, sunrealtype* hcur);
|
|
226
|
+
SUNDIALS_EXPORT int CVodeGetCurrentState(void* cvode_mem,
|
|
227
|
+
N_Vector* y); // nb::rv_policy::reference
|
|
228
|
+
SUNDIALS_EXPORT int CVodeGetCurrentTime(void* cvode_mem, sunrealtype* tcur);
|
|
229
|
+
SUNDIALS_EXPORT int CVodeGetTolScaleFactor(void* cvode_mem, sunrealtype* tolsfac);
|
|
230
|
+
SUNDIALS_EXPORT int CVodeGetErrWeights(void* cvode_mem, N_Vector eweight);
|
|
231
|
+
SUNDIALS_EXPORT int CVodeGetEstLocalErrors(void* cvode_mem, N_Vector ele);
|
|
232
|
+
SUNDIALS_EXPORT int CVodeGetNumGEvals(void* cvode_mem, long int* ngevals);
|
|
233
|
+
SUNDIALS_EXPORT int CVodeGetRootInfo(void* cvode_mem, int* rootsfound_1d);
|
|
234
|
+
SUNDIALS_EXPORT int CVodeGetIntegratorStats(
|
|
235
|
+
void* cvode_mem, long int* nsteps, long int* nfevals, long int* nlinsetups,
|
|
236
|
+
long int* netfails, int* qlast, int* qcur, sunrealtype* hinused,
|
|
237
|
+
sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur);
|
|
238
|
+
SUNDIALS_EXPORT int CVodeGetNonlinearSystemData(
|
|
239
|
+
void* cvode_mem, sunrealtype* tcur, N_Vector* ypred, N_Vector* yn,
|
|
240
|
+
N_Vector* fn, sunrealtype* gamma, sunrealtype* rl1, N_Vector* zn1,
|
|
241
|
+
void** user_data); // nb::rv_policy::reference
|
|
242
|
+
SUNDIALS_EXPORT int CVodeGetNumNonlinSolvIters(void* cvode_mem,
|
|
243
|
+
long int* nniters);
|
|
244
|
+
SUNDIALS_EXPORT int CVodeGetNumNonlinSolvConvFails(void* cvode_mem,
|
|
245
|
+
long int* nnfails);
|
|
246
|
+
SUNDIALS_EXPORT int CVodeGetNonlinSolvStats(void* cvode_mem, long int* nniters,
|
|
247
|
+
long int* nnfails);
|
|
248
|
+
SUNDIALS_EXPORT int CVodeGetNumStepSolveFails(void* cvode_mem,
|
|
249
|
+
long int* nncfails);
|
|
250
|
+
SUNDIALS_EXPORT int CVodeGetNumConstraintFails(void* cvode_mem,
|
|
251
|
+
long int* num_fails_out);
|
|
252
|
+
SUNDIALS_EXPORT int CVodeGetNumConstraintCorrections(void* cvode_mem,
|
|
253
|
+
long int* num_corrections_out);
|
|
254
|
+
SUNDIALS_EXPORT int CVodeGetUserData(void* cvode_mem, void** user_data);
|
|
255
|
+
SUNDIALS_EXPORT int CVodePrintAllStats(void* cvode_mem, FILE* outfile,
|
|
256
|
+
SUNOutputFormat fmt);
|
|
257
|
+
SUNDIALS_EXPORT char* CVodeGetReturnFlagName(long int flag);
|
|
258
|
+
|
|
259
|
+
/* Free function */
|
|
260
|
+
SUNDIALS_EXPORT void CVodeFree(void** cvode_mem);
|
|
261
|
+
|
|
262
|
+
/* CVLS interface function that depends on CVRhsFn */
|
|
263
|
+
SUNDIALS_EXPORT int CVodeSetJacTimesRhsFn(void* cvode_mem, CVRhsFn jtimesRhsFn);
|
|
264
|
+
|
|
265
|
+
#ifdef __cplusplus
|
|
266
|
+
}
|
|
267
|
+
#endif
|
|
268
|
+
|
|
269
|
+
#endif
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* ---------------------------------------------------------------------
|
|
2
|
+
* Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
|
|
3
|
+
* Radu Serban @ LLNL
|
|
4
|
+
* ---------------------------------------------------------------------
|
|
5
|
+
* SUNDIALS Copyright Start
|
|
6
|
+
* Copyright (c) 2025-2026, Lawrence Livermore National Security,
|
|
7
|
+
* University of Maryland Baltimore County, and the SUNDIALS contributors.
|
|
8
|
+
* Copyright (c) 2013-2025, Lawrence Livermore National Security
|
|
9
|
+
* and Southern Methodist University.
|
|
10
|
+
* Copyright (c) 2002-2013, Lawrence Livermore National Security.
|
|
11
|
+
* All rights reserved.
|
|
12
|
+
*
|
|
13
|
+
* See the top-level LICENSE and NOTICE files for details.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
* SUNDIALS Copyright End
|
|
17
|
+
* ---------------------------------------------------------------------
|
|
18
|
+
* This is the header file for the CVODE diagonal linear solver, CVDIAG.
|
|
19
|
+
* ---------------------------------------------------------------------*/
|
|
20
|
+
|
|
21
|
+
#ifndef _CVDIAG_H
|
|
22
|
+
#define _CVDIAG_H
|
|
23
|
+
|
|
24
|
+
#include <sundials/sundials_nvector.h>
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus /* wrapper to enable C++ usage */
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/* ---------------------
|
|
31
|
+
* CVDIAG return values
|
|
32
|
+
* --------------------- */
|
|
33
|
+
|
|
34
|
+
#define CVDIAG_SUCCESS 0
|
|
35
|
+
#define CVDIAG_MEM_NULL -1
|
|
36
|
+
#define CVDIAG_LMEM_NULL -2
|
|
37
|
+
#define CVDIAG_ILL_INPUT -3
|
|
38
|
+
#define CVDIAG_MEM_FAIL -4
|
|
39
|
+
|
|
40
|
+
/* Additional last_flag values */
|
|
41
|
+
|
|
42
|
+
#define CVDIAG_INV_FAIL -5
|
|
43
|
+
#define CVDIAG_RHSFUNC_UNRECVR -6
|
|
44
|
+
#define CVDIAG_RHSFUNC_RECVR -7
|
|
45
|
+
|
|
46
|
+
/* CVDiag initialization function */
|
|
47
|
+
|
|
48
|
+
SUNDIALS_EXPORT int CVDiag(void* cvode_mem);
|
|
49
|
+
|
|
50
|
+
/* Optional output functions */
|
|
51
|
+
|
|
52
|
+
SUNDIALS_DEPRECATED_EXPORT_MSG(
|
|
53
|
+
"Work space functions will be removed in version 8.0.0")
|
|
54
|
+
int CVDiagGetWorkSpace(void* cvode_mem, long int* lenrwLS, long int* leniwLS);
|
|
55
|
+
SUNDIALS_EXPORT int CVDiagGetNumRhsEvals(void* cvode_mem, long int* nfevalsLS);
|
|
56
|
+
SUNDIALS_EXPORT int CVDiagGetLastFlag(void* cvode_mem, long int* flag);
|
|
57
|
+
SUNDIALS_EXPORT char* CVDiagGetReturnFlagName(long int flag);
|
|
58
|
+
|
|
59
|
+
#ifdef __cplusplus
|
|
60
|
+
}
|
|
61
|
+
#endif
|
|
62
|
+
|
|
63
|
+
#endif
|