Lorenz.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:SINDy 作者: loiseaujc 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号