/[escript]/trunk/doc/examples/geotutorial/backward_euler.py
ViewVC logotype

Contents of /trunk/doc/examples/geotutorial/backward_euler.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3346 - (show annotations)
Fri Nov 12 01:19:02 2010 UTC (12 years ago) by caltinay
File MIME type: text/x-python
File size: 1917 byte(s)
Replaced usage of esys.escript.util.saveVTK by weipa.saveVTK in all python
scripts.

1 ########################################################
2 #
3 # Copyright (c) 2003-2010 by University of Queensland
4 # Earth Systems Science Computational Center (ESSCC)
5 # http://www.uq.edu.au/esscc
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 ########################################################
12
13 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
14 Earth Systems Science Computational Center (ESSCC)
15 http://www.uq.edu.au/esscc
16 Primary Business: Queensland, Australia"""
17 __license__="""Licensed under the Open Software License version 3.0
18 http://www.opensource.org/licenses/osl-3.0.php"""
19 __url__="https://launchpad.net/escript-finley"
20
21 # import tools
22 from esys.escript import *
23 from esys.escript.linearPDEs import LinearPDE
24 from esys.dudley import Rectangle
25 from esys.weipa import saveVTK
26 # end of simulation time
27 t_end=0.1
28 # time step size:
29 dt=0.01
30 # dimensions:
31 L0=1.;L1=1.
32 # location, size and value of heat source
33 xc=[0.3,0.4]; r=0.1; Qc=3000
34 # material parameter
35 k=1; rhocp=100;
36 # bottom temperature:
37 T_bot=100
38 # generate domain:
39 mydomain=Rectangle(l0=L0,l1=L1,n0=20,n1=20)
40 x=mydomain.getX()
41 # set boundray temperature:
42 T_D=T_bot/L1*(L1-x[1])
43 # set heat source:
44 Q=Qc*whereNegative(length(x-xc)-r)
45 # generate domain:
46 mypde=LinearPDE(mydomain)
47 mypde.setSymmetryOn()
48 # set PDE coefficients:
49 mypde.setValue(A=dt*k*kronecker(mydomain), D=dt*rhocp,
50 r=T_D, q=whereZero(x[1])+whereZero(x[1]-L1))
51 # initial temperature
52 T=T_D
53 # step counter and time marker:
54 N=0; t=0
55 # stop when t_end is reached:
56 while t<t_end:
57 print N,"-th time step t=",t
58 # update PDE coefficient:
59 mypde.setValue(Y=dt*rhocp*T+dt*Q)
60 # new temperature:
61 T=mypde.getSolution()
62 # save as VTK for visualisation:
63 saveVTK("u.%s.vtu"%N,T=T)
64 # increase counter and marker:
65 N+=1; t+=dt

  ViewVC Help
Powered by ViewVC 1.1.26