Skip to content

Instantly share code, notes, and snippets.

@CryogenicPlanet
Last active March 23, 2020 00:16
Show Gist options
  • Select an option

  • Save CryogenicPlanet/e07988808d14be57334c1ef6d8112e09 to your computer and use it in GitHub Desktop.

Select an option

Save CryogenicPlanet/e07988808d14be57334c1ef6d8112e09 to your computer and use it in GitHub Desktop.
Solving the Lorenz System
def lorenz(x0,y0,z0,start_time,time_step):
"""
Returns an array of points, which the lorenz system passes by iteratively perfoming each rk4 timestep
"""
x,y,z = [x0],[y0],[z0] # Start Points
count = 0
t = start_time or 0 # Start Time
dt = time_step or 0.01 # Time Step
while t < 150:
t+= dt
tempx,tempy,tempz = x[count],y[count],z[count] # Temporary Start Points
func = np.array([dx,dy,dz])
runge_kutta_4 = rk4(func,t,tempx,tempy,tempz,dt) # Rk4 Function
tempx += runge_kutta_4[0]
tempy += runge_kutta_4[1]
tempz += runge_kutta_4[2]
count +=1
x.append(tempx)
y.append(tempy)
z.append(tempz)
return x,y,z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment