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

Revision 155 - (show annotations)
Wed Nov 9 02:02:19 2005 UTC (14 years, 11 months ago) by jgs
File MIME type: text/x-python
File size: 2713 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2


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