Hi Marshall:

Thank you for the example.  I hadn't thought about using list_plot, and this
is excellent.  This is great support.

Regards,
Steve


On Tue, Feb 17, 2009 at 12:10 AM, Marshall Hampton <[email protected]>wrote:

>
> Here's a sort of hybrid solution, using odeint but then converting out
> of the numpy types.
>
> T_steam = 250.0
> UA = 10.0
> M = 1000.0
> W = 100.0
> Cp = 2.0
> To = 20.0
> import numpy
> from scipy.integrate import odeint
> 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 numpy.array([dT1dt, dT2dt, dT3dt], dtype=float)
> t = numpy.arange(0r,200r,1r,dtype=float)
> T_int = numpy.array([20.0r,20.0r,20.0r],dtype=float)
> T = odeint(dTdt,T_int,t)
> sdata = [[float(y) for y in x] for x in T.transpose()]
> plots = [list_plot(x, plotjoined = True, rgbcolor = hue(sdata.index(x)/
> 3,1,1)) for x in sdata]
> show(sum(plots), axes_labels=['t','Temperature'], ymax = 60)
>
> There is some work being done on improving support for plot legends
> and better axes in Sage (by A. Bergeron and M. Hansen I believe);
> right now sometimes its necessary to add text more directly with the
> "text" command (produces a graphics object you can add to other
> graphics).
>
> Hope that helps,
> M. Hampton
>
>
> On Feb 17, 12:25 am, Steve Yarbro <[email protected]> wrote:
> > Hi Mike:
> >
> > Wow, thanks for the very timely response, that was warp speed.  I've
> tried
> > your suggestion and I've stopped having the error message, but for some
> > reason, I don't get a plot.  I'm a newbie with Python coming from the
> MATLAB
> > world.  I'll keep working with it, but here is what I have:
> >
> > t = arange(0r,200r,1r)
> > T_int = array([20.0r,20.0r,20.0r])
> >
> > T = odeint(dTdt,T_int,t)
> >
> > plot(t,T)
> > xlabel('t')
> > ylabel('Temperature')
> >
> > When I evaluate, I get the following:
> >
> > Text(0.5,0.5,'Temperature')
> >
> > Would a better approach be to use the ode_solver from Sage?
> >
> > On Mon, Feb 16, 2009 at 2:17 PM, Mike Hansen <[email protected]> wrote:
> >
> > > Hello,
> >
> > > This is due to the interaction between numpy/scipy and Sage's
> > > datatypes.  See my response at
> >
> > >http://groups.google.com/group/sage-devel/browse_thread/thread/7038a4.
> ..
> >
> > > --Mike
> >
>

--~--~---------~--~----~------------~-------~--~----~
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