Single Reservoir Model

When modelling a single reservoir, the user does not need to create his own model file. Instead, the ReservoirModel class will use a default model file. Details of this model file will be described here. Note that it is not necessary to understand these details in order to use ReservoirModel, but it provides some insight into how things work under the hood. The model is written in the modeilca language. Here we describe the model assumptions, and include the model itself for the interested user.

The single reservoir is modelled as having a single inflow, and single outflow. This outflow can be made up of components flowing through a spillway or turbine if applicable (activated through the use of schemes, see Reservoir API). The reservoir has an associated elevation, and volume. It is also possible to account for the effects of rain or evaporation (see Reservoir API).

The single reservoir model.

Inputs

input variables are required for the simulation model to run.

  • H_observed: The observed elevation of the reservoir

  • Q_in: The inflow into the reservoir.

  • Q_turbine: The outflow from the reservoir which flows through a turbine.

  • Q_sluice: The outflow from the reservoir which flows through a sluice.

  • do_spill: A boolean which determines whether or not the spillway scheme is applied.

  • do_pass: A boolean which determines whether or not the passflow scheme is applied.

  • do_poolq: A boolean which determines whether or not the poolq scheme is applied.

  • include_evaporation: A boolean which determines whether or not evaporation is accounted for.

  • include_rain: A boolean which determines whether or not rain is accounted for.

  • mm_evaporation_per_hour: The evaporation from the reservoir (mm per hour).

  • mm_rain_per_hour: The rain falling in the reservoir (mm per hour).

  • Q_out_from_input: The total outflow of the reservoir if set by the user using the set_q scheme.

  • do_set_q_out: A boolean which determines whether or total reservoir outflow is set by applying the set_q scheme.

For variables such as Q_in, Q_turbine, Q_sluice, mm_evaporation_per_hour, Q_out_from_input and mm_rain_per_hour, default values are set via the python script if they are not provided by the user. These defaults do not negatively affect the solution, but allow the script to run if the user is not interested in considering a turbine flow for instance, or wishes to set reservoir inflow via a scheme.

All input booleans which refer to the application of schemes have a default of False.

Outputs

output variables are calculated during the simulation run.

  • V: The volume of the reservoir.

  • Q_out: The outflow from the reservoir.

  • H: The elevation of the reservoir.

  • Q_evap: The amount of water leaving the reservoir at each timestep due to evaporation.

  • Q_rain: The amount of water entering the reservoir at each timestep due to rain.

  • Q_spill: The outflow from the reservoir which flows through a spillway.

There are various states which are used to aid calculations, but are not outputs from the model. These include;

  • Q_out_from_lookup_table: The outflow from the reservoir read from a lookup table.

  • Area: The area of the reservoir.

  • Q_spill_from_lookup_table: The outflow through the spillway as given by a lookup table.

Parameters

Parameters have fixed values for times during the simulation run. The model considers the following parameters;

  • H_crest: The crest level of the reservoir.

  • max_reservoir_area: The maximum area of the reservoir.

Units

The unit of each paramter/input/output variable can be seen when it is defined. The standard units library of Modelica is used. The flow per unit area is not defined in this library, thus we define it as;

type FlowRatePerArea = Real(unit = "mm/hour");

The Modelica model

reservoir.mo file contains the default model for a single reservoir. In text mode, the Modelica model looks as follows

 1model Reservoir
 2  type FlowRatePerArea = Real(unit = "mm/hour");
 3  import SI = Modelica.SIunits;
 4
 5  // Parameters
 6  parameter SI.Length H_crest();
 7  parameter SI.Area max_reservoir_area() = 0;
 8
 9  // Inputs
10  // The fixed argument is necessary for defining optimization problems.
11  input SI.Length H_observed(fixed=true);
12  input SI.VolumeFlowRate Q_in(fixed=true);
13  input SI.VolumeFlowRate Q_turbine(fixed=false);
14  input SI.VolumeFlowRate Q_sluice(fixed=false);
15  input SI.VolumeFlowRate Q_out_from_input(fixed=false);
16  input Boolean do_spill(fixed=true);
17  input Boolean do_pass(fixed=true);
18  input Boolean do_poolq(fixed=true);
19  input Boolean do_set_q_out(fixed=true);
20  input Boolean use_composite_q(fixed=true);
21  input Boolean include_evaporation(fixed=true);
22  input Boolean include_rain(fixed=true);
23  input FlowRatePerArea mm_evaporation_per_hour(fixed=true);
24  input FlowRatePerArea mm_rain_per_hour(fixed=true);
25  input Integer day(fixed=true);
26
27  // Outputs/Intermediates
28  output SI.Volume V();
29  SI.Volume V_observed();
30  output SI.VolumeFlowRate Q_out();
31  SI.VolumeFlowRate Q_out_from_lookup_table();
32  output SI.Length H();
33  output SI.VolumeFlowRate Q_evap();
34  output SI.VolumeFlowRate Q_rain();
35  SI.Area Area();
36  SI.VolumeFlowRate Q_spill_from_lookup_table();
37  output SI.VolumeFlowRate Q_spill();
38
39equation
40  // Lookup tables:
41  // V -> Area
42  // V -> H
43  // H -> QSpill_from_lookup_table
44  // V -> QOut (when do_poolq)
45
46  der(V) - (Q_in - Q_out + Q_rain - Q_evap) = 0;
47
48  Q_evap = Area * mm_evaporation_per_hour / 3600 / 1000 * include_evaporation;
49  Q_rain = max_reservoir_area * mm_rain_per_hour / 3600 / 1000 * include_rain;
50
51  Q_spill = do_spill * Q_spill_from_lookup_table;
52
53  Q_out = (
54    do_pass * Q_in
55    + do_poolq * Q_out_from_lookup_table
56    + use_composite_q * (Q_turbine + Q_spill + Q_sluice)
57    + do_set_q_out * Q_out_from_input
58  );
59
60end Reservoir;

Note

Modelica is not a programming language, but just describes the equations and variables that form a model. Therefore, equations in Modelica just equate expressions as opposed to assigning the value of one variable to another like in Python.