# 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/

edit retag close merge delete

Sort by ยป oldest newest most voted

Thanks for posting your question here.

Basically, change two lines:

def g(x,v): to def g(x,v,t): (make the function also take time as the last input, even if we don't use it). You can even make t have a default value so you don't actually have to specify it when calling: def g(x,v,t=0):

F=[v,g(x,v)] to F=[v,g] (don't call the function g when you define F; that sets F to the result of g. Instead, just pass the function itself in.

more

That did it! Thanks!

( 2012-01-18 08:36:09 -0600 )edit