/[escript]/trunk-mpi-branch/doc/examples/heatedblock.py
ViewVC logotype

Contents of /trunk-mpi-branch/doc/examples/heatedblock.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1306 - (show annotations)
Tue Sep 18 05:51:09 2007 UTC (11 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 1641 byte(s)
New Copyright in each .c .h .cpp and .py file

1 #
2 # $Id$
3 #
4 #######################################################
5 #
6 # Copyright 2003-2007 by ACceSS MNRF
7 # Copyright 2007 by University of Queensland
8 #
9 # http://esscc.uq.edu.au
10 # Primary Business: Queensland, Australia
11 # Licensed under the Open Software License version 3.0
12 # http://www.opensource.org/licenses/osl-3.0.php
13 #
14 #######################################################
15 #
16
17 from esys.escript import *
18 from esys.escript.linearPDEs import LinearPDE
19 from esys.finley import Brick
20 #... set some parameters ...
21 lam=1.
22 mu=0.1
23 alpha=1.e-6
24 xc=[0.3,0.3,1.]
25 beta=8.
26 T_ref=0.
27 T_0=1.
28 #... 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 #... set coefficients ...
37 C=Tensor4(0.,Function(mydomain))
38 for i in range(mydomain.getDim()):
39 for j in range(mydomain.getDim()):
40 C[i,i,j,j]+=lam
41 C[j,i,j,i]+=mu
42 C[j,i,i,j]+=mu
43 msk=whereZero(x[0])*[1.,0.,0.] \
44 +whereZero(x[1])*[0.,1.,0.] \
45 +whereZero(x[2])*[0.,0.,1.]
46 sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
47 mypde.setValue(A=C,X=sigma0,q=msk)
48 #... solve pde ...
49 u=mypde.getSolution()
50 #... calculate von-Misses
51 g=grad(u)
52 sigma=mu*(g+transpose(g))+lam*trace(g)*kronecker(mydomain)-sigma0
53 sigma_mises=sqrt(((sigma[0,0]-sigma[1,1])**2+(sigma[1,1]-sigma[2,2])**2+ \
54 (sigma[2,2]-sigma[0,0])**2)/6. \
55 +sigma[0,1]**2 + sigma[1,2]**2 + sigma[2,0]**2)
56 #... output ...
57 saveVTK("deform.xml",disp=u,stress=sigma_mises)
58

  ViewVC Help
Powered by ViewVC 1.1.26