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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1387 - (hide annotations)
Fri Jan 11 07:45:26 2008 UTC (11 years, 3 months ago) by trankine
Original Path: temp/doc/examples/pyvisi/diffusion_with_pyvisi.py
File MIME type: text/x-python
File size: 1680 byte(s)
Restore the trunk that existed before the windows changes were committed to the (now moved to branches) old trunk.
1 jongui 1203 """
2     Author: Lutz Gross, l.gross@uq.edu.au
3     Author: John Ngui, john.ngui@uq.edu.au
4     """
5    
6 ksteube 1147 # Import the necessary modules.
7     from esys.escript import *
8     from esys.escript.linearPDEs import LinearPDE
9     from esys.finley import Rectangle
10     from esys.pyvisi import Scene, DataCollector, Map, Camera
11     from esys.pyvisi.constant import *
12 jongui 1148 import os
13 ksteube 1147
14 jongui 1148 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
15 ksteube 1147 X_SIZE = 400
16     Y_SIZE = 400
17 jongui 1148 JPG_RENDERER = Renderer.ONLINE_JPG
18 ksteube 1147
19     #... set some parameters ...
20     xc=[0.02,0.002]
21     r=0.001
22     qc=50.e6
23     Tref=0.
24     rhocp=2.6e6
25     eta=75.
26     kappa=240.
27     tend=5.
28     # ... time, time step size and counter ...
29     t=0
30     h=0.1
31     i=0
32 jongui 1153
33 ksteube 1147 #... generate domain ...
34     mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
35     #... open PDE ...
36     mypde=LinearPDE(mydomain)
37     mypde.setSymmetryOn()
38     mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
39     # ... set heat source: ....
40     x=mydomain.getX()
41     qH=qc*whereNegative(length(x-xc)-r)
42     # ... set initial temperature ....
43     T=Tref
44    
45     # Create a Scene.
46     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
47 jongui 1148
48 ksteube 1147 # Create a DataCollector reading directly from escript objects.
49     dc = DataCollector(source = Source.ESCRIPT)
50    
51 jongui 1148 # Create a Map.
52 jongui 1158 m = Map(scene = s, data_collector = dc, \
53     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, \
54 ksteube 1147 cell_to_point = False, outline = True)
55    
56 jongui 1148 # Create a Camera.
57     c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
58    
59 ksteube 1147 # ... start iteration:
60 jongui 1191 while t<0.4:
61 ksteube 1147 i+=1
62     t+=h
63     mypde.setValue(Y=qH+rhocp/h*T)
64     T=mypde.getSolution()
65    
66     dc.setData(temp = T)
67    
68     # Render the object.
69 jongui 1158 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
70 jongui 1148 "diffusion%02d.jpg") % i)
71 ksteube 1147

  ViewVC Help
Powered by ViewVC 1.1.26