/[escript]/trunk/modellib/py_src/temperature.py
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3432 - (hide 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 ksteube 1809
2     ########################################################
3 ksteube 1312 #
4 jfenwick 2881 # Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1809 # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7 ksteube 1312 #
8 ksteube 1809 # 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 ksteube 1312 #
12 ksteube 1809 ########################################################
13 jgs 127
14 jfenwick 2881 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15 ksteube 1809 Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18 elspeth 628 __license__="""Licensed under the Open Software License version 3.0
19 ksteube 1809 http://www.opensource.org/licenses/osl-3.0.php"""
20 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
21 elspeth 628
22 jfenwick 3432 from esys.escript import Data, inf, sup, length, grad, inner
23 jgs 149 from esys.escript.modelframe import Model,IterationDivergenceError
24 gross 1137 from esys.escript.linearPDEs import LinearPDE
25 jfenwick 3432 import numpy
26 jgs 127
27    
28 jgs 147 class TemperatureAdvection(Model):
29     """
30 jgs 127
31 jgs 149 The conservation of internal heat energy is given by
32 jgs 147
33 jfenwick 2625 *rho c_p ( dT/dt+v[j] * grad(T)[j])-grad(\kappa grad(T)_{,i}=Q*
34 jgs 147
35 jfenwick 2625 *n_i \kappa T_{,i}=0*
36 jgs 147
37 jfenwick 2625 it is assummed that *\rho c_p* is constant in time.
38 jgs 147
39 jgs 149 solved by Taylor Galerkin method
40    
41 jgs 147 """
42 gross 918 def __init__(self,**kwargs):
43     super(TemperatureAdvection, self).__init__(**kwargs)
44 jgs 127 self.declareParameter(domain=None, \
45     temperature=1., \
46 jfenwick 2455 velocity=numpy.zeros([3]),
47 jgs 127 density=1., \
48 jgs 147 heat_capacity=1., \
49 jgs 127 thermal_permabilty=1., \
50 jgs 147 # reference_temperature=0., \
51     # radiation_coefficient=0., \
52 jgs 127 thermal_source=0., \
53 jgs 147 fixed_temperature=0.,
54     location_fixed_temperature=Data(),
55     safety_factor=0.1)
56 jgs 127
57 jgs 147 def doInitialization(self):
58     self.__pde=LinearPDE(self.domain)
59     self.__pde.setSymmetryOn()
60 jgs 151 self.__pde.setReducedOrderOn()
61 gross 2474 self.__pde.getSolverOptions().setSolverMethod(self.__pde.getSolverOptions().LUMPING)
62 jgs 147 self.__pde.setValue(D=self.heat_capacity*self.density)
63 jgs 127
64     def getSafeTimeStepSize(self,dt):
65 jgs 149 """
66     returns new step size
67     """
68 jgs 147 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 jgs 127
71 jgs 147 def G(self,T,alpha):
72 jgs 149 """
73     tangential operator for taylor galerikin
74     """
75 jgs 147 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 jgs 127
83 jgs 147 def doStepPostprocessing(self,dt):
84 jgs 149 """
85     perform taylor galerkin step
86     """
87 jgs 147 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