1 |
gross |
2156 |
######################################################## |
2 |
|
|
# |
3 |
|
|
# Copyright (c) 2003-2008 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-2008 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 |
jfenwick |
2344 |
__url__="https://launchpad.net/escript-finley" |
20 |
gross |
2156 |
|
21 |
|
|
# import tools |
22 |
|
|
from esys.escript import * |
23 |
|
|
from esys.escript.linearPDEs import LinearPDE |
24 |
|
|
from esys.finley import Rectangle |
25 |
|
|
# end of simulation time |
26 |
|
|
t_end=0.1 |
27 |
|
|
# dimensions: |
28 |
|
|
L0=1.;L1=1. |
29 |
|
|
# location, size and value of heat source |
30 |
|
|
xc=[0.3,0.4]; r=0.1; Qc=3000 |
31 |
|
|
# material parameter |
32 |
|
|
k=1.; rhocp=100; |
33 |
|
|
# bottom temperature: |
34 |
|
|
T_bot=100 |
35 |
|
|
# generate domain: |
36 |
|
|
mydomain=Rectangle(l0=L0,l1=L1,n0=20,n1=20) |
37 |
|
|
x=mydomain.getX() |
38 |
|
|
# set boundray temperature: |
39 |
|
|
T_D=T_bot/L1*(L1-x[1]) |
40 |
|
|
# set heat source: |
41 |
|
|
Q=Qc*whereNegative(length(x-xc)-r) |
42 |
|
|
# time step size: |
43 |
|
|
dt=0.01 |
44 |
|
|
# or use adaptive choice dt=0.05*inf(rhocp*mydomain.getSize()**2/k) |
45 |
|
|
print "time step size = ",dt |
46 |
|
|
# generate domain: |
47 |
|
|
mypde=LinearPDE(mydomain) |
48 |
|
|
mypde.setSymmetryOn() |
49 |
|
|
# set PDE coefficients: |
50 |
|
|
mypde.setValue(D=rhocp, |
51 |
|
|
r=T_D, q=whereZero(x[1])+whereZero(x[1]-L1)) |
52 |
|
|
# initial temperature |
53 |
|
|
T=T_D |
54 |
|
|
# step counter and time marker: |
55 |
|
|
N=0; t=0 |
56 |
|
|
# stop when t_end is reached: |
57 |
|
|
while t<t_end: |
58 |
|
|
print N,"-th time step t=",t," T_max=", Lsup(T) |
59 |
|
|
# update PDE coefficient: |
60 |
|
|
mypde.setValue(Y=rhocp*T+dt*Q, X=-k*dt*grad(T)) |
61 |
|
|
# new temperature: |
62 |
|
|
T=mypde.getSolution() |
63 |
|
|
# save to vtk for mayavi: |
64 |
|
|
# saveVTK("u.%s.xml"%N,T=T) |
65 |
|
|
# increase counter and marker: |
66 |
|
|
N+=1; t+=dt |