1

I am using JiTCODE to calculate the Lyapunov exponents of the Lorenz oscillator.

Here is the simple script following the documentation:

import numpy as np
import pylab as plt
from jitcode import jitcode_lyap, y


p, r, b = 10.0, 28.0, 8.0/3.0

x0 = np.array([10.0, 10.0, 5.0])
f = [
    p * y(1) - p * y(0),
    -y(0) * y(2) + r * y(0) - y(1),
    y(0) * y(1) - b * y(2)
]

n = len(f)
times = range(10, 1000, 10)
nstep = len(times)
lyaps = np.zeros((nstep, n))

ODE = jitcode_lyap(f, n_lyap=n)
ODE.set_integrator("vode")
ODE.set_initial_value(x0, 0.0)

for time in times:
    print(ODE.integrate(time)[1])

And I got the following error.

Generating, compiling, and loading C code.
generated C code for f
generated symbolic Jacobian
generated C code for Jacobian
/usr/local/lib/python3.6/dist-packages/scipy/integrate/_ode.py:1009: UserWarning: vode: Excess work done on this call. (Perhaps wrong MF.)
  self.messages.get(istate, unexpected_istate_msg)))
Traceback (most recent call last):
  File "main.py", line 29, in <module>
    print(ODE.integrate(time)[1])
  File "/home/abolfazl/.local/lib/python3.6/site-packages/jitcode/_jitcode.py", line 755, in integrate
    super(jitcode_lyap, self).integrate(*args, **kwargs)
  File "/home/abolfazl/.local/lib/python3.6/site-packages/jitcode/_jitcode.py", line 656, in integrate
    return self.integrator.integrate(*args,**kwargs)
  File "/home/abolfazl/.local/lib/python3.6/site-packages/jitcode/integrator_tools.py", line 131, in integrate
    raise UnsuccessfulIntegration
jitcode.integrator_tools.UnsuccessfulIntegration

I think the equation is not the problem because I have solved that with jitcode but jitcode_lyap can not solve it.

Wrzlprmft
  • 4,234
  • 1
  • 28
  • 54
Abolfazl
  • 1,047
  • 2
  • 12
  • 29

1 Answers1

0

I got the answer from the developer:

Your problem is that your integration steps are too long. Since the tangent vectors are only re-normalised after every integration step, this causes numerical overflows in them as the Lorenz system has a much smaller time scale than the one used as an example in the documentation.

Using times = range(1, 100, 1) fixes this.

Wrzlprmft
  • 4,234
  • 1
  • 28
  • 54
Abolfazl
  • 1,047
  • 2
  • 12
  • 29