Hi All:

Sage Version: 3.2.1
OS: Windows Vista Home

I have tried the following script in IPthyon using the Python(x,y)
distribution.  It calculates the temperature profile in a set of three
continuously stirred tank reactors starting from an initial condition
and runs fine in Python 2.5, except throws an error in Sage.

Script:

# Problem 1.15 in Cutlip and Shacham
# Define constants
T_steam = 250.0
UA = 10.0
M = 1000.0
W = 100.0
Cp = 2.0
To = 20.0

from scipy import *
from pylab import *
from scipy.integrate import odeint

#Define the differential equations

def dTdt(T,t):

    dT1dt = (W*Cp*(To-T[0])+UA*(T_steam-T[0]))/(M*Cp)
    dT2dt = (W*Cp*(T[0]-T[1])+UA*(T_steam-T[1]))/(M*Cp)
    dT3dt = (W*Cp*(T[1]-T[2])+UA*(T_steam-T[2]))/(M*Cp)
    return array([dT1dt, dT2dt, dT3dt], dtype=float)

t = arange(0,100,1)
T_int = array([To,To,To])

T = odeint(dTdt,T_int,t)

pylab.plot(t,T)
pylab.title('Temperature in Stirred Tanks')
pylab.xlabel('t');pylab.ylabel('Temperature')

When I run this script in Sage I get the following error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/notebook/sage_notebook/worksheets/admin/11/code/2.py",
line 6, in <module>
    T = odeint(dTdt,T_int,t)
  File "/usr/local/sage/local/lib/python2.5/site-packages/
zope.interface-3.3.0-py2.5-linux-i686.egg/", line 1, in <module>

  File "/usr/local/sage/local/lib/python2.5/site-packages/scipy/
integrate/odepack.py", line 124, in odeint
    ixpr, mxstep, mxhnil, mxordn, mxords)
TypeError: array cannot be safely cast to required type

I am not matching types somehow in Sage.  I have tried defining the
initial conditions both as arrays and as lists, the same with the
return in the function definition.  Thanks for any help.

Regards,
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to