/[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 1148 - (hide annotations)
Wed May 16 22:45:33 2007 UTC (15 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 1591 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 ksteube 1147 # 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 jongui 1148 import os
8 ksteube 1147
9 jongui 1148 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
10 ksteube 1147 X_SIZE = 400
11     Y_SIZE = 400
12 jongui 1148 JPG_RENDERER = Renderer.ONLINE_JPG
13 ksteube 1147
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     #... generate domain ...
28     mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
29     #... open PDE ...
30     mypde=LinearPDE(mydomain)
31     mypde.setSymmetryOn()
32     mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
33     # ... set heat source: ....
34     x=mydomain.getX()
35     qH=qc*whereNegative(length(x-xc)-r)
36     # ... set initial temperature ....
37     T=Tref
38    
39     # Create a Scene.
40     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
41 jongui 1148
42 ksteube 1147 # Create a DataCollector reading directly from escript objects.
43     dc = DataCollector(source = Source.ESCRIPT)
44    
45 jongui 1148 # Create a Map.
46     m = Map(scene = s, data_collector = dc,
47 ksteube 1147 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
48     cell_to_point = False, outline = True)
49    
50 jongui 1148 # Create a Camera.
51     c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
52    
53 ksteube 1147 # ... start iteration:
54 jongui 1148 while t<0.4:
55 ksteube 1147 i+=1
56     t+=h
57     mypde.setValue(Y=qH+rhocp/h*T)
58     T=mypde.getSolution()
59    
60     dc.setData(temp = T)
61    
62     # Render the object.
63 jongui 1148 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,
64     "diffusion%02d.jpg") % i)
65 ksteube 1147

  ViewVC Help
Powered by ViewVC 1.1.26