/[escript]/trunk/pyvisi/test/python/run_escript.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/run_escript.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1103 - (show annotations)
Wed Apr 18 04:31:06 2007 UTC (12 years ago) by jongui
File MIME type: text/x-python
File size: 2253 byte(s)
Some updates.
1 from esys.escript import *
2 from esys.escript.linearPDEs import LinearPDE
3 from esys.finley import Rectangle, Brick
4 from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Ellipsoid
5 from esys.pyvisi.constant import *
6 import unittest
7 #from stat import ST_SIZE
8
9 PYVISI_TEST_ESCRIPT_IMAGES_PATH = "data_sample_images/escript/"
10 MIN_IMAGE_SIZE = 100
11
12 X_SIZE = 400
13 Y_SIZE = 400
14 JPG_RENDERER = Renderer.OFFLINE_JPG
15
16 class TestPointData(unittest.TestCase):
17 def testPointData(self):
18 #... set some parameters ...
19 xc=[0.02,0.002]
20 r=0.001
21 qc=50.e6
22 Tref=0.
23 rhocp=2.6e6
24 eta=75.
25 kappa=240.
26 tend=5.
27 # ... time, time step size and counter ...
28 t=0
29 h=0.1
30 i=0
31 #... generate domain ...
32 mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
33 #... open PDE ...
34 mypde=LinearPDE(mydomain)
35 mypde.setSymmetryOn()
36 mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
37 # ... set heat source: ....
38 x=mydomain.getX()
39 qH=qc*whereNegative(length(x-xc)-r)
40 # ... set initial temperature ....
41 T=Tref
42
43 # Create a Scene.
44 s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
45 # Create a DataCollector reading directly from escript objects.
46 dc = DataCollector(source = Source.ESCRIPT)
47
48 # ... start iteration:
49 while t<0.4:
50 i+=1
51 t+=h
52 print "time step :",t
53 mypde.setValue(Y=qH+rhocp/h*T)
54 T=mypde.getSolution()
55
56 dc.setData(temp = T)
57 # Create a Map.
58 Map(scene = s, data_collector = dc,
59 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
60 cell_to_point = False, outline = True)
61
62 # Create a Camera.
63 c= Camera(scene = s, data_collector = dc,
64 viewport = Viewport.SOUTH_WEST)
65
66 # Render the object.
67 s.render(image_name = PYVISI_TEST_ESCRIPT_IMAGES_PATH +
68 "diffusion%02d.jpg" % i)
69
70 ###############################################################################
71 if __name__ == '__main__':
72 suite = unittest.TestSuite()
73 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestPointData))
74 #suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestPointAndCellData))
75 #suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCellAndPointData))
76 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26