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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2667 - (hide annotations)
Thu Sep 17 01:49:11 2009 UTC (10 years, 2 months ago) by jfenwick
Original Path: trunk/doc/examples/cookbook/onedheatdiff.py
File MIME type: text/x-python
File size: 2608 byte(s)
Renamed the main cookbook tex file to match our convention.
Replaced doc/cookbook/figures/heatrefraction002contqu.pdf with
a version which is actually pdf. However it needs to be regnerated since
it it sideways.

The examples have had their copyright notices fixed (dates were too early).
sb2.py has been removed since it uses pyvisi.

scons will now build the cookbook as parts of a docs build.
Also in reposnse to :
scons cookbook_pdf


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     # 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 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     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 jfenwick 2648 from cblib import needdirs
32 ahallam 2392
33    
34     ##ESTABLISHING VARIABLES
35     #PDE related
36     q=50.e6 #our heat source temperature
37     Tref=0. #the starting temperature of our iron bar
38     rho=2.6e6
39 ahallam 2397 eta=0#75.
40 ahallam 2392 kappa=240.
41     #Script/Iteration Related
42     t=0 #our start time, usually zero
43     tend=5.#the time we want to end the simulation
44     h=0.05 #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" #the folder to put our outputs in, leave blank "" for script path - note this folder path must exist to work
50 jfenwick 2648 needdirs([save_path])
51 ahallam 2392
52     #... generate domain ...
53     rod = Rectangle(l0=0.05,l1=.01,n0=500, n1=1)
54     # extract finite points
55 ahallam 2397 x=rod.getX()
56 ahallam 2392 #... open PDE ...
57     mypde=LinearPDE(rod)
58     mypde.setSymmetryOn()
59     mypde.setValue(A=kappa*kronecker(rod),D=rho/h,d=eta,y=eta*Tref)
60     # ... set heat source: ....
61    
62     qH=q*whereZero(x[0])
63     # ... set initial temperature ....
64     T=Tref
65    
66     # ... start iteration:
67     while t<=tend:
68     i+=1
69     t+=h
70 ahallam 2397 mypde.setValue(Y=qH+rho/h*T)
71 ahallam 2392 T=mypde.getSolution()
72     print T
73 caltinay 2534 saveVTK(os.path.join(save_path,"data%03d.vtu") %i,sol=T)
74 ahallam 2392
75 ahallam 2597 #~ command = ('mencoder',
76     #~ 'mf://*.png',
77     #~ '-mf',
78     #~ 'type=png:w=800:h=600:fps=25',
79     #~ '-ovc',
80     #~ 'lavc',
81     #~ '-lavcopts',
82     #~ 'vcodec=mpeg4',
83     #~ '-oac',
84     #~ 'copy',
85     #~ '-o',
86     #~ 'output.avi')
87 ahallam 2392

  ViewVC Help
Powered by ViewVC 1.1.26