# Annotation of /trunk/modellib/py_src/temperature.py

Revision 147 - (hide annotations)
Fri Aug 12 01:45:47 2005 UTC (15 years, 2 months ago) by jgs
Original Path: trunk/esys2/modellib/py_src/temperature.py
File MIME type: text/x-python
File size: 2684 byte(s)
erge of development branch dev-02 back to main trunk on 2005-08-12


 1 jgs 127 # $Id$ 2 3 jgs 147 from escript.escript import * 4 from escript.modelframe import Model,IterationDivergenceError 5 from escript.linearPDEs import AdvectivePDE,LinearPDE 6 import numarray 7 jgs 127 8 9 jgs 147 class TemperatureAdvection(Model): 10 """ 11 jgs 127 12 jgs 147 The conservation of internal heat energy is given by 13 14 \f[ 15 \rho c_p ( T_{,t}+v_{j}T_{,j} )-(\kappa T_{,i})_{,i}=Q, 16 \f] 17 \f[ 18 n_i\kappa T_{,i}=0 19 \f] 20 21 it is assummed that \f[ \rho c_p \f] is constant in time. 22 23 solved by Taylor Galerkin method 24 25 """ 26 jgs 127 def __init__(self,debug=False): 27 Model.__init__(self,debug=debug) 28 self.declareParameter(domain=None, \ 29 temperature=1., \ 30 jgs 147 velocity=numarray.zeros([3]), 31 jgs 127 density=1., \ 32 jgs 147 heat_capacity=1., \ 33 jgs 127 thermal_permabilty=1., \ 34 jgs 147 # reference_temperature=0., \ 35 # radiation_coefficient=0., \ 36 jgs 127 thermal_source=0., \ 37 jgs 147 fixed_temperature=0., 38 location_fixed_temperature=Data(), 39 safety_factor=0.1) 40 jgs 127 41 jgs 147 def doInitialization(self): 42 self.__pde=LinearPDE(self.domain) 43 self.__pde.setSymmetryOn() 44 # self.__pde.setReducedOrderOn() 45 # self.__pde.setLumpingOn() 46 self.__pde.setValue(D=self.heat_capacity*self.density) 47 jgs 127 48 def getSafeTimeStepSize(self,dt): 49 jgs 147 """returns new step size""" 50 h=self.domain.getSize() 51 return self.safety_factor*inf(h**2/(h*abs(self.heat_capacity*self.density)*length(self.velocity)+self.thermal_permabilty)) 52 jgs 127 53 jgs 147 def G(self,T,alpha): 54 """tangential operator for taylor galerikin""" 55 g=grad(T) 56 self.__pde.setValue(X=-self.thermal_permabilty*g, \ 57 Y=self.thermal_source-self.__rhocp*inner(self.velocity,g), \ 58 r=(self.__fixed_T-self.temperature)*alpha,\ 59 q=self.location_fixed_temperature) 60 return self.__pde.getSolution() 61 62 jgs 127 63 jgs 147 def doStepPostprocessing(self,dt): 64 """perform taylor galerkin step""" 65 T=self.temperature 66 self.__rhocp=self.heat_capacity*self.density 67 self.__fixed_T=self.fixed_temperature 68 self.temperature=dt*self.G(dt/2*self.G(T,1./dt)+T,1./dt)+T 69 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