/[escript]/trunk/doc/cookbook/onedheatdiff_var001.py
ViewVC logotype

Contents of /trunk/doc/cookbook/onedheatdiff_var001.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2393 - (show annotations)
Thu Apr 16 04:24:07 2009 UTC (13 years, 5 months ago) by ahallam
File MIME type: text/x-python
File size: 2382 byte(s)
End Day Commit
Working on onedheatdiff_var001
1
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 #PDE related
36 q=0 #our heat source temperature is now zero
37 Tref=50.e6 #the starting temperature of our iron bar
38 rho=2.6e6
39 eta=75.
40 kappa=240.
41 #Script/Iteration Related
42 t=0 #our start time, usually zero
43 tend=100.#the time we want to end the simulation
44 h=0.25 #size of time step
45
46 print "Expected Number of Output Files is: ", (tend-t)/h
47
48 i=0 #loop counter
49 save_path = "data/onedheatdiff_var001" #the folder to put our outputs in, leave blank "" for script path - note this folder path must exist to work
50
51 #... generate domain ...
52 rod = Rectangle(l0=0.05,l1=.01,n0=500, n1=1)
53 # extract finite points
54 x=rod.getX()
55 #... open PDE ...
56 mypde=LinearPDE(rod)
57 mypde.setSymmetryOn()
58 mypde.setValue(A=kappa*kronecker(rod),D=rho/h,d=eta,y=eta*Tref)
59
60 # ... set initial temperature ....
61 T= -1*Tref*whereNegative(x[0]-0.025)+0.01*Tref*wherePositive(x[0]-0.025)+0.99*Tref*wherePositive(x[0]-0.04)
62
63 saveVTK(os.path.join(save_path,"data%03d.xml") %i,sol=T)
64
65 # ... start iteration:
66 while t<=tend:
67 i+=1
68 t+=h
69 mypde.setValue(Y=rho/h*T)
70 T=mypde.getSolution()
71 print T
72 saveVTK(os.path.join(save_path,"data%03d.xml") %i,sol=T)
73
74

  ViewVC Help
Powered by ViewVC 1.1.26