/[escript]/trunk/doc/examples/pyvisi/diffusion_with_pyvisi.py
ViewVC logotype

Contents of /trunk/doc/examples/pyvisi/diffusion_with_pyvisi.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 6 months ago) by ksteube
File MIME type: text/x-python
File size: 2445 byte(s)
Copyright updated in all files

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 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-2008 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__="http://www.uq.edu.au/esscc/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 xc=[0.02,0.002]
42 r=0.001
43 qc=50.e6
44 Tref=0.
45 rhocp=2.6e6
46 eta=75.
47 kappa=240.
48 tend=5.
49 # ... time, time step size and counter ...
50 t=0
51 h=0.1
52 i=0
53
54 #... generate domain ...
55 mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
56 #... open PDE ...
57 mypde=LinearPDE(mydomain)
58 mypde.setSymmetryOn()
59 mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
60 # ... set heat source: ....
61 x=mydomain.getX()
62 qH=qc*whereNegative(length(x-xc)-r)
63 # ... set initial temperature ....
64 T=Tref
65
66 # Create a Scene.
67 s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
68
69 # Create a DataCollector reading directly from escript objects.
70 dc = DataCollector(source = Source.ESCRIPT)
71
72 # Create a Map.
73 m = Map(scene = s, data_collector = dc, \
74 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, \
75 cell_to_point = False, outline = True)
76
77 # Create a Camera.
78 c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
79
80 # ... start iteration:
81 while t<0.4:
82 i+=1
83 t+=h
84 mypde.setValue(Y=qH+rhocp/h*T)
85 T=mypde.getSolution()
86
87 dc.setData(temp = T)
88
89 # Render the object.
90 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
91 "diffusion%02d.jpg") % i)
92

  ViewVC Help
Powered by ViewVC 1.1.26