/[escript]/trunk/modellib/py_src/probe.py
ViewVC logotype

Diff of /trunk/modellib/py_src/probe.py

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

trunk/esys2/modellib/py_src/probe.py revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC trunk/modellib/py_src/probe.py revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3  from escript.modelframe import Model  from esys.escript.modelframe import Model,ParameterSet
4  from escript.escript import Data  from esys.escript.escript import Data
5  from escript.util import *  from esys.escript.util import *
6    
7    
8  class EvaluateExpression(Model):  class EvaluateExpression(ParameterSet):
9         """@brief return the evaluation of an expression at current time t and locations in the domain         """
10           Return the evaluation of an expression at current time t and
11             WARNING: this class use python's eval function!!!!! Please use input.InterpolateOverBox is possible!!!!         locations in the domain
12    
13            @param expression (in) - expression or list of expressions defining expression value         @warning: this class use python's eval function!!!!!
14            @param out (out) - current value of the expression                   Please use input.InterpolateOverBox is possible!!!!
15           @ivar expression (in): expression or list of expressions defining
16          """                   expression value
17           @ivar out (callable): current value of the expression
18           """
19    
20         def __init__(self,debug=False):         def __init__(self,debug=False):
21             """set up parameters"""             """
22             Model.__init__(self,debug=debug)             Set up parameters
23               """
24               ParameterSet.__init__(self,debug=debug)
25             self.declareParameter(domain=None, \             self.declareParameter(domain=None, \
26                                   t=0., \                                   t=0., \
27                                   expression="x[0]")                                   expression="x[0]")
# Line 33  class EvaluateExpression(Model): Line 37  class EvaluateExpression(Model):
37           return out           return out
38    
39  class Probe(Model):  class Probe(Model):
40         """@brief tests values against a expression which may depend on time and spatial coordinates         """
41                   it prints out the relative error in each time step and the maximum relative error over         Tests values against a expression which may depend on time and spatial
42                   all time steps at the end         coordinates.
43          
44             WARNING: this class use python's eval function!!!!!         It prints out the relative error in each time step and the maximum
45           relative error over all time steps at the end.
46            @param value (in) - values to be tested  
47            @param expression (in) - expressions defining expression values to test against. If None only value is reported.         @warning: this class use python's eval function!!!!!
48            @param line_tag (in) - tag to be used when printing error         @ivar value (in): values to be tested
49            @param t (in) - current time         @ivar expression (in): expressions defining expression values to test against. If None only value is reported.
50            @param max_error (out) - maximum error         @ivar line_tag (in): tag to be used when printing error
51            @param t_max (out) - time of maximum error         @ivar t (in): current time
52           @ivar max_error (out): maximum error
53           @ivar t_max (out): time of maximum error
54    
55          """         """
56    
57         def __init__(self,debug=False):         def __init__(self,debug=False):
58             """set up parameters"""             """
59               Set up parameters
60               """
61             Model.__init__(self,debug=debug)             Model.__init__(self,debug=debug)
62             self.declareParameter(expression=None, \             self.declareParameter(expression=None, \
63                                   value=0., \                                   value=0., \
# Line 57  class Probe(Model): Line 65  class Probe(Model):
65                                   line_tag="PROBE")                                   line_tag="PROBE")
66    
67         def doInitialization(self):         def doInitialization(self):
68             """initializes values"""             """
69               Initializes values
70               """
71             self.t_max=None             self.t_max=None
72             self.max_error=0.             self.max_error=0.
73    
# Line 94  class Probe(Model): Line 104  class Probe(Model):
104                     self.max_error=err                     self.max_error=err
105    
106         def doFinalization(self):         def doFinalization(self):
107            """print out the maximum error"""            """
108          Print out the maximum error.
109          """
110            if not self.t_max==None: print "%s : == maximum error %e at time %e == "%(self.line_tag,self.max_error,self.t_max)            if not self.t_max==None: print "%s : == maximum error %e at time %e == "%(self.line_tag,self.max_error,self.t_max)
111    
112    # vim: expandtab shiftwidth=4:

Legend:
Removed from v.147  
changed lines
  Added in v.155

  ViewVC Help
Powered by ViewVC 1.1.26