1

我正在使用 JiTCODE 来计算 Lorenz 振荡器的 Lyapunov 指数。

这是文档之后的简单脚本:

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])

我收到以下错误。

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

我认为方程式不是问题,因为我已经解决了jitcodejitcode_lyap无法解决。

4

1 回答 1

0

从开发者那里得到了答案

您的问题是您的集成步骤太长。由于切向量仅在每个积分步骤后重新归一化,这会导致它们中的数值溢出,因为洛伦兹系统的时间尺度比文档中用作示例的时间尺度小得多。

使用times = range(1, 100, 1)修复此问题。

于 2020-12-06T15:25:54.453 回答