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

Annotation of /trunk/doc/examples/cookbook/onedheatdiff001.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2401 - (hide annotations)
Wed Apr 29 04:23:07 2009 UTC (11 years, 8 months ago) by ahallam
Original Path: trunk/doc/cookbook/onedheatdiff001.py
File MIME type: text/x-python
File size: 2628 byte(s)
End Week 5:
Renamed *.tex files to more logical, changed to chapter format as HEAT_DIFFUSION.tex
Editted and Reviewed text portion and some python scripts for heat diffusion.
Looking to push for finalisation on heat diffusion in the next couple of week to begin next modelling problem/Chapter.
1 ahallam 2401
2     ########################################################
3     #
4     # Copyright (c) 2003-2009 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) 2003-2009 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    
33    
34     ##ESTABLISHING VARIABLES
35     #Domain related.
36     mx = 1 #meters - model lenght
37     my = .1 #meters - model width
38     ndx = 100 # steps in x direction
39     ndy = 1 # steps in y direction
40    
41     #PDE related
42     q=473. #Kelvin - our heat source temperature
43     Tref = 273. # Kelvin - starting temp of iron bar
44     rho = 7874. #kg/m^{3} density of iron
45     cp = 449. #j/Kg.K
46     rhocp = rho*cp
47     eta = 0 #radiation condition
48     kappa = 68. #temperature diffusion constant
49     #Script/Iteration Related
50     t=0 #our start time, usually zero
51     tend=5.*60. #seconds - time to end simulation
52     outputs = 200 # number of time steps required.
53     h=(tend-t)/outputs #size of time step
54     print "Expected Number of Output Files is: ", (tend-t)/h
55     i=0 #loop counter
56     #the folder to put our outputs in, leave blank "" for script path
57     #note this folder path must exist to work
58     save_path = "data/onedheatdiff001"
59    
60     #... generate domain ...
61     rod = Rectangle(l0=mx,l1=my,n0=ndx, n1=ndy)
62     # extract finite points
63     x=rod.getX()
64     #... open PDE ...
65     mypde=LinearPDE(rod)
66     mypde.setSymmetryOn()
67     mypde.setValue(A=kappa*kronecker(rod),D=rhocp/h,d=eta,y=eta*Tref)
68    
69     # ... set heat source: ....
70     qH=q*whereZero(x[0])
71     # ... set initial temperature ....
72     T=Tref
73    
74     #saveVTK(os.path.join(save_path,"data%03d.xml") %i,sol=T)
75    
76     # ... start iteration:
77     while t<=tend:
78     i+=1
79     t+=h
80     mypde.setValue(Y=qH+rhocp/h*T)
81     T=mypde.getSolution()
82     saveVTK(os.path.join(save_path,"data%03d.xml") %i,sol=T)
83    
84    

  ViewVC Help
Powered by ViewVC 1.1.26