/[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 4821 - (hide annotations)
Tue Apr 1 04:58:33 2014 UTC (5 years, 5 months ago) by sshaw
File MIME type: text/x-python
File size: 3668 byte(s)
moved SolverOptions to c++, split into SolverOptions for the options and SolverBuddy as the state as a precursor to per-pde solving... does break some use cases (e.g. pde.getSolverOptions().DIRECT will now fail, new value access is with SolverOptions.DIRECT), examples and documentation updated to match
1 ksteube 1809
2 jfenwick 3981 ##############################################################################
3 ksteube 1312 #
4 jfenwick 4657 # Copyright (c) 2003-2014 by University of Queensland
5 jfenwick 3981 # http://www.uq.edu.au
6 ksteube 1312 #
7 ksteube 1809 # Primary Business: Queensland, Australia
8     # Licensed under the Open Software License version 3.0
9     # http://www.opensource.org/licenses/osl-3.0.php
10 ksteube 1312 #
11 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
13     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 #
15     ##############################################################################
16 jgs 127
17 jfenwick 4657 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 jfenwick 3981 http://www.uq.edu.au
19 ksteube 1809 Primary Business: Queensland, Australia"""
20 elspeth 628 __license__="""Licensed under the Open Software License version 3.0
21 ksteube 1809 http://www.opensource.org/licenses/osl-3.0.php"""
22 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
23 elspeth 628
24 jfenwick 3432 from esys.escript import Data, inf, sup, length, grad, inner
25 jgs 149 from esys.escript.modelframe import Model,IterationDivergenceError
26 sshaw 4821 from esys.escript.linearPDEs import LinearPDE, SolverOptions
27 jfenwick 3432 import numpy
28 jgs 127
29    
30 jgs 147 class TemperatureAdvection(Model):
31     """
32 jgs 127
33 jgs 149 The conservation of internal heat energy is given by
34 jgs 147
35 jfenwick 2625 *rho c_p ( dT/dt+v[j] * grad(T)[j])-grad(\kappa grad(T)_{,i}=Q*
36 jgs 147
37 jfenwick 2625 *n_i \kappa T_{,i}=0*
38 jgs 147
39 jfenwick 2625 it is assummed that *\rho c_p* is constant in time.
40 jgs 147
41 jgs 149 solved by Taylor Galerkin method
42    
43 jgs 147 """
44 gross 918 def __init__(self,**kwargs):
45     super(TemperatureAdvection, self).__init__(**kwargs)
46 jgs 127 self.declareParameter(domain=None, \
47     temperature=1., \
48 jfenwick 2455 velocity=numpy.zeros([3]),
49 jgs 127 density=1., \
50 jgs 147 heat_capacity=1., \
51 jgs 127 thermal_permabilty=1., \
52 jgs 147 # reference_temperature=0., \
53     # radiation_coefficient=0., \
54 jgs 127 thermal_source=0., \
55 jgs 147 fixed_temperature=0.,
56     location_fixed_temperature=Data(),
57     safety_factor=0.1)
58 jgs 127
59 jgs 147 def doInitialization(self):
60     self.__pde=LinearPDE(self.domain)
61     self.__pde.setSymmetryOn()
62 jgs 151 self.__pde.setReducedOrderOn()
63 sshaw 4821 self.__pde.getSolverOptions().setSolverMethod(SolverOptions.LUMPING)
64 jgs 147 self.__pde.setValue(D=self.heat_capacity*self.density)
65 jgs 127
66     def getSafeTimeStepSize(self,dt):
67 jgs 149 """
68     returns new step size
69     """
70 jgs 147 h=self.domain.getSize()
71     return self.safety_factor*inf(h**2/(h*abs(self.heat_capacity*self.density)*length(self.velocity)+self.thermal_permabilty))
72 jgs 127
73 jgs 147 def G(self,T,alpha):
74 jgs 149 """
75     tangential operator for taylor galerikin
76     """
77 jgs 147 g=grad(T)
78     self.__pde.setValue(X=-self.thermal_permabilty*g, \
79     Y=self.thermal_source-self.__rhocp*inner(self.velocity,g), \
80     r=(self.__fixed_T-self.temperature)*alpha,\
81     q=self.location_fixed_temperature)
82     return self.__pde.getSolution()
83    
84 jgs 127
85 jgs 147 def doStepPostprocessing(self,dt):
86 jgs 149 """
87     perform taylor galerkin step
88     """
89 jgs 147 T=self.temperature
90 jfenwick 3892 self.__rhocp=self.heat_capacity*self.density
91 jgs 147 self.__fixed_T=self.fixed_temperature
92     self.temperature=dt*self.G(dt/2*self.G(T,1./dt)+T,1./dt)+T
93     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