1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
from escript.modelframe import Model,ParameterSet |
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(ParameterSet): |
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 |
|
Set up parameters |
23 |
|
""" |
24 |
ParameterSet.__init__(self,debug=debug) |
ParameterSet.__init__(self,debug=debug) |
25 |
self.declareParameter(domain=None, \ |
self.declareParameter(domain=None, \ |
26 |
t=0., \ |
t=0., \ |
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., \ |
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 |
|
|
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: |