/[escript]/trunk/escript/py_src/heat.py
ViewVC logotype

Contents of /trunk/escript/py_src/heat.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1417 - (show annotations)
Mon Feb 25 04:45:48 2008 UTC (11 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 3412 byte(s)
some more work on the transport solver.
1 # $Id:$
2 #
3 #######################################################
4 #
5 # Copyright 2008 by University of Queensland
6 #
7 # http://esscc.uq.edu.au
8 # 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 #
12 #######################################################
13 #
14
15 """
16 Some models for heat advection-diffusion
17
18 @var __author__: name of author
19 @var __copyright__: copyrights
20 @var __license__: licence agreement
21 @var __url__: url entry point on documentation
22 @var __version__: version
23 @var __date__: date of the version
24 """
25
26 __author__="Lutz Gross, l.gross@uq.edu.au"
27 __copyright__=""" Copyright (c) 2008 by ACcESS MNRF
28 http://www.access.edu.au
29 Primary Business: Queensland, Australia"""
30 __license__="""Licensed under the Open Software License version 3.0
31 http://www.opensource.org/licenses/osl-3.0.php"""
32 __url__="http://www.iservo.edu.au/esys"
33 __version__="$Revision:$"
34 __date__="$Date:$"
35
36 # from escript import *
37 import util
38 from linearPDEs import TransportPDE
39
40 class TemperatureCartesian(TransportPDE):
41 """
42 solves
43
44 rhocp(T_{,t} + v_i T_{,i} - ( k T_{,i})_i = Q
45
46 k T_{,i}*n_i=surface_flux
47
48 T_{,t} = 0 where given_T_mask>0
49
50 if surface_flux is not give 0 is assumed.
51
52 typical usage:
53
54 sp=TemperatureCartesian(domain)
55 sp.setTolerance(1.e-4)
56 t=0
57 T=...
58 sp.setValues(rhocp = .., v=.., k=.., given_T_mask=..)
59 sp.setInitialTemperature(T)
60 while t < t_end:
61 sp.setValue(Q= ...)
62 T=sp.getTemperature(dt)
63 t+=dt
64 """
65 def __init__(self,domain,theta=0.5,**kwargs):
66 """
67 initializes tmperature advection-diffuision problem
68
69 @param domain: domain of the problem
70 @param theta: method control: theta=1. backward Euler
71 theta=0.5: Crank-Nicholson scheme
72 thete=0.: forward Euler (not recommendable)
73 """
74 TransportPDE.__init__(self,domain,num_equations=1,theta=theta,**kwargs)
75 self.setReducedOn()
76 self.__rhocp=None
77 self.__v=None
78 def setInitialTemperature(self,T):
79 self.setInitialSolution(T)
80 def setValue(self,rhocp=None,v=None,k=None,Q=None,surface_flux=None,given_T_mask=None):
81 if rhocp!=None:
82 self.__rhocp=rhocp
83 if v!=None:
84 self.__v=v
85 if rhocp!=None:
86 super(TemperatureCartesian,self).setValue(M=self.__rhocp)
87 if (rhocp!=None or v!=None) and self.__rhocp!=None and self.__v!=None:
88 super(TemperatureCartesian,self).setValue(C=-self.__rhocp*self.__v)
89 if k!=None:
90 super(TemperatureCartesian,self).setValue(A=-k*util.kronecker(self.getDomain()))
91 if Q!=None:
92 super(TemperatureCartesian,self).setValue(Y=Q)
93 if surface_flux!=None:
94 super(TemperatureCartesian,self).setValue(y=surface_flux)
95 if given_T_mask!=None:
96 super(TemperatureCartesian,self).setValue(q=given_T_mask)
97
98 def getTemperature(self,dt,**kwargs):
99 return self.solve(dt,**kwargs)

  ViewVC Help
Powered by ViewVC 1.1.26