apply_fillspill Scheme Example

This example shows how to use the ReservoirModel.apply_fillspill() scheme when modelling a single reservoir model. It will aim to satisfy a certain target elevation, fill if below it, and spill if it exceeds a threshold elevation.

Note

For details about the full model file structure please see Basic Single Reservoir.

We consider a reservoir with a single inflow, Q_in, and an outflow Q_out. Q_out is comprised of two components, a turbine, Q_turbine, and a spillway, ‘’Q_spill’’. The scheme requires the presence of several parameters in the file ‘input/rtcParameterConfig.xml’.

“Reservoir_Htarget”: Elevation that the scheme tries to satisfy at minimum. “Spillway_H”: elevation above which the spillway will be activated according to the Q/H relationship. “Reservoir_Qmax”: Maximum turbine discharge “Reservoir_Qmin”: Minimum turbine discharge demand, for example based on energy demand or downstream water demand

Main Model (python) File

An example of the main model file fillspill_example.py is given below.

 1"""Example that illustrates use of fillspill scheme only."""
 2
 3from pathlib import Path
 4
 5from rtctools_simulation.reservoir.model import ModelConfig, ReservoirModel
 6
 7CONFIG = ModelConfig(base_dir=Path(__file__).parent)
 8
 9
10class SingleReservoir(ReservoirModel):
11    """Example single reservoir model."""
12
13    def apply_schemes(self):
14        """Apply schemes for controlling the reservoir."""
15
16        # Collect reservoir elevation.
17        self.apply_fillspill()
18
19
20# Create and run the model.
21if __name__ == "__main__":
22    model = SingleReservoir(CONFIG)
23    model.simulate()

The template file mentioned in the Basic Single Reservoir will look very similar to this file, except that the apply_schemes() method still needs to be filled out.

The line

CONFIG = ModelConfig(base_dir=Path(__file__).parent)

sets the model configuration. This model configuration is defined by the base directory base_dir. In most cases, the base directory is Path(__file__).parent, which is the directory of the current file.

The line

class SingleReservoir(ReservoirModel):

defines a class SingleReservoir that inherits all properties and functionalities of the predefined class ReservoirModel. An overview of this class can be found in Reservoir API and details of the underlying model it uses can be found in Single Reservoir Model.

The method ReservoirModel.apply_schemes() is called every timestep and contains the logic for which schemes are applied. The first argument self is the SingleReservoir object itself. Since SingleReservoir inherits from ReservoirModel, self can call any of the ReservoirModel methods, such as ReservoirModel.apply_fillspill(). An overview of all available ReservoirModel methods can be found in Reservoir API.

The ReservoirModel.apply_fillspill() scheme is then applied to set the reservoir outflow through the turbine. It will minimally release water when H < Reservoir_Htarget, pass the inflow when Reservoir_Htarget < H < Spillway_H, and spill when H exceeds Spillway_H. Furthermore, it considers the limits on the discharge through the turbine.

Lookup tables

The ReservoirModel.apply_fillspill() scheme uses a lookup table v_from_h. This uses the same data as the h_from_v lookup table, the data mapping can be achieved in the lookup_tables.csv file.

<base_dir>/lookup_tables/lookup_tables.csv

name

data

var_in

var_out

h_from_v

v_h.csv

volume_m3

height_m

v_from_h

v_h.csv

height_m

volume_m3

area_from_v

v_area.csv

volume_m3

area_m2

qout_from_v

qout_v.csv

day volume_m3

qout_m3_per_s

qspill_from_h

h_qspill.csv

height_m

qspill_m3_per_s

This model also uses the standard lookup table h_from_v. For other lookup tables, defaults from the generated template files can be used.

Note

For further details about the lookup tables please see Basic Single Reservoir.

Input Data Files

The ReservoirModel.apply_fillspill() scheme requires the following parameters from the rtcParameterConfig.xml file. “Reservoir_Htarget”: Elevation that the scheme tries to satisfy at minimum. “Spillway_H”: elevation above which the spillway will be activated according to the Q/H relationship. “Reservoir_Qmax”: Maximum turbine discharge “Reservoir_Qmin”: Minimum turbine discharge demand, for example based on energy demand or downstream water demand

These parameters are supplied to the model via the rtcParameterConfig.xml input file.

        <parameter id="Reservoir_Hmin">
        	<dblValue>1580.0</dblValue>
        </parameter>
        <parameter id="Reservoir_Qmin">
        	<dblValue>20</dblValue>
        </parameter>

Output Data

The results of the simulation will appear in the output folder in a file called timeseries_export.xml. The data is linked to model variables via the rtcDataConfig.xml in the same way as with timeseries_import.xml.

Automatic Plotting

You can optionally include a plot_table.csv in the input folder. This is used by the rtc-tools-interfaces module (automatically installed with this package) to plot the model output. For more details on how to use this file and visualize results, see RTC-Tools-Interface.

The results of the simulation run can be seen in the plot below.