1

I am working on an overly stiff, Michaelis-Menten-type system (already implemented and published in Matlab, solved easily with ode15s). I translated it to Python, but no solver can move on beyond step 2 in the integration. I have tried:

#time
t_start = -10
t_end = 12
t_step = 0.01

# Number of time steps: 1 extra for initial condition
num_steps = np.floor((t_end - t_start)/t_step) + 1
[...]
#integration

r = integrate.ode(JahanModel_ODE).set_integrator('lsoda', atol=1e-8,rtol=1e-6)

and also for the integrator:

 r = integrate.ode(JahanModel_ODE).set_integrator('vode',method='bdf', order=5)

with different tolerances.

All I get is

UserWarning: lsoda: Excess work done on this call (perhaps wrong Dfun type). 'Unexpected istate=%s' % istate))

or

UserWarning: vode: Excess work done on this call. (Perhaps wrong MF.) 'Unexpected istate=%s' % istate))

I also tried different values for t_step.

There already seemed to be a satisfying answer here: Integrate stiff ODEs with Python, but the links are not working anymore and googling suggested that lsoda is already superior to LSODE.

EDIT: Here is the complete code, without the plotting instances. Gistlink

Community
  • 1
  • 1
Moiraine24
  • 369
  • 1
  • 5
  • 16
  • 1
    Can you post your whole code? Solving stiff systems can be fiddly and it would be easier to help you out if I could try to solve the system myself. – davidrpugh Apr 12 '17 at 08:36
  • Since you've translated this code, I'd also suggest checking that you haven't introduced any typos. These systems can be sensitive to any transposition of a parameter's digits or sign. It should be straightforward to feed feed the outputs from `ode15s` into both your Matlab and Python ODE functions to confirm that the results are the same (within a small numerical tolerance). – horchler Apr 12 '17 at 20:41
  • The code appears to be too long @davidrpugh, by 15000 characters. How can I upload it? Since it was mostly copy&paste and I checked it several times, I don't think the possibility of typos is that big. I will check it again though. – Moiraine24 Apr 13 '17 at 07:13
  • @Moiraine24 If you have a GitHub account, then you could make the code available via a gist and then provide a link in your SO post. – davidrpugh Apr 13 '17 at 10:44
  • @davidrpugh alright! I hope it works... – Moiraine24 Apr 13 '17 at 11:59
  • 1
    Did you try changing the `order=15` to like `order=2` in line 1031 of your code [(from the scipy code if you are using BDF order <=5)](https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.integrate.ode.html) – qbzenker Apr 15 '17 at 23:16
  • 1
    @qbzenker: yes, I tried different orders, tolerances and also different values for t_step. Nothing worked. – Moiraine24 Apr 18 '17 at 09:21

0 Answers0