/[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 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (8 years, 10 months ago) by jfenwick
File MIME type: text/x-python
File size: 1886 byte(s)
Merging dudley and scons updates from branches

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 # end of simulation time
26 t_end=0.1
27 # time step size:
28 dt=0.01
29 # dimensions:
30 L0=1.;L1=1.
31 # location, size and value of heat source
32 xc=[0.3,0.4]; r=0.1; Qc=3000
33 # material parameter
34 k=1; rhocp=100;
35 # bottom temperature:
36 T_bot=100
37 # generate domain:
38 mydomain=Rectangle(l0=L0,l1=L1,n0=20,n1=20)
39 x=mydomain.getX()
40 # set boundray temperature:
41 T_D=T_bot/L1*(L1-x[1])
42 # set heat source:
43 Q=Qc*whereNegative(length(x-xc)-r)
44 # generate domain:
45 mypde=LinearPDE(mydomain)
46 mypde.setSymmetryOn()
47 # set PDE coefficients:
48 mypde.setValue(A=dt*k*kronecker(mydomain), D=dt*rhocp,
49 r=T_D, q=whereZero(x[1])+whereZero(x[1]-L1))
50 # initial temperature
51 T=T_D
52 # step counter and time marker:
53 N=0; t=0
54 # stop when t_end is reached:
55 while t<t_end:
56 print N,"-th time step t=",t
57 # update PDE coefficient:
58 mypde.setValue(Y=dt*rhocp*T+dt*Q)
59 # new temperature:
60 T=mypde.getSolution()
61 # save as VTK for visualisation:
62 saveVTK("u.%s.vtu"%N,T=T)
63 # increase counter and marker:
64 N+=1; t+=dt

  ViewVC Help
Powered by ViewVC 1.1.26