python - TypeError: unsupported operand type(s) for *: 'float' and 'function' -


i new python , made program calculate speed function of time of man falling approximatly 40 km. now, when run program, gives me following error:

line 85

float(dvoorpara=cd*0.5*rho1*v**2*sf) typeerror: unsupported operand type(s) *: 'float' , 'function'

this whole program:

#data mc=1315. #kg mb=1360. #kg ms=10. #kg mh=4. #kg mp=27. #kg mf=77. #kg mused=ms+mh+mp+mf cd=1.0 sf=1.0 #m^2 sp=14.0 #m^2 r=287.0 #j/kgk g0=9.80665 #m/s^2 h=38969.3 #m hfall=36402.6 #m hpara=h-hfall #m stot=sf+sp #m^2 v=0 #m/s a=-0.0065 a2=+0.001 a3=+0.0028 rho0=1.225 #kg/m^3 p0 = 101325.0 #pa t0 = 288.15 #k t = 0 #s import matplotlib.pyplot plt  #isa formulas def rho1(h):     if h<=11000:         t1=t0+a*(h-0)         p1=((t1/t0)**(-g0/(a*r)))*p0         rho1=((t1/t0)**((-g0/(a*r))-1))*rho0     elif h>=11000 , h<=20000:         t1 = (t0+a*11000)         p0 = (((t1/t0)**(-g0/(a*r)))*p0)         rho0 = (((t1/t0)**((-g0/(a*r))-1))*rho0)         p1 = (math.e**((-g0/(r*t1))*(h-11000)))*p0         rho1 = (math.e**((-g0/(r*t1))*(h-11000)))*rho0     elif h>=20000 , h<=32000:         t0 = (-56.5+273.15)         t1 = (-56.5+273.15)+(a2*(h-20000))         p0 = (((t0/288.15)**(-g0/(a*r)))*p0)         p0=(math.e**((-g0/(r*t0))*(20000-11000)))*p0         p1=((t1/t0)**(-g0/(a2*r)))*p0         rho0 = (((t0/288.15)**((-g0/(a*r))-1))*rho0)         rho0= (math.e**((-g0/(r*t0))*(20000-11000)))*rho0         rho1=((t1/t0)**((-g0/(a2*r))-1))*rho0     elif h>=320000 , h==h:         t0 = (-44.5+273.15)         t1 = (-44.5+273.15)+(a3*(h-32000))         p0 = (((216.65/288.15)**(-g0/(a*r)))*p0)         p0 =(math.e**((-g0/(r*216.65))*(20000-11000)))*p0         p0 = ((t0/216.65)**(-g0/(a2*r)))*p0         p1= ((t1/t0)**(-g0/(a3*r)))*p0         rho0 = (((216.65/288.15)**((-g0/(a*r))-1))*rho0)         rho0 = (math.e**((-g0/(r*216.65))*(20000-11000)))*rho0         rho0 = ((t0/216.65)**((-g0/(a2*r))-1))*rho0         rho1 = ((t1/t0)**((-g0/(a3*r))-1))*rho0 def t1(h):     if h<=11000:         t1=t0+a*(h-0)     elif h>=11000 , h<=20000:         t1 = (t0+a*11000)     elif h>=20000 , h<=32000:         t0 = (-56.5+273.15)         t1 = (-56.5+273.15)+(a2*(h-20000))     elif h>=320000 , h==h:          t0 = (-44.5+273.15)          t1 = (-44.5+273.15)+(a3*(h-32000))    #tables ttab=[] htab=[] vtab=[] mtab=[]  #set formula motion dt = 0.01 #s while h>=0:     if h>hpara:    #cycle behore parachute         t = t+dt         dvoorpara=cd*0.5*rho1*v**2*sf)         = -g + dvoorpara/mused         v = v + a*dt         m = abs(v/(math.sqrt(1.4*t1*r)))         h = h+v*dt         ttab.append(t)         htab.append(h)         vtab.append(v)         mtab.append(m)     elif h<=hpara , h>0:         t = t+dt         dvoorpara=cd*0.5*rho1*v**2*sf         = -g + dvoorpara/mused         v = v + a*dt         dnapara=cd*0.5*rho1*v**2*stot         = -g + dnapara/mused         v = v + a*dt         m = abs(v/(math.sqrt(1.4*t1*r)))         h = hpara + v*dt         ttab.append(t)         htab.append(h)         vtab.append(v)         mtab.append(m) #graphs plt.subplot(241) plt.subplot(ttab,htab) plt.title("altitude function of time") plt.xlabel("t(s)") plt.ylabel("h(m)")  plt.subplot(242) plt.subplot(ttab,vtab) plt.title("speed function of time") plt.xlabel("t(s)") plt.ylabel("v (m/s)")  plt.subplot(243) plt.subplot(vtab,htab) plt.title("altitude function of speed") plt.xlabel("v (m/s)") plt.ylabel("h (m)")  plt.subplot(244) plt.subplot(mtab,htab) plt.xlabel("m") plt.ylabel("h (m)")  plt.show() 

i guess has me using def(rho) wrongly.

thanks help!

you have several expressions in code:

dvoorpara=cd*0.5*rho1*v**2*sf 

rho1 function -- 1 you've defined. you're using rho1 -- function -- when mean using value returns when called, in rho1(h) (for h).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -