Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2012-01-18 07:17:25 -0500

calc314 gravatar image

ODE solving question

I'm stumped here. I am implementing a parachute model for use in my modeling class and am using a nice ODE class devised by oddrobot and modified by Jason Grout. To model the opening of the parachute, I need to make a parameter's value depend on the height of the parachutist. But, the if..then statements in my code appear to be getting ignored. What am I missing here?

Here is what I'm doing. (Note that DESolution is a command in the ODE solving routine that I'm using.)

var('x,v')
g1=9.81

def g(x,v):
    if x>50:
        return(-g1-0.3*abs(v)*v)
    elif x>0:
        return(-g1-2*abs(v)*v)
    else:
        return(0)
def f(x,v):
    if x>0:
        return(v)
    else:
        return(0)
F=[f(x,v),g(x,v)]
solution=DESolution(F,[t,0,40],[(x,100),(v,0)])
solution.coordinates(['red','blue'])

The complete code is published at:

http://sage.maa.org/home/pub/104/