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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1099 - (hide annotations)
Tue Apr 17 01:45:08 2007 UTC (14 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 1853 byte(s)
Upated some examples.
1 jongui 1095 # $Id$
2     from esys.escript import *
3     from esys.escript.linearPDEs import LinearPDE
4     from esys.finley import Brick
5 jongui 1099 from esys.pyvisi import Scene, DataCollector, Velocity, Camera
6 jongui 1095 from esys.pyvisi.constant import *
7     #... set some parameters ...
8     lam=1.
9     mu=0.1
10     alpha=1.e-6
11     xc=[0.3,0.3,1.]
12     beta=8.
13     T_ref=0.
14     T_0=1.
15     #... generate domain ...
16     mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
17     x=mydomain.getX()
18     #... set temperature ...
19     T=T_0*exp(-beta*length(x-xc))
20     #... open symmetric PDE ...
21     mypde=LinearPDE(mydomain)
22     mypde.setSymmetryOn()
23     #... set coefficients ...
24     C=Tensor4(0.,Function(mydomain))
25     for i in range(mydomain.getDim()):
26     for j in range(mydomain.getDim()):
27     C[i,i,j,j]+=lam
28     C[j,i,j,i]+=mu
29     C[j,i,i,j]+=mu
30     msk=whereZero(x[0])*[1.,0.,0.] \
31     +whereZero(x[1])*[0.,1.,0.] \
32     +whereZero(x[2])*[0.,0.,1.]
33     sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
34     mypde.setValue(A=C,X=sigma0,q=msk)
35     #... solve pde ...
36     u=mypde.getSolution()
37     #... calculate von-Misses
38     g=grad(u)
39     sigma=mu*(g+transpose(g))+lam*trace(g)*kronecker(mydomain)-sigma0
40     sigma_mises=sqrt(((sigma[0,0]-sigma[1,1])**2+(sigma[1,1]-sigma[2,2])**2+ \
41     (sigma[2,2]-sigma[0,0])**2)/6. \
42     +sigma[0,1]**2 + sigma[1,2]**2 + sigma[2,0]**2)
43     #... output ...
44     #saveVTK("deform.xml",disp=u,stress=sigma_mises)
45    
46 jongui 1099 s = Scene(renderer = Renderer.OFFLINE_JPG, x_size = 500, y_size = 500)
47 jongui 1097
48 jongui 1095 dc = DataCollector(source = Source.ESCRIPT)
49 jongui 1097 dc.setData(disp = u,stress = sigma_mises)
50 jongui 1095
51 jongui 1099 v = Velocity(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,
52     arrow = Arrow.THREE_D, color_mode = ColorMode.SCALAR,
53     lut = Lut.COLOR, cell_to_point = True, outline = True)
54     v.setScaleFactor(scale_factor = 0.3)
55 jongui 1095
56 jongui 1099 c = Camera(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST)
57     c.isometricView()
58    
59 jongui 1095 s.render(image_name = "heatedblock.jpg")

  ViewVC Help
Powered by ViewVC 1.1.26