def Lorenz(x0, sigma, rho, beta, time):
"""
This small function runs a simulation of the Lorenz system.
Inputs
------
x0 : numpy array containing the initial condition.
sigma, rho, beta : parameters of the Lorenz system.
time : numpy array for the evaluation of the state of
the Lorenz system at some given time instants.
Outputs
-------
x : numpy two-dimensional array.
State vector of the vector for the time instants
specified in time.
xdot : corresponding derivatives evaluated using
central differences.
"""
def dynamical_system(y,t):
dy = np.zeros_like(y)
dy[0] = sigma*(y[1]-y[0])
dy[1] = y[0]*(rho - y[2]) - y[1]
dy[2] = y[0]*y[1] - beta*y[2]
return dy
x = odeint(dynamical_system,x0,time)
dt = time[1]-time[0]
from sparse_identification.utils import derivative
xdot = derivative(x,dt)
return x, xdot
评论列表
文章目录