/[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 1153 - (show annotations)
Thu May 17 06:33:54 2007 UTC (13 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 1592 byte(s)
Made some minor modifications and fixed minor bugs. Most tests appear to pass on the Altix although there are two tests which occasionally throw an error related to memory corruption.
1 # Import the necessary modules.
2 from esys.escript import *
3 from esys.escript.linearPDEs import LinearPDE
4 from esys.finley import Rectangle
5 from esys.pyvisi import Scene, DataCollector, Map, Camera
6 from esys.pyvisi.constant import *
7 import os
8
9 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
10 X_SIZE = 400
11 Y_SIZE = 400
12 JPG_RENDERER = Renderer.ONLINE_JPG
13
14 #... set some parameters ...
15 xc=[0.02,0.002]
16 r=0.001
17 qc=50.e6
18 Tref=0.
19 rhocp=2.6e6
20 eta=75.
21 kappa=240.
22 tend=5.
23 # ... time, time step size and counter ...
24 t=0
25 h=0.1
26 i=0
27
28 #... generate domain ...
29 mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
30 #... open PDE ...
31 mypde=LinearPDE(mydomain)
32 mypde.setSymmetryOn()
33 mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
34 # ... set heat source: ....
35 x=mydomain.getX()
36 qH=qc*whereNegative(length(x-xc)-r)
37 # ... set initial temperature ....
38 T=Tref
39
40 # Create a Scene.
41 s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
42
43 # Create a DataCollector reading directly from escript objects.
44 dc = DataCollector(source = Source.ESCRIPT)
45
46 # Create a Map.
47 m = Map(scene = s, data_collector = dc,
48 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
49 cell_to_point = False, outline = True)
50
51 # Create a Camera.
52 c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
53
54 # ... start iteration:
55 while t<0.4:
56 i+=1
57 t+=h
58 mypde.setValue(Y=qH+rhocp/h*T)
59 T=mypde.getSolution()
60
61 dc.setData(temp = T)
62
63 # Render the object.
64 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,
65 "diffusion%02d.jpg") % i)
66

  ViewVC Help
Powered by ViewVC 1.1.26