/[escript]/trunk/modellib/py_src/temperature.py
ViewVC logotype

Contents of /trunk/modellib/py_src/temperature.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (6 months, 2 weeks ago) by uqaeller
File MIME type: text/x-python
File size: 3763 byte(s)
Updated the copyright header.


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

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26