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

Annotation of /trunk/doc/examples/geotutorial/forward_euler.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (3 years, 8 months ago) by jfenwick
File MIME type: text/x-python
File size: 2506 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 jfenwick 3981 ##############################################################################
2 gross 2156 #
3 jfenwick 6651 # Copyright (c) 2003-2018 by The University of Queensland
4 jfenwick 3981 # http://www.uq.edu.au
5 gross 2156 #
6     # Primary Business: Queensland, Australia
7 jfenwick 6112 # Licensed under the Apache License, version 2.0
8     # http://www.apache.org/licenses/LICENSE-2.0
9 gross 2156 #
10 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
12     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 jfenwick 3981 #
14     ##############################################################################
15 sshaw 5707 from __future__ import division, print_function
16 gross 2156
17 jfenwick 6651 __copyright__="""Copyright (c) 2003-2018 by The University of Queensland
18 jfenwick 3981 http://www.uq.edu.au
19 gross 2156 Primary Business: Queensland, Australia"""
20 jfenwick 6112 __license__="""Licensed under the Apache License, version 2.0
21     http://www.apache.org/licenses/LICENSE-2.0"""
22 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
23 gross 2156
24     # import tools
25     from esys.escript import *
26     from esys.escript.linearPDEs import LinearPDE
27 sshaw 5288 try:
28     from esys.dudley import Rectangle
29     HAVE_DUDLEY = True
30     except ImportError:
31     HAVE_DUDLEY = False
32 caltinay 3346 from esys.weipa import saveVTK
33 caltinay 3953
34 sshaw 5288 if not HAVE_DUDLEY:
35     print("Dudley module not available")
36     else:
37     # end of simulation time
38     t_end=0.1
39     # dimensions:
40     L0=1.;L1=1.
41     # location, size and value of heat source
42     xc=[0.3,0.4]; r=0.1; Qc=3000
43     # material parameter
44     k=1.; rhocp=100;
45     # bottom temperature:
46     T_bot=100
47     # generate domain:
48     mydomain=Rectangle(l0=L0,l1=L1,n0=20,n1=20)
49     x=mydomain.getX()
50     # set boundray temperature:
51     T_D=T_bot/L1*(L1-x[1])
52     # set heat source:
53     Q=Qc*whereNegative(length(x-xc)-r)
54     # time step size:
55     dt=0.01
56     # or use adaptive choice dt=0.05*inf(rhocp*mydomain.getSize()**2/k)
57     print("time step size = %s"%dt)
58     # generate domain:
59     mypde=LinearPDE(mydomain)
60     mypde.setSymmetryOn()
61     # set PDE coefficients:
62     mypde.setValue(D=rhocp,
63     r=T_D, q=whereZero(x[1])+whereZero(x[1]-L1))
64     # initial temperature
65     T=T_D
66     # step counter and time marker:
67     N=0; t=0
68     # stop when t_end is reached:
69     while t<t_end:
70     print("time step %d, t=%s, T_max=%s"%(N, t, Lsup(T)))
71     # update PDE coefficient:
72     mypde.setValue(Y=rhocp*T+dt*Q, X=-k*dt*grad(T))
73     # new temperature:
74     T=mypde.getSolution()
75     # save as VTK for visualisation:
76     # saveVTK("u.%s.vtu"%N,T=T)
77     # increase counter and marker:
78     N+=1; t+=dt
79    

  ViewVC Help
Powered by ViewVC 1.1.26