/[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 1147 - (hide annotations)
Wed May 16 06:39:11 2007 UTC (11 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 1811 byte(s)
Added back in some files that were accidentally deleted.

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    
8     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
9     X_SIZE = 400
10     Y_SIZE = 400
11     JPG_RENDERER = Renderer.DISPLAY
12    
13     #... set some parameters ...
14     xc=[0.02,0.002]
15     r=0.001
16     qc=50.e6
17     Tref=0.
18     rhocp=2.6e6
19     eta=75.
20     kappa=240.
21     tend=5.
22     # ... time, time step size and counter ...
23     t=0
24     h=0.1
25     i=0
26     #... generate domain ...
27     mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
28     #... open PDE ...
29     mypde=LinearPDE(mydomain)
30     mypde.setSymmetryOn()
31     mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
32     # ... set heat source: ....
33     x=mydomain.getX()
34     qH=qc*whereNegative(length(x-xc)-r)
35     # ... set initial temperature ....
36     T=Tref
37    
38     # Create a Scene.
39     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
40     # Create a DataCollector reading directly from escript objects.
41     dc = DataCollector(source = Source.ESCRIPT)
42    
43     Map(scene = s, data_collector = dc,
44     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
45     cell_to_point = False, outline = True)
46    
47     # ... start iteration:
48     while t<0.4*100:
49     i+=1
50     t+=h
51     print "time step :",t
52     mypde.setValue(Y=qH+rhocp/h*T)
53     T=mypde.getSolution()
54    
55     dc.setData(temp = T)
56     # Create a Map.
57     #Map(scene = s, data_collector = dc,
58     #viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
59     #cell_to_point = False, outline = True)
60    
61     # Create a Camera.
62     #c= Camera(scene = s, data_collector = dc,
63     # viewport = Viewport.SOUTH_WEST)
64    
65     # Render the object.
66     s.render(image_name = PYVISI_EXAMPLE_IMAGES_PATH +
67     "diffusion%02d.jpg" % i)
68    

  ViewVC Help
Powered by ViewVC 1.1.26