/[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 147 - (show 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 # $Id$
2
3 from escript.escript import *
4 from escript.modelframe import Model,IterationDivergenceError
5 from 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 \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 def __init__(self,debug=False):
27 Model.__init__(self,debug=debug)
28 self.declareParameter(domain=None, \
29 temperature=1., \
30 velocity=numarray.zeros([3]),
31 density=1., \
32 heat_capacity=1., \
33 thermal_permabilty=1., \
34 # reference_temperature=0., \
35 # radiation_coefficient=0., \
36 thermal_source=0., \
37 fixed_temperature=0.,
38 location_fixed_temperature=Data(),
39 safety_factor=0.1)
40
41 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
48 def getSafeTimeStepSize(self,dt):
49 """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
53 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
63 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

  ViewVC Help
Powered by ViewVC 1.1.26