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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2484 - (hide annotations)
Mon Jun 22 04:22:19 2009 UTC (9 years, 9 months ago) by gross
File MIME type: text/x-python
File size: 2028 byte(s)
numarray removed from docu; Locator revised.
1 ksteube 1811
2     ########################################################
3     #
4     # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7     #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12     ########################################################
13    
14     __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
21 ksteube 1811
22 gross 578 from esys.escript import *
23     from esys.escript.linearPDEs import LinearPDE
24 gross 579 from esys.finley import Brick
25 gross 578 #... set some parameters ...
26 gross 579 lam=1.
27     mu=0.1
28     alpha=1.e-6
29     xc=[0.3,0.3,1.]
30     beta=8.
31     T_ref=0.
32     T_0=1.
33 gross 578 #... generate domain ...
34 gross 579 mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
35     x=mydomain.getX()
36     #... set temperature ...
37     T=T_0*exp(-beta*length(x-xc))
38     #... open symmetric PDE ...
39 gross 578 mypde=LinearPDE(mydomain)
40     mypde.setSymmetryOn()
41 gross 579 #... set coefficients ...
42     C=Tensor4(0.,Function(mydomain))
43     for i in range(mydomain.getDim()):
44     for j in range(mydomain.getDim()):
45     C[i,i,j,j]+=lam
46     C[j,i,j,i]+=mu
47     C[j,i,i,j]+=mu
48     msk=whereZero(x[0])*[1.,0.,0.] \
49     +whereZero(x[1])*[0.,1.,0.] \
50     +whereZero(x[2])*[0.,0.,1.]
51     sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
52     mypde.setValue(A=C,X=sigma0,q=msk)
53 artak 1892 mypde.setSolverMethod(mypde.PCG,mypde.AMG)
54 gross 579 #... solve pde ...
55 artak 1892 u=mypde.getSolution(verbose=True)
56 gross 579 #... calculate von-Misses
57     g=grad(u)
58     sigma=mu*(g+transpose(g))+lam*trace(g)*kronecker(mydomain)-sigma0
59     sigma_mises=sqrt(((sigma[0,0]-sigma[1,1])**2+(sigma[1,1]-sigma[2,2])**2+ \
60     (sigma[2,2]-sigma[0,0])**2)/6. \
61     +sigma[0,1]**2 + sigma[1,2]**2 + sigma[2,0]**2)
62     #... output ...
63     saveVTK("deform.xml",disp=u,stress=sigma_mises)
64 gross 578

Properties

Name Value
svn:mergeinfo

  ViewVC Help
Powered by ViewVC 1.1.26