scipy - Having trouble with odeint in python -


i trying write script solve ode in python , graph result. using scipy.integrate.odeint task. followed simple tutorial , modified code work ode want solve

import numpy np import matplotlib.pyplot plt import pylab plb scipy.integrate import ode odeint math import pi  t = np.arange(2, 67., 0.01)  #these values need function p=2.7 * (10**3)     #kg/m^3   density v=pi * 0.3042 * ((0.0251 / 2)**2)          #volume m^3 c=904        #heat capacity j/kgk a=pi * ((0.0251 / 2)**2)         #cross sectional area m^2 e= 3490000      #emmisitivy  b=5.6704 * (10** -8)     #boltzmans d=0.251         #diameter m t= 21.2        #ambient temp # initial condition x0 = 76  plt.clf()  def f(x, t, p, v, c, a, e, b, d, t):     y=(1/(p*v*c)) * (a*e*b*np.power(t, 4) - (a*e*b*np.power(x, 4)) - ((1.32*a)/(d**0.25))*(np.power((x-t), 1.25)))     return y  x = odeint(f, x0, t, (p, v, c, a, e, b, d, t))  # plot numerical solution plt.plot(t, x) plt.xlabel('time (min)')  plt.ylabel('temperature (celsius)')  plt.title('temperature vs time rough rod')  # plot empirical data data = plb.loadtxt('rough.csv', skiprows=2)  x = data[:,0] y = data[:,1] sigma = data[:,2]  plt.errorbar(x, y, sigma, linestyle='', fmt='.')  plt.legend(['numerical solution', 'data points'], loc='best')   plt.show() 

this code runs simple function -x, problem not work function using there. can plot out of method, same plot whether use

y=(1/(p*v*c)) * (a*e*b*np.power(t, 4) - (a*e*b*np.power(x, 4)) - ((1.32*a)/(d**0.25))*(np.power((x-t), 1.25)))

or

y=(1/(p*v*c)) * (a*e*b*pow(t, 4) - (a*e*b*pow(x, 4)) - ((1.32*a)/(d**0.25))*(pow((x-t), 1.25)))

or

y=(1/(p*v*c)) * (a*e*b*np.power(t, 4) - (a*e*b*np.power(x, 4))

i think gives me same plot

y=(1/(p*v*c)) * ((-a*e*b*np.power(x, 4))

also, value of e should between 0 , 1 have use huge numbers looks exponential decay. trying this: sfu.ca/~rca10/rants/convection.pdf. ode in question @ top of page 4. guy in link can use normal emissivities, can't, though solving same ode's same values (i doing exact same lab)

what heck doing wrong?

i think there error in import statement:

from scipy.integrate import ode odeint 

should be:

from scipy.integrate import odeint 

the rest should work. since not have input file ('rough.csv') cannot reproduce graph.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -