/[escript]/trunk/doc/examples/cookbook/onedheatdiff002.py
ViewVC logotype

Diff of /trunk/doc/examples/cookbook/onedheatdiff002.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2657 by jfenwick, Mon Sep 7 00:06:15 2009 UTC revision 2658 by ahallam, Thu Sep 10 02:58:44 2009 UTC
# Line 38  from esys.escript.linearPDEs import Line Line 38  from esys.escript.linearPDEs import Line
38  from esys.finley import Rectangle  from esys.finley import Rectangle
39  # A useful unit handling package which will make sure all our units  # A useful unit handling package which will make sure all our units
40  # match up in the equations under SI.  # match up in the equations under SI.
41  from esys.escript.unitsSI import *  from esys.escript.unitsSI import *
42    #For interactive use, you can comment out the next two lines
43    import matplotlib
44    matplotlib.use('agg') #It's just here for automated testing
45  import pylab as pl #Plotting package.  import pylab as pl #Plotting package.
46  import numpy as np #Array package.  import numpy as np #Array package.
47  import os #This package is necessary to handle saving our data.  import os #This package is necessary to handle saving our data.
48  from cblib import needdirs  from cblib import needdirs
49    
50    ########################################################MPI WORLD CHECK
51    if getMPISizeWorld() > 1:
52        import sys
53        print "This example will not run in an MPI world."
54        sys.exit(0)
55    
56  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
57  #PDE related  #PDE related
# Line 69  h=(tend-t)/outputs #size of time step Line 77  h=(tend-t)/outputs #size of time step
77  print "Expected Number of Output Files is: ", outputs  print "Expected Number of Output Files is: ", outputs
78  print "Step size is: ", h/(24.*60*60), "days"  print "Step size is: ", h/(24.*60*60), "days"
79  i=0 #loop counter  i=0 #loop counter
80  #the folder to put our outputs in, leave blank "" for script path  #the folder to put our outputs in, leave blank "" for script path
81  save_path="data/onedheatdiff002"  save_path= os.path.join("data","onedheatdiff002")
82  needdirs([save_path])  needdirs([save_path])
83  ########## note this folder path must exist to work ###################  ########## note this folder path must exist to work ###################
84    
# Line 106  while t<=tend: Line 114  while t<=tend:
114      pl.plot(plx,tempT)      pl.plot(plx,tempT)
115      pl.axis([0,500,0,2500])      pl.axis([0,500,0,2500])
116      pl.title("Temperature accross Interface")      pl.title("Temperature accross Interface")
117      pl.savefig(os.path.join(save_path,"intpyplot%03d.png") %i)      if getMPIRankWorld() == 0:
118            pl.savefig(os.path.join(save_path,"intpyplot%03d.png" %i))
119      pl.clf()      pl.clf()
120            
121  # compile the *.png files to create an *.avi video that shows T change  # compile the *.png files to create two *.avi videos that show T change
122  # with time. This opperation uses linux mencoder.  # with time. This opperation uses linux mencoder. For other operating
123  os.system("mencoder mf://"+save_path+"/*.png -mf type=png:\  # systems it is possible to use your favourite video compiler to
124  w=800:h=600:fps=25 -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o \  # convert image files to videos. To enable this step uncomment the
125  onedheatdiff002tempT.avi")  # following lines.
126    
127    #os.system("mencoder mf://"+save_path+"/*.png -mf type=png:\
128    #w=800:h=600:fps=25 -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o \
129    #onedheatdiff002tempT.avi")

Legend:
Removed from v.2657  
changed lines
  Added in v.2658

  ViewVC Help
Powered by ViewVC 1.1.26