# Annotation of /trunk/doc/examples/cookbook/example01a.py

Revision 2980 - (hide annotations)
Tue Mar 9 03:50:58 2010 UTC (9 years, 1 month ago) by artak
File MIME type: text/x-python
File size: 3397 byte(s)
```minor change to fix latest bug
```
 1 ahallam 2392 2 ######################################################## 3 # 4 jfenwick 2667 # Copyright (c) 2009 by University of Queensland 5 ahallam 2392 # Earth Systems Science Computational Center (ESSCC) 6 7 # 8 # Primary Business: Queensland, Australia 9 # Licensed under the Open Software License version 3.0 10 11 # 12 ######################################################## 13 14 jfenwick 2667 __copyright__="""Copyright (c) 2009 by University of Queensland 15 ahallam 2392 Earth Systems Science Computational Center (ESSCC) 16 http://www.uq.edu.au/esscc 17 Primary Business: Queensland, Australia""" 18 __license__="""Licensed under the Open Software License version 3.0 19 20 __url__= 21 22 """ 23 Author: Antony Hallam antony.hallam@uqconnect.edu.au 24 """ 25 ahallam 2977 ############################################################FILE HEADER 26 # example01a.py 27 # Model temperature diffusion between two granite blocks of unequal 28 # initial temperature. Solve for total energy in the system. 29 ahallam 2392 30 ahallam 2977 #######################################################EXTERNAL MODULES 31 ahallam 2392 # To solve the problem it is necessary to import the modules we require. 32 from esys.escript import * # This imports everything from the escript library 33 gross 2904 from esys.escript.unitsSI import * 34 ahallam 2392 from esys.escript.linearPDEs import LinearPDE # This defines LinearPDE as LinearPDE 35 from esys.finley import Rectangle # This imports the rectangle domain function from finley 36 37 ahallam 2977 #################################################ESTABLISHING VARIABLES 38 gross 2904 #Domain related. 39 mx = 500*m #meters - model length 40 my = 100*m #meters - model width 41 ndx = 100 # mesh steps in x direction 42 ndy = 1 # mesh steps in y direction - one dimension means one element 43 boundloc = mx/2 # location of boundary between the two blocks 44 ahallam 2392 #PDE related 45 gross 2904 rho = 7874. *kg/m**3 #kg/m^{3} density of iron 46 cp = 449.*J/(kg*K) # J/Kg.K thermal capacity 47 rhocp = rho*cp 48 kappa = 80.*W/m/K # watts/m.Kthermal conductivity 49 qH=0 * J/(sec*m**3) # J/(sec.m^{3}) no heat source 50 T1=20 * Celsius # initial temperature at Block 1 51 T2=2273. * Celsius # initial temperature at Block 2 52 ahallam 2392 53 ahallam 2977 ################################################ESTABLISHING PARAMETERS 54 gross 2904 t=0 * day # our start time, usually zero 55 tend=50 * yr # - time to end simulation 56 outputs = 200 # number of time steps required. 57 h=(tend-t)/outputs #size of time step 58 #user warning statement 59 print "Expected Number of time outputs is: ", (tend-t)/h 60 i=0 #loop counter 61 #the folder to put our outputs in, leave blank "" for script path 62 gross 2949 save_path= os.path.join("data","example01") 63 gross 2904 #ensure the dir exists 64 mkDir(save_path, os.path.join(save_path,"tempT")) 65 ahallam 2392 66 ahallam 2977 ####################################################DOMAIN CONSTRUCTION 67 gross 2904 blocks = Rectangle(l0=mx,l1=my,n0=ndx, n1=ndy) 68 ahallam 2977 69 ###############################################ESCRIPT PDE CONSTRUCTION 70 artak 2980 #... open PDE and set coefficients ... 71 mypde=LinearPDE(blocks) 72 ahallam 2392 mypde.setSymmetryOn() 73 gross 2904 A=zeros((2,2)) 74 A[0,0]=kappa 75 mypde.setValue(A=A,D=rhocp/h) 76 ahallam 2392 # ... set initial temperature .... 77 gross 2904 x=Solution(blocks).getX() 78 T= T1*whereNegative(x[0]-boundloc)+T2*(1-whereNegative(x[0]-boundloc)) 79 ahallam 2392 80 ahallam 2977 ########################################################START ITERATION 81 gross 2904 while t

 ViewVC Help Powered by ViewVC 1.1.26