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: 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.

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

Bases: 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: 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: 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: 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: 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: Parameters, cls_fastaccess: Type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

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: SubParameters)[source]

Bases: Parameter

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

alias of float

TIME: bool | None = None
SPAN: Tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'k'

Name of the variable in lower case letters.

unit: str = '1/T'

Unit of the variable.

class hydpy.models.test.test_control.N(subvars: SubParameters)[source]

Bases: Parameter

Number of storages [-].

Required by the methods:

Calc_QV_V1 Calc_SV_V1

NDIM: int = 0
TYPE

alias of int

TIME: bool | None = None
SPAN: Tuple[int | float | bool | None, int | float | bool | None] = (1, None)
name: str = 'n'

Name of the variable in lower case letters.

unit: str = '-'

Unit of the variable.

Solver parameters

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

Bases: SubParameters

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: SolverParameter

Absolute numerical error tolerance [mm/T].

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: Tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
INIT: int | float | bool = 0.01
name: str = 'abserrormax'

Name of the variable in lower case letters.

unit: str = 'mm/T'

Unit of the variable.

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

Bases: SolverParameter

Relative numerical error tolerance [1/T].

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: Tuple[int | float | bool | None, int | float | bool | None] = (0.0, None)
INIT: int | float | bool = nan
name: str = 'relerrormax'

Name of the variable in lower case letters.

unit: str = '1/T'

Unit of the variable.

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

Bases: SolverParameter

Smallest relative integration time step size allowed [-].

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: Tuple[int | float | bool | None, int | float | bool | None] = (0.0, 1.0)
INIT: int | float | bool = 0.001
name: str = 'reldtmin'

Name of the variable in lower case letters.

unit: str = '-'

Unit of the variable.

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

Bases: SolverParameter

Largest relative integration time step size allowed [-].

NDIM: int = 0
TYPE

alias of float

TIME: bool | None = None
SPAN: Tuple[int | float | bool | None, int | float | bool | None] = (0.0, 1.0)
INIT: int | float | bool = 1.0
name: str = 'reldtmax'

Name of the variable in lower case letters.

unit: str = '-'

Unit of the variable.

Sequence Features

Flux sequences

class hydpy.models.test.FluxSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: FluxSequences

Flux sequences of model test.

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

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

class hydpy.models.test.test_fluxes.Q(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

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[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'q'

Name of the variable in lower case letters.

unit: str = 'mm/T'

Unit of the variable.

class hydpy.models.test.test_fluxes.QV(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: FluxSequence

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[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'qv'

Name of the variable in lower case letters.

unit: str = 'mm/T'

Unit of the variable.

State sequences

class hydpy.models.test.StateSequences(master: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: StateSequences

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: ModelSequences[ModelSequence, FastAccess])[source]

Bases: StateSequence

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[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 's'

Name of the variable in lower case letters.

unit: str = 'mm'

Unit of the variable.

class hydpy.models.test.test_states.SV(subvars: ModelSequences[ModelSequence, FastAccess])[source]

Bases: StateSequence

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[int | float | bool | None, int | float | bool | None] = (0.0, None)
name: str = 'sv'

Name of the variable in lower case letters.

unit: str = 'mm'

Unit of the variable.

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

Bases: SubParameters

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: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: FluxSequences

Flux sequences of model test.

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

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

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

Bases: SubParameters

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: Sequences, cls_fastaccess: Type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: StateSequences

State sequences of model test.

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

  • SV() Storage content vector[mm].