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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1809 - (hide annotations)
Thu Sep 25 06:43:44 2008 UTC (10 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 3424 byte(s)
Copyright updated in all python files

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

  ViewVC Help
Powered by ViewVC 1.1.26