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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2549 - (show annotations)
Mon Jul 20 06:43:47 2009 UTC (9 years, 11 months ago) by jfenwick
File MIME type: text/x-python
File size: 2629 byte(s)
Remainder of copyright date fixes
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: Lutz Gross, l.gross@uq.edu.au
24 Author: John Ngui, john.ngui@uq.edu.au
25 """
26
27 # Import the necessary modules.
28 from esys.escript import *
29 from esys.escript.linearPDEs import LinearPDE
30 from esys.finley import Rectangle
31 from esys.pyvisi import Scene, DataCollector, Map, Camera
32 from esys.pyvisi.constant import *
33 import os
34
35 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
36 X_SIZE = 400
37 Y_SIZE = 400
38 JPG_RENDERER = Renderer.ONLINE_JPG
39
40 #... set some parameters ...
41 qc=50.e6
42 Tref=0.
43 rhocp=2.6e6
44 eta=75.
45 kappa=240.
46 tend=5.
47 # ... time, time step size and counter ...
48 t=0
49 h=0.1
50 i=0
51
52 #... generate domain ...
53 mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
54 #... open PDE ...
55 mypde=LinearPDE(mydomain)
56 mypde.setSymmetryOn()
57 mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
58 # ... set heat source: ....
59 x=mydomain.getX()
60
61 # ... set initial temperature ....
62 T=0.1*whereNonNegative(x[0]-0.025)
63 T=-0.1*whereNonPositive(x[0]-0.025)
64 qH=0*qc*whereZero(x[0]-0.001)
65 # Create a Scene.
66 s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
67
68 # Create a DataCollector reading directly from escript objects.
69 dc = DataCollector(source = Source.ESCRIPT)
70
71 # Create a Map.
72 m = Map(scene = s, data_collector = dc, \
73 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, \
74 cell_to_point = False, outline = True)
75
76 # Create a Camera.
77 c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
78
79 dc.setData(temp = T)
80
81 # Render the object.
82 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
83 "diffusion%02d.jpg") % i)
84
85 # ... start iteration:
86 while t<1.0:
87 i+=1
88 t+=h
89 mypde.setValue(Y=qH+rhocp/h*T)
90 T=mypde.getSolution()
91
92 dc.setData(temp = T)
93
94 # Render the object.
95 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
96 "diffusion%02d.jpg") % i)
97

  ViewVC Help
Powered by ViewVC 1.1.26