/[escript]/release/5.2/modellib/py_src/temperature.py
ViewVC logotype

Contents of /release/5.2/modellib/py_src/temperature.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6692 - (show annotations)
Mon Jun 25 02:31:06 2018 UTC (3 years, 1 month ago) by jfenwick
File MIME type: text/x-python
File size: 3693 byte(s)
Fix

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2018 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Apache License, version 2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 from __future__ import division, print_function
18
19 __copyright__="""Copyright (c) 2003-2018 by The University of Queensland
20 http://www.uq.edu.au
21 Primary Business: Queensland, Australia"""
22 __license__="""Licensed under the Apache License, version 2.0
23 http://www.apache.org/licenses/LICENSE-2.0"""
24 __url__="https://launchpad.net/escript-finley"
25
26 from esys.escript import Data, inf, sup, length, grad, inner
27 from esys.escript.modelframe import Model,IterationDivergenceError
28 import numpy
29 import esys.escript.linearPDEs as lpde
30
31
32 class TemperatureAdvection(Model):
33 """
34
35 The conservation of internal heat energy is given by
36
37 *rho c_p ( dT/dt+v[j] * grad(T)[j])-grad(\kappa grad(T)_{,i}=Q*
38
39 *n_i \kappa T_{,i}=0*
40
41 it is assummed that *\rho c_p* is constant in time.
42
43 solved by Taylor Galerkin method
44
45 """
46 def __init__(self,**kwargs):
47 super(TemperatureAdvection, self).__init__(**kwargs)
48 self.declareParameter(domain=None, \
49 temperature=1., \
50 velocity=numpy.zeros([3]),
51 density=1., \
52 heat_capacity=1., \
53 thermal_permabilty=1., \
54 # reference_temperature=0., \
55 # radiation_coefficient=0., \
56 thermal_source=0., \
57 fixed_temperature=0.,
58 location_fixed_temperature=Data(),
59 safety_factor=0.1)
60
61 def doInitialization(self):
62 self.__pde=lpde.LinearPDE(self.domain)
63 self.__pde.setSymmetryOn()
64 self.__pde.setReducedOrderOn()
65 self.__pde.getSolverOptions().setSolverMethod(lpde.SolverOptions.LUMPING)
66 self.__pde.setValue(D=self.heat_capacity*self.density)
67
68 def getSafeTimeStepSize(self,dt):
69 """
70 returns new step size
71 """
72 h=self.domain.getSize()
73 return self.safety_factor*inf(h**2/(h*abs(self.heat_capacity*self.density)*length(self.velocity)+self.thermal_permabilty))
74
75 def G(self,T,alpha):
76 """
77 tangential operator for taylor galerikin
78 """
79 g=grad(T)
80 self.__pde.setValue(X=-self.thermal_permabilty*g, \
81 Y=self.thermal_source-self.__rhocp*inner(self.velocity,g), \
82 r=(self.__fixed_T-self.temperature)*alpha,\
83 q=self.location_fixed_temperature)
84 return self.__pde.getSolution()
85
86
87 def doStepPostprocessing(self,dt):
88 """
89 perform taylor galerkin step
90 """
91 T=self.temperature
92 self.__rhocp=self.heat_capacity*self.density
93 self.__fixed_T=self.fixed_temperature
94 self.temperature=dt*self.G(dt/2*self.G(T,1./dt)+T,1./dt)+T
95 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