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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1387 - (hide annotations)
Fri Jan 11 07:45:26 2008 UTC (13 years, 3 months ago) by trankine
Original Path: temp/doc/examples/pyvisi/heatedblock_with_pyvisi.py
File MIME type: text/x-python
File size: 2200 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 Brick
10     from esys.pyvisi import Scene, DataCollector, Velocity, 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     JPG_RENDERER = Renderer.ONLINE_JPG
18    
19     #... set some parameters ...
20     lam=1.
21     mu=0.1
22     alpha=1.e-6
23     xc=[0.3,0.3,1.]
24     beta=8.
25     T_ref=0.
26     T_0=1.
27 jongui 1153
28 ksteube 1147 #... generate domain ...
29     mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
30     x=mydomain.getX()
31     #... set temperature ...
32     T=T_0*exp(-beta*length(x-xc))
33     #... open symmetric PDE ...
34     mypde=LinearPDE(mydomain)
35     mypde.setSymmetryOn()
36 jongui 1153
37 ksteube 1147 #... set coefficients ...
38     C=Tensor4(0.,Function(mydomain))
39     for i in range(mydomain.getDim()):
40     for j in range(mydomain.getDim()):
41     C[i,i,j,j]+=lam
42     C[j,i,j,i]+=mu
43     C[j,i,i,j]+=mu
44     msk=whereZero(x[0])*[1.,0.,0.] \
45     +whereZero(x[1])*[0.,1.,0.] \
46     +whereZero(x[2])*[0.,0.,1.]
47     sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
48     mypde.setValue(A=C,X=sigma0,q=msk)
49 jongui 1153
50 ksteube 1147 #... solve pde ...
51     u=mypde.getSolution()
52     #... calculate von-Misses
53     g=grad(u)
54     sigma=mu*(g+transpose(g))+lam*trace(g)*kronecker(mydomain)-sigma0
55     sigma_mises=sqrt(((sigma[0,0]-sigma[1,1])**2+(sigma[1,1]-sigma[2,2])**2+ \
56     (sigma[2,2]-sigma[0,0])**2)/6. \
57     +sigma[0,1]**2 + sigma[1,2]**2 + sigma[2,0]**2)
58    
59     # Create a Scene.
60     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
61    
62     # Create a DataCollector reading directly from an escript object.
63     dc = DataCollector(source = Source.ESCRIPT)
64 jongui 1148 dc.setData(disp = u, stress = sigma_mises)
65 ksteube 1147
66     # Create a Velocity.
67     v = Velocity(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,
68     arrow = Arrow.THREE_D, color_mode = ColorMode.SCALAR,
69     lut = Lut.COLOR, cell_to_point = True, outline = True)
70     v.setScaleFactor(scale_factor = 0.3)
71    
72     # Create a Camera.
73 jongui 1148 c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
74 ksteube 1147 c.isometricView()
75    
76     # Render the object.
77 jongui 1148 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,\
78     "heatedblock.jpg"))

  ViewVC Help
Powered by ViewVC 1.1.26