/[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 148 by jgs, Tue Aug 23 01:24:31 2005 UTC trunk/modellib/py_src/probe.py revision 628 by elspeth, Thu Mar 23 02:27:57 2006 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3  from escript.modelframe import Model,ParameterSet  __copyright__="""  Copyright (c) 2006 by ACcESS MNRF
4  from escript.escript import Data                      http://www.access.edu.au
5  from escript.util import *                  Primary Business: Queensland, Australia"""
6    __license__="""Licensed under the Open Software License version 3.0
7                 http://www.opensource.org/licenses/osl-3.0.php"""
8    
9    from esys.escript.modelframe import Model,ParameterSet
10    from esys.escript.escript import Data
11    from esys.escript.util import *
12    
13    
14  class EvaluateExpression(ParameterSet):  class EvaluateExpression(ParameterSet):
15         """@brief return the evaluation of an expression at current time t and locations in the domain         """
16           Return the evaluation of an expression at current time t and
17             WARNING: this class use python's eval function!!!!! Please use input.InterpolateOverBox is possible!!!!         locations in the domain
18    
19            @param expression (in) - expression or list of expressions defining expression value         @warning: this class use python's eval function!!!!!
20            @param out (out) - current value of the expression                   Please use input.InterpolateOverBox is possible!!!!
21           @ivar expression (in): expression or list of expressions defining
22          """                   expression value
23           @ivar out (callable): current value of the expression
24           """
25    
26         def __init__(self,debug=False):         def __init__(self,debug=False):
27             """set up parameters"""             """
28               Set up parameters
29               """
30             ParameterSet.__init__(self,debug=debug)             ParameterSet.__init__(self,debug=debug)
31             self.declareParameter(domain=None, \             self.declareParameter(domain=None, \
32                                   t=0., \                                   t=0., \
# Line 33  class EvaluateExpression(ParameterSet): Line 43  class EvaluateExpression(ParameterSet):
43           return out           return out
44    
45  class Probe(Model):  class Probe(Model):
46         """@brief tests values against a expression which may depend on time and spatial coordinates         """
47                   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
48                   all time steps at the end         coordinates.
49          
50             WARNING: this class use python's eval function!!!!!         It prints out the relative error in each time step and the maximum
51           relative error over all time steps at the end.
52            @param value (in) - values to be tested  
53            @param expression (in) - expressions defining expression values to test against. If None only value is reported.         @warning: this class use python's eval function!!!!!
54            @param line_tag (in) - tag to be used when printing error         @ivar value (in): values to be tested
55            @param t (in) - current time         @ivar expression (in): expressions defining expression values to test against. If None only value is reported.
56            @param max_error (out) - maximum error         @ivar line_tag (in): tag to be used when printing error
57            @param t_max (out) - time of maximum error         @ivar t (in): current time
58           @ivar max_error (out): maximum error
59           @ivar t_max (out): time of maximum error
60    
61          """         """
62    
63         def __init__(self,debug=False):         def __init__(self,debug=False):
64             """set up parameters"""             """
65               Set up parameters
66               """
67             Model.__init__(self,debug=debug)             Model.__init__(self,debug=debug)
68             self.declareParameter(expression=None, \             self.declareParameter(expression=None, \
69                                   value=0., \                                   value=0., \
# Line 57  class Probe(Model): Line 71  class Probe(Model):
71                                   line_tag="PROBE")                                   line_tag="PROBE")
72    
73         def doInitialization(self):         def doInitialization(self):
74             """initializes values"""             """
75               Initializes values
76               """
77             self.t_max=None             self.t_max=None
78             self.max_error=0.             self.max_error=0.
79    
# Line 94  class Probe(Model): Line 110  class Probe(Model):
110                     self.max_error=err                     self.max_error=err
111    
112         def doFinalization(self):         def doFinalization(self):
113            """print out the maximum error"""            """
114          Print out the maximum error.
115          """
116            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)
117    
118    # vim: expandtab shiftwidth=4:

Legend:
Removed from v.148  
changed lines
  Added in v.628

  ViewVC Help
Powered by ViewVC 1.1.26