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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2478 by jfenwick, Mon Mar 30 02:13:58 2009 UTC revision 2479 by gross, Thu Jun 18 06:50:37 2009 UTC
# Line 102  class TemperatureCartesian(TransportPDE) Line 102  class TemperatureCartesian(TransportPDE)
102          """          """
103          return self.getSolution(dt,**kwargs)          return self.getSolution(dt,**kwargs)
104    
105    
106    class Tracer(TransportPDE):
107        """
108        Represents and solves the tracer problem
109    
110        M{C_{,t} + v_i C_{,i} - ( k T_{,i})_i) = 0}
111    
112        M{C_{,t} = 0} where C{given_C_mask}>0.
113        M{C_{,i}*n_i=0}
114    
115        Typical usage::
116    
117            sp = Tracer(domain)
118            sp.setTolerance(1.e-4)
119            t = 0
120            T = ...
121            sp.setValues(given_C_mask=...)
122            sp.setInitialTracer(C)
123            while t < t_end:
124                sp.setValue(v=...)
125                dt.getSaveTimeStepSize()
126                C = sp.getTracer(dt)
127                t += dt
128        """
129        def __init__(self,domain,useBackwardEuler=False,**kwargs):
130            """
131            Initializes the Tracer advection problem
132    
133            @param domain: domain of the problem
134            @param useBackwardEuler: if set the backward Euler scheme is used. Otherwise the Crank-Nicholson scheme is applied. Not that backward Euler scheme will return a safe time step size which is practically infinity as the scheme is unconditional unstable. So other measures need to be applied to control the time step size. The Crank-Nicholson scheme provides a higher accuracy but requires to limit the time step size to be stable.
135            @type useBackwardEuler: C{bool}
136            """
137            TransportPDE.__init__(self,domain,numEquations=1,useBackwardEuler=useBackwardEuler,**kwargs)
138            self.setReducedOrderOn()
139            super(Tracer,self).setValue(M=1.)
140    
141        def setInitialTracer(self,C):
142            """
143            Same as L{setInitialSolution}.
144            """
145            self.setInitialSolution(C)
146    
147        def setValue(self,v=None,given_C_mask=None, k=None):
148            if v!=None:
149                super(Tracer,self).setValue(C=-v)
150            if k!=None:
151                super(Tracer,self).setValue(A=-k*util.kronecker(self.getDomain()))
152            if given_C_mask!=None:
153                super(Tracer,self).setValue(q=given_C_mask)
154    
155        def getTracer(self,dt,**kwargs):
156            """
157            Same as L{getSolution}.
158            """
159            return self.getSolution(dt,**kwargs)
160    

Legend:
Removed from v.2478  
changed lines
  Added in v.2479

  ViewVC Help
Powered by ViewVC 1.1.26