bmcage / odes Goto Github PK
View Code? Open in Web Editor NEWThe ODES scikit for ordinary differential and algebraic equations, an extension to scipy
Home Page: https://scikits-odes.readthedocs.io/
License: Other
The ODES scikit for ordinary differential and algebraic equations, an extension to scipy
Home Page: https://scikits-odes.readthedocs.io/
License: Other
I was trying to integrate the heat equation on a 100x100x100 grid, and scikits.odes
's rk5
gives incorrect results (compared to scipy
's solve_ivp
). The values I get from scipy
are always bounded between 0 and 1 (which they should be since I use 0 and 1 as Dirichlet boundary conditions), but those I get from scikits.odes
blow up to ~10^10. Here's how to reproduce it:
# %% Import libraries
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp
from scikits.odes.odeint import odeint
from time import time
# %% Define du/dt
def func(t, v, du, params):
h, k, Nx, Ny, Nz = params
is3d = True if Nz > 1 else False
u = v.reshape((Nx, Ny, Nz))
idx = np.arange(1, Nx-1)
idy = np.arange(1, Ny-1)
idz = np.arange(1, Nz-1) if is3d else np.array([0])
u_xx = (u[np.ix_(idx-1, idy, idz)] - 2*u[np.ix_(idx, idy, idz)] + u[np.ix_(idx+1, idy, idz)]) / h**2
u_yy = (u[np.ix_(idx, idy-1, idz)] - 2*u[np.ix_(idx, idy, idz)] + u[np.ix_(idx, idy+1, idz)]) / h**2
if is3d:
u_zz = (u[np.ix_(idx, idy, idz-1)] - 2*u[np.ix_(idx, idy, idz)] + u[np.ix_(idx, idy, idz+1)]) / h**2
else:
u_zz = 0.0
idx1d = np.ravel_multi_index(np.ix_(idx, idy, idz), (Nx, Ny, Nz)).flatten()
du[idx1d] = k * (u_xx + u_yy + u_zz).flatten()
return du
# %% Define model parameters
Nx, Ny, Nz = 100, 100, 100
Lx = 1.0
Ly = Lx * (Ny-1)/(Nx-1)
Lz = Lx * (Nz-1)/(Nx-1)
h = Lx/(Nx-1)
D = 5e-3
params = (h, D, Nx, Ny, Nz)
# Safety checks
assert Nx >= 3
assert Ny >= 3
if Nz != 1:
assert Nz >= 3
# %% Scikits.Odes
def func_odes(t, u, du):
func(t, u, du, params)
tspan = (0.0, 5.0)
tout = np.linspace(tspan[0], tspan[1], 10)
u0 = np.zeros((Nx, Ny, Nz)) # IC @ t = 0 ; u = 0.0
u0[0, ...] = 1.0 # BC @ x = 0 ; u = 1.0
u0[-1, ...] = 1.0 # BC @ x = L ; u = 1.0
u0[:, 0, :] = 1.0 # BC @ y = 0 ; u = 1.0
u0[:, -1, :] = 1.0 # BC @ y = L ; u = 1.0
t0 = time()
out = odeint(func_odes, tout, u0.flatten(), method="rk5",
rtol=1e-3, atol=1e-3)
print(f"Scikits.Odes runtime (rk5): {time()-t0:.2f} s")
# t0 = time()
# out = odeint(func_odes, tout, u0.flatten(), method="cvode", rtol=1e-3, atol=1e-3)
# print(f"Scikits.Odes runtime (cvode): {time()-t0:.2f} s")
u3d_odes = out.values.y.reshape((tout.size, Nx, Ny, Nz))
fig, ax = plt.subplots()
f = ax.imshow(u3d_odes[-1, ..., Nz//2], vmin=0, vmax=u3d_odes.max())
ax.set_title("Scikits.Odes")
plt.colorbar(f)
# %% Scipy
du = np.zeros(u0.size)
def func_scipy(t, u):
return func(t, u, du, params)
t0 = time()
sol = solve_ivp(func_scipy, tspan, u0.flatten(), method="RK45",
t_eval=tout, rtol=1e-3, atol=1e-3)
print(f"Scipy runtime (rk45): {time()-t0:.2f} s")
u3d_scipy = sol.y.reshape(Nx, Ny, Nz, sol.t.size)
fig, ax = plt.subplots()
f = ax.imshow(u3d_scipy[..., Nz//2, -1], vmin=0, vmax=u3d_scipy.max())
ax.set_title("Scipy")
plt.colorbar(f)
plt.show()
I use Spyder IDE with its embedded IPython console to write/run Python code. If you run the code snippet in #127 more than once (in the same IPython console), the package seems to break and no longer returns correct values (actually, most of the time it diverges, it only runs correctly the first time). So, every time I have to restart Spyder's IPython console for it to work. I don't exactly know what's causing the issue, but it seems to occur when re-importing the already imported scikits.odes
library.
Hi,
I am testing the ODES using Sundials 5.7.0 and Python 3.8. Everything seems to be fine, except for some DeprecationWarning running nose. Nevertheless I cannot converge the tutorial cases or even the nose tests.
My packages:
(venv) ~/ pip freeze
nose==1.3.7
numpy==1.20.1
scikits.odes==2.6.1
scipy==1.6.1
Here it is a test case:
import numpy as np
from scikits.odes.dae import dae
SOLVER = 'ida'
tout = np.linspace(0, 1)
y_initial = np.array([0])
ydot_initial = np.array([0])
extra_options = {'old_api': False}
def right_hand_side(t, y, ydot, residue):
"""
User's right hand side function
"""
pass
dae_solver = dae(SOLVER, right_hand_side, **extra_options)
output = dae_solver.solve(tout, y_initial, ydot_initial)
print(output.values.y)
That outputs the following error:
[IDA ERROR] IDASolve
At t = 0 and h = 1.94627e-11, the corrector convergence failed repeatedly or with |h| = hmin.
[[0.]]
Here it is my nose tests output (all failed in Sundials calculations):
(venv) ~/ python -c "import scikits.odes as od; od.test()"
Running unit tests for scikits.odes
NumPy version 1.20.1
NumPy relaxed strides checking option: True
NumPy is installed in /Users/jaimenms/PycharmProjects/optimal-design/venv/lib/python3.8/site-packages/numpy
Python version 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) [Clang 6.0 (clang-600.0.57)]
nose version 1.3.7
/Users/jaimenms/PycharmProjects/optimal-design/venv/lib/python3.8/site-packages/nose/suite.py:106: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
if isinstance(tests, collections.Callable) and not is_suite:
<__array_function__ internals>:5: DeprecationWarning: `np.alen` is deprecated, use `len` instead
../Users/jaimenms/PycharmProjects/optimal-design/venv/lib/python3.8/site-packages/scikits/odes/dae.py:389: DeprecationWarning: Old api is deprecated, move to new api
return self._integrator.init_step(t0, y0, yp0, y_ic0_retn, yp_ic0_retn)
......ode.get_info() =
{'NumSteps': 19, 'NumRhsEvals': 26, 'NumLinSolvSetups': 16, 'NumErrTestFails': 1, 'LastOrder': 2, 'CurrentOrder': 2, 'ActualInitStep': 0.0005000002493687262, 'LastStep': 5.632767015984214, 'CurrentStep': 11.121864790716213}
.True solution:
[ 1. 4. 9. 16. 25. 36. 49. 64. 81. 100.]
Integrated:
[ 1. 4.00000181 9.00000189 16.00000196 25.00000201
36.00000205 49.00000213 64.00000218 81.00000222 100.00000225]
Difference:
[0.00000000e+00 1.80709183e-06 1.88536923e-06 1.95964126e-06
2.00559588e-06 2.05370031e-06 2.12527937e-06 2.18137136e-06
2.22197630e-06 2.24709419e-06]
Relative:
[0.00000000e+00 4.51772957e-07 2.09485470e-07 1.22477579e-07
8.02238353e-08 5.70472309e-08 4.33730483e-08 3.40839275e-08
2.74318062e-08 2.24709419e-08]
.ode.get_info() =
{'NumSteps': 19, 'NumRhsEvals': 28, 'NumLinSolvSetups': 0, 'NumErrTestFails': 1, 'LastOrder': 2, 'CurrentOrder': 2, 'ActualInitStep': 0.0005000002493687262, 'LastStep': 5.632767015984214, 'CurrentStep': 11.121864790716213, 'NumPrecEvals': 0, 'NumPrecSolves': 0, 'NumJtimesEvals': 20, 'NumLinIters': 20, 'NumRhsEvalsJtimesFD': 20}
..............................
[CVLS ERROR] cvLsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVLS ERROR] cvLsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0 and h = 2.6974e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVODE ERROR] CVode
At t = 0 and h = 1.90735e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVLS ERROR] cvLsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVLS ERROR] cvLsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.0314249, mxstep steps taken before reaching tout.
.
[CVODE ERROR] CVode
At t = 0.0222206, mxstep steps taken before reaching tout.
.......
[CVODE ERROR] CVode
At t = 0, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.458122, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
The right-hand side routine failed at the first call.
.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
The above warning has been issued mxhnil times and will not be issued again for this problem.
[CVODE ERROR] CVode
At t = 0.5, mxstep steps taken before reaching tout.
..
[CVODE ERROR] cvRcheck1
At t = 0, the rootfinding routine failed in an unrecoverable manner.
.
[CVODE ERROR] cvRcheck3
At t = 0.458122, the rootfinding routine failed in an unrecoverable manner.
.
[CVODES WARNING] CVode
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
[CVLS ERROR] cvLsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVLS ERROR] cvLsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0 and h = 2.6974e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVODE ERROR] CVode
At t = 0 and h = 1.90735e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVLS ERROR] cvLsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVLS ERROR] cvLsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.0314249, mxstep steps taken before reaching tout.
.
[CVODE ERROR] CVode
At t = 0.0222206, mxstep steps taken before reaching tout.
.......
[CVODE ERROR] CVode
At t = 0, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.458122, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
The right-hand side routine failed at the first call.
.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
The above warning has been issued mxhnil times and will not be issued again for this problem.
[CVODE ERROR] CVode
At t = 0.5, mxstep steps taken before reaching tout.
..
[CVODE ERROR] cvRcheck1
At t = 0, the rootfinding routine failed in an unrecoverable manner.
.
[CVODE ERROR] cvRcheck3
At t = 0.458122, the rootfinding routine failed in an unrecoverable manner.
.
[CVODES WARNING] CVode
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
[IDALS ERROR] idaLsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDALS ERROR] idaLsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.....
[IDA ERROR] IDASolve
At t = 0, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0.287979, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0, repeated recoverable residual errors.
.
[IDA ERROR] IDASolve
At t = 0.5, , mxstep steps taken before reaching tout.
..
[IDA ERROR] IDARcheck1
At t = 0, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA ERROR] IDARcheck3
At t = 0.287979, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA WARNING] IDASolve
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
[IDALS ERROR] idaLsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDALS ERROR] idaLsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.....
[IDA ERROR] IDASolve
At t = 0, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0.287979, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0, repeated recoverable residual errors.
.
[IDA ERROR] IDASolve
At t = 0.5, , mxstep steps taken before reaching tout.
..
[IDA ERROR] IDARcheck1
At t = 0, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA ERROR] IDARcheck3
At t = 0.287979, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA WARNING] IDASolve
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
----------------------------------------------------------------------
Ran 124 tests in 0.748s
OK
I would like to know if it is a incompatibility with my Sundials version. If so, what is the most recent version that can be wrapped by ODES?
Thanks!
Hi, I am trying to use Performance tests.ipynb with Cython to check the speedup.
However, I encountered CompileError, I think that is due to Cython/gcc.
Any idea about this? Thanks.
CompileError Traceback (most recent call last)
<ipython-input-15-12eebe5eed09> in <module>()
----> 1 get_ipython().run_cell_magic(u'cython', u'-I /home/yangh/odes-master/odes/scikits/odes/sundials/ -I /home/yangh/anaconda2/lib/python2.7/site-packages/scikits/odes/sundials/', u"## update include flag -I to point to odes/sundials directory!\nimport numpy as np\nfrom cpython cimport bool\ncimport numpy as np\nfrom scikits.odes.sundials.cvode cimport CV_RhsFunction\n\n#scikits.odes allows cython functions only if derived from correct class\n\ncdef class egfngf_cython_model(CV_RhsFunction):\n cdef public ts, k, y0, userdata\n cdef public object name\n cdef public CV_RhsFunction f_odes\n cdef public bool has_userdata, has_userdata_odes\n \n def __cinit__(self):\n self.name = 'egfngf_cython'\n self.ts = np.linspace(0, 120, 121, dtype=float)\n self.has_userdata = True\n self.has_userdata_odes = True\n self.k = np.array([\n 2.18503E-5,\n 0.0121008,\n 1.38209E-7,\n 0.00723811,\n 694.731,\n 6086070.0,\n 389.428,\n 2112.66,\n 1611.97,\n 896896.0,\n 32.344,\n 35954.3,\n 1509.36,\n 1432410.0,\n 0.884096,\n 62464.6,\n 185.759,\n 4768350.0,\n 125.089,\n 157948.0,\n 2.83243,\n 518753.0,\n 9.85367,\n 1007340.0,\n 8.8912,\n 3496490.0,\n 0.0213697,\n 763523.0,\n 10.6737,\n 184912.0,\n 0.0771067,\n 272056.0,\n 0.0566279,\n 653951.0,\n 15.1212,\n 119355.0,\n 146.912,\n 12876.2,\n 1.40145,\n 10965.6,\n 27.265,\n 295990.0,\n 2.20995,\n 1025460.0,\n 0.126329,\n 1061.71,\n 441.287,\n 1.08795E7\n ], float)\n \n self.userdata = self.k\n\n self.y0 = np.array([\n 1000,\n 4560,\n 80000.0,\n 0.0,\n 10000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 0.0,\n 600000.0,\n 0.0,\n 600000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 0.0,\n 120000.0,\n 120000.0,\n 120000.0,\n 120000.0\n ], float)\n\n cpdef np.ndarray[double, ndim=1] f(self, double t, np.ndarray[double, ndim=1] y, \n np.ndarray[double, ndim=1] k):\n return np.array([\n ((-1.0 * k[0] * y[0] * y[2])) + (1.0 * k[1] * y[3]),\n ((-1.0 * k[2] * y[1] * y[4])) + (1.0 * k[3] * y[5]),\n ((-1.0 * k[0] * y[0] * y[2])) + (1.0 * k[1] * y[3]),\n ((1.0 * k[0] * y[0] * y[2]) + (-1.0 * k[1] * y[3])),\n ((-1.0 * k[2] * y[1] * y[4]) + (1.0 * k[3] * y[5])),\n ((1.0 * k[2] * y[1] * y[4]) + (-1.0 * k[3] * y[5])),\n ((-1.0 * k[4] * y[3] * y[6] / (y[6] + k[5])) + (-1.0 * k[6] * y[5] * y[6] / (y[6] + k[7])) + (\n 1.0 * k[8] * y[9] * y[7] / (y[7] + k[9]))),\n ((1.0 * k[4] * y[3] * y[6] / (y[6] + k[5])) + (1.0 * k[6] * y[5] * y[6] / (y[6] + k[7])) + (\n -1.0 * k[8] * y[9] * y[7] / (y[7] + k[9]))),\n ((-1.0 * k[26] * y[19] * y[8] / (y[8] + k[27]))),\n ((1.0 * k[26] * y[19] * y[8] / (y[8] + k[27]))),\n ((-1.0 * k[10] * y[7] * y[10] / (y[10] + k[11])) + (1.0 * k[12] * y[28] * y[11] / (y[11] + k[13]))),\n ((1.0 * k[10] * y[7] * y[10] / (y[10] + k[11])) + (-1.0 * k[12] * y[28] * y[11] / (y[11] + k[13]))),\n ((-1.0 * k[14] * y[11] * y[12] / (y[12] + k[15])) + (1.0 * k[44] * y[31] * y[13] / (y[13] + k[45])) + (\n 1.0 * k[34] * y[23] * y[13] / (y[13] + k[35]))),\n ((1.0 * k[14] * y[11] * y[12] / (y[12] + k[15])) + (-1.0 * k[44] * y[31] * y[13] / (y[13] + k[45])) + (\n -1.0 * k[34] * y[23] * y[13] / (y[13] + k[35]))),\n ((-1.0 * k[42] * y[27] * y[14] / (y[14] + k[43])) + (1.0 * k[46] * y[31] * y[15] / (y[15] + k[47]))),\n ((1.0 * k[42] * y[27] * y[14] / (y[14] + k[43])) + (-1.0 * k[46] * y[31] * y[15] / (y[15] + k[47]))),\n ((-1.0 * k[16] * y[13] * y[16] / (y[16] + k[17])) + (-1.0 * k[18] * y[15] * y[16] / (y[16] + k[19])) + (\n 1.0 * k[20] * y[30] * y[17] / (y[17] + k[21]))),\n ((1.0 * k[16] * y[13] * y[16] / (y[16] + k[17])) + (1.0 * k[18] * y[15] * y[16] / (y[16] + k[19])) + (\n -1.0 * k[20] * y[30] * y[17] / (y[17] + k[21]))),\n ((-1.0 * k[22] * y[17] * y[18] / (y[18] + k[23])) + (1.0 * k[24] * y[30] * y[19] / (y[19] + k[25]))),\n ((1.0 * k[22] * y[17] * y[18] / (y[18] + k[23])) + (-1.0 * k[24] * y[30] * y[19] / (y[19] + k[25]))),\n ((-1.0 * k[28] * y[3] * y[20] / (y[20] + k[29])) + (-1.0 * k[30] * y[11] * y[20] / (y[20] + k[31]))),\n ((1.0 * k[28] * y[3] * y[20] / (y[20] + k[29])) + (1.0 * k[30] * y[11] * y[20] / (y[20] + k[31]))),\n ((-1.0 * k[32] * y[21] * y[22] / (y[22] + k[33]))),\n ((1.0 * k[32] * y[21] * y[22] / (y[22] + k[33]))),\n ((-1.0 * k[36] * y[5] * y[24] / (y[24] + k[37]))),\n ((1.0 * k[36] * y[5] * y[24] / (y[24] + k[37]))),\n ((-1.0 * k[38] * y[25] * y[26] / (y[26] + k[39])) + (1.0 * k[40] * y[29] * y[27] / (y[27] + k[41]))),\n ((1.0 * k[38] * y[25] * y[26] / (y[26] + k[39])) + (-1.0 * k[40] * y[29] * y[27] / (y[27] + k[41]))),\n 0,\n 0,\n 0,\n 0], float)\n\n \n cpdef int evaluate(self, double t,\n np.ndarray[double, ndim=1] y,\n np.ndarray[double, ndim=1] yout,\n object userdata = None) except? -1:\n #cdef np.ndarray[double, ndim=1] k = self.k # avoid self.k gives quite some speedup!\n cdef np.ndarray[double, ndim=1] k = userdata\n # avoiding creation of temporary arrays gives quite some speedup!\n yout[0] = ((-1.0 * k[0] * y[0] * y[2])) + (1.0 * k[1] * y[3])\n yout[1] = ((-1.0 * k[2] * y[1] * y[4])) + (1.0 * k[3] * y[5])\n yout[2] = ((-1.0 * k[0] * y[0] * y[2])) + (1.0 * k[1] * y[3])\n yout[3] = ((1.0 * k[0] * y[0] * y[2]) + (-1.0 * k[1] * y[3]))\n yout[4] = ((-1.0 * k[2] * y[1] * y[4]) + (1.0 * k[3] * y[5]))\n yout[5] = ((1.0 * k[2] * y[1] * y[4]) + (-1.0 * k[3] * y[5]))\n yout[6] = ((-1.0 * k[4] * y[3] * y[6] / (y[6] + k[5])) + (-1.0 * k[6] * y[5] * y[6] / (y[6] + k[7])) + (\n 1.0 * k[8] * y[9] * y[7] / (y[7] + k[9])))\n yout[7] = ((1.0 * k[4] * y[3] * y[6] / (y[6] + k[5])) + (1.0 * k[6] * y[5] * y[6] / (y[6] + k[7])) + (\n -1.0 * k[8] * y[9] * y[7] / (y[7] + k[9])))\n yout[8] = ((-1.0 * k[26] * y[19] * y[8] / (y[8] + k[27])))\n yout[9] = ((1.0 * k[26] * y[19] * y[8] / (y[8] + k[27])))\n yout[10] = ((-1.0 * k[10] * y[7] * y[10] / (y[10] + k[11])) + (1.0 * k[12] * y[28] * y[11] / (y[11] + k[13])))\n yout[11] = ((1.0 * k[10] * y[7] * y[10] / (y[10] + k[11])) + (-1.0 * k[12] * y[28] * y[11] / (y[11] + k[13])))\n yout[12] = ((-1.0 * k[14] * y[11] * y[12] / (y[12] + k[15])) + (1.0 * k[44] * y[31] * y[13] / (y[13] + k[45])) + (\n 1.0 * k[34] * y[23] * y[13] / (y[13] + k[35])))\n yout[13] = ((1.0 * k[14] * y[11] * y[12] / (y[12] + k[15])) + (-1.0 * k[44] * y[31] * y[13] / (y[13] + k[45])) + (\n -1.0 * k[34] * y[23] * y[13] / (y[13] + k[35])))\n yout[14] = ((-1.0 * k[42] * y[27] * y[14] / (y[14] + k[43])) + (1.0 * k[46] * y[31] * y[15] / (y[15] + k[47])))\n yout[15] = ((1.0 * k[42] * y[27] * y[14] / (y[14] + k[43])) + (-1.0 * k[46] * y[31] * y[15] / (y[15] + k[47])))\n yout[16] = ((-1.0 * k[16] * y[13] * y[16] / (y[16] + k[17])) + (-1.0 * k[18] * y[15] * y[16] / (y[16] + k[19])) + (\n 1.0 * k[20] * y[30] * y[17] / (y[17] + k[21])))\n yout[17] = ((1.0 * k[16] * y[13] * y[16] / (y[16] + k[17])) + (1.0 * k[18] * y[15] * y[16] / (y[16] + k[19])) + (\n -1.0 * k[20] * y[30] * y[17] / (y[17] + k[21])))\n yout[18] = ((-1.0 * k[22] * y[17] * y[18] / (y[18] + k[23])) + (1.0 * k[24] * y[30] * y[19] / (y[19] + k[25])))\n yout[19] = ((1.0 * k[22] * y[17] * y[18] / (y[18] + k[23])) + (-1.0 * k[24] * y[30] * y[19] / (y[19] + k[25])))\n yout[20] = ((-1.0 * k[28] * y[3] * y[20] / (y[20] + k[29])) + (-1.0 * k[30] * y[11] * y[20] / (y[20] + k[31])))\n yout[21] = ((1.0 * k[28] * y[3] * y[20] / (y[20] + k[29])) + (1.0 * k[30] * y[11] * y[20] / (y[20] + k[31])))\n yout[22] = ((-1.0 * k[32] * y[21] * y[22] / (y[22] + k[33])))\n yout[23] = ((1.0 * k[32] * y[21] * y[22] / (y[22] + k[33])))\n yout[24] = ((-1.0 * k[36] * y[5] * y[24] / (y[24] + k[37])))\n yout[25] = ((1.0 * k[36] * y[5] * y[24] / (y[24] + k[37])))\n yout[26] = ((-1.0 * k[38] * y[25] * y[26] / (y[26] + k[39])) + (1.0 * k[40] * y[29] * y[27] / (y[27] + k[41])))\n yout[27] = ((1.0 * k[38] * y[25] * y[26] / (y[26] + k[39])) + (-1.0 * k[40] * y[29] * y[27] / (y[27] + k[41])))\n yout[28] = 0\n yout[29] = 0\n yout[30] = 0\n yout[31] = 0\n return 0\n ")
/home/yangh/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
2113 magic_arg_s = self.var_expand(line, stack_depth)
2114 with self.builtin_trap:
-> 2115 result = fn(magic_arg_s, cell)
2116 return result
2117
<decorator-gen-124> in cython(self, line, cell)
/home/yangh/anaconda2/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
/home/yangh/anaconda2/lib/python2.7/site-packages/Cython/Build/IpythonMagic.pyc in cython(self, line, cell)
289 build_extension.build_temp = os.path.dirname(pyx_file)
290 build_extension.build_lib = lib_dir
--> 291 build_extension.run()
292 self._code_cache[key] = module_name
293
/home/yangh/anaconda2/lib/python2.7/distutils/command/build_ext.pyc in run(self)
338
339 # Now actually compile and link everything.
--> 340 self.build_extensions()
341
342 def check_extensions_list(self, extensions):
/home/yangh/anaconda2/lib/python2.7/distutils/command/build_ext.pyc in build_extensions(self)
447
448 for ext in self.extensions:
--> 449 self.build_extension(ext)
450
451 def build_extension(self, ext):
/home/yangh/anaconda2/lib/python2.7/distutils/command/build_ext.pyc in build_extension(self, ext)
497 debug=self.debug,
498 extra_postargs=extra_args,
--> 499 depends=ext.depends)
500
501 # XXX -- this is a Vile HACK!
/home/yangh/anaconda2/lib/python2.7/distutils/ccompiler.pyc in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends)
572 except KeyError:
573 continue
--> 574 self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
575
576 # Return *all* object filenames, not just the ones we just built.
/home/yangh/anaconda2/lib/python2.7/distutils/unixccompiler.pyc in _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
122 extra_postargs)
123 except DistutilsExecError, msg:
--> 124 raise CompileError, msg
125
126 def create_static_lib(self, objects, output_libname,
CompileError: command 'gcc' failed with exit status 1
I tried pointing scikits-odes to sundials 5.1.0, but it fails to compile:
/nix/store/fdgwwak9g61j6jyilqpiswih02llm81l-gfortran-wrapper-9.2.0/bin/gfortran -Wall -g -Wall -g -shared build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/scikits/odes/lsodimodule.o build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/build/src.linux-x86_64-2.7/scikits/odes/fortranobject.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/xerrwv.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/vnorm.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/stodi.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/solsy.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/prepji.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/lsodi.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/intdy.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/ewset.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/dlinpk.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/ddaspk.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/daux.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/cfode.o build/temp.linux-x86_64-2.7/scikits/odes/daepack/ainvg.o -L/nix/store/m62n6i62f7vkman907blw7znjlkvla2b-gfortran-9.2.0-lib/lib -L/nix/store/m62n6i62f7vkman907blw7znjlkvla2b-gfortran-9.2.0-lib/lib -L/nix/store/bh447min7f6vqdw3x1iywr1vxyx4ix8y-python-2.7.17/lib -lpython2.7 -lgfortran -o build/lib.linux-x86_64-2.7/scikits/odes/lsodi.so
building 'scikits.odes.sundials.common_defs' extension
compiling C sources
C compiler: gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC
creating build/temp.linux-x86_64-2.7/scikits/odes/sundials
compile options: '-I/nix/store/q1sxwhf9zysd4vhkxqzzh4l1sd28spaz-python2.7-numpy-1.16.5/lib/python2.7/site-packages/numpy/core/include -I/nix/store/bh447min7f6vqdw3x1iywr1vxyx4ix8y-python-2.7.17/include/python2.7 -c'
gcc: scikits/odes/sundials/common_defs.c
In file included from /nix/store/q1sxwhf9zysd4vhkxqzzh4l1sd28spaz-python2.7-numpy-1.16.5/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /nix/store/q1sxwhf9zysd4vhkxqzzh4l1sd28spaz-python2.7-numpy-1.16.5/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /nix/store/q1sxwhf9zysd4vhkxqzzh4l1sd28spaz-python2.7-numpy-1.16.5/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from scikits/odes/sundials/common_defs.c:631:
/nix/store/q1sxwhf9zysd4vhkxqzzh4l1sd28spaz-python2.7-numpy-1.16.5/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
17 | #warning "Using deprecated NumPy API, disable it with " \
| ^~~~~~~
scikits/odes/sundials/common_defs.c:641:10: fatal error: sundials/sundials_pcg.h: No such file or directory
641 | #include "sundials/sundials_pcg.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: Command "gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/nix/store/q1sxwhf9zysd4vhkxqzzh4l1sd28spaz-python2.7-numpy-1.16.5/lib/python2.7/site-packages/numpy/core/include -I/nix/store/bh447min7f6vqdw3x1iywr1vxyx4ix8y-python-2.7.17/include/python2.7 -c scikits/odes/sundials/common_defs.c -o build/temp.linux-x86_64-2.7/scikits/odes/sundials/common_defs.o -MMD -MF build/temp.linux-x86_64-2.7/scikits/odes/sundials/common_defs.o.d" failed with exit status 1
builder for '/nix/store/n8hmyyvyjhvlhxmjpb95j612kwgdyp92-python2.7-scikits.odes-2.4.0-9-g93075ae.drv' failed with exit code 1
error: build of '/nix/store/n8hmyyvyjhvlhxmjpb95j612kwgdyp92-python2.7-scikits.odes-2.4.0-9-g93075ae.drv' failed
/nix/store/fdgwwak9g61j6jyilqpiswih02llm81l-gfortran-wrapper-9.2.0/bin/gfortran -Wall -g -Wall -g -shared build/temp.linux-x86_64-3.7/build/src.linux-x86_64-3.7/scikits/odes/lsodimodule.o build/temp.linux-x86_64-3.7/build/src.linux-x86_64-3.7/build/src.linux-x86_64-3.7/scikits/odes/fortranobject.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/xerrwv.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/vnorm.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/stodi.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/solsy.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/prepji.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/lsodi.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/intdy.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/ewset.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/dlinpk.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/ddaspk.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/daux.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/cfode.o build/temp.linux-x86_64-3.7/scikits/odes/daepack/ainvg.o -L/nix/store/m62n6i62f7vkman907blw7znjlkvla2b-gfortran-9.2.0-lib/lib -L/nix/store/m62n6i62f7vkman907blw7znjlkvla2b-gfortran-9.2.0-lib/lib -L/nix/store/ja04f3cmapzb3f2mvjrb883bfqclsirq-python3-3.7.6/lib -lpython3.7m -lgfortran -o build/lib.linux-x86_64-3.7/scikits/odes/lsodi.cpython-37m-x86_64-linux-gnu.so
building 'scikits.odes.sundials.common_defs' extension
compiling C sources
C compiler: gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC
creating build/temp.linux-x86_64-3.7/scikits/odes/sundials
compile options: '-I/nix/store/hzh4nqhzr0a86mh1dd8r806cq5sn95pn-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/core/include -I/nix/store/ja04f3cmapzb3f2mvjrb883bfqclsirq-python3-3.7.6/include/python3.7m -c'
gcc: scikits/odes/sundials/common_defs.c
In file included from /nix/store/hzh4nqhzr0a86mh1dd8r806cq5sn95pn-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832,
from /nix/store/hzh4nqhzr0a86mh1dd8r806cq5sn95pn-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /nix/store/hzh4nqhzr0a86mh1dd8r806cq5sn95pn-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from scikits/odes/sundials/common_defs.c:631:
/nix/store/hzh4nqhzr0a86mh1dd8r806cq5sn95pn-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
17 | #warning "Using deprecated NumPy API, disable it with " \
| ^~~~~~~
scikits/odes/sundials/common_defs.c:641:10: fatal error: sundials/sundials_pcg.h: No such file or directory
641 | #include "sundials/sundials_pcg.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: Command "gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/nix/store/hzh4nqhzr0a86mh1dd8r806cq5sn95pn-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/core/include -I/nix/store/ja04f3cmapzb3f2mvjrb883bfqclsirq-python3-3.7.6/include/python3.7m -c scikits/odes/sundials/common_defs.c -o build/temp.linux-x86_64-3.7/scikits/odes/sundials/common_defs.o -MMD -MF build/temp.linux-x86_64-3.7/scikits/odes/sundials/common_defs.o.d" failed with exit status 1
builder for '/nix/store/8721l6n8czwy6nmf10gyghkcnixifgqa-python3.7-scikits.odes-2.4.0-9-g93075ae.drv' failed with exit code 1
error: build of '/nix/store/8721l6n8czwy6nmf10gyghkcnixifgqa-python3.7-scikits.odes-2.4.0-9-g93075ae.drv' failed
Hello Folks
Is it possible to pass a python reference to scikits.odes.ode.ode() and then have the solver pass the reference back to eqsrhs()? It appears from
Values: function of class CV_RhsFunction or a python function
with signature (t, y, yp) or (t, y, yp, userdata)
in odes/scikits/odes/sundials/cvode.pyx that this might be possible, but I'm not confident that I understand it.
The reference would be handy, but not essential. Otherwise I can hack a class variable that eqsrhs() can use to obtain the necessary data.
Thanks
Arthur
in the file ida.pyx there is a description of the option 'algebraic_vars_idx' that says "... These are denoted by the position (index) in the residual vector..." This is wrong. It should be "... These are denoted by the position (index) in the state vector y..."
This may seem like a small thing, but it caused me some grief. This change also aligns the documentation with the way Octave documents its implementation of IDA.
Thanks!
Hi,
What I did:
sudo apt update
sudo apt upgrade
sudo apt install build-essential python3-gdbm cmake
sudo apt install python3-dev gfortran libblas-dev libopenblas-dev liblapack-dev libatlas-base-dev
curl -o sundials-2.7.0.tar.gz https://computation.llnl.gov/projects/sundials/download/sundials-2.7.0.tar.gz
tar -xzf sundials-2.7.0.tar.gz
mkdir build-sundials-2.7.0
cd build-sundials-2.7.0/
cmake -DLAPACK_ENABLE=ON -DCMAKE_INSTALL_PREFIX=/usr/lib/sundials-2.7.0/ /home/ubuntu/sundials-2.7.0
After running above, Return:
-- The C compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for _POSIX_TIMERS
-- Looking for _POSIX_TIMERS - found
-- The Fortran compiler identification is GNU 5.4.0
-- Searching for a Fortran compiler... /usr/bin/gfortran
-- Trying to compile and link a simple Fortran program... OK
-- Determining Fortran name-mangling scheme... OK
-- Looking for Fortran dgemm
-- Looking for Fortran dgemm - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- A library with BLAS API found.
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- A library with LAPACK API found.
-- Looking for LAPACK libraries... OK
-- Checking if Lapack works... OK
-- Added NVECTOR_SERIAL module
-- Added ARKODE module
-- Added CVODE module
-- Added CVODES module
-- Added IDA module
-- Added IDAS module
-- Added KINSOL module
-- Found PythonInterp: /usr/bin/python (found version "2.7.12")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/build-sundials-2.7.0
(And I have changed python to python3.6 in CMakeCache.txt as below:
//Path to a program.
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3.6
//Details about finding PythonInterp
FIND_PACKAGE_MESSAGE_DETAILS_PythonInterp:INTERNAL=[/usr/bin/python3.6][]
And rerun cmake -DLAPACK_ENABLE=ON -DCMAKE_INSTALL_PREFIX=/usr/lib/sundials-2.7.0/ /home/ubuntu/sundials-2.7.0;
Result:
-- The Fortran compiler identification is GNU 5.4.0
-- Searching for a Fortran compiler... /usr/bin/gfortran
-- Trying to compile and link a simple Fortran program... OK
-- Determining Fortran name-mangling scheme... OK
-- Looking for LAPACK libraries... OK
-- Checking if Lapack works... OK
-- Added NVECTOR_SERIAL module
-- Added ARKODE module
-- Added CVODE module
-- Added CVODES module
-- Added IDA module
-- Added IDAS module
-- Added KINSOL module
-- Found PythonInterp: /usr/bin/python3.6 (found version "3.6.4")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/build-sundials-2.7.0
)
sudo make install;
Result of installation seems no problem at all.
I have changed .bashrc $SUNDIALS_INST as
export SUNDIALS_INST=/usr/lib/sundials-2.7.0/
sudo pip3 install scikits.odes;
Result:
Collecting scikits.odes
Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from scikits.odes)
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from scipy->scikits.odes)
Installing collected packages: scikits.odes
Successfully installed scikits.odes-2.3.2
However, when i try to run test code as below:
ubuntu:~/ctrnn_ann$ ipython
Python 3.6.4 (default, Jan 28 2018, 17:52:01)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import scikits.odes as od;
In [2]: od.test()
Running unit tests for scikits.odes
NumPy version 1.13.3
NumPy relaxed strides checking option: True
NumPy is installed in /usr/local/lib/python3.6/dist-packages/numpy
Python version 3.6.4 (default, Jan 28 2018, 17:52:01) [GCC 5.4.0 20160609]
nose version 1.3.7
/usr/lib/python3.6/importlib/_bootstrap.py:219: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
return f(*args, **kwds)
libsundials_ida.so.2: cannot open shared object file: No such file or directory
libsundials_cvode.so.2: cannot open shared object file: No such file or directory
EEException ignored in: <bound method dae.__del__ of <scikits.odes.dae.dae object at 0x7fca5fbb3be0>>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/dae.py", line 445, in __del__
del self._integrator
AttributeError: _integrator
EException ignored in: <bound method dae.__del__ of <scikits.odes.dae.dae object at 0x7fca5fbb3e10>>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/dae.py", line 445, in __del__
del self._integrator
AttributeError: _integrator
E.EEEEEE.EE.EEEE
======================================================================
ERROR: Check the ddaspk solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 52, in test_ddaspk
problem = problem_cls()
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 211, in __init__
old_api=False,
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: Check the ida solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 71, in test_ida
self._do_problem(problem, 'ida', old_api=False, **problem.ida_pars)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 27, in _do_problem
ig = dae(integrator, res, jacfn=jac, old_api=old_api)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/dae.py", line 280, in __init__
integrator = find_dae_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/dae.py", line 481, in find_dae_integrator
raise ValueError('Integrator name %s does not exsist' % name)
ValueError: Integrator name ida does not exsist
======================================================================
ERROR: Check the ida solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 65, in test_ida_old_api
self._do_problem(problem, 'ida', old_api=True, **problem.ida_pars)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 27, in _do_problem
ig = dae(integrator, res, jacfn=jac, old_api=old_api)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/dae.py", line 280, in __init__
integrator = find_dae_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/dae.py", line 481, in find_dae_integrator
raise ValueError('Integrator name %s does not exsist' % name)
ValueError: Integrator name ida does not exsist
======================================================================
ERROR: Check the lsodi solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 58, in test_lsodi
problem = problem_cls()
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_dae.py", line 211, in __init__
old_api=False,
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_get_info_is_exposed_on_ode (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_get_info_returns_dict (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_ode_exposes_num_rhs_evals (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_we_integrated_correctly (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_ode_exposes_num_njtimes_evals (scikits.odes.tests.test_get_info.GetInfoTestSpils)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_get_info.py", line 50, in setUp
self.ode = ode('cvode', rhs, linsolver="spgmr", old_api=False)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_odeint (scikits.odes.tests.test_odeint.TestOdeint)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_odeint.py", line 47, in test_odeint
self._do_problem(problem)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_odeint.py", line 33, in _do_problem
sol = odeint(problem.f, t, problem.z0, method=method)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: scikits.odes.tests.test_odeint.test_odeint_banded_jacobian
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_odeint.py", line 292, in test_odeint_banded_jacobian
jacfn=jac)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: scikits.odes.tests.test_odeint.test_odeint_errors
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_odeint.py", line 403, in test_odeint_errors
assert_raises(ZeroDivisionError, odeint, bad1, [0, 1], [1.0])
File "/usr/local/lib/python3.6/dist-packages/numpy/testing/utils.py", line 1190, in assert_raises
return nose.tools.assert_raises(*args,**kwargs)
File "/usr/lib/python3.6/unittest/case.py", line 733, in assertRaises
return context.handle('assertRaises', args, kwargs)
File "/usr/lib/python3.6/unittest/case.py", line 178, in handle
callable_obj(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: Failure: ImportError (libsundials_cvode.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/usr/local/lib/python3.6/dist-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/python3.6/imp.py", line 235, in load_module
return load_source(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_on_funcs.py", line 16, in <module>
from scikits.odes.sundials.cvode import StatusEnum
ImportError: libsundials_cvode.so.2: cannot open shared object file: No such file or directory
======================================================================
ERROR: Failure: ImportError (libsundials_ida.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/usr/local/lib/python3.6/dist-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/python3.6/imp.py", line 235, in load_module
return load_source(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_on_funcs_ida.py", line 16, in <module>
from scikits.odes.sundials.ida import StatusEnumIDA
ImportError: libsundials_ida.so.2: cannot open shared object file: No such file or directory
======================================================================
ERROR: Failure: ImportError (libsundials_cvode.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/usr/local/lib/python3.6/dist-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/python3.6/imp.py", line 235, in load_module
return load_source(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_user_return_vals_cvode.py", line 5, in <module>
from ..sundials.cvode import StatusEnum
ImportError: libsundials_cvode.so.2: cannot open shared object file: No such file or directory
======================================================================
ERROR: Failure: ImportError (libsundials_ida.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/usr/local/lib/python3.6/dist-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/local/lib/python3.6/dist-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/python3.6/imp.py", line 235, in load_module
return load_source(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.6/dist-packages/scikits/odes/tests/test_user_return_vals_ida.py", line 5, in <module>
from ..sundials.ida import StatusEnumIDA
ImportError: libsundials_ida.so.2: cannot open shared object file: No such file or directory
----------------------------------------------------------------------
Ran 19 tests in 0.013s
FAILED (errors=16)
Out[2]: <nose.result.TextTestResult run=19 errors=16 failures=0>
May I know what is the reason for the errors? I have been trying out many different ways and tried to check online if anything similar but to no avail. Does anyone have any idea?
I know this is a pain as I've had to do it for the Haskell bindings to sundials but it would be good if it happened :)
I want to use scikits.odes and Sundials for the solution of differential algebraic equations in Python and therefore I am trying to install it on Ubuntu.
For the installation of Sundials, I followed the installation instructions and for my understanding it worked well.
cmake -DLAPACK_ENABLE=ON -DCMAKE_INSTALL_PREFIX=/usr/local/lib/sundials-4.0.2/ -DEXAMPLES_INSTALL_PATH=/home/myname/opt/sundials/examples-4.0.2 /home/myname/opt/sundials/sundials-4.0.2
make
sudo make install
Then I tried to install scikits.odes with the command pip3 install scikits.odes
, but I get the following error message (the last rows of the terminal output).
In file included from /home/veit/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
from /home/veit/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /home/veit/.local/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from scikits/odes/sundials/common_defs.c:639:
/home/veit/.local/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
scikits/odes/sundials/common_defs.c:641:10: fatal error: sundials/sundials_types.h: Datei oder Verzeichnis nicht gefunden
#include "sundials/sundials_types.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: Command "x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/veit/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c scikits/odes/sundials/common_defs.c -o build/temp.linux-x86_64-3.6/scikits/odes/sundials/common_defs.o -MMD -MF build/temp.linux-x86_64-3.6/scikits/odes/sundials/common_defs.o.d" failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-z5r81sw1/scikits.odes/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-gbpyrsno-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-z5r81sw1/scikits.odes/
What is wrong and how can I fix it? Any help would be appreciated!
Been using odes for a year or so but suddenly won't work. I'm on python 3.7.0, Arch linux. Sundials 3.1.2 is installed. I try reinstalling with pip install scikits.odes and get many errors as below. Thanks for any help!
odes_errors.txt
np.alen
is deprecated in 1.18. It can be replaced with len
.
Following up with issue #107, when I am using the command
from scikits.odes.sundials.cvode cimport CV_RhsFunction
and cythonize, I get the following error
hello.pyx:5:0: 'scikits/odes/sundials/cvode.pxd' not found
hello.pyx:5:0: 'scikits/odes/sundials/cvode/CV_RhsFunction.pxd' not found
Traceback (most recent call last):
File "setup.py", line 5, in
ext_modules=cythonize("hello.pyx"))
File "/gscratch/pfaendtner/Chowdhury/codes/Anaconda/envs/odes/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1096, in cythonize
cythonize_one(*args)
File "/gscratch/pfaendtner/Chowdhury/codes/Anaconda/envs/odes/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1219, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: hello.pyx
I get the same error too when I try to use cython magic in Jupiter notebook. I think I managed to install both the sundials and scikits.odes successfully as I can run other non-cython examples and nosetests. I also have set SUNDIALS_INST and LD_LIBRARY_PATH.
Any idea why this is not working?
I've been struggling with the instalation of scikits.odes through pip. I am currently working with Anaconda so I installed sundials using conda install -c conda-forge sundials
. Then, I read the conda documentation and said that for non-conda packages (like scikits.odes), one can use pip.
So I did sudo pip install scikits.odes
and surprisingly, an error occurred while executing setup.py, specifically: ImportError: No module named 'numpy'
.
I don't know why numpy is not found during the installation. Any ideas on how to fix this problem?
Python version: 2.7
conda version: 4.3.29
pip version: 9.0.1
scikits.odes version: 2.3.1
OS: Linux Mint 18
Thanks.
I am trying to install and use scikits.odes through pip on a Windows machine, but it is not working. The final error I get in the command prompt is:
Command "c:\users\miles\anaconda2\python.exe -u -c "import setuptools, tokenize;file='c:\users\miles\appdata\local\temp\pip-build-sekgu8\scikits.odes\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record c:\users\miles\appdata\local\temp\pip-sr8fq6-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\miles\appdata\local\temp\pip-build-sekgu8\scikits.odes\
I also got this error:
Failed building wheel for scikits.odes
Any ideas what the problem could be? I got assimulo up and running fine. I am running into a problem where my model is very slow, and I wanted to see if scikits.odes has any potential to improve the simulation speed.
Miles
I'm attempting to build ODES on a MacBook Pro running Mac OS X El Capitan (10.11.6). The problem I'm having is with the build ODES Scikits step of the procedure (see attached file).
One issue I've observed is that the script uses the gfortran compiler instead of the Absoft 2016 Pro Fortran compiler used in building the sundials procedure.
Please advise.
build_log_odes.txt
I should do a new release, but with all doc changes an pypi changes, I'm not sure about all steps. It used to be:
For a Release:
python setup.py sdist --formats=gztar register upload
Nothing changed to these instructions? I'd like to add these instructions to a dorelease.md in the project, so as to easily retrieve them later.
For the release number 2.3.2 or 2.4.0 ? I'd take 2.3.2 as changes mostly doc related, not API.
Or do you have something in the pipeline you would want in the next release?
I have build problems on my Mac (Big Sur) for python versions larger than 3.7. I try to compile the git-version of odes with sundials version 5.8 (since 6.0 changed the API).
It works for Python 3.7 but not for 3.8 and 3.9 and there is something in the build system I think. The error is AttributeError: 'Extension' object has no attribute 'extra_c_compile_args'
and I unfortunately don't know how to solve the problem.
Below is the traceback reporting the error.
Best,
Erik
Traceback (most recent call last):
File "setup.py", line 45, in <module>
setup(
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/__init__.py", line 155, in setup
return distutils.core.setup(**attrs)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 148, in setup
return run_commands(dist)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
dist.run_commands()
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
self.run_command(cmd)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/numpy/distutils/command/build.py", line 61, in run
old_build.run(self)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/Users/erifr93/tmp/odes_build/odes/setup_build.py", line 338, in run
_build_ext.run(self) # actually do the build
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/numpy/distutils/command/build_ext.py", line 316, in run
self.build_extensions()
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/Users/erifr93/tmp/odes_build/env/lib/python3.8/site-packages/numpy/distutils/command/build_ext.py", line 380, in build_extension
extra_cflags = ext.extra_c_compile_args or []
AttributeError: 'Extension' object has no attribute 'extra_c_compile_args'
Dear fellows,
I have tried to install scikits.odes on a Windows 10 OS with Anaconda 3, but I had some issues.
Packages Installed successfully:
SUNDIALS (conda install -c conda-forge sundials
)
c-complier (conda install -c conda-forge c-compiler
)
fortran-compiles (conda install -c conda-forge fortran-compiler
)
lapack (conda install -c conda-forge lapack
)
blas (conda install -c conda-forge blas
)
However, I had the following problems in order to install scikits.odes (pip install scikits.odes
)
error_scikits_odes.txt
Even with pip install -v scikits.odes
i had problems
ERROR: Failed building wheel for scikits.odes
ERROR: Could not build wheels for scikits.odes which use PEP 517 and cannot be installed directly
Could you help me ?
Thanks in advance.
We're using scikits.odes in a battery modelling project PyBaMM. We've run into the following difficulty getting it working as expected with our continuous integration: everything works fine with Python 3.6, but not with Python 3.5 and 3.7.
Example failure on 3.5
Example success on 3.6
Example failure on 3.7
In each of the failures the errors are reported as
ValueError: Integrator name <ida or cvode> does not exsist
With these specific failures I have tried using your Sundials installation scripts, and can't see any obvious reason that there would be any difference between python versions.
Have you seen this before? Any ideas what the problem might be? Thanks for your help!
numpy.distutils
is going to go away sometime in the near future (the timeline is unclear, likely due to it being driven by the CPython core devs). scipy seems to be switching to meson, so once they do a release with meson, I'll look at what's needed to convert this over.
I am going to install scikit.odes on Ubuntu
I do the following steps from an earlier post
conda create -n odes numpy cython
conda install -n odes -c conda-forge sundials=2.7.0
export SUNDIALS_INST="${HOME}/anaconda3/pkgs/sundials-2.7.0-blas_openblash0edd121_6"
source activate odes
pip install scikits.odes
but I get an error log.txt
Hi all, I wonder whether odes offers sensitivity equations from the Cvodes. Do we have some example for that? Thanks. Huan
Was digging to why I was getting errors like SystemError: x returned a result with an error set
(x is a placeholder) from inside odes, it appears except -1
/except? -1
doesn't behave like we expected (or at least how I expect it): it appears what it does is propagate the exception upwards when -1 is returned (rather than returning -1 on an exception). This means if you do raise an exception inside user code, you get weird SystemErrors which occur at the next "python" frame (which may be inside cython-compiled code). I think the solution is to remove the except
tags and use try-except with Exception (or BaseException), and return the error code manually in the except statement. I guess we should ask about this on the one of the cython mailing lists?
@florian98765 Did you have an example of where the exception handling works? I currently have a short test which I'll provide as a PR which breaks for me, but if you have an working example it may help understand what's going on...
Hello. I am trying to install scikits.odes on Mac OS 10.14. I am using Python 3.6 and 3.7 and SUNDIALS 3.1.1.
Both when using pip install
and python setup.py install
after cloning, I run into
/usr/local/bin/gfortran [... lots of linking] -lgfortran -o build/lib.macosx-10.9-x86_64-3.7/scikits/odes/ddaspk.cpython-37m-darwin.so
Undefined symbols for architecture x86_64:
"_PyArg_ParseTupleAndKeywords", referenced from:
_f2py_rout_ddaspk_ddaspk in ddaspkmodule.o
[... more stuff like this]
"__Py_NoneStruct", referenced from:
_f2py_rout_ddaspk_ddaspk in ddaspkmodule.o
_cb_res_in_ddaspk__user__routines in ddaspkmodule.o
_create_cb_arglist in ddaspkmodule.o
_cb_jac_in_ddaspk__user__routines in ddaspkmodule.o
_fortran_getattr in fortranobject.o
_fortran_setattr in fortranobject.o
_array_from_pyobj in fortranobject.o
...
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
and then
error: Command "/usr/local/bin/gfortran [... lots of linking] -lgfortran -o build/lib.macosx-10.9-x86_64-3.7/scikits/odes/ddaspk.cpython-37m-darwin.so" failed with exit status 1
Could you please guide me how to resolve this problem?
Hi!
Nice work with odes! But, of course, i have a question. Is this possible to use sparse jacobians in IDA? And another one: can i use iterative preconditioned solvers with custom preconditioner? Unfortunately my problems are quite large and dense jacobians is not an option for me so i'm looking for possible solutions...
Best regards,
Marek
One of my officemates was trying to cite scikits.odes (in https://arxiv.org/abs/1612.09383), but there's currently no citable object (e.g. paper, doi). We should add to http://joss.theoj.org/ (and maybe http://ascl.net/), so that scikits.odes can be cited.
Hi,
I am trying to use scikits.odes and managed to successfully install and run at Linux-based Hyak mox supercomputing cluster in University of Washington. Following the same protocol, I installed scikits.odes in my iMac (deleted the relevant words as found in #105). I got confirmation that it got installed properly (Successfully installed scikits.odes-2.4.1.dev0 scipy-1.3.1). However, when I try to run the simple piece of code for solving theVan der Pol oscillator, I get the following error
dlopen(/Users/chowdhury/anaconda2/envs/odes/lib/python3.6/site-packages/scikits/odes/sundials/cvode.cpython-36m-darwin.so, 2): Library not loaded: libsundials_cvode.3.dylib
Referenced from: /Users/chowdhury/anaconda2/envs/odes/lib/python3.6/site-packages/scikits/odes/sundials/cvode.cpython-36m-darwin.so
Reason: image not found
Traceback (most recent call last):
File "test.py", line 11, in
solution = ode('cvode', van_der_pol, old_api=False).solve(np.linspace(t0,500,200), y0)
File "/Users/chowdhury/anaconda2/envs/odes/lib/python3.6/site-packages/scikits/odes/ode.py", line 273, in init
integrator = find_ode_integrator(integrator_name)
File "/Users/chowdhury/anaconda2/envs/odes/lib/python3.6/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
I was wondering if you have any suggestion regarding this issue. Thanks a lot.
I have successfully installed scikits.odes using the following commands:
cmake -DLAPACK_ENABLE=ON -DCMAKE_INSTALL_PREFIX=/usr/local/lib/sundials-3.1.1/ -DEXAMPLES_INSTALL_PATH=/home/xenhua/Downloads/cantera-related/sundials-3.1.1/examples-3.1.1 ../sundials-3.1.1/
make
sudo make install
export SUNDIALS_INST=/usr/local/lib/sundials-3.1.1/
pip3 install scikits.odes
I can then verify the correct installation by using the "pip3 freeze" command: For example,
pip3 freeze | grep scikits
scikits.bootstrap==0.3.3
scikits.odes==2.4.0
and
pip freeze | grep scikit
scikit-learn==0.21.2
But then when I try to run the tests by importing scikits.odes as od, I get the following "ModuleNotFoundError:
import scikits.odes as od
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scikits'
I appear to have installed scikit-odes
successfully
bash-3.2$ CC=gcc-9 pip3 install scikits.odes
CC=gcc-9 pip3 install scikits.odes
Collecting scikits.odes
Using cached https://files.pythonhosted.org/packages/91/65/ab7ebd1a9a921f96bfb3d4e38db3c203e0f7e0781d73e35139277ea04baa/scikits.odes-2.4.0.tar.gz
Installing build dependencies ... done
Requirement already satisfied: scipy in /usr/local/lib/python3.7/site-packages (from scikits.odes) (1.3.0)
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/site-packages (from scipy->scikits.odes) (1.16.0)
Building wheels for collected packages: scikits.odes
Running setup.py bdist_wheel for scikits.odes ... done
Stored in directory: /Users/dominic.steinitz/Library/Caches/pip/wheels/5f/6e/6e/e0623cfb3bc8e90514e6b4c66e9587ecd83922304912fc9bed
Successfully built scikits.odes
Installing collected packages: scikits.odes
Successfully installed scikits.odes-2.4.0
bash-3.2$ python3
python3
Python 3.7.0 (default, Oct 2 2018, 09:20:07)
[Clang 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
import pkg_resources
>>> pkg_resources.get_distribution("scikits.odes").version
pkg_resources.get_distribution("scikits.odes").version
'2.4.0'
>>> quit()
quit()
But the tests fail
bash-3.2$ python3
python3
Python 3.7.0 (default, Oct 2 2018, 09:20:07)
[Clang 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scikits.odes as od; od.test()
import scikits.odes as od; od.test()
Running unit tests for scikits.odes
NumPy version 1.16.0
NumPy relaxed strides checking option: True
NumPy is installed in /usr/local/lib/python3.7/site-packages/numpy
Python version 3.7.0 (default, Oct 2 2018, 09:20:07) [Clang 10.0.0 (clang-1000.11.45.2)]
nose version 1.3.7
/usr/local/lib/python3.7/site-packages/nose/suite.py:106: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
if isinstance(tests, collections.Callable) and not is_suite:
../usr/local/lib/python3.7/site-packages/scikits/odes/dae.py:389: DeprecationWarning: Old api is deprecated, move to new api
return self._integrator.init_step(t0, y0, yp0, y_ic0_retn, yp_ic0_retn)
.....ode.get_info() =
{'NumSteps': 19, 'NumRhsEvals': 27, 'NumLinSolvSetups': 16, 'NumErrTestFails': 1, 'LastOrder': 2, 'CurrentOrder': 2, 'ActualInitStep': 0.0005000002493687262, 'LastStep': 5.632767015984214, 'CurrentStep': 11.121864790716213}
.True solution:
[ 1. 4. 9. 16. 25. 36. 49. 64. 81. 100.]
Integrated:
[ 1. 4.00000181 9.00000189 16.00000196 25.00000201
36.00000205 49.00000213 64.00000218 81.00000222 100.00000225]
Difference:
[0.00000000e+00 1.80709183e-06 1.88536923e-06 1.95964127e-06
2.00559588e-06 2.05370031e-06 2.12527937e-06 2.18137134e-06
2.22197630e-06 2.24709419e-06]
Relative:
[0.00000000e+00 4.51772957e-07 2.09485470e-07 1.22477579e-07
8.02238353e-08 5.70472309e-08 4.33730483e-08 3.40839272e-08
2.74318062e-08 2.24709419e-08]
.ode.get_info() =
{'NumSteps': 19, 'NumRhsEvals': 29, 'NumLinSolvSetups': 0, 'NumErrTestFails': 1, 'LastOrder': 2, 'CurrentOrder': 2, 'ActualInitStep': 0.0005000002493687262, 'LastStep': 5.632767015984214, 'CurrentStep': 11.121864790716213, 'NumPrecEvals': 0, 'NumPrecSolves': 0, 'NumJtimesEvals': 20, 'NumLinIters': 20, 'NumRhsEvalsJtimesFD': 20}
...E..........................
[CVDLS ERROR] cvDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVDLS ERROR] cvDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0 and h = 2.6974e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVODE ERROR] CVode
At t = 0 and h = 1.90735e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVSPILS ERROR] cvSpilsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVSPILS ERROR] cvSpilsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.0314249, mxstep steps taken before reaching tout.
.
[CVODE ERROR] CVode
At t = 0.0222206, mxstep steps taken before reaching tout.
.......
[CVODE ERROR] CVode
At t = 0, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.458122, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
The right-hand side routine failed at the first call.
.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
The above warning has been issued mxhnil times and will not be issued again for this problem.
[CVODE ERROR] CVode
At t = 0.5, mxstep steps taken before reaching tout.
..
[CVODE ERROR] cvRcheck1
At t = 0, the rootfinding routine failed in an unrecoverable manner.
.
[CVODE ERROR] cvRcheck3
At t = 0.458122, the rootfinding routine failed in an unrecoverable manner.
.
[CVODES WARNING] CVode
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
[IDADLS ERROR] idaDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDADLS ERROR] idaDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.....
[IDA ERROR] IDASolve
At t = 0, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0.287979, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0, repeated recoverable residual errors.
.
[IDA ERROR] IDASolve
At t = 0.5, , mxstep steps taken before reaching tout.
..
[IDA ERROR] IDARcheck1
At t = 0, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA ERROR] IDARcheck3
At t = 0.287979, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA WARNING] IDASolve
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
======================================================================
ERROR: odes.tests.test_odeint.test_odeint_banded_jacobian
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/usr/local/lib/python3.7/site-packages/scikits/odes/tests/test_odeint.py", line 330, in test_odeint_banded_jacobian
linsolver='lapackdense')
File "/usr/local/lib/python3.7/site-packages/scikits/odes/odeint.py", line 216, in odeint
return solver.solve(t, y0)
File "/usr/local/lib/python3.7/site-packages/scikits/odes/ode.py", line 333, in solve
return self._integrator.solve(tspan, y0)
File "scikits/odes/sundials/cvode.pyx", line 1724, in scikits.odes.sundials.cvode.CVODE.solve
File "scikits/odes/sundials/cvode.pyx", line 1762, in scikits.odes.sundials.cvode.CVODE._solve
File "scikits/odes/sundials/cvode.pyx", line 1577, in scikits.odes.sundials.cvode.CVODE._init_step
ValueError: LinSolver: Unknown solver type: lapackdense
----------------------------------------------------------------------
Ran 81 tests in 0.519s
FAILED (errors=1)
<nose.result.TextTestResult run=81 errors=1 failures=0>
>>> quit()
quit()
I'm working from the the freefall.py
example. I see how to find roots, and, I infer that the nr_rootfns=1
keyword argument is used to save them in the object returned when old_api=False
is given (though I can't find any documentation of this).
Is there any better documentation for the keyword arguments available when using cvode? I see
options : additional options of the solver
See set_options method of the `integrator_name` you selected for
details.
Set option `old_api=False` to use the new API. In the future, this
will become the default!
In the docstring for scikits.odes.ode
, but the docstring for my cvode solver's set_options
method is just
Set specific options for the solver.
See the solver documentation for details.
Calling set_options a second time, is only possible for options that
can change during runtime.
This is true whether or not I create the solver with old_api=False
.
From the freefall.py
example, I see how to find roots, and, I infer that the nr_rootfns=1
keyword argument is used to save them in the object returned when old_api=False
is given (though I can't find any documentation of this).
Is there a way to stop the integrator when it has found a root to some tolerance? Or do I just have to keep extending my solution until I find a root, then manually prune the excess trajectory using the information in result.roots
?
I spent several hours installing this morning :( I'm still not convinced everything is correct #95 but I can solve a simple ode now).
Even installing sundials wasn't entirely trivial. It would better to use homebrew or nixpkgs to ensure the required version (in fact nix or something similar is really the way to go packages that rely on other packages outside the the python ecosystem IMHO).
cd MyWorkingSundials/
cmake -DCMAKE_INSTALL_PREFIX=/Users/myname/MySundials/instdir -DEXAMPLES_INSTALL_PATH=/Users/myname/MySundials/instdir/examples /Users/myname/sundials-3.1.1
export SUNDIALS_INST=/Users/myname/MySundials/instdir
CC=gcc-9 pip3 install scikits.odes
export DYLD_LIBRARY_PATH=/Users/myname/MySundials/instdir/lib
I may have missed some steps.
There should be clear guidelines for third-parties wishing to:
-Contribute to the software
-Report issues or problems with the software
-Seek support
See for example this Contributing.md
While packaging scikits-odes for nixpkgs, I noticed TestDae.test_lsodi fails on aarch64-linux
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-4.6.3, py-1.7.0, pluggy-0.12.0
rootdir: /nix/store/avziwbawg0ibqccizgxfmhjcnjbbg7nd-python3.7-scikits.odes-2.4.0/lib/python3.7/site-packages/scikits/odes/tests
collected 81 items
test_dae.py ...F [ 4%]
test_dop.py . [ 6%]
test_get_info.py ..... [ 12%]
test_odeint.py ..... [ 18%]
test_on_funcs.py ............ [ 33%]
test_on_funcs_ida.py ............ [ 48%]
test_user_return_vals_cvode.py ........................ [ 77%]
test_user_return_vals_ida.py .................. [100%]
=================================== FAILURES ===================================
______________________________ TestDae.test_lsodi ______________________________
self = <odes.tests.test_dae.TestDae testMethod=test_lsodi>
def test_lsodi(self):
"""Check the lsodi solver"""
for problem_cls in PROBLEMS_LSODI:
problem = problem_cls()
> self._do_problem(problem, 'lsodi', **problem.lsodi_pars)
test_dae.py:59:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_dae.py:34: in _do_problem
soln = ig.step(time, z[i], zprime[i])
../dae.py:439: in step
return self._integrator.step(t, y_retn, yp_retn)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <scikits.odes.lsodiint.lsodi object at 0xffff7ae2b310>, t = 400.0
y_retn = array([4.70187465e-01, 3.48124556e-06, 5.29809054e-01])
yp_retn = array([4.50537891e-01, 3.22315111e-06, 5.49458886e-01])
def step(self, t, y_retn, yp_retn = None):
""" See dae.DaeBase
"""
if not self.initialized:
raise ValueError('Method ''init_step'' has to be called prior to the'
'first call of ''step'' method, or after changing options')
if t > 0.0:
if self.tstop is None:
itask = 1
self.call_args[3] = 1
else:
itask = self.call_args[3]
self.call_args[3] = 4
self.y, self.yp, self.t = self.__run(self.y, self.yp, self.t, t)
self.call_args[3] = itask
else:
itask = self.call_args[3]
if self.tstop is None:
self.call_args[3] = 2
else:
self.call_args[3] = 5
self.y, self.yp, self.t = self.__run(self.y, self.yp, self.t, -t)
self.call_args[3] = itask
y_retn[:] = self.y[:]
if yp_retn is not None:
> yp_retn[:] = self.yp[:]
E TypeError: 'NoneType' object is not subscriptable
../lsodiint.py:376: TypeError
----------------------------- Captured stdout call -----------------------------
lsodi: excess work done on this call (check all inputs).
lsodi: present residual is [-1.17961196e-15 5.42101086e-20 -6.17733149e-12]
=============================== warnings summary ===============================
test_dae.py::TestDae::test_ida_old_api
test_dae.py::TestDae::test_ida_old_api
test_dae.py::TestDae::test_ida_old_api
/nix/store/avziwbawg0ibqccizgxfmhjcnjbbg7nd-python3.7-scikits.odes-2.4.0/lib/python3.7/site-packages/scikits/odes/dae.py:389: DeprecationWarning: Old api is deprecated, move to new api
return self._integrator.init_step(t0, y0, yp0, y_ic0_retn, yp_ic0_retn)
-- Docs: https://docs.pytest.org/en/latest/warnings.html
=============== 1 failed, 80 passed, 3 warnings in 1.94 seconds ================
builder for '/nix/store/p3r9d2bn6dl34ghgpq7fv3v0i4p9ql5l-python3.7-scikits.odes-2.4.0.drv' failed with exit code 1
It's only that one test, and it runs on both x86_64-linux
and x86_64-darwin
just fine. Anybody knows what's going on here?
I'm trying to find out how many evaluations of the RHS the integrator needed to reach a certain time. Is it possible to get the result of CVodeGetNumRhsEvals? Haven't found anything besides the definition while digging through the code base.
If I haven't overlooked it, I'd be happy to implement this. Any preferences for the API? I'm imagining adding it to the CVODE class in scikits/odes/sundials/cvode.pyx
.
Using ubuntu:16.04
image.
apt-get install python python-dev python-virtualenv virtualenvwrapper cmake cmake-curses-gui libopenblas-* libatlas-* liblapack-*
I compiled sundials with LAPACK interface as for documentation
mkvirtualenv pysundials
pip install numpy
pip install scikits.odes
tid@ab44bef2e9ee:~$ SUNDIALS_INST=/opt/sundials pip install scikits.odes
Collecting scikits.odes
Using cached scikits.odes-2.3.1.tar.gz
Complete output from command python setup.py egg_info:
=============================================
parent package is scikits
top path is /tmp/pip-build-qar7lr/scikits.odes
=============================================
pkgconfig module not found, using preset paths
SUNDIALS installation path set to `/opt/sundials` via $SUNDIALS_INST.
lapack_opt_info:
lapack_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/home/tid/.virtualenvs/pysundials/lib', '/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
NOT AVAILABLE
openblas_lapack_info:
customize UnixCCompiler
customize UnixCCompiler
customize UnixCCompiler
C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC
creating /tmp/tmpYg2j4J/tmp
creating /tmp/tmpYg2j4J/tmp/tmpYg2j4J
compile options: '-c'
x86_64-linux-gnu-gcc: /tmp/tmpYg2j4J/source.c
/tmp/tmpYg2j4J/source.c:1:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
void zungqr();
^
/tmp/tmpYg2j4J/source.c: In function 'main':
/tmp/tmpYg2j4J/source.c:4:13: warning: implicit declaration of function 'zungqr_' [-Wimplicit-function-declaration]
zungqr_();
^
x86_64-linux-gnu-gcc -pthread /tmp/tmpYg2j4J/tmp/tmpYg2j4J/source.o -lopenblas -o /tmp/tmpYg2j4J/a.out
customize UnixCCompiler
FOUND:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
FOUND:
libraries = ['openblas', 'openblas']
library_dirs = ['/usr/lib']
language = c
define_macros = [('HAVE_CBLAS', None)]
Found LAPACK paths via lapack_opt ...
=============================================
parent package is scikits.odes
top path is /tmp/pip-build-qar7lr/scikits.odes
=============================================
cython -2 -o /tmp/pip-build-qar7lr/scikits.odes/scikits/odes/sundials/common_defs.c.new /tmp/pip-build-qar7lr/scikits.odes/scikits/odes/sundials/common_defs.pyx
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-qar7lr/scikits.odes/setup.py", line 62, in <module>
setup_package()
File "/tmp/pip-build-qar7lr/scikits.odes/setup.py", line 56, in setup_package
'': ['*.pxd'],
File "/home/tid/.virtualenvs/pysundials/local/lib/python2.7/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "/tmp/pip-build-qar7lr/scikits.odes/setup.py", line 36, in configuration
config.add_subpackage(DISTNAME)
File "/home/tid/.virtualenvs/pysundials/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
caller_level = 2)
File "/home/tid/.virtualenvs/pysundials/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
caller_level = caller_level + 1)
File "/home/tid/.virtualenvs/pysundials/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scikits/odes/setup.py", line 26, in configuration
config.add_subpackage('sundials')
File "/home/tid/.virtualenvs/pysundials/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
caller_level = 2)
File "/home/tid/.virtualenvs/pysundials/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
caller_level = caller_level + 1)
File "/home/tid/.virtualenvs/pysundials/local/lib/python2.7/site-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scikits/odes/sundials/setup.py", line 114, in configuration
include_dirs=[])
File "/tmp/pip-build-qar7lr/scikits.odes/scikits/odes/_build.py", line 85, in cython
status = subprocess.call(['cython', '-2', '-o', c_file_new, pyxfile])
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-qar7lr/scikits.odes/
(pysundials) tid@ab44bef2e9ee:~$ ls /opt/sundials/
LICENSE examples include lib
What am I missing?
Fedora 31 x86_64, Python 3.7, openblas from fedora repo, scikits.odes ver. 2.6.1
Sundials 5.1.0 (as recomended) installed to $HOME/opt/sundials/
:
cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_SIZE=64 -DCMAKE_INSTALL_PREFIX=$HOME/opt/sundials/ ../sundials-5.1.0/
make install
For my setup, snippet above installs libraries to lib64 subdirectory not lib/
After that pip fails due to ld cannot locate sundials libraries:
export SUNDIALS_INST=$HOME/opt/sundials
pip3 install scikits.odes
<...>
gcc -pthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -g build/temp.linux-x86_64-3.7/scikits/odes/sundials/common_defs.o -L/home/my_user/opt/sundials/lib -L/usr/lib64 -L/usr/lib64 -lsundials_nvecserial -lsundials_sunlinsollapackband -lsundials_sunlinsollapackdense -lsundials_sunlinsolband -lsundials_sunlinsoldense -lsundials_sunlinsolpcg -lsundials_sunlinsolspbcgs -lsundials_sunlinsolspfgmr -lsundials_sunlinsolspgmr -lsundials_sunlinsolsptfqmr -lsundials_sunmatrixband -lsundials_sunmatrixdense -lsundials_sunmatrixsparse -lopenblas -lopenblas -lpython3.7m -o build/lib.linux-x86_64-3.7/scikits/odes/sundials/common_defs.cpython-37m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lsundials_nvecserial
/usr/bin/ld: cannot find -lsundials_sunlinsollapackband
/usr/bin/ld: cannot find -lsundials_sunlinsollapackdense
<...>
So we can see there's only -L/home/my_user/opt/sundials/lib
library path and no lib64
one.
Exporting LD_LIBRARY_PATH didn't help.
But when I created link ln -s $SUNDIALS_INST/lib64/ $SUNDIALS_INST/lib
, installation worked well.
Hi All,
I wondered whether we set parameters for rhs function in scikits.odes.ode, something similar to sicpy: scipy.integrate.ode.set_f_params.
I have tried to set parameters as global ones which works indeed. However, I still want to know whether I can set parameters more explicitly because that will probably make easier in some cases e.g when multiple cores are used for different sets of parameter values. Thanks.
Regards,
Huan
I'm trying to install odes on an ubuntu 18.04 system. I've installed the dependencies and sundials as per the instructions here: https://scikits-odes.readthedocs.io/en/latest/installation.html#requirements-before-install
when I try to install odes with the command:
SUNDIALS_INST=/home/mrobins/sundials-3.1.1/install pip install scikits.odes
It falls over with the error shown below.
Collecting scikits.odes
Using cached https://files.pythonhosted.org/packages/91/65/ab7ebd1a9a921f96bfb3d4e38db3c203e0f7e0781d73e35139277ea04baa/scikits.odes-2.4.0.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... error
Complete output from command /home/mrobins/tmp/test/bin/python3 /home/mrobins/tmp/test/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp4httixax:
Traceback (most recent call last):
File "/home/mrobins/tmp/test/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/home/mrobins/tmp/test/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/mrobins/tmp/test/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-163crzl0/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 115, in get_requires_for_build_wheel
return _get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-163crzl0/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 101, in _get_build_requires
_run_setup()
File "/tmp/pip-build-env-163crzl0/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 85, in _run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 15, in <module>
from common import *
ModuleNotFoundError: No module named 'common'
----------------------------------------
Command "/home/mrobins/tmp/test/bin/python3 /home/mrobins/tmp/test/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp4httixax" failed with error code 1 in /tmp/pip-install-nja1jf80/scikits.odes
It looks like it can't see the common.py
in the root directory of your repo, but I can't see why not.
I installed odes, but the tests using the command
import scikits.odes as od; od.test()
fail. I get the following output:
Running unit tests for scikits.odes
NumPy version 1.14.3
NumPy relaxed strides checking option: True
NumPy is installed in /usr/lib64/python2.7/site-packages/numpy
Python version 2.7.15 (default, May 16 2018, 17:50:09) [GCC 8.1.1 20180502 (Red Hat 8.1.1-1)]
nose version 1.3.7
libsundials_ida.so.2: cannot open shared object file: No such file or directory
libsundials_cvode.so.2: cannot open shared object file: No such file or directory
EEException AttributeError: "'dae' object has no attribute '_integrator'" in <bound method dae.__del__ of <scikits.odes.dae.dae object at 0x7f4a48da2c50>> ignored
EException AttributeError: "'dae' object has no attribute '_integrator'" in <bound method dae.__del__ of <scikits.odes.dae.dae object at 0x7f4a488eb410>> ignored
E.EEEEEE.EE.EEEE
======================================================================
ERROR: Check the ddaspk solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 52, in test_ddaspk
problem = problem_cls()
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 211, in __init__
old_api=False,
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: Check the ida solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 71, in test_ida
self._do_problem(problem, 'ida', old_api=False, **problem.ida_pars)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 27, in _do_problem
ig = dae(integrator, res, jacfn=jac, old_api=old_api)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/dae.py", line 280, in __init__
integrator = find_dae_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/dae.py", line 481, in find_dae_integrator
raise ValueError('Integrator name %s does not exsist' % name)
ValueError: Integrator name ida does not exsist
======================================================================
ERROR: Check the ida solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 65, in test_ida_old_api
self._do_problem(problem, 'ida', old_api=True, **problem.ida_pars)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 27, in _do_problem
ig = dae(integrator, res, jacfn=jac, old_api=old_api)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/dae.py", line 280, in __init__
integrator = find_dae_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/dae.py", line 481, in find_dae_integrator
raise ValueError('Integrator name %s does not exsist' % name)
ValueError: Integrator name ida does not exsist
======================================================================
ERROR: Check the lsodi solver
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 58, in test_lsodi
problem = problem_cls()
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_dae.py", line 211, in __init__
old_api=False,
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_get_info_is_exposed_on_ode (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_get_info_returns_dict (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_ode_exposes_num_rhs_evals (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_we_integrated_correctly (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_ode_exposes_num_njtimes_evals (scikits.odes.tests.test_get_info.GetInfoTestSpils)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_get_info.py", line 50, in setUp
self.ode = ode('cvode', rhs, linsolver="spgmr", old_api=False)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_odeint (scikits.odes.tests.test_odeint.TestOdeint)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_odeint.py", line 47, in test_odeint
self._do_problem(problem)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_odeint.py", line 33, in _do_problem
sol = odeint(problem.f, t, problem.z0, method=method)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: scikits.odes.tests.test_odeint.test_odeint_banded_jacobian
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_odeint.py", line 292, in test_odeint_banded_jacobian
jacfn=jac)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: scikits.odes.tests.test_odeint.test_odeint_errors
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_odeint.py", line 403, in test_odeint_errors
assert_raises(ZeroDivisionError, odeint, bad1, [0, 1], [1.0])
File "/usr/lib64/python2.7/site-packages/numpy/testing/nose_tools/utils.py", line 1191, in assert_raises
return nose.tools.assert_raises(*args,**kwargs)
File "/usr/lib64/python2.7/unittest/case.py", line 511, in assertRaises
callableObj(*args, **kwargs)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: Failure: ImportError (libsundials_cvode.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_on_funcs.py", line 16, in <module>
from scikits.odes.sundials.cvode import StatusEnum
ImportError: libsundials_cvode.so.2: cannot open shared object file: No such file or directory
======================================================================
ERROR: Failure: ImportError (libsundials_ida.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_on_funcs_ida.py", line 16, in <module>
from scikits.odes.sundials.ida import StatusEnumIDA
ImportError: libsundials_ida.so.2: cannot open shared object file: No such file or directory
======================================================================
ERROR: Failure: ImportError (libsundials_cvode.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_user_return_vals_cvode.py", line 5, in <module>
from ..sundials.cvode import StatusEnum
ImportError: libsundials_cvode.so.2: cannot open shared object file: No such file or directory
======================================================================
ERROR: Failure: ImportError (libsundials_ida.so.2: cannot open shared object file: No such file or directory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/dhalpern/.local/lib/python2.7/site-packages/scikits/odes/tests/test_user_return_vals_ida.py", line 5, in <module>
from ..sundials.ida import StatusEnumIDA
ImportError: libsundials_ida.so.2: cannot open shared object file: No such file or directory
----------------------------------------------------------------------
Ran 19 tests in 0.009s
FAILED (errors=16)
<nose.result.TextTestResult run=19 errors=16 failures=0>
>>>
FYI, I have sundials installed in /usr/local/sundials27
I tried to modify scikits/odes/sundials/setup.py but this didn't work.
Any suggestions would be greatly appreciated.
See this github page for a good guide to get a DOI via Zenodo. The badge can also be added to the read-me if desired
I'm using scikits
because it's listed on the CVODE webpage. I'm building a biochemical simulator. Since populations of molecules must be non-negative, I'm following the advice in Hindmarsh, Serban and Reynolds, User Documentation for cvode v5.0.0, 2019, which recommends that tighter absolute tolerances be used to reduce the magnitude of negative values. However, I find that changing atol
does not change the solver behavior. I'm passing atol like this:
from scikits.odes import ode
options = {'atol': 1e-11}
CVODE_SOLVER = 'cvode'
solver = ode(CVODE_SOLVER, right_hand_side, old_api=False, **options)
Is this correct? Do you have an example that uses atol to adjust absolute tolerances for CVODE?
Thanks, Arthur
We should move to latest sundials.
Much to do as solvers have been abstracted away.
start of a working branch: https://github.com/bmcage/odes/tree/sundials_3_1
Hi,
Thanks for bringing together this very nice work! I tried to compile it on macOS Catalina with Sundials 5.0.0. It says #include <sundials/sundials_pcg.h> file not found.
I downgraded to sundials=4.1.0 and it compiles. There is no particular reason for me to use a higher version though. I'm posting the issue here for reference.
I will look into it later.
Hi, I have a question regarding the performance graph in the documentation.
I tried cvode
and rk5
on a small 3d finite difference discretization (11x11x11), cvode
turned out to be much slower than rk5
:
RK5: 22 ms
CVODE: 1.57 s
I think the performance graph in the docs is for a relatively small system (<100 equations), and as the number of equations increase, explicit integrators tend to outperform implicit ones, even though they use a much larger number of time steps (to maintain stability). What do you think?
I believe I have built sundials with lapack:
cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_TYPE=int32_t -DCMAKE_INSTALL_PREFIX=/Users/dominic.steinitz/MySundials/instdir -DEXAMPLES_INSTALL_PATH=/Users/dominic.steinitz/MySundials/instdir/examples /Users/dominic.steinitz/sundials-3.1.1
-- The Fortran compiler identification is GNU 9.1.0
-- Searching for a Fortran compiler... /usr/local/bin/gfortran
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Trying to compile and link a simple Fortran program... OK
-- Determining Fortran name-mangling scheme... OK
-- Looking for LAPACK libraries... OK
-- Checking if LAPACK works... OK
-- Added NVECTOR_SERIAL module
-- Added SUNMATRIX_DENSE module
-- Added SUNMATRIX_BAND module
-- Added SUNMATRIX_SPARSE module
-- Added SUNLINSOL_BAND module
-- Added SUNLINSOL_DENSE module
-- Added SUNLINSOL_LAPACKBAND module
-- Added SUNLINSOL_LAPACKDENSE module
-- Added SUNLINSOL_SPGMR module
-- Added SUNLINSOL_SPFGMR module
-- Added SUNLINSOL_SPBCGS module
-- Added SUNLINSOL_SPTFQMR module
-- Added SUNLINSOL_PCG module
-- Added ARKODE module
-- Added CVODE module
-- Added CVODES module
-- Added IDA module
-- Added IDAS module
-- Added KINSOL module
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
sundials_arkode_shared
sundials_cvode_shared
sundials_cvodes_shared
sundials_ida_shared
sundials_idas_shared
sundials_kinsol_shared
sundials_nvecserial_shared
sundials_sunlinsolband_shared
sundials_sunlinsoldense_shared
sundials_sunlinsollapackband_shared
sundials_sunlinsollapackdense_shared
sundials_sunlinsolpcg_shared
sundials_sunlinsolspbcgs_shared
sundials_sunlinsolspfgmr_shared
sundials_sunlinsolspgmr_shared
sundials_sunlinsolsptfqmr_shared
sundials_sunmatrixband_shared
sundials_sunmatrixdense_shared
sundials_sunmatrixsparse_shared
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
But if I run the tests I get this error
python3
Python 3.7.0 (default, Oct 2 2018, 09:20:07)
[Clang 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scikits.odes as od; od.test()
import scikits.odes as od; od.test()
Running unit tests for scikits.odes
NumPy version 1.16.4
NumPy relaxed strides checking option: True
NumPy is installed in /usr/local/lib/python3.7/site-packages/numpy
Python version 3.7.0 (default, Oct 2 2018, 09:20:07) [Clang 10.0.0 (clang-1000.11.45.2)]
nose version 1.3.7
/usr/local/lib/python3.7/site-packages/nose/suite.py:106: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
if isinstance(tests, collections.Callable) and not is_suite:
../usr/local/lib/python3.7/site-packages/scikits/odes/dae.py:389: DeprecationWarning: Old api is deprecated, move to new api
return self._integrator.init_step(t0, y0, yp0, y_ic0_retn, yp_ic0_retn)
.....ode.get_info() =
{'NumSteps': 19, 'NumRhsEvals': 27, 'NumLinSolvSetups': 16, 'NumErrTestFails': 1, 'LastOrder': 2, 'CurrentOrder': 2, 'ActualInitStep': 0.0005000002493687262, 'LastStep': 5.632767015984214, 'CurrentStep': 11.121864790716213}
.True solution:
[ 1. 4. 9. 16. 25. 36. 49. 64. 81. 100.]
Integrated:
[ 1. 4.00000181 9.00000189 16.00000196 25.00000201
36.00000205 49.00000213 64.00000218 81.00000222 100.00000225]
Difference:
[0.00000000e+00 1.80709183e-06 1.88536923e-06 1.95964127e-06
2.00559588e-06 2.05370031e-06 2.12527937e-06 2.18137134e-06
2.22197630e-06 2.24709419e-06]
Relative:
[0.00000000e+00 4.51772957e-07 2.09485470e-07 1.22477579e-07
8.02238353e-08 5.70472309e-08 4.33730483e-08 3.40839272e-08
2.74318062e-08 2.24709419e-08]
.ode.get_info() =
{'NumSteps': 19, 'NumRhsEvals': 29, 'NumLinSolvSetups': 0, 'NumErrTestFails': 1, 'LastOrder': 2, 'CurrentOrder': 2, 'ActualInitStep': 0.0005000002493687262, 'LastStep': 5.632767015984214, 'CurrentStep': 11.121864790716213, 'NumPrecEvals': 0, 'NumPrecSolves': 0, 'NumJtimesEvals': 20, 'NumLinIters': 20, 'NumRhsEvalsJtimesFD': 20}
..............................
[CVDLS ERROR] cvDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVDLS ERROR] cvDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the setup routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0 and h = 2.6974e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVODE ERROR] CVode
At t = 0 and h = 1.90735e-09, the corrector convergence test failed repeatedly or with |h| = hmin.
.
[CVSPILS ERROR] cvSpilsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVSPILS ERROR] cvSpilsSolve
The Jacobian x vector routine failed in an unrecoverable manner.
[CVODE ERROR] CVode
At t = 0, the solve routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.0314249, mxstep steps taken before reaching tout.
.
[CVODE ERROR] CVode
At t = 0.0222206, mxstep steps taken before reaching tout.
.......
[CVODE ERROR] CVode
At t = 0, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
At t = 0.458122, the right-hand side routine failed in an unrecoverable manner.
.
[CVODE ERROR] CVode
The right-hand side routine failed at the first call.
.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.70033e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.25083e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 2.65677e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 1.66048e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
Internal t = 0.5 and h = 4.1512e-17 are such that t + h = t on the next step. The solver will continue anyway.
[CVODE WARNING] CVode
The above warning has been issued mxhnil times and will not be issued again for this problem.
[CVODE ERROR] CVode
At t = 0.5, mxstep steps taken before reaching tout.
..
[CVODE ERROR] cvRcheck1
At t = 0, the rootfinding routine failed in an unrecoverable manner.
.
[CVODE ERROR] cvRcheck3
At t = 0.458122, the rootfinding routine failed in an unrecoverable manner.
.
[CVODES WARNING] CVode
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
[IDADLS ERROR] idaDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDADLS ERROR] idaDlsSetup
The Jacobian routine failed in an unrecoverable manner.
[IDA ERROR] IDASolve
At t = 0, the linear solver setup failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.
[IDA ERROR] IDASolve
At t = 0 and h = 9.53674e-10, the corrector convergence failed repeatedly or with |h| = hmin.
.....
[IDA ERROR] IDASolve
At t = 0, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0.287979, the residual function failed unrecoverably.
.
[IDA ERROR] IDASolve
At t = 0, repeated recoverable residual errors.
.
[IDA ERROR] IDASolve
At t = 0.5, , mxstep steps taken before reaching tout.
..
[IDA ERROR] IDARcheck1
At t = 0, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA ERROR] IDARcheck3
At t = 0.287979, , the rootfinding routine failed in an unrecoverable manner.
.
[IDA WARNING] IDASolve
At the end of the first step, there are still some root functions identically 0. This warning will not be issued again.
...
----------------------------------------------------------------------
Ran 81 tests in 0.599s
OK
<nose.result.TextTestResult run=81 errors=0 failures=0>
Hey, guys, really nice work!
I checked in cvode.pyx and apparently CVODE's default multistep (lmm_type in defaults dictionary) method is BDF, is that right? Just wanted a confirmation. Maybe I didn't see it, but I couldn't find it on the documentation.
In https://github.com/bmcage/odes/blob/master/docs/ipython/Performance%20tests.ipynb
the userdata k is passed as an object.
Is that the reason for little speedup for cvode in cythonized version?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.