/[escript]/trunk/doc/examples/usersguide/heatedblock.py
ViewVC logotype

Contents of /trunk/doc/examples/usersguide/heatedblock.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1387 - (show annotations)
Fri Jan 11 07:45:26 2008 UTC (11 years, 1 month ago) by trankine
Original Path: temp/doc/examples/heatedblock.py
File MIME type: text/x-python
File size: 1220 byte(s)
Restore the trunk that existed before the windows changes were committed to the (now moved to branches) old trunk.
1 # $Id$
2 from esys.escript import *
3 from esys.escript.linearPDEs import LinearPDE
4 from esys.finley import Brick
5 #... set some parameters ...
6 lam=1.
7 mu=0.1
8 alpha=1.e-6
9 xc=[0.3,0.3,1.]
10 beta=8.
11 T_ref=0.
12 T_0=1.
13 #... generate domain ...
14 mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
15 x=mydomain.getX()
16 #... set temperature ...
17 T=T_0*exp(-beta*length(x-xc))
18 #... open symmetric PDE ...
19 mypde=LinearPDE(mydomain)
20 mypde.setSymmetryOn()
21 #... set coefficients ...
22 C=Tensor4(0.,Function(mydomain))
23 for i in range(mydomain.getDim()):
24 for j in range(mydomain.getDim()):
25 C[i,i,j,j]+=lam
26 C[j,i,j,i]+=mu
27 C[j,i,i,j]+=mu
28 msk=whereZero(x[0])*[1.,0.,0.] \
29 +whereZero(x[1])*[0.,1.,0.] \
30 +whereZero(x[2])*[0.,0.,1.]
31 sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
32 mypde.setValue(A=C,X=sigma0,q=msk)
33 #... solve pde ...
34 u=mypde.getSolution()
35 #... calculate von-Misses
36 g=grad(u)
37 sigma=mu*(g+transpose(g))+lam*trace(g)*kronecker(mydomain)-sigma0
38 sigma_mises=sqrt(((sigma[0,0]-sigma[1,1])**2+(sigma[1,1]-sigma[2,2])**2+ \
39 (sigma[2,2]-sigma[0,0])**2)/6. \
40 +sigma[0,1]**2 + sigma[1,2]**2 + sigma[2,0]**2)
41 #... output ...
42 saveVTK("deform.xml",disp=u,stress=sigma_mises)
43

  ViewVC Help
Powered by ViewVC 1.1.26