test

The base model test is intended for implementing small application model that allow for testing or demonstrating specific features of the HydPy framework.

Method Features

class hydpy.models.test.test_model.Model[source]

Bases: hydpy.core.modeltools.ELSModel

Test model.

The following methods define the relevant components of a system of ODE equations (e.g. direct runoff):
The following methods define the complete equations of an ODE system (e.g. change in storage of fast water due to effective precipitation and direct runoff):
  • Calc_S_V1 Calculate the actual storage content.

  • Calc_SV_V1 Calculate the actual storage contenst.

numconsts: hydpy.core.modeltools.NumConstsELS
numvars: hydpy.core.modeltools.NumVarsELS
element: Optional[‘devicetools.Element’]
cymodel: Optional[typingtools.CyModelProtocol]
parameters: parametertools.Parameters
sequences: sequencetools.Sequences
masks: masktools.Masks
class hydpy.models.test.test_model.Calc_Q_V1[source]

Bases: hydpy.core.modeltools.Method

Calculate the actual storage loss.

Requires the control parameter:

K

Requires the state sequence:

S

Calculates the flux sequence:

Q

This simple equation is continuous but potentially stiff.

Basic equation:

\(Q = K \cdot S\)

Example:

>>> from hydpy.models.test import *
>>> parameterstep()
>>> k(0.5)
>>> states.s = 2.0
>>> model.calc_q_v1()
>>> fluxes.q
q(1.0)
class hydpy.models.test.test_model.Calc_Q_V2[source]

Bases: hydpy.core.modeltools.Method

Calculate the actual storage loss.

Requires the control parameter:

K

Requires the state sequence:

S

Calculates the flux sequence:

Q

This simple equation is discontinuous.

Basic equation:

\(Q = \Bigl \lbrace { {K \ | \ S > 0} \atop {0 \ | \ S \leq 0} }\)

Examples:

>>> from hydpy.models.test import *
>>> parameterstep()
>>> k(0.5)
>>> states.s = 2.0
>>> model.calc_q_v2()
>>> fluxes.q
q(0.5)
>>> states.s = -1.0
>>> model.calc_q_v2()
>>> fluxes.q
q(0.0)
class hydpy.models.test.test_model.Calc_QV_V1[source]

Bases: hydpy.core.modeltools.Method

Calculate the actual storage losses.

Requires the control parameters:

N K

Requires the state sequence:

SV

Calculates the flux sequence:

QV

Identical with Calc_Q_V1, but working on a vector of states.

Basic equation:

\(Q = K \cdot S\)

Example:

>>> from hydpy.models.test import *
>>> parameterstep()
>>> n(2)
>>> k(0.5)
>>> states.sv = 2.0, 3.0
>>> model.calc_qv_v1()
>>> fluxes.qv
qv(1.0, 1.5)
class hydpy.models.test.test_model.Calc_S_V1[source]

Bases: hydpy.core.modeltools.Method

Calculate the actual storage content.

Requires the flux sequence:

Q

Updates the state sequence:

S

Basic equation:

\(\frac{dS}{dt} = Q\)

Example:

>>> from hydpy.models.test import *
>>> parameterstep()
>>> states.s.old = 1.0
>>> fluxes.q = 0.8
>>> model.calc_s_v1()
>>> states.s
s(0.2)
class hydpy.models.test.test_model.Calc_SV_V1[source]

Bases: hydpy.core.modeltools.Method

Calculate the actual storage contenst.

Requires the control parameter:

N

Requires the flux sequence:

QV

Updates the state sequence:

SV

Identical with Calc_S_V1, but working on a vector of fluxes.

Basic equation:

\(\frac{dS}{dt} = Q\)

Example:

>>> from hydpy.models.test import *
>>> parameterstep()
>>> n(2)
>>> states.sv.old = 1.0, 2.0
>>> fluxes.qv = 0.8
>>> model.calc_sv_v1()
>>> states.sv
sv(0.2, 1.2)

Parameter Features

Control parameters

class hydpy.models.test.ControlParameters(master: hydpy.core.parametertools.Parameters, cls_fastaccess: Optional[Type[hydpy.core.parametertools.FastAccessParameter]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.variabletools.SubVariables[hydpy.core.parametertools.Parameters, Parameter, hydpy.core.parametertools.FastAccessParameter]

Control parameters of model test.

The following classes are selected:
  • K() Storage coefficient [1/T].

  • N() Number of storages [-].

class hydpy.models.test.test_control.K(subvars: SubVariablesType)[source]

Bases: hydpy.core.variabletools.Variable[hydpy.core.parametertools.SubParameters, hydpy.core.parametertools.FastAccessParameter]

Storage coefficient [1/T].

Required by the methods:

Calc_QV_V1 Calc_Q_V1 Calc_Q_V2

For educational purposes, the actual value of parameter K does not depend on the difference between the actual simulation time step and the actual parameter time step.

NDIM: int = 0
TYPE
TIME: Optional[bool] = None
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, None)
name: str = 'k'
unit: str = '1/T'
subvars: SubVariablesType
class hydpy.models.test.test_control.N(subvars: SubVariablesType)[source]

Bases: hydpy.core.variabletools.Variable[hydpy.core.parametertools.SubParameters, hydpy.core.parametertools.FastAccessParameter]

Number of storages [-].

Required by the methods:

Calc_QV_V1 Calc_SV_V1

NDIM: int = 0
TYPE
TIME: Optional[bool] = None
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (1, None)
name: str = 'n'
unit: str = '-'
subvars: SubVariablesType

Solver parameters

class hydpy.models.test.SolverParameters(master: hydpy.core.parametertools.Parameters, cls_fastaccess: Optional[Type[hydpy.core.parametertools.FastAccessParameter]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.variabletools.SubVariables[hydpy.core.parametertools.Parameters, Parameter, hydpy.core.parametertools.FastAccessParameter]

Solver parameters of model test.

The following classes are selected:
  • AbsErrorMax() Absolute numerical error tolerance [mm/T].

  • RelErrorMax() Relative numerical error tolerance [1/T].

  • RelDTMin() Smallest relative integration time step size allowed [-].

  • RelDTMax() Largest relative integration time step size allowed [-].

class hydpy.models.test.test_solver.AbsErrorMax(subvars)[source]

Bases: hydpy.core.variabletools.Variable[hydpy.core.parametertools.SubParameters, hydpy.core.parametertools.FastAccessParameter]

Absolute numerical error tolerance [mm/T].

NDIM: int = 0
TYPE
TIME: Optional[bool] = None
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, None)
INIT: Union[int, float, bool] = 0.01
name: str = 'abserrormax'
unit: str = 'mm/T'
subvars: SubVariablesType
class hydpy.models.test.test_solver.RelErrorMax(subvars)[source]

Bases: hydpy.core.variabletools.Variable[hydpy.core.parametertools.SubParameters, hydpy.core.parametertools.FastAccessParameter]

Relative numerical error tolerance [1/T].

NDIM: int = 0
TYPE
TIME: Optional[bool] = None
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, None)
INIT: Union[int, float, bool] = nan
name: str = 'relerrormax'
unit: str = '1/T'
subvars: SubVariablesType
class hydpy.models.test.test_solver.RelDTMin(subvars)[source]

Bases: hydpy.core.variabletools.Variable[hydpy.core.parametertools.SubParameters, hydpy.core.parametertools.FastAccessParameter]

Smallest relative integration time step size allowed [-].

NDIM: int = 0
TYPE
TIME: Optional[bool] = None
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, 1.0)
INIT: Union[int, float, bool] = 0.001
name: str = 'reldtmin'
unit: str = '-'
subvars: SubVariablesType
class hydpy.models.test.test_solver.RelDTMax(subvars)[source]

Bases: hydpy.core.variabletools.Variable[hydpy.core.parametertools.SubParameters, hydpy.core.parametertools.FastAccessParameter]

Largest relative integration time step size allowed [-].

NDIM: int = 0
TYPE
TIME: Optional[bool] = None
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, 1.0)
INIT: Union[int, float, bool] = 1.0
name: str = 'reldtmax'
unit: str = '-'
subvars: SubVariablesType

Sequence Features

Flux sequences

class hydpy.models.test.FluxSequences(master: hydpy.core.sequencetools.Sequences, cls_fastaccess: Optional[Type[FastAccessType]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.sequencetools.OutputSequences[FluxSequence]

Flux sequences of model test.

The following classes are selected:
  • Q() Storage loss [mm/T]

  • QV() Storage loss vector [mm/T]

vars: GroupType
class hydpy.models.test.test_fluxes.Q(subvars: SubVariablesType)[source]

Bases: hydpy.core.sequencetools.OutputSequence[hydpy.core.sequencetools.FluxSequences]

Storage loss [mm/T]

Calculated by the methods:

Calc_Q_V1 Calc_Q_V2

Required by the method:

Calc_S_V1

NDIM: int = 0
NUMERIC: bool = True
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, None)
name: str = 'q'
unit: str = 'mm/T'
subvars: SubVariablesType
class hydpy.models.test.test_fluxes.QV(subvars: SubVariablesType)[source]

Bases: hydpy.core.sequencetools.OutputSequence[hydpy.core.sequencetools.FluxSequences]

Storage loss vector [mm/T]

Calculated by the method:

Calc_QV_V1

Required by the method:

Calc_SV_V1

NDIM: int = 1
NUMERIC: bool = True
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, None)
name: str = 'qv'
unit: str = 'mm/T'
subvars: SubVariablesType

State sequences

class hydpy.models.test.StateSequences(master: hydpy.core.sequencetools.Sequences, cls_fastaccess: Optional[Type[FastAccessType]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.sequencetools.OutputSequences[StateSequence]

State sequences of model test.

The following classes are selected:
  • S() Storage content [mm].

  • SV() Storage content vector[mm].

class hydpy.models.test.test_states.S(subvars: SubVariablesType)[source]

Bases: hydpy.core.sequencetools.OutputSequence[hydpy.core.sequencetools.StateSequences], hydpy.core.sequencetools.ConditionSequence[hydpy.core.sequencetools.StateSequences, hydpy.core.sequencetools.FastAccessOutputSequence]

Storage content [mm].

Updated by the method:

Calc_S_V1

Required by the methods:

Calc_Q_V1 Calc_Q_V2

NDIM: int = 0
NUMERIC: bool = True
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, None)
name: str = 's'
unit: str = 'mm'
subvars: SubVariablesType
class hydpy.models.test.test_states.SV(subvars: SubVariablesType)[source]

Bases: hydpy.core.sequencetools.OutputSequence[hydpy.core.sequencetools.StateSequences], hydpy.core.sequencetools.ConditionSequence[hydpy.core.sequencetools.StateSequences, hydpy.core.sequencetools.FastAccessOutputSequence]

Storage content vector[mm].

Updated by the method:

Calc_SV_V1

Required by the method:

Calc_QV_V1

NDIM: int = 1
NUMERIC: bool = True
SPAN: Tuple[Union[int, float, bool, None], Union[int, float, bool, None]] = (0.0, None)
name: str = 'sv'
unit: str = 'mm'
subvars: SubVariablesType
class hydpy.models.test.ControlParameters(master: hydpy.core.parametertools.Parameters, cls_fastaccess: Optional[Type[hydpy.core.parametertools.FastAccessParameter]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.variabletools.SubVariables[hydpy.core.parametertools.Parameters, Parameter, hydpy.core.parametertools.FastAccessParameter]

Control parameters of model test.

The following classes are selected:
  • K() Storage coefficient [1/T].

  • N() Number of storages [-].

class hydpy.models.test.FluxSequences(master: hydpy.core.sequencetools.Sequences, cls_fastaccess: Optional[Type[FastAccessType]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.sequencetools.OutputSequences[FluxSequence]

Flux sequences of model test.

The following classes are selected:
  • Q() Storage loss [mm/T]

  • QV() Storage loss vector [mm/T]

vars: GroupType
class hydpy.models.test.SolverParameters(master: hydpy.core.parametertools.Parameters, cls_fastaccess: Optional[Type[hydpy.core.parametertools.FastAccessParameter]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.variabletools.SubVariables[hydpy.core.parametertools.Parameters, Parameter, hydpy.core.parametertools.FastAccessParameter]

Solver parameters of model test.

The following classes are selected:
  • AbsErrorMax() Absolute numerical error tolerance [mm/T].

  • RelErrorMax() Relative numerical error tolerance [1/T].

  • RelDTMin() Smallest relative integration time step size allowed [-].

  • RelDTMax() Largest relative integration time step size allowed [-].

class hydpy.models.test.StateSequences(master: hydpy.core.sequencetools.Sequences, cls_fastaccess: Optional[Type[FastAccessType]] = None, cymodel: Optional[hydpy.core.typingtools.CyModelProtocol] = None)

Bases: hydpy.core.sequencetools.OutputSequences[StateSequence]

State sequences of model test.

The following classes are selected:
  • S() Storage content [mm].

  • SV() Storage content vector[mm].