/[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 5593 - (show annotations)
Fri Apr 24 01:36:26 2015 UTC (4 years, 6 months ago) by jfenwick
File MIME type: text/x-python
File size: 2524 byte(s)
Fixing institution name to comply with policy
1 from __future__ import division
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2015 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2015 by The University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 from esys.escript import *
25 from esys.escript.linearPDEs import LinearPDE
26 from esys.weipa import saveVTK
27
28 try:
29 from esys.finley import Brick
30 HAVE_FINLEY = True
31 except ImportError:
32 print("Finley module required but not available")
33 HAVE_FINLEY = False
34
35 if HAVE_FINLEY:
36
37 #... set some parameters ...
38 lam=1.
39 mu=0.1
40 alpha=1.e-6
41 xc=[0.3,0.3,1.]
42 beta=8.
43 T_ref=0.
44 T_0=1.
45 #... generate domain ...
46 mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
47 x=mydomain.getX()
48 #... set temperature ...
49 T=T_0*exp(-beta*length(x-xc))
50 #... open symmetric PDE ...
51 mypde=LinearPDE(mydomain)
52 mypde.setSymmetryOn()
53 #... set coefficients ...
54 C=Tensor4(0.,Function(mydomain))
55 for i in range(mydomain.getDim()):
56 for j in range(mydomain.getDim()):
57 C[i,i,j,j]+=lam
58 C[i,j,i,j]+=mu
59 C[i,j,j,i]+=mu
60 msk=whereZero(x[0])*[1.,0.,0.] \
61 +whereZero(x[1])*[0.,1.,0.] \
62 +whereZero(x[2])*[0.,0.,1.]
63 sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
64 mypde.setValue(A=C,X=sigma0,q=msk)
65 mypde.getSolverOptions().setVerbosityOn()
66 #... solve pde ...
67 u=mypde.getSolution()
68 #... calculate von-Misses
69 g=grad(u)
70 sigma=mu*(g+transpose(g))+lam*trace(g)*kronecker(mydomain)-sigma0
71 sigma_mises=sqrt(((sigma[0,0]-sigma[1,1])**2+(sigma[1,1]-sigma[2,2])**2+ \
72 (sigma[2,2]-sigma[0,0])**2)/2. \
73 +3*(sigma[0,1]**2 + sigma[1,2]**2 + sigma[2,0]**2))
74 #... output ...
75 saveVTK("deform.vtu",disp=u,stress=sigma_mises)
76

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/doc/examples/usersguide/heatedblock.py:5567-5588 /branches/lapack2681/doc/examples/usersguide/heatedblock.py:2682-2741 /branches/pasowrap/doc/examples/usersguide/heatedblock.py:3661-3674 /branches/py3_attempt2/doc/examples/usersguide/heatedblock.py:3871-3891 /branches/restext/doc/examples/usersguide/heatedblock.py:2610-2624 /branches/ripleygmg_from_3668/doc/examples/usersguide/heatedblock.py:3669-3791 /branches/symbolic_from_3470/doc/examples/usersguide/heatedblock.py:3471-3974 /branches/symbolic_from_3470/ripley/test/python/doc/examples/usersguide/heatedblock.py:3517-3974 /release/4.0/doc/examples/usersguide/heatedblock.py:5380-5406 /trunk/doc/examples/usersguide/heatedblock.py:1388-2483 /trunk/ripley/test/python/doc/examples/usersguide/heatedblock.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26