1 |
ksteube |
1809 |
|
2 |
jfenwick |
3981 |
############################################################################## |
3 |
ksteube |
1312 |
# |
4 |
uqaeller |
6939 |
# Copyright (c) 2003-2020 by The University of Queensland |
5 |
jfenwick |
3981 |
# http://www.uq.edu.au |
6 |
ksteube |
1312 |
# |
7 |
ksteube |
1809 |
# Primary Business: Queensland, Australia |
8 |
jfenwick |
6112 |
# Licensed under the Apache License, version 2.0 |
9 |
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
10 |
ksteube |
1312 |
# |
11 |
jfenwick |
3981 |
# Development until 2012 by Earth Systems Science Computational Center (ESSCC) |
12 |
jfenwick |
4657 |
# Development 2012-2013 by School of Earth Sciences |
13 |
|
|
# Development from 2014 by Centre for Geoscience Computing (GeoComp) |
14 |
uqaeller |
6939 |
# Development from 2019 by School of Earth and Environmental Sciences |
15 |
jfenwick |
3981 |
# |
16 |
|
|
############################################################################## |
17 |
jgs |
127 |
|
18 |
sshaw |
5706 |
from __future__ import division, print_function |
19 |
|
|
|
20 |
uqaeller |
6939 |
__copyright__="""Copyright (c) 2003-2020 by The University of Queensland |
21 |
jfenwick |
3981 |
http://www.uq.edu.au |
22 |
ksteube |
1809 |
Primary Business: Queensland, Australia""" |
23 |
jfenwick |
6112 |
__license__="""Licensed under the Apache License, version 2.0 |
24 |
|
|
http://www.apache.org/licenses/LICENSE-2.0""" |
25 |
jfenwick |
2344 |
__url__="https://launchpad.net/escript-finley" |
26 |
elspeth |
628 |
|
27 |
jfenwick |
3432 |
from esys.escript import Data, inf, sup, length, grad, inner |
28 |
jgs |
149 |
from esys.escript.modelframe import Model,IterationDivergenceError |
29 |
jfenwick |
3432 |
import numpy |
30 |
jfenwick |
6647 |
import esys.escript.linearPDEs as lpde |
31 |
jgs |
127 |
|
32 |
|
|
|
33 |
jgs |
147 |
class TemperatureAdvection(Model): |
34 |
|
|
""" |
35 |
jgs |
127 |
|
36 |
jgs |
149 |
The conservation of internal heat energy is given by |
37 |
jgs |
147 |
|
38 |
jfenwick |
2625 |
*rho c_p ( dT/dt+v[j] * grad(T)[j])-grad(\kappa grad(T)_{,i}=Q* |
39 |
jgs |
147 |
|
40 |
jfenwick |
2625 |
*n_i \kappa T_{,i}=0* |
41 |
jgs |
147 |
|
42 |
jfenwick |
2625 |
it is assummed that *\rho c_p* is constant in time. |
43 |
jgs |
147 |
|
44 |
jgs |
149 |
solved by Taylor Galerkin method |
45 |
|
|
|
46 |
jgs |
147 |
""" |
47 |
gross |
918 |
def __init__(self,**kwargs): |
48 |
|
|
super(TemperatureAdvection, self).__init__(**kwargs) |
49 |
jgs |
127 |
self.declareParameter(domain=None, \ |
50 |
|
|
temperature=1., \ |
51 |
jfenwick |
2455 |
velocity=numpy.zeros([3]), |
52 |
jgs |
127 |
density=1., \ |
53 |
jgs |
147 |
heat_capacity=1., \ |
54 |
jgs |
127 |
thermal_permabilty=1., \ |
55 |
jgs |
147 |
# reference_temperature=0., \ |
56 |
|
|
# radiation_coefficient=0., \ |
57 |
jgs |
127 |
thermal_source=0., \ |
58 |
jgs |
147 |
fixed_temperature=0., |
59 |
|
|
location_fixed_temperature=Data(), |
60 |
|
|
safety_factor=0.1) |
61 |
jgs |
127 |
|
62 |
jgs |
147 |
def doInitialization(self): |
63 |
jfenwick |
6647 |
self.__pde=lpde.LinearPDE(self.domain) |
64 |
jgs |
147 |
self.__pde.setSymmetryOn() |
65 |
jgs |
151 |
self.__pde.setReducedOrderOn() |
66 |
jfenwick |
6647 |
self.__pde.getSolverOptions().setSolverMethod(lpde.SolverOptions.LUMPING) |
67 |
jgs |
147 |
self.__pde.setValue(D=self.heat_capacity*self.density) |
68 |
jgs |
127 |
|
69 |
|
|
def getSafeTimeStepSize(self,dt): |
70 |
jgs |
149 |
""" |
71 |
|
|
returns new step size |
72 |
|
|
""" |
73 |
jgs |
147 |
h=self.domain.getSize() |
74 |
|
|
return self.safety_factor*inf(h**2/(h*abs(self.heat_capacity*self.density)*length(self.velocity)+self.thermal_permabilty)) |
75 |
jgs |
127 |
|
76 |
jgs |
147 |
def G(self,T,alpha): |
77 |
jgs |
149 |
""" |
78 |
|
|
tangential operator for taylor galerikin |
79 |
|
|
""" |
80 |
jgs |
147 |
g=grad(T) |
81 |
|
|
self.__pde.setValue(X=-self.thermal_permabilty*g, \ |
82 |
|
|
Y=self.thermal_source-self.__rhocp*inner(self.velocity,g), \ |
83 |
|
|
r=(self.__fixed_T-self.temperature)*alpha,\ |
84 |
|
|
q=self.location_fixed_temperature) |
85 |
|
|
return self.__pde.getSolution() |
86 |
|
|
|
87 |
jgs |
127 |
|
88 |
jgs |
147 |
def doStepPostprocessing(self,dt): |
89 |
jgs |
149 |
""" |
90 |
|
|
perform taylor galerkin step |
91 |
|
|
""" |
92 |
jgs |
147 |
T=self.temperature |
93 |
jfenwick |
3892 |
self.__rhocp=self.heat_capacity*self.density |
94 |
jgs |
147 |
self.__fixed_T=self.fixed_temperature |
95 |
|
|
self.temperature=dt*self.G(dt/2*self.G(T,1./dt)+T,1./dt)+T |
96 |
|
|
self.trace("Temperature range is %e %e"%(inf(self.temperature),sup(self.temperature))) |