如何使用 integrate.odeint 解释已求解的 ODE 系统的结果?
How can one interpret the results from a solved system of ODEs using integrate.odeint?
我正在求解洛伦兹方程组(3 个常微分方程),我的代码如下。
from scipy.integrate import odeint
import numpy as np
from numpy import array, arange
def Lorentz(state,t): #Define the function for the derivatives for each equation
u = state[0]
v = state[1]
w = state[2] #Give each differential equation (u, v and w) a state.
a = 5.0
b = 0.9
c = 8.2 #Define the constants a, b and c.
du = -a*(u - v)
dv = c*u - v - u*w
dw = -b*w + u*v #Define the differential equations u, v and w.
return [du, dv, dw] #Return the set of differential equations that the function defines.
state0 = [0.0, 1.0, 2.0] #Define the set of inition conditions for u, v and w, respectively.
t = arange(0.0, 10.0, 0.7) #Solve the equations from t=0 to t=10.
print odeint(Lorentz, state0, t)
当我运行代码用
t = arange(0.0, 10.0, arg)
我得到的结果数量取决于 "arg" 的值。如果我选择一个大的值,我会得到少量的结果。对于任何高于 10.0 的值,这都会给出一个数组 [0.0, 1.0, 2.0]。
对于较低的值,数组中的行数会变大,但第一行保持不变。对于像 0.01 这样非常低的值,我得到了大量的数字,第一行总是 [0.0, 1.0, 2.0].
数组中的所有数字是多少?微分方程组的每个方程肯定只有一个解吗?
您知道 ODE 积分的结果是一个函数吗?
第 k
行(从 0
开始)对应于时间 t[k]
的函数值。时间 t[0]
的第一行包含初始值 state0
.
我正在求解洛伦兹方程组(3 个常微分方程),我的代码如下。
from scipy.integrate import odeint
import numpy as np
from numpy import array, arange
def Lorentz(state,t): #Define the function for the derivatives for each equation
u = state[0]
v = state[1]
w = state[2] #Give each differential equation (u, v and w) a state.
a = 5.0
b = 0.9
c = 8.2 #Define the constants a, b and c.
du = -a*(u - v)
dv = c*u - v - u*w
dw = -b*w + u*v #Define the differential equations u, v and w.
return [du, dv, dw] #Return the set of differential equations that the function defines.
state0 = [0.0, 1.0, 2.0] #Define the set of inition conditions for u, v and w, respectively.
t = arange(0.0, 10.0, 0.7) #Solve the equations from t=0 to t=10.
print odeint(Lorentz, state0, t)
当我运行代码用
t = arange(0.0, 10.0, arg)
我得到的结果数量取决于 "arg" 的值。如果我选择一个大的值,我会得到少量的结果。对于任何高于 10.0 的值,这都会给出一个数组 [0.0, 1.0, 2.0]。
对于较低的值,数组中的行数会变大,但第一行保持不变。对于像 0.01 这样非常低的值,我得到了大量的数字,第一行总是 [0.0, 1.0, 2.0].
数组中的所有数字是多少?微分方程组的每个方程肯定只有一个解吗?
您知道 ODE 积分的结果是一个函数吗?
第 k
行(从 0
开始)对应于时间 t[k]
的函数值。时间 t[0]
的第一行包含初始值 state0
.