# Diff of /trunk/doc/examples/cookbook/twodheatdiff001.py

revision 2644 by ahallam, Wed Aug 26 22:18:19 2009 UTC revision 2645 by ahallam, Thu Sep 3 02:20:33 2009 UTC
# Line 43  from esys.escript.unitsSI import * Line 43  from esys.escript.unitsSI import *
43  import pylab as pl #Plotting package.  import pylab as pl #Plotting package.
44  import numpy as np #Array package.  import numpy as np #Array package.
45  import os #This package is necessary to handle saving our data.  import os #This package is necessary to handle saving our data.
46    from cblib import toXYTuple
47
48  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
49  #PDE related  #PDE related
# Line 102  T= Ti*whereNegative(bound)+Tc*wherePosit Line 103  T= Ti*whereNegative(bound)+Tc*wherePosit
103  # rearrage mymesh to suit solution function space for contouring        # rearrage mymesh to suit solution function space for contouring
104  oldspacecoords=model.getX()  oldspacecoords=model.getX()
105  coords=Data(oldspacecoords, T.getFunctionSpace())  coords=Data(oldspacecoords, T.getFunctionSpace())
106  coords = np.array(coords.toListOfTuples())  #coords = np.array(coords.toListOfTuples())
107  coordX = coords[:,0]  coordX, coordY = toXYTuple(coords)
coordY = coords[:,1]
108  # create regular grid  # create regular grid
109  xi = np.linspace(0.0,600.0,100)  xi = np.linspace(0.0,mx,100)
110  yi = np.linspace(0.0,600.0,100)  yi = np.linspace(0.0,my,100)
111
112  #... start iteration:  #... start iteration:
113  while t<=tend:  while t<=tend:
114        i+=1        i+=1 #counter
115        t+=h        t+=h #curretn time
116        Y = T*D        Y = T*D #
117        mypde.setValue(Y=Y)        mypde.setValue(Y=Y)
118        T=mypde.getSolution()        T=mypde.getSolution()
119        tempT = T.toListOfTuples(scalarastuple=False)        tempT = T.toListOfTuples(scalarastuple=False)
# Line 130  while t<=tend: Line 130  while t<=tend:
130        pl.ylabel("Depth (m)")        pl.ylabel("Depth (m)")
131        pl.savefig(os.path.join(save_path,"heatrefraction%03d.png") %i)        pl.savefig(os.path.join(save_path,"heatrefraction%03d.png") %i)
132        pl.clf()                    pl.clf()
#     saveVTK(os.path.join(save_path,"data%03d.vtu") %i,sol=T)
133
134  # compile the *.png files to create an *.avi video that shows T change  # compile the *.png files to create an *.avi video that shows T change
135  # with time. This opperation uses linux mencoder.  # with time. This opperation uses linux mencoder.

Legend:
 Removed from v.2644 changed lines Added in v.2645