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

Revision 628 - (hide annotations)
Thu Mar 23 02:27:57 2006 UTC (14 years, 4 months ago) by elspeth
File MIME type: text/x-python
File size: 3002 byte(s)
Copyright information added.


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