Open Source Modelling and Simulation of the Nordic Hydro Power System †

: In this paper, we present the results from the development and the simulation of a hydro power model for Sweden and Norway, using SpineOpt software and openly available data. We employ (i) hydrological and market data from the Nordic region and (ii) the abstract representation of the multi-vector modelling and simulation engine SpineOpt, to compile an open-source model of a large portion of the hydro power plants of the Nordic region, for conducting realistic hydro power generation studies. We place the hydro power system operation within the structuring of the Nordic electricity market and study the effect that different objectives have on the operational results. By employing the SpineOpt functionalities for automating the transformation of the temporal resolution of the model, we explore the trade-of between its computational burden and accuracy.


Introduction
The ambitious targets set by the EU by 2050, as a way to combat the devastating impacts of climate change comprise amongst others, a substantial rise in the share of renewable energy in the production mix, with electricity being half as much of it [1]. The variable nature of the intermittent Renewable Energy Sources (RES), on the other hand, calls for increased balancing and storage capabilities. Besides the various smart grid-based solutions, hydro power can play a salient role in this problem. Specifically in the Nordic region, the large hydro reservoirs and hydro power production facilities can contribute significantly in balancing the variable renewable production in Continental Europe and UK with very short up and down regulation time frames and low costs [2]. Therefore, the need to realistically model and simulate the coordinated operation of complex hydro power systems is evident. The task, however, of calculating the optimal water discharge of large hydrologically-coupled hydro power systems comes with a labyrinthine complexity. The challenges typically derive from the requirement to realistically model the reservoir capacities, the water delay times for a system of hydro power plants across a river, the stochasticity of water inflows (usually expressed in terms of seasonality and variability), the nonlinearity of the electricity production curves for different types of production units, the environmental restrictions, etc. The impact of climate change and global warming on the water cycle poses another important challenge that needs to be assessed as well [3], especially apropos of the long-term planning of the future electricity system.

Contributions and Organisation
Nevertheless, in order to advance the detailed modelling and simulation of hydro power systems and make the results available for a broader use and audience, there are great benefits of using fully open-source models and software. Starting from the generic SpineOpt software, which does not rely on any other commercial/proprietary software (e.g., GAMS or Cplex), we showcase how to build a highly specific and complicated case study, without the requirement for actual coding. Building on our previous work [16] that studied the market-based hourly operation of coupled hydro power plants of a single river in Sweden (Skellefteälven), we: • compile a hydro power model of 620 hydro power plants (making up 96.54% and 92.1% of the installed capacity of Sweden and Norway, respectively) by gathering up heterogeneous data from various sources, into a single openly available integrated model [17]. The model can be used in a large variety of power system studies (e.g., transmission and generation expansion planning studies, etc.); • introduce a multi-area implementation by grouping the hydro power plants in their market regions and also modelling aggregated conventional and wind generation units, and demand for each area, taking into account the inter-area exchanges; • demonstrate how different objectives for the hydro power generation schedule, such as the minimisation of spilled water, affect the results. We claim that it is not required to reprogram the model, but only change the data in order to implement a different optimization problem; • perform a sensitivity analysis for reducing the time resolution of the simulation, investigating how it influences the accuracy and the computational time of the simulations.
The rest of the paper is organised as follows; in Section 2, the SpineOpt software and its modelling conventions and capabilities are introduced, Section 3 presents the mathematical formulation of the developed model, the data gathering process that was followed and the overall implementation of the model in SpineOpt. The results are given in Section 4 and conclusions are provided in the end.

SpineOpt and Spine Toolbox
SpineOpt is an open-source generic energy modelling software developed in Spine Project [18]. Together with Spine Toolbox [19], it functions as a generic model generator and simulator and is designed to accommodate multi-vector energy systems (Figure 1a). The Spine data structure, in combination with the data importing and exporting tools, define and construct, respectively, the abstract flow-based multi-commodity energy models for SpineOpt. Software and user interfaces integrate various functionalities and facilitate the model construction and validation by the end-user (Figure 1b).

Spine Toolbox Spine Model
Spine data import/export

The SpineOpt Building Blocks
The SpineOpt data structure is based on a generic Entity-Attribute-Value scheme, using classes and relationships. The abstract classes and the relationships between them enable the formulation of a multi-commodity, flow-based model of an energy system, in an object-oriented manner. The main abstract classes are described below [20]: • Node: a point in space where energy from a certain vector gets balanced. • Unit: a device, installed between two nodes, capable of converting energy from one vector to another. • Connection: a device, also installed between two nodes, capable of transferring energy within the same vector, or enabling the flow of a commodity. • Commodity: a type of energy flow, uniquely associated with an energy vector.
• Temporal block: a period of time with a specific time resolution.
For compiling a model, the modeller employs the various abstract building blocks and defines the required relationships between them, according to the topology of the system and the coupling constraints between the nodal and flow variables. This is handled by the user interface of Spine toolbox using drag-and-drop functionality. Depending on the specific needs of the system to be modelled, various parameters (predefined or even custom) can be specified for capturing the physics of the flow of each commodity and the transformations between them.
A very important functionality of SpineOpt is the automated manipulation of the temporal resolution of the energy models. In practice, when data of different time resolution are available, these can be integrated into a single model by either reducing, or increasing the time resolution where necessary. This functionality also allows the user to reduce the resolution of the whole model in order to simplify the computational complexity of the optimisation problem, when that is required.

The Hydro Power System in Sweden and Norway
Sweden and Norway rely heavily on hydro power for their electricity generation. Approximately a third of all the hydro power produced in Europe is produced in Sweden and Norway. In Sweden, the installed capacity of hydro power reaches 16,200 MW from the about 2000 hydro power plants available, procuring almost half of the electricity consumed in the country. Most of this energy, around 80%, is produced in the northern parts of Sweden. In Sweden, around 68 TWh hydro power is produced every year [21].
In Norway, over 90% of the produced energy is hydro power. There are over 1600 hydro power plants and more than 1000 hydro power storage reservoirs. With a total reservoir capacity of more than 86.5 TWh, the reservoirs can store up to 70% of the annual electricity consumption in Norway. With a yearly production of 135.6 TWh on average, Norway produces almost twice as much hydro power compared to Sweden. The installed capacity of hydro power in Norway is more than twice as large as in Sweden, with 32,671 MW, by January 2020 [21].

Problem Formulation
In order to use the available water in the most efficient way, the operation of the hydro power plants which are located in the same river system should be coordinated. For achieving that, the power plants should operate at the optimal efficiency, while taking into account the water flow delays from one station to the next across the river, the volume of water that can be stored in the reservoir of each station and avoiding situations where spillage is necessary [22]. For the purpose of this case study, which is to showcase the coordinated operation of the hydro power system of Sweden and Norway, we formulate the optimisation objective as the minimisation of the total power imbalances within each area. This way, we aim at balancing the hydro power that is produced within each market area with its variable wind power and demand. The first term in the objective function (Equation (1a)) expresses this goal, while the second penalises the water that is spilled (S i,t ): subject to: P + a,t − P − a,t = P a,t + P G a,t + P W The constraint in Equation (1b) expresses the power imbalances of each area and for each time-step as a function of the thermal, wind and hydro production, the demand and the power exchanged between the areas (using non-negative auxiliary variables, Equation (1c)). In Equation (1d), the water discharge from each power plant is converted to power, taking into account a variable efficiency. We model these power conversion curves of each power plant following a piecewise-linear approximation methodology, and, depending on the available data, we employ one or several line segments. The conversion ratios (the slopes of the line segments) are decreasing for higher discharges, thus avoiding a mixed-integer formulation [7]. The capacity of each area interconnection is constrained in Equation (1e).
In order to consider the hydrological coupling between the power plants, the reservoir content at time t should be equal to the reservoir content at time t − 1, adding inflows and subtracting outflows. This is imposed in Equation (1f), that is the so-called hydrological balance equation. Equation (1g) expresses the total water discharge of each power plant for the different line efficiency segments, while Equations (1h) and Equation (1i) emulate the water flow delays of the discharge and spilled water, respectively, initialising the said variables at the first time steps of the optimisation window to some fixed, predefined values-when that is required. The constraints in Equation (1j)-Equation (1l) enforce the technical limits for the discharge assuming different efficiency line segments, the reservoir levels and the permissible limits for the spillage.
Assuming a constant time delay for each plant, independent of the discharge, the quantity τ q i can be expressed in hours (h q i ) and minutes (m q i ). Equation (2) provides the delayed upstream flow as the weighted average of the discharge between the hours hj and hj + 1. A similar expression is used to express the spillage delays. It should be stressed that the formulation of the optimization as it has been presented above is generic with regard to the time dimension, i.e., t does not necessarily denote hours or any other specific time interval; instead, it permits the modelling of the problem in the time intervals that are dictated from the input data time series:

Data Gathering and Preprocessing
In order to model the hydro power system using the formulation of Section 3.2, the following parameters are required for each power plant: • The installed capacity. • The production equivalent. • The maximum reservoir volume. • The reservoir volume at the start and end of the simulated week. • The water flow at the start of the simulation. • The local inflow of water. • The topology, i.e., the downstream power plant, for both discharge and spillage. • The flow delay to downstream power plant, for both discharge and spillage.
For the Swedish hydro power system, the data were mostly derived from [23], while, for the Norwegian system, data were mined from [24]. In addition, for both countries, a lot of relevant information was taken from [25]. Due to the large number of hydro power plants in Norway, not all were in fact included in the model, but only those with installed capacity of more than 10 MW. This resulted in the inclusion of 363 hydro power plants with a total installed capacity of 30,093.18 MW, which constitutes the 92.1% of the total installed capacity in Norway, and a total average yearly production of 125.64 TWh, which is the 95.5% of the total average yearly production in Norway. Most of the data used were from the year 2019. In Figure 2a  The reservoir volumes were retrieved from the sources mentioned above and assigned to the power plants that they feed. Where required, the units for the maximum volumes were converted to Hour Equivalents (HE-which represent a water flow of 1 m 3 /s during 1 h). For the hydro power plants that had more than one reservoir, their reservoirs were approximated with a single larger reservoir.
The water flow of each river was approximated by taking the average energy production (P avg ) in GWh per year and the production equivalent µ, in kWh/m 3 , or GWh/Mm 3 , converting them afterwards in m 3 /s. For estimating the flow delays, the following methodology was employed. By measuring distances along the rivers on maps, and assuming that the water flows approximately at a speed of 4-5 m/s, the flow delays were estimated. This was done both for the discharged and the spilled water, in the cases that different routes existed for them. If the spillage route was not able to be determined, the spillage flow delay was set the same as the discharge flow delay.
The historical data for the hourly electricity demand, for each market area, along with the conventional and wind generation, and the capacities in the area interconnectors were taken from Svenska Kraftnät [26] and Nord Pool [27]. The historical hydro production data were also taken from the same sources. The market areas of Sweden and Norway are shown in Figure 2b. The simulation window of the model spanned from 11 February 2019 to 18 February 2019. In Table 1, the parameters of several power plants of a specific river of Sweden (the Skellefte river) are shown.

Compiling the Hydro Power System in SpineOpt
The model is assembled in SpineOpt by using the node, connection, unit and relationship classes, presented in Section 2.2. For each market area of Sweden and Norway, a single electricity node is defined, while, for the interconnections between neighbouring areas, units are defined modelling the power exchanges between them. It should be noted that, since the units' flows can only take positive values in SpineOpt, two sets of units are used in the actual model. A graphical representation of the electricity nodes and exchanges is shown in Figure 3, where for reasons of clarity, only one unit per interconnection is presented. Each unit is associated with two nodes, enabling the transfer of electricity from the one to the other. The capacity of each unit is taken from historical data as mentioned above. The demand time series for each electricity area is defined as a parameter of the corresponding node.
Next, each hydro power plant is modelled and assigned to an electricity node. This process is more elaborate and a graphical example is shown in Figure 4 for the Yngeredsfors power plant. The said plant succeeds the Bällforsen and precedes the Ätrafors power plants, respectively, across the river Ätran in southern Sweden. All three power plants belong to the same electricity area, SE4. A node imposes the balance of a certain commodity flowing in and out of it; hence, for each modelled power plant, one node can be used to represent the hydrological balance constraints, Equation (1f), while a unit can represent the actual power plant, with the set conversion rates (µ i,j ), from water to electricity. In a higher detail, for each power plant, the following SpineOpt building blocks are used: 1.
two nodes are introduced for modelling the discharged and spilled water, an "upper" node and a "lower" node. One of them models M i , as its state variable (Yngereds-fors_upper in Figure 4),

2.
relationships are used to define the topology and the coupling of the decision variables, 3.
one unit is introduced for modelling P i,t . For each unit between a set of nodes, three types of relationships are required, a set of relationships between each node and the unit that defines the topology, and a relationship coupling simultaneously all three entities that acts as a placeholder for the conversion ratio parameter(Yngeredsfors_pwr_plant in Figure 4), 4.
another unit is introduced for including the water spillage minimization term in the objective function (Yngeredsfors_to_Ätrafors_node in Figure 4), 5.
two connections with the downstream power plant represent Q i,t and S i,t , (Yngereds-fors_to_Ätrafors_disch and Yngeredsfors_to_Ätrafors_spill, shown in Figure 4, model the discharge and spillage, respectively).  Following the above procedure, it is possible to emulate the diffluence of the two water flows-one corresponding to the water that is being spilled and hence not used for the electricity production, and the other one corresponding to the water that is being discharged for producing electricity. The connections are used for modelling the water flows between successive power plants. For each power plant, there are at least two upstream and two downstream connections: one for spillage, connecting the upper node of a hydro power plant with the upper node of the next downstream power plant (i.e., water that is spilled and becomes available to the next plant), and the other one for the discharge, connecting the lower node of a plant with the upper node of the next plant (i.e., water that is used for electricity and can also be used by the next plant).
The decision variables of the model are specified from the defined nodes (e.g., the node state), units related to nodes (e.g., the flow between the unit and the node) and connections related to nodes (e.g., the flow between the connection and the node). It should be stressed that the links (relationships) in Figure 4 do not correspond to the actual water flows but rather define the coupling of the decision variables. By using these objects and relationships, it is possible to specify parameters that form the constraints, (such as the technical limits, the flow delays, etc.). In addition, note that the "upper" and "lower" nodes of each power plant do not correspond to the level difference, but, combined with the respective unit, constitute one way for modelling the hydro balance equation. The electricity production takes place between the "upper" node, the unit, and the electricity node only. The electricity node of each area aggregates the electricity production of all power plants of this area. The temporal block, as well as the commodity block, are associated with each node (but not all the relationships of the developed model are depicted in Figure 4 for simplicity). The former defines the temporal structure of the variables it is associated with, while the latter, the type of the commodity that each associated node balances.

Short-Term Scheduling of the Hydro Power System of Sweden and Norway
In this section, various results from the simulated system are presented, along with an overview of some input data. In Figure 5a, the historical total wind production time series for each market area of Sweden and in Figure 5b the demand for two areas of Norway, as they are included into the model, are shown. In Figure 6, selected results are given, from a specific river in Northern Sweden, the Lule river. From the 10 hydro power plants currently in operation, the scheduling results of two stations are presented, (the Vittjarv station in Figure 6a, the Ligga station in Figure 6b, while the total hydro power production of all the power plants of the river is shown in Figure 6c. Figure 7 presents the scheduling of two Norwegian hydro power plants of the model, the Vinje station, located in the market area NO2 (Figure 7a) and the Kobbelv station, located in the market area NO4 (Figure 7b). In the next figures (Figures 8-11), the total hydro production of specific areas is presented, while the total system production is shown in Figure 12. In order to demonstrate the capability of SpineOpt in reducing the temporal resolution of the model and evaluate it in qualitative manner, we superimpose the results from simulating the model with different temporal resolutions on the same figure. The results are obtained by gradually reducing the temporal resolution of the whole model (and therefore its computational complexity) from the hourly up to a daily resolution.

Discussion
From the previous figures, it can be easily observed that the results from simulating the model with different temporal resolutions present, as expected, a gradually decreasing similarity. From a visual inspection, the results of the simulated model with a 2-h and a 4-h resolution are outstandingly similar to the results from the hourly resolution model. This observation corroborates the great flexibility that the SpineOpt generated model, together with the generic formulation of the coordinated hydro power scheduling problem (presented in Section 3.2), have to offer to the modeller. The modeller is able to choose the level of detail (and hence the complexity) that is of interest to study, according to the requirements of the specific case.
In Figure 13, the results from the total hydro power production for both Sweden and Norway are obtained and compared with historical hydro power production. The two curves deviate for a number of reasons such as the different objectives of the actual hydro power plants (i.e., usually, they aim at maximising their profits by participating in the electricity market); the exchanges with other neighbouring countries area not considered in this model, there are some hydro power plants missing and possibly modelling errors could be attributed to the various approximations that were performed.  Figure 14 investigates the effect that different objectives have on the results of the simulated model. The three different simulations were conducted by adjusting the objective (Equation (1a)), firstly keeping only the first summation term that penalises the imbalances, then, keeping also the second term which penalises the spillages and, lastly, introducing another penalty term for minimising the power exchanged between the modelled market areas. It is interesting to observe that the first and the third choices present a better similarity with the historical data for the hydro production. Another interesting insight from the results is that the first and third options for the objective increased the total imbalances of the model, which were reduced to zero in the second case. Another desirable outcome of the second modelling choice is the provision of a smoother solution time series. In general, we can argue that the selection of the penalty values for the different objective terms, as well as the form of the objective function, should be set according to the needs of the specific study that uses the developed hydro power model.

Assessing the Computational Complexity and the Validity of the Model for Reduced Temporal Resolutions
While the simulation of the full model for one week takes approximately less than 30 min on a contemporary laptop computer (with a 2.4 GHz 8-Core CPU and 32 GB of RAM), as shown in Figure 15, reducing the temporal resolution of the model decreases both the time and the memory allocations significantly. This is due to the fact that, for example, an optimisation model with a 2-h resolution requires half the amount of variables and constraints than the same model with an hourly time resolution. For being able to provide some practical validation of how the error of the simulated model is affected by the different temporal resolutions, we perform an exact comparison of the various obtained results, since merely comparing the objective values (shown in Figure 15c) does not provide a great insight. In Table 2, two numerical metrics are calculated for the comparison of the results from simulations with different temporal resolutions (considering the total hydro power production of the model, shown in Figure 12). These are the mean relative error and the Root Mean Squared Error-RMSE, which are evaluated for each pair of the reference results (the hourly resolution curve) and the lower resolution curve.
Since the calculation of the above metrics for time series with varying temporal resolutions is not straightforward, we need to perform upsampling of each curve to an hourly resolution. We do that using linear interpolation for the missing values. Then, we calculate the mean relative error and the RMSE between the comparable time series. Even though the objective value error (shown in Figure 15c) exceeds the value of 40% for the simulations with 12 and 24h resolutions, the mean error is maintained significantly lower (less than 8%), which is a promising result. Furthermore, the visual observation that the 2h and 4h resolution results are very similar is graciously confirmed, since the calculated error metrics are maintained at acceptable levels.

Conclusions
We have presented the development and simulation of an open-source hydro power model for Sweden and Norway, using SpineOpt software and openly available data. The model includes 257 hydro power plants of Sweden and 363 of Norway, making up 96.54% and 92.1% of their installed capacity, respectively. The hydro power stations are assigned to the market areas they belong to, but the results can also be filtered by specific rivers. Historical data have been used for the conventional and wind generation as well as for the demand of each area. Different objectives for the hydro power generation schedule were evaluated, showing that these should be chosen depending on the needs of the case under study, while the minimisation of the imbalances (as those are defined in this paper) seemed to mimic the historical data more closely. The trade-off between the computational burden and the accuracy of the developed was assessed, in terms of reducing its temporal resolution and hence the size of the optimisation problem. For future work, the missing hydro power stations can possibly be included in the model and the exchanges with other countries can also be introduced. An alternative formulation for the objective function that maximises the income of the hydro power stations as a way to produce results that match the historical data more closely can be examined, along with penalties for achieving smoother solutions.   Yearly average inflow of water to each reservoir per hour.
V i,t Water inflow for reservoir i and time t.

Indices and Sets
A Set of the market areas.