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