 # Diff of /trunk/doc/cookbook/example01.tex

revision 3372 by ahallam, Sun Nov 21 23:22:25 2010 UTC revision 3373 by ahallam, Tue Nov 23 00:29:07 2010 UTC
# Line 488  T2=2273. * Celsius # base temperature at Line 488  T2=2273. * Celsius # base temperature at
488  Finally, to control our script we will have to specify our timing controls and  Finally, to control our script we will have to specify our timing controls and
489  where we would like to save the output from the solver. This is simple enough:  where we would like to save the output from the solver. This is simple enough:
490  \begin{python}  \begin{python}
491  t=0 * day  #our start time, usually zero  t=0 * day  # our start time, usually zero
492  tend=1. * day # - time to end simulation  tend=50 * yr # - time to end simulation
493  outputs = 200 # number of time steps required.  outputs = 200 # number of time steps required.
494  h=(tend-t)/outputs #size of time step  h=(tend-t)/outputs #size of time step
495  #user warning statement  #user warning statement
# Line 787  following iteration. Line 787  following iteration.
787  \begin{python}  \begin{python}
788  # ... start iteration:  # ... start iteration:
789  while t<tend:  while t<tend:
790          ....        i+=1
791      T=mypde.getSolution() #get the PDE solution        t+=h
792          tempT = T.toListOfTuples() # convert to a tuple        mypde.setValue(Y=qH+rhocp/h*T)
793          pl.plot(plx,tempT) # plot solution        T=mypde.getSolution()
794      # set scale (Temperature should be between Tref and T0)        totE=integrate(rhocp*T)
795          pl.axis([0,mx,Tref*.9,T0*1.1])        print "time step %s at t=%e days completed. total energy = %e."%(i,t/day,totE)
797      pl.title("Temperature across the blocks at time %e minutes"%(t/day))        E_list.append(totE)
798      #save figure to file
799      pl.savefig(os.path.join(save_path,"tempT","blockspyplot%03d.png") %i)        #establish figure 1 for temperature vs x plots
800  \end{python}        tempT = T.toListOfTuples()
801          pl.figure(1) #current figure
802          pl.plot(plx,tempT) #plot solution
804          pl.axis([0,mx,T1*.9,T2*1.1])
805          pl.title("Temperature across blocks at time %d days"%(t/day))
806          #save figure to file
807          pl.savefig(os.path.join(save_path,"tempT", "blockspyplot%03d.png"%i))
808          pl.clf() #clear figure
809    \end{python}
810  Some results are shown in \reffig{fig:onedheatout}.  Some results are shown in \reffig{fig:onedheatout}.
811
812  \subsection{Making a Video}  \subsection{Making a Video}

Legend:
 Removed from v.3372 changed lines Added in v.3373