混沌系统数值模拟

4阶 龙格库塔方法

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from mpl_toolkits.mplot3d import Axes3D
from math import *

def dxdt(x,y,z,h=2e-2):

    K1, L1, M1 = f1(x,y,z), f2(x,y,z), f3(x,y,z)
    dx, dy, dz = h*K1/2, h*L1/2, h*M1/2
    K2, L2, M2 = f1(x+dx,y+dy, z+dz), f2(x+dx,y+dy, z+dz), f3(x+dx,y+dy, z+dz) 
    dx, dy, dz = h*K2/2, h*L2/2, h*M2/2
    K3, L3, M3 = f1(x+dx,y+dy, z+dz), f2(x+dx,y+dy, z+dz), f3(x+dx,y+dy, z+dz)
    dx, dy, dz = h*K3, h*L3, h*M3  
    K4, L4, M4 = f1(x+dx,y+dy, z+dz), f2(x+dx,y+dy, z+dz), f3(x+dx,y+dy, z+dz)

    dx = (K1 + 2*K2 + 2*K3 + K4)*h/6
    dy = (L1 + 2*L2 + 2*L3 + L4)*h/6
    dz = (M1 + 2*M2 + 2*M3 + M4)*h/6
    return dx, dy, dz

def trajectory(initial_point = [0.1, 0.1, 0.1], num_points=1e4, h=2e-2):
    x0, y0, z0 = initial_point[0], initial_point[1], initial_point[2]
    n = int(num_points)
    x = np.zeros([n,3])
    x[0,:] = [x0,y0,z0]

    for k in range(1,n):
        dx,dy,dz = dxdt(x[k-1,0],x[k-1,1],x[k-1,2],h)
        x[k,0] = x[k-1,0] + dx
        x[k,1] = x[k-1,1] + dy
        x[k,2] = x[k-1,2] + dz

    return x.T

洛伦兹系统

def f1(x,y,z):
    A = 10
    return A*(y - x)


def f2(x,y,z):
    B = 28;
    return B*x - y - x*z;
    

def f3(x,y,z):
    C = 8/3
    return x*y - C*z


N = 5000
scale  = 50
x = trajectory([0.1,0.100001,0.1],N)/scale
x_ = trajectory([0.1, 0.1, 0.1],num_points=N)/scale
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.plot(*x, 'g')
plt.show()
plt.subplot(3,1,1)
plt.plot(x[0], 'r'), plt.plot(x_[0], 'g')
plt.subplot(3,1,2)
plt.plot(x[1], 'r'), plt.plot(x_[1], 'g')
plt.subplot(3,1,3)
plt.plot(x[2], 'r'), plt.plot(x_[2], 'g')
plt.show()

在这里插入图片描述
在这里插入图片描述

Rossler 系统

def f1(x,y,z):
    return -y-z

def f2(x,y,z):
    A = 0.25
    return x + A*y
    
def f3(x,y,z):
    B = 1
    C = 5
    return B + z*(x - C)

N = 10000
scale  = 5
x = trajectory([0.10001,0.1,0.1],N)/scale
x_ = trajectory([0.1, 0.1, 0.1],num_points=N)/scale
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.plot(*x, 'g')
plt.show()
plt.subplot(3,1,1)
plt.plot(x[0], 'r'), plt.plot(x_[0], 'g')
plt.subplot(3,1,2)
plt.plot(x[1], 'r'), plt.plot(x_[1], 'g')
plt.subplot(3,1,3)
plt.plot(x[2], 'r'), plt.plot(x_[2], 'g')
plt.show()

在这里插入图片描述
在这里插入图片描述

Chua 系统

def g(x):
    return 0.6*x -1.1*x*fabs(x) + 0.45*x**3

a = 12.8
b = 19.1
x0, y0, z0 = 1.7, 0.0, -1.9

def f1(x,y,z):
    return a*(y -g(x))

def f2(x,y,z):
    return x - y + z
    
def f3(x,y,z):
    return -b*y


N = 10000
scale  = 5
x = trajectory([0.1,0.1,0.1],N)/scale
x_ = trajectory([1, 1, 1],num_points=N)/scale
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.plot(*x_, 'g')
plt.plot(*x, 'r')
plt.show()
plt.subplot(3,1,1)
plt.plot(x[0], 'r')
# plt.plot(x_[0], 'g')
plt.subplot(3,1,2)
plt.plot(x[1], 'r')
# plt.plot(x_[1], 'g')
plt.subplot(3,1,3)
plt.plot(x[2], 'r')
# plt.plot(x_[2], 'g')
plt.show()

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Chen 系统

a=40.
b=3.
c=28.
step=0.002
x0=-0.1
y0=0.5
z0=-0.6


def f1(x,y,z):
    return a*(y - x)

def f2(x,y,z):
    return (c-a)*x - x*z + c*y
    
def f3(x,y,z):
    return x*y - b*z

N = 10000
scale  = 5
x = trajectory([x0, y0, z0],N,step)/scale
x_ = trajectory([x0+0.001, y0, z0],N,step)/scale
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.plot(*x, 'r')
plt.show()
plt.subplot(3,1,1)
plt.plot(x[0], 'r'), plt.plot(x_[0], 'g')
plt.subplot(3,1,2)
plt.plot(x[1], 'r'), plt.plot(x_[1], 'g')
plt.subplot(3,1,3)
plt.plot(x[2], 'r'), plt.plot(x_[2], 'g')
plt.show()

在这里插入图片描述
在这里插入图片描述

Rabinovich-Fabrikant 系统

ParamA = 1.1
ParamB = 0.87

def f1(x,y,z):
    return y*(z - 1 + x*x) + ParamB*x

def f2(x,y,z):
    return x*(3*z + 1 - x*x) + ParamB*y
    
def f3(x,y,z):
    return -2*z*(ParamA + x*y)

N = 5000
scale  = 5
x = trajectory([-1,0,0.5],N,h=2e-2)/scale
x_ = trajectory([-1,0.001,0.5],N,h=2e-2)/scale
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.plot(*x, 'r')
plt.show()
plt.subplot(3,1,1)
plt.plot(x[0], 'r'), plt.plot(x_[0], 'g')
plt.subplot(3,1,2)
plt.plot(x[1], 'r'), plt.plot(x_[1], 'g')
plt.subplot(3,1,3)
plt.plot(x[2], 'r'), plt.plot(x_[2], 'g')
plt.show()

在这里插入图片描述
在这里插入图片描述

  • 3
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值