Power Market Tool (POMATO) for the Analysis of Zonal Electricity Markets

The proposed open-source Power Market Tool (POMATO) aims to enable research on interconnected modern and future electricity markets in the context of the physical transmission system and its secure operation. POMATO has been designed to study capacity allocation and congestion management (CACM) policies of European zonal electricity markets, especially flow-based market coupling (FBMC). For this purpose, POMATO implements methods for the analysis of simultaneous zonal market clearing, nodal (N-k secure) power flow computation for capacity allocation, and multi-stage market clearing with adaptive grid representation and redispatch. The computationally demanding N-k secure power flow is enabled via an efficient constraint reduction algorithm. POMATO provides an integrated environment for data read-in, pre- and post-processing and interactive result visualization. Comprehensive data sets of European electricity systems compiled from Open Power System Data and Matpower Cases are part of the distribution. POMATO is implemented in Python and Julia, leveraging Python's easily maintainable data processing and user interaction features and Julia's well readable algebraic modeling language, superior computational performance and interfaces to open-source and commercial solvers.


Motivation, Significance and Impact
Europe's increasing electricity production from renewable energy resources in combination with a significant decline of conventional generation capacity, has spawned political and academic interest in the transmission system's ability to accommodate this transition, [1]. Central to this discussion is the efficiency of capacity allocation and congestion management (CACM) policies between and within electricity market areas that share transmission infrastructure, [2]. Capacity allocation (CA) summarizes regulatory and market mechanisms that constrain electricity trading volumes between two adjacent market areas with respect to the expected available cross-border transmission capacity at time of delivery. Congestion management (CM), on the other hand, refers to methods ensuring that the physical system state at time of delivery indeed remains within its security margins, e.g. does not cause transmission line overloads. Noticeably, well defined CA based on suitable forecasts can reduce CM measures, such as out-of-market generator redispatch coordinated by the transmission system operator (TSO). Previously implemented CA policies based on static net-transfer capacities (NTCs) consider tie-line capacities between markets, but neglect restricting transmission assets within market zones, thus leading to often non-feasible market outcomes, increased CM (redispatch) or overly conservative market results, [3,4]. To overcome these deficiencies and in an effort to "move towards a genuinely integrated [European] electricity market", [2], the centralwestern European (CWE) countries inaugurated flow-based market coupling (FBMC), a more complex CA policy that aims to increase the potential vol-ume of cross-border electricity trading while decreasing CM requirements by explicitly accounting for cross-border and zone-internal transmission limits.
The proposed Power Market Tool (POMATO) has been designed to enable further research on the status-quo and future policies of practical zonal electricity markets, especially FBMC. While the theory of a centrally coordinated zonal electricity market is somewhat mature, see e.g. [5], practical implementation with imperfect coordination between market and system operators requires ongoing analyses. The current European FBMC is a multi-stage process coordinated by multiple TSOs and involves detailed zone-specific load and generation forecasts and network models, which are typically not, or only partially, disclosed by the TSOs, [6]. However, the medium-and long-term evolution of the FBMC design requires an informed public decision based on independent FBMC analyses that study the impact of, e.g., more countries joining the coupled market or bidding zone layouts (which have been declared inefficient by a recent TSO study, [7]). Notably, the yearly federal report on the future of the grid in Germany ("Netzentwicklungsplan"), included a rudimentary FBMC representation for the first time in its 2018 edition, [8], three years after FBMC implementation.
There are few model implementations of the FBMC process available to the academic community, [9,10,11]. In [9] Aravena et al. compare various CA policies and demonstrate the benefits of FBMC traditional approaches using real-world data sets. Also, this study proposes an iterative approach to meet the practical requirement that any dispatch has to be robust against unplanned transmission equipment outage (N-1 security). However, datasets and model implementation are not published along the paper. Similarly, Matthes et al. [10] present a FBMC formulation for estimating future FBMC parameters and studying the impact of regulations that require additional security margins on critical transmission lines. This model uses an external convex hull reduction for a N-1 secure FBMC solution and is implemented in the MILES framework, [12], which, to our knowledge, is also not publicly available. Schönheit et al. [11] extend the classic GAMS 2 model ELMOD [13] to facilitate FBMC analyses and study the impact of regulations requiring a minimum availability of interzonal trading volumes, [14]. Here, N-1 security is approximated through static security margins and despite comprehensive documentation in [11] the code extension itself is undisclosed.
POMATO aims to overcome some of the caveats of [9,10,11] by providing a documented and open-source framework that is easy to use and goes beyond the implementation of an academic optimization model. Some main features and contributions are: (a) Separation of data processing (implemented in Python 3 ) and optimization (implemented in Julia 4 ) to achieve a flexible Python-based user interface that is familiar to many users, while creating a lean implementation of the central optimization model in the well-readable JuMP algebraic modeling language, [15]. (b) Open-source available and documented on GitHub 5 , [16,17]. (c) Comprehensive data set of the European electricity market and transmission infrastructure based on Open Power Systems Data 6 and Matpower 7 data sets. (d) Electricity market model with zonal and nodal market clearing and a module to synthesize the FBMC process, including heat sector coupling. The underlying mathematical model has been reported in our previous work [6]. (e) Exact N-1 secure dispatch implementation suitable for large-scale networks and multi-period analyses. The used algorithm removes redundant constraints, similar to the convex hull approach in [10], but has been optimized for optimal power flow (OPF) analyses, yielding improved computation times. This algorithm has been presented in our previous work [18]. (f) Stochastic OPF using chance-constraints to analyse the impact of forecast errors from renewable energy sources.

Software Description
POMATO's architecture is structured in three layers as shown in Figure 1. The model core collects the mathematical formulations of the necessary optimization problems and provides an interface to the required solvers.
To ensure a lean model implementation and efficient re-runs without recalculating large parameter sets, the model core is encapsulated in a data processing layer. This layer automates parameter calculation and validation, provides parameters to the model core, and validates and processes the resulting model output. Finally, all functionality of POMATO is collected in the outer user interface layer via readable API-like commands. 3 www.python.org 4 www.julialang.org 5 github.com/richard-weinhold/pomato 6 open-power-system-data.org/ 7 matpower.org/ Figure 1: POMATO's layered architecture. The inner model core is colored purple, the data processing layer is colored yellow, and the outer user interface is colored blue.

Model Core
The core of POMATO is an electricity market model. This model is an optimization problem that finds the least cost generation schedule that matches system demand with respect to all technical constraints. Equation (1) shows the general structure of such a model: Objective (1a) minimizes the cost of electricity generation (COST G), heat generation (COST H ), load curtailment (COST CURT ) and out-of market penalties (OOM PEN , e.g. cost of redispatch) over all units and time steps. Constraints in (1b) define these cost components as sets of linear functions. Depending on the modeled market framework, some cost may be zero. Constraints (1c) and (1d) enforce limits on the available electricity and heat generation, respectively. Constraints (1e) enforce the time-coupled energy constraints for storages and limit their efficiency-corrected charging and discharging power. Balancing constraints in (1f) ensure that for all market areas generation equals demand plus net export (export minus import) at all times. Network constraints (1g) capture the transmission system topology as nodes (buses) and lines and enforce exchange capacity limits. Physical flows are modeled using some modification of the linearized (DC) power flow equations so that nodal net injections can be mapped to power flows via a power transfer distribution factor (PTDF) matrix or voltage angles, see e.g. [18,19]. The specific definitions of constraints (1b) -(1g) are activated and parametrized by POMATO "on the fly" based on user-defined options. For example, nodal market clearing enforces an energy balance in (1f) for each node and exchanges are limited by the physical power flow and the thermal transmission system capacities. Zonal markets, on the other hand, ensure an aggregated energy balance for an entire zone (i.e. multiple connected nodes). Exchanges with neighboring zones are limited either explicitly by NTCs, which constrain individual cross-border exchanges, or implicitly through constraints on the net positions (total net export) of each zone. The latter is used to model FBMC by calculating zonal PTDFs, see e.g. [6], that map zonal net positions to power flows on (critical) lines. Additionally, constraints to model CM (redispatch) and external security requirements (contingency ro-bustness) can be included. For redispatch models, a nodal market is solved subject to additional out-of-market penalties based on results of a previously solved zonal market. Specifically, the optimal redispatch is the leastcost change from a given generation schedule with predefined out-of-market penalties and fixed zonal balances so that the resulting nodal balances are feasible for the given transmission network. Preventive system security requirements based on contingency (N − 1) analyses, are enforced through a suitable extensions of zonal and nodal PTDF matrices.
Optimal dispatch with preventive robustness against contingencies (unplanned outages) is computationally demanding and requires additional effort, as the number of constraints grows exponentially with the network size which often renders the problem unsolvable for multi-period economic analyses, [18]. However, it has been shown that many (in fact most) of these constraints are redundant, i.e. never binding in the optimal solution due to the existence of more restrictive constraints, [20]. To ensure feasible solution times for real-world networks over non-trivial time horizons, POMATO's model core includes additional functionality to identify these redundant constraints. Implementation and performance of this redundancy-removal algorithm has been presented in our previous work [18], where we showed that for most of the studied transmission networks over 99% of the constraints can be removed from the optimization problem, allowing to solve previously infeasible larger market models and significantly reducing the solve time of smaller problems.
The methods and algorithms implemented in the model core require a suitable framework that enables fast robust computations and facilitates the use of interchangeable solver back-ends. The open-source Julia Language provides a competitive combination of performance and readability, [21], as well as suitable libraries for implementing the required mathematical programming (electricity market model and redundancy removal). Here, we opted for the popular, well-readable and flexible JuMP package, [15]. PO-MATO's Julia modules (MarketModel.jl and RedundancyRemoval.jl) are parametrized and called automatically by the higher POMATO layers, as indicated in Figure 1.
Feature Remark 1 (Chance Constrained Economic Dispatch). When modeling systems with high shares of intermittent renewable generation, internalisation of the feed-in uncertainty with respect to capacity reserve and network constraints can be done using Chance Constraints, [22,23]. This capability is also included in POMATO as an experimental feature and subject to future publication.
Feature Remark 2 (Solvers). JuMP allows to easily communicate with a wide range of solvers. Per default, POMATO will install and use the open CLP solver 8 . However, if available on the user's system, POMATO can be configured to use commercial solvers like Mosek 9 or Gurobi 10 .

Data Management and Pre-Processing
POMATO's central Data-Management layer, see Figure 1, manages the functionality of the model core by providing data and model parametrizations, calling and monitoring the Julia processes, and validating their results. To enable flexible data-handling that avoids redundant calculations, we leverage Python and its object-oriented programming paradigm which resolves issues typically related to static scripts. In such linear approaches, e.g. in GAMS, all parameters are handled in the global scope of the program so that any desired conditional functionality renders the code overly complex and hard to maintain. Alternatively, encapsulating the required functionally in different objects (modules), ensures data consistency and compatible methods.
The data-management layer consists of four main modules, DataManagement, GridTopology, GridModel and MarketModel. These modules are created once in every instance of POMATO and each provides specific methods to the user-interface and other modules. Additionally, single-use modules are used for result processing, e.g. FBMC calculations and result visualization. DataManagement is the central module to handle all data and their corresponding options. All input data is validated with respect to predefined data structures that are required to run the desired market model and are made available to other modules. Due to the persistence of DataManagement, changes in data, e.g. from user manipulations or model results, are propagated throughout POMATO.
Pre-processing and validation of data related to the transmission network topology requires specific methods that are collected in the GridTopology module. It uses nodes and lines data and provides the parameters for subsequent power flow calculations. Additionally, GridTopology verifies the properties of the network graph, sets reference nodes for multiple disconnected networks, creates contingency scenarios and manages settings of phase shifting transformers.
The verified and pre-processed data is then used by the GridModel and MarketModel modules to provide the input data for the model core. Based on the market model that is desired from the user (and that is feasible given the available data), GridModel uses the data provided from GridTopology and DataManagement to compile the correct grid representation with all physical properties. This includes the parametrization of the network constraints, as discussed in Section 2.1 above, as well as generator locations, cost models, and zonal configurations. Also, GridModel calls RedundancyRemoval in the process of compiling the set of parameters for a N-1 secure dispatch. If this algorithm has been performed in previous runs, GridModel loads available parameters to avoid time-consuming re-runs. These parameters define the constraints under which the market has to be cleared. Finally, MarketModel collects these constraints and manages the required model runs. After the optimization in the model core has obtained an optimal solution, MarketModel instantiates a new Results object in the DataManagement module. Communication between the POMATO instance and the mathematical core is achieved via a threaded process within the JuliaDaemon module, see Remark 4.
The decoupling of model runs and data processing allows to efficiently solve multi-stage market clearing processes that iterate between different market model configurations. Two relevant examples are itemized below.
Ex. 1 -Redispatch Analysis: Zonal electricity markets are cleared as a single price zone without any internal network constraints. In a second stage, potential transmission line overloads are rectified by out-of-market CM measures, i.e. redispatch. For this purpose, a second model run with nodal resolution is required.
Ex. 2 -FBMC: FBMC uses a forecasted nodal dispatch (base case) to derive zonal PTDF matrices that establish the relation between zonal netpositions and flows on critical network elements (CBCOs, critical branches under critical outages). The resulting feasible region of net-positions with respect to the technical limits of the CBCOs are called FBMC domains. These domains are used to solve the zonal market clearing that is then corrected by subsequent CM measures. To automatize the necessary re-parametrization of parts of the model data, including the generation of the FBMC domains depicted in Figure 2, and re-runs of the optimization model, the additional FBMCModule has been implemented.
Feature Remark 3 (Contingency Scenarios). Alternatively to a strict N-1 contingency analyses, i.e. protecting the system against the outage of every single transmission line, the user can specify customized contingency scenarios. Such scenarios can either ignore certain lines as potential contingencies or define contingency groups of outages that are likely to occur simultaneously, e.g. parallel lines.
Feature Remark 4 (Python-Julia Interface). Communication between the Julia language and Python is implemented by a JuliaDaemon class that maintains a threaded Julia program and executes its functions when requested by MarketModel or GridModel. Instructions are transferred via json files that are written to the POMATO package folder. This way, the Julia process has to be started only once and remains alive after a model is completed, which allows fast re-solving of a model with different parameters.

User Interface
All modules of the data processing layer presented in previous Section 2.2 are attributed to the overall POMATO object, which provides a comprehensive set of functions to the user. Although the methods of the lower level modules are accessible to the user, the POMATO module provides predefined methods for the typical use cases of this program. A brief overview is presented in the illustrative application in Section 3. Additionally, POMATO provides a collection of visualization features. The GeoPlot module shows market and redispatch results including prices on an interactive map using the Bokeh 11 library. Additionally, many results, such as the FBMC domains, can be automatically plotted as a collection of 2D diagrams.

Publication
POMATO is available under the LGPLv3 license on GitHub including a comprehensive documentation, [16,17]. The repository also includes exem-plary data-sets that cover the core functionality. These include a data-set for the German power system, that has been compiled to showcase POMATO's functionality, as well as the NREL 118 bus network, [24], and Matpower case files. More details on how to create custom data-sets can be found in the accompanying documentation 12 .
Feature Remark 5. (Installation) POMATO requires Python and Julia to be installed. Installation of the Python modules is managed via pip 13 . If a working Julia distribution is detected on the system, the two Julia packages, MarketModel and RedundancyRemoval are automatically pulled from their separate repositories and installed during this process.

Illustrative Application
This section illustrates the application of POMATO and the corresponding example code is shown below. After importing the POMATO module (1), a new POMATO class is instantiated in 3 with the requested working directory (wdir) and an options file in the JSON 14 format that configures the model run. In this example the options file specifies a zonal market clearing and subsequent redispatch with redispatch-cost and model horizon: {"optimization": { "type": "dispatch", "model_horizon": [0, 168], "redispatch": { "include": true, "cost": 50}} A comprehensive list and descriptions of possible configurations can be found in the online documentation 15 . In 4 the POMATO object loads the required data, which automatically instantiates the data management objects as described in Section 2.2 above. The command in 6 creates the grid representation for the specified model run and 7 starts the actual model run. After successful completion, two Results are instantiated into DataManagement and are available to the user (9) for further analysis, e.g. to check for overloaded lines with and without contingencies (11)(12)(13)(14)(15)(16)(17)(18)(19)(20). Finally the GeoPlot is created in 22 which yields Figure 3. Execution time of this example is about 7.5 minutes, including data readin, Julia start-up, solving both the market-and the redispatch problem, as well as the final result analysis and plotting. Computation times of subsequent runs will be shorter due to already active Julia process.

Conclusion and further development
This paper presents a tool that aims to enable the broad analyses of zonal electricity markets. The proposed Power Market Tool POMATO is open-source, provides essential data-sets and comprehensive online documentation. Central to POMATO's functionality is its ability to synthesize the flow-based market-coupling (FBMC) process. Further POMATO includes a 14 www.json.org 15 pomato.readthedocs.io/en/latest/options.html redundancy removal algorithm that enables security constrained (N-k) dispatch with feasible computation times. While the current version of PO-MATO already includes prototypical options for the analyses of stochastic (chance-constrained) market clearing, extensions to stochastic and risk-aware markets and power flow analyses along the lines of [22,23] are subject to ongoing development. Figure 3: GeoPlot of market-and redispatch result for Germany. Red and green circles indicate negative and positive changes in generation schedules, respectively, due to redispatch. Change magnitude are proportional to the circles' radius. Line colors indicate average line load where green is low loads and red is high load. Prices as dual multipliers on the nodal power balances of the redispatch run are indicated by the contour plot overlay.

Conflict of Interest
We wish to confirm that there are no known conflicts of interest associated with this publication and there has been no significant financial support for this work that could have influenced its outcome.