/[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 3981 - (show annotations)
Fri Sep 21 02:47:54 2012 UTC (7 years ago) by jfenwick
File MIME type: text/x-python
File size: 3601 byte(s)
First pass of updating copyright notices
1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2012 by University of Queensland
5 # http://www.uq.edu.au
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 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development since 2012 by School of Earth Sciences
13 #
14 ##############################################################################
15
16 __copyright__="""Copyright (c) 2003-2012 by University of Queensland
17 http://www.uq.edu.au
18 Primary Business: Queensland, Australia"""
19 __license__="""Licensed under the Open Software License version 3.0
20 http://www.opensource.org/licenses/osl-3.0.php"""
21 __url__="https://launchpad.net/escript-finley"
22
23 from esys.escript import Data, inf, sup, length, grad, inner
24 from esys.escript.modelframe import Model,IterationDivergenceError
25 from esys.escript.linearPDEs import LinearPDE
26 import numpy
27
28
29 class TemperatureAdvection(Model):
30 """
31
32 The conservation of internal heat energy is given by
33
34 *rho c_p ( dT/dt+v[j] * grad(T)[j])-grad(\kappa grad(T)_{,i}=Q*
35
36 *n_i \kappa T_{,i}=0*
37
38 it is assummed that *\rho c_p* is constant in time.
39
40 solved by Taylor Galerkin method
41
42 """
43 def __init__(self,**kwargs):
44 super(TemperatureAdvection, self).__init__(**kwargs)
45 self.declareParameter(domain=None, \
46 temperature=1., \
47 velocity=numpy.zeros([3]),
48 density=1., \
49 heat_capacity=1., \
50 thermal_permabilty=1., \
51 # reference_temperature=0., \
52 # radiation_coefficient=0., \
53 thermal_source=0., \
54 fixed_temperature=0.,
55 location_fixed_temperature=Data(),
56 safety_factor=0.1)
57
58 def doInitialization(self):
59 self.__pde=LinearPDE(self.domain)
60 self.__pde.setSymmetryOn()
61 self.__pde.setReducedOrderOn()
62 self.__pde.getSolverOptions().setSolverMethod(self.__pde.getSolverOptions().LUMPING)
63 self.__pde.setValue(D=self.heat_capacity*self.density)
64
65 def getSafeTimeStepSize(self,dt):
66 """
67 returns new step size
68 """
69 h=self.domain.getSize()
70 return self.safety_factor*inf(h**2/(h*abs(self.heat_capacity*self.density)*length(self.velocity)+self.thermal_permabilty))
71
72 def G(self,T,alpha):
73 """
74 tangential operator for taylor galerikin
75 """
76 g=grad(T)
77 self.__pde.setValue(X=-self.thermal_permabilty*g, \
78 Y=self.thermal_source-self.__rhocp*inner(self.velocity,g), \
79 r=(self.__fixed_T-self.temperature)*alpha,\
80 q=self.location_fixed_temperature)
81 return self.__pde.getSolution()
82
83
84 def doStepPostprocessing(self,dt):
85 """
86 perform taylor galerkin step
87 """
88 T=self.temperature
89 self.__rhocp=self.heat_capacity*self.density
90 self.__fixed_T=self.fixed_temperature
91 self.temperature=dt*self.G(dt/2*self.G(T,1./dt)+T,1./dt)+T
92 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