# Diff of /trunk/doc/user/examples/heatedblock.py

revision 578 by gross, Mon Mar 6 06:12:04 2006 UTC revision 579 by gross, Tue Mar 7 01:28:23 2006 UTC
# Line 1  Line 1
1  # \$Id: helmholtz.py 575 2006-03-03 03:33:07Z lkettle \$  # \$Id\$
2  from esys.escript import *  from esys.escript import *
3  from esys.escript.linearPDEs import LinearPDE  from esys.escript.linearPDEs import LinearPDE
4  from esys.finley import Rectangle  from esys.finley import Brick
5  #... set some parameters ...  #... set some parameters ...
6  kappa=1.  lam=1.
7  omega=0.1  mu=0.1
8  eta=10.  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 ...  #... generate domain ...
14  mydomain = Rectangle(l0=5.,l1=1.,n0=50, n1=10)  mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
15  #... open PDE and set coefficients ...  x=mydomain.getX()
16    #... set temperature ...
17    T=T_0*exp(-beta*length(x-xc))
18    #... open symmetric PDE ...
19  mypde=LinearPDE(mydomain)  mypde=LinearPDE(mydomain)
20  mypde.setSymmetryOn()  mypde.setSymmetryOn()
21  n=mydomain.getNormal()  #... set coefficients ...
22  x=mydomain.getX()  C=Tensor4(0.,Function(mydomain))
23  mypde.setValue(A=kappa*kronecker(mydomain),D=omega,Y=omega*x[0], \  for i in range(mydomain.getDim()):
24                 d=eta,y=kappa*n[0]+eta*x[0])    for j in range(mydomain.getDim()):
25  #... calculate error of the PDE solution ...       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()  u=mypde.getSolution()
35  print "error is ",Lsup(u-x[0])  #... calculate von-Misses
36  # output should be similar to "error is 1.e-7"  g=grad(u)
37  saveVTK("x0.xml",sol=u)  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

Legend:
 Removed from v.578 changed lines Added in v.579