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

Contents of /trunk/doc/examples/cookbook/twodheatdiff.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2904 - (show annotations)
Tue Feb 2 04:21:52 2010 UTC (9 years, 2 months ago) by gross
File MIME type: text/x-python
File size: 3168 byte(s)
more revision on cookbook: example 1 and 2 have been swapped.
1
2 ########################################################
3 #
4 # Copyright (c) 2009-2010 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2009-2010 by University of Queensland
15 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 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 """
23 Author: Antony Hallam antony.hallam@uqconnect.edu.au
24 """
25
26 # To solve the problem it is necessary to import the modules we require.
27 from esys.escript import * # This imports everything from the escript library
28 from esys.escript.linearPDEs import LinearPDE # This defines LinearPDE as LinearPDE
29 from esys.finley import Rectangle # This imports the rectangle domain function from finley
30 import os #This package is necessary to handle saving our data.
31
32 ##ESTABLISHING VARIABLES
33 #PDE related
34 mx = 600 # model lenght
35 my = 600 # model width
36 ndx = 100 # steps in x direction
37 ndy = 100 # steps in y direction
38 r = 200 # radius of intrusion
39 ic = [300, 0] #centre of intrusion
40
41 q=0 #our heat source temperature is now zero
42 Ti=2273 # Kelvin #the starting temperature of our iron bar
43 rhoi = 2750 #kg/m^{3} density
44 cpi = 790 #j/kg specific heat
45 rhocpi = rhoi*cpi #DENSITY * SPECIFIC HEAT
46 eta=0. # RADIATION CONDITION
47 kappai=2.2 # Watts/(meter*Kelvin) DIFFUSION CONSTANT, HEAT PERMEABILITY
48
49 Tc = 200
50 rhoc = 2200
51 cpc = 400
52 rhocpc = rhoc*cpc
53 kappac = 0.1
54
55
56 #Script/Iteration Related
57 t=0. #our start time, usually zero
58 tday=100*365. #the time we want to end the simulation in days
59 tend=tday*24*60*60
60 outputs = 200 # number of time steps required.
61 h=(tend-t)/outputs #size of time step
62
63 print "Expected Number of Output Files is: ", outputs
64 print "Step size is: ", h/(24.*60*60), "days"
65
66
67 i=0 #loop counter
68 save_path = "data/twodheatdiff" #the folder to put our outputs in, leave blank "" for script path - note this folder path must exist to work
69 mkDir(save_path)
70
71 #... generate domain ...
72 model = Rectangle(l0=mx,l1=my,n0=ndx, n1=ndy)
73 # extract finite points
74 x=model.getX()
75
76 #... open PDE ...
77 mypde=LinearPDE(model)
78 mypde.setSymmetryOn()
79
80 bound = length(x-ic)-r #where the boundary will be located
81
82 A = (kappai)*whereNegative(bound)+(kappac)*wherePositive(bound)
83 D = (rhocpi/h)*whereNegative(bound)+(rhocpc/h)*wherePositive(bound)
84
85 mypde.setValue(A=A*kronecker(model),D=D,d=eta,y=eta*Tc)
86
87 # ... set initial temperature ....
88
89 T= Ti*whereNegative(bound)+Tc*wherePositive(bound) #defining the initial temperatures.
90 saveVTK(os.path.join(save_path,"dataedge.vtu"), sol=bound)
91 saveVTK(os.path.join(save_path,"data%03d.vtu") %i,sol=T)
92
93 #... start iteration:
94 while t<=tend:
95 i+=1
96 t+=h
97 Y = T*D
98 mypde.setValue(Y=Y)
99 T=mypde.getSolution()
100 saveVTK(os.path.join(save_path,"data%03d.vtu") %i,sol=T)

  ViewVC Help
Powered by ViewVC 1.1.26