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

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

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

revision 2680 by ahallam, Fri Sep 18 01:46:47 2009 UTC revision 2681 by ahallam, Thu Sep 24 03:04:04 2009 UTC
# Line 37  Author: Antony Hallam antony.hallam@uqco Line 37  Author: Antony Hallam antony.hallam@uqco
37  # This imports everything from the escript library  # This imports everything from the escript library
38  from esys.escript import *  from esys.escript import *
39  # This defines LinearPDE as LinearPDE  # This defines LinearPDE as LinearPDE
40  from esys.escript.linearPDEs import LinearPDE, Poisson  from esys.escript.linearPDEs import LinearPDE, Poisson
41    # smoothing operator
42  from esys.escript.pdetools import Projector  from esys.escript.pdetools import Projector
43  # This imports the rectangle domain function from finley  # This imports the rectangle domain function from finley
44  from esys.finley import Rectangle, ReadMesh, Domain  from esys.finley import Rectangle, ReadMesh, Domain
# Line 116  quT=qu.toListOfTuples() Line 117  quT=qu.toListOfTuples()
117  proj=Projector(mymesh)  proj=Projector(mymesh)
118  smthT=proj(T)  smthT=proj(T)
119    
 quivshape = [20,20] #quivers x and quivers y  
 # function to calculate quiver locations  
 qu,qulocs = toQuivLocs(quivshape,width,depth,qu)  
   
120  #move data to a regular grid for plotting  #move data to a regular grid for plotting
121  xi,yi,zi = toRegGrid(smthT,mymesh,200,200,width,depth)  xi,yi,zi = toRegGrid(smthT,mymesh,200,200,width,depth)
122    
 # contour the gridded data,  
 # plotting dots at the randomly spaced data points.  
   
 # select colour  
 pl.matplotlib.pyplot.autumn()  
 # plot polygons for boundaries  
 CKL = pl.fill(tpgx,tpgy,'brown',label='2 W/m/k',zorder=-1000)  
 CKM = pl.fill(bpgx,bpgy,'red',label='4 W/m/k',zorder=-1000)  
 # contour temperature  
 CS = pl.contour(xi,yi,zi,5,linewidths=0.5,colors='k')  
 # labels and formatting  
 pl.clabel(CS, inline=1, fontsize=8)  
 pl.title("Heat Refraction across a clinal structure.")  
 pl.xlabel("Horizontal Displacement (m)")  
 pl.ylabel("Depth (m)")  
 pl.legend()  
 if getMPIRankWorld() == 0: #check for MPI processing  
     pl.savefig(os.path.join(saved_path,"heatrefraction001_cont.png"))  
   
 #Quiver Plot qulocs -> tail location, qu -> quiver length/direction  
 QUIV=pl.quiver(qulocs[:,0],qulocs[:,1],qu[:,0],qu[:,1],\  
                 angles='xy',color="white")  
 pl.title("Heat Refraction across a clinal structure\n with\  
 gradient quivers.")  
 if getMPIRankWorld() == 0: #check for MPI processing  
     pl.savefig(os.path.join(saved_path,"heatrefraction001_contqu.png"))  
   
123  #Temperature Depth Profile along x[50]  #Temperature Depth Profile along x[50]
124  cut=int(len(xi)/2)  cut=int(len(xi)/2)
125  pl.clf()  pl.clf()
# Line 160  pl.ylabel("Depth (m)") Line 130  pl.ylabel("Depth (m)")
130  if getMPIRankWorld() == 0: #check for MPI processing  if getMPIRankWorld() == 0: #check for MPI processing
131      pl.savefig(os.path.join(saved_path,"heatrefraction001_tdp.png"))      pl.savefig(os.path.join(saved_path,"heatrefraction001_tdp.png"))
132            
133  #Temperature Gradient Profile along x[50]  # Heat flow depth profile.
   
   
   
134  pl.clf()  pl.clf()
135  # grid the data.  # grid the data.
136  qu=proj(-kappa*grad(T))  qu=proj(-kappa*grad(T))
# Line 176  pl.ylabel("Depth (m)") Line 143  pl.ylabel("Depth (m)")
143  if getMPIRankWorld() == 0: #check for MPI processing  if getMPIRankWorld() == 0: #check for MPI processing
144      pl.savefig(os.path.join(saved_path,"heatrefraction001_hf.png"))      pl.savefig(os.path.join(saved_path,"heatrefraction001_hf.png"))
145    
146    # Temperature Gradient Depth Profile at x[50]
147  pl.clf()  pl.clf()
148  zT=proj(-grad(T))  zT=proj(-grad(T))
   
149  xt,yt,zt=gradtoRegGrid(zT,mymesh,200,200,width,depth,1)  xt,yt,zt=gradtoRegGrid(zT,mymesh,200,200,width,depth,1)
150  cut=int(len(xt)/2)  cut=int(len(xt)/2)
151  pl.plot(zt[:,cut]*1000.,yt)  pl.plot(zt[:,cut]*1000.,yt)
# Line 187  pl.xlabel("Temperature (K/Km)") Line 154  pl.xlabel("Temperature (K/Km)")
154  pl.ylabel("Depth (m)")  pl.ylabel("Depth (m)")
155  if getMPIRankWorld() == 0: #check for MPI processing  if getMPIRankWorld() == 0: #check for MPI processing
156      pl.savefig(os.path.join(saved_path,"heatrefraction001_tgdp.png"))      pl.savefig(os.path.join(saved_path,"heatrefraction001_tgdp.png"))
157        
158    # Thermal Conditions Depth Profile    
159  pl.clf()  pl.clf()
160  xk,yk,zk = toRegGrid(kappa,mymesh,200,200,width,depth)  xk,yk,zk = toRegGrid(kappa,mymesh,200,200,width,depth)
161  cut=int(len(xk)/2)  cut=int(len(xk)/2)
# Line 198  pl.ylabel("Depth (m)") Line 166  pl.ylabel("Depth (m)")
166  pl.axis([1,5,-6000,0])  pl.axis([1,5,-6000,0])
167  if getMPIRankWorld() == 0: #check for MPI processing  if getMPIRankWorld() == 0: #check for MPI processing
168      pl.savefig(os.path.join(saved_path,"heatrefraction001_tcdp.png"))      pl.savefig(os.path.join(saved_path,"heatrefraction001_tcdp.png"))
169        
170    # contour the gridded data,
171    # plotting dots at the randomly spaced data points.
172    quivshape = [20,20] #quivers x and quivers y
173    # function to calculate quiver locations
174    qu,qulocs = toQuivLocs(quivshape,width,depth,qu)
175    
176    # select colour
177    pl.matplotlib.pyplot.autumn()
178    pl.clf()
179    # plot polygons for boundaries
180    CKL = pl.fill(tpgx,tpgy,'brown',label='2 W/m/k',zorder=-1000)
181    CKM = pl.fill(bpgx,bpgy,'red',label='4 W/m/k',zorder=-1000)
182    # contour temperature
183    CS = pl.contour(xi,yi,zi,5,linewidths=0.5,colors='k')
184    # labels and formatting
185    pl.clabel(CS, inline=1, fontsize=8)
186    pl.title("Heat Refraction across a clinal structure.")
187    pl.xlabel("Horizontal Displacement (m)")
188    pl.ylabel("Depth (m)")
189    pl.legend()
190    if getMPIRankWorld() == 0: #check for MPI processing
191        pl.savefig(os.path.join(saved_path,"heatrefraction001_cont.png"))
192    
193    #Quiver Plot qulocs -> tail location, qu -> quiver length/direction
194    QUIV=pl.quiver(qulocs[:,0],qulocs[:,1],qu[:,0],qu[:,1],\
195                    angles='xy',color="white")
196    pl.title("Heat Refraction across a clinal structure\n with\
197    gradient quivers.")
198    if getMPIRankWorld() == 0: #check for MPI processing
199        pl.savefig(os.path.join(saved_path,"heatrefraction001_contqu.png"))
200    
201    

Legend:
Removed from v.2680  
changed lines
  Added in v.2681

  ViewVC Help
Powered by ViewVC 1.1.26