Skip to content

Instantly share code, notes, and snippets.

@springcoil

springcoil/ODEgist.py Secret

Created Apr 15, 2015
Embed
What would you like to do?
Simple Gist of an ODE
import numpy as np
A1 = bs * ( astr * N ) ** 2
A2 = c1 / tdS
A3 = ( 1 - bs ) * ( astr * N ) ** 2
A4 = A1 * z0
A5 = A3 * z0
A6 = C
A7 = 0.5 * ( ( c2 / tt ) + ( c1 / tdS ) )
A8 = ( c2 / tt ) - ( c1 / tdS )
def dX_dt(X, t=0):
""" Return the triple ODE calculations """
return array([ - A1 * X[2] + A4,
- A2 * X[1] + A3 * X[2] - A5,
X[0] - X[1] ])
from scipy import integrate
t = linspace(0, 35, 1000) # time
X0 = array([0, 1, 0]) # initials conditions
X, infodict = integrate.odeint(dX_dt, X0, t, full_output=True)
infodict['message']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.