OpenTEPES: Open-source Transmission and Generation Expansion Planning ✩

The expansion of the transmission network will be a key enabler of the energy transition. However, the high level of technical detail involved in network studies, where a DCPF and the consideration of discrete investment are necessary, meant that it was accessible only to very specialized researchers. OpenTEPES changes the picture by providing an open-access tool with full functionality. OpenTEPES determines the investment plans for new power facilities (generating units and lines) necessary to supply future demand at minimum cost. OpenTEPES represents hierarchically the different time scopes involved in the planning decisions, from the medium to the very long term. It includes the uncertainty related to system operation, such as the availability of renewable energy sources and electricity demand, and multiple criteria such as investment cost or carbon emissions. OpenTEPES is a flexible tool that has been applied to planning projects in a European context. It has been developed as part of the H2020 project OpenENTRANCE and is now available open-source for the energy planning community.

former: although many GEP models exist this is not the case in TEP. We refer the reader to [3] for a review of energy planning models and to [4] for a review of existent TEP models, and to the Impact section for an updated summary of the most relevant ones.
However, even if not many models are available, the transmission network is the bridge between generation and distribution, and it plays a pivotal role in the power system. TEP, the expansion of the network that carries power from generation plants to demand centres, is increasing in relevance in the past few years: the growth in renewable penetration is set to continue [2][3][4]: Europe aims at a +30% energy efficiency and a +27% in renewables, cutting emissions by 40% by 2050 [4][5][6]. In the US, a similar role is provided by the Renewable Portfolio Standards, which introduce state-dependent renewable targets [5]. These renewables can be located far away from current generation or demand centres, which creates a need for additional transmission infrastructure. Besides, the need for tighter market integration calls for the expansion of cross-border capacity. This means that the next couple of decades should see very relevant investments in transmission capacity.
In addition, grid reinforcements serve the function of alleviating congestions in the power system, which leads to price differences between zones. Congestion can happen between different countries or regions or within them. Transmission infrastructure can also improve the reliability of the power system, as it can increase the security of supply by providing alternative paths for power flows in the event of failures. It can also reduce network losses. The authors refer to their publication [6] for a recent, exhaustive review on TEP and its challenges.
When performing energy planning, it is not sufficient to consider the expansion of generation: we need to incorporate the idiosyncrasies of the network. Current tools for doing so are either proprietary or do not have an appropriate level of modelling detail to really capture network dynamics. In particular, although there are many tools that perform energy planning at a general level, they all consider the transmission grid at a very rough level: only Net transfer Capacities (NTCs) between regions are considered, and the physics of power flows are ignored, with only a transportation model defining the exchanges between regions. In addition, the transportation model between regions allows for linear investments, which is also far from reality: transmission lines can only be installed in discrete capacities and this has an important effect on the system. However, as recognized in the power system literature, this is not enough to accurately capture the dynamics of transmission investment. It is necessary to include at least a DCPF and discrete investments at the planning stage and, later, refine the transmission expansion plans obtained from optimization by simulating several operation conditions in an even more detailed ACPF (where nonlinearities mean that, although it can be simulated, cannot be adequately handled in optimization) [6][7][8]. This means that, if there is a need to calculate network reinforcements, a general energy planning model will need to be used in conjunction with a more accurate model for the transmission system. However, until now, only proprietary models could play this role.
openTEPES provides the first open-access model that performs TEP together with GEP while considering the details of the network: DCPF and discrete investment. We refer to the Significance section for a detailed account of the most relevant planning tools and their relative advantages and disadvantages.
OpenTEPES is the open-access evolution of TEPES (Transmission Expansion Planning for an Electric System), a commercial version developed by Universidad Pontificia Comillas and used in a long list of planning projects. OpenTEPES retains the main functionalities of TEPES while providing open access to its code and data. It was developed as part of the European project openENTRANCE, which has the mission to make energy systems tools available to modellers at a European scale. The high level of technical detail involved meant that these types of studies used to be accessible only to very specialized researchers. OpenTEPES changes the picture by providing an open-access tool with full functionality.

Software description
OpenTEPES has been created using Python 3.7.4 and Pyomo 5.6.6 and uses a csv format for its inputs and outputs. It can be customized to use a licenced solver o an open-source alternative. By default, it uses Gurobi 8.1. as a MIP solver. Currently, openTEPES does not support MacOS.
This section describes its inputs and outputs as well as the main features of the model.

Software architecture
Give a short overview of the overall software architecture; provide a pictorial component overview or similar (if possible). If necessary, provide implementation details .
The overview of the openTEPES model is shown in Fig. 1. Where the red boxes (openTEPES_Main.py and openTEPES.py) are the management scripts, the blue boxes correspond to the scripts that read data, define parameters, variables, and constraints, whilst the yellow box receives the model and sends it first to the solver and then back to the management script. The green box collects results and creates the output files in CSV format. In addition, this section describes concisely the inputs and outputs of the model. The full list of inputs and outputs can be found at the user guide.

Metadata:
The python code was made trying to follow the PEP 8 recommendations. Likewise, all the callbacks of the functions were linked through a file ''_init_.py'', which declared all possible functions defined in the scrips shown previously. In addition, we define userfriendly instructions in the "openTEPES_Main.py" script to request the user the case study's path, the name of the case study, and the solver chosen to solve the problem. The "openTEPES.py" script is used to define the execution order of the functions, reading the input files and saving the output results into CSV files. Furthermore, the "openTEPES.py" script defines the concrete model called ''openTEPES'' using pyomo, which will comprise parameters, variables, and constraints.

Input Files:
The files used for input of the data are briefly described in Table 1.

openTEPES_InputData.py:
This script is divided into two main functions: Processing data and definition of the model's input data. The first one is about reading the data from the CSV files and transforming the data to pandas dataframes. The second one uses the data transformed in dataframes to set up the parameters and variables objects of the model. Note that objects such as ''Param'' and ''Var'' are used to define the parameters and variables of the concrete model, respectively.

openTEPES_ModelFormulation
This script is divided in multiple functions that focus on groups of constraints. The complete function and its respective constraints are illustrated in Table 2. Note that the mathematical formulation of each constraint can be found in [2].

openTEPES_ProblemSolving.py:
This script is used to set up the solver options as well as to the definition of the action to send the model to the solver and recover its solution (that is, ''run the model''). In addition, if the use of discrete variables is activated, this script executes the model a second time in order to get the dual variables.

openTEPES_OutputResults.py:
This script obtains the solution of the problem. It means to get the optimal value from the variable objects and transform it using pandas dataframes in order to be saved in csv files.

Output Files
The files used for output of the data are briefly described in the following OpenTEPES takes the input data, applies the mathematical formulation found in the user's guide, and populates the output files with the optimal expansion solution and the complete information about the system's operation across scenarios. All input files can but must not be filled. This means that all inputs that were not populated by the user will not be considered by the expansion (i.e., if no data for storage are provided, then storage will not be included).

Installation checker
The OpenTEPES can be installed via the instructions in [1]. Moreover, the repository comprises a workflow to test the installation. The workflow uses the known GitHub Action called ''Python Package using Conda''. It comprises a build-in Linux and Windows for users that follows the next steps: -Set up job sets up the operating system, virtual environment, workflow directory as well as the downloading of the repository.
-Run actions/checkout@v2 synchronizes the repository, choosing the git version and determining the checkout information in the virtual environment.
-Set up Python 3.8|3.9 sets up Python 3.8 and 3.9 in parallel.
-Add conda to system path: It sets up conda as an environment variable, pointing to the root of the miniconda directory.
-Install dependencies installs all the packages needed to run python, conda and openTEPES with its workflow.
-Run the test code runs the openTEPES code.
-Lint with flake8 installs flake8 and its dependencies. Flake8 is used to determine the lint of the code that is also called ''lint code''.
-Post Run actions/checkout@v2 cleans all installation made to test the installation of the openTEPES.
-Complete job cleans up any orphan processes.

Software functionalities
OpenTEPES is a decision support system for defining the generation and transmission expansion plan of a large-scale electric system at a tactical level, defined as a set of generation and network investment decisions for future years. The candidate generators, ESS and lines are pre-defined by the user, so the model determines the optimal decisions among those specified by the user.
It determines automatically optimal expansion plans that satisfy simultaneously several attributes. Its main characteristics are: • Flexible time definition: the scope of the model corresponds to a single year at a long-term horizon, 2030 or 2040 for example. It represents hierarchically the different time scopes to take decisions in an electric system, with periods that are usually defined as one year and load levels that can be hourly. This time division allows a flexible representation of the periods for evaluating system operation. For example, by a set of non-chronological isolated snapshots or by 2920 periods of three hours or by the 8760 h of the year.
• Stochastic: several stochastic parameters that can influence the optimal generation and transmission expansion decisions are considered. The model considers stochastic short-term yearly uncertainties (scenarios) related to the system operation. The operation scenarios can reflect different conditions in renewable energy availability and electricity demand.
• Multicriteria: the objective function incorporates some of the main quantifiable objectives: generation and transmission investment cost (CAPEX) and expected variable operation costs (including generation emission cost) (system OPEX).
The model formulates an optimization problem including generation and network discrete investment decisions and operation decisions.
The operation model is a network constrained unit commitment (NCUC) based on a tight and compact network unit commitment (UC) model including operating reserves with a DC power flow (DCPF). Network ohmic losses are considered proportional to the line flow. It considers different energy storage systems (ESS), e.g., pumped-storage hydro, battery, etc. It allows to analyse the trade-off between the investment in generation/transmission and the use of storage capacity.
The outputs of the model include: • Investment: investment decisions and cost.
• Operation: the output of different units and technologies (thermal, storage hydro, pumped-storage hydro, RES), RES curtailment, line flows, line ohmic losses, node voltage angles.
• A careful implementation has been done to avoid numerical problems by scaling parameters, variables and equations of the optimization problem allowing the model to be used for large-scale cases.

Illustrative examples
We include three case studies which can be downloaded from [2], as an example of the functionalities of openTEPES: a small, illustrative case study (9n), a realistic one (sSEP), and a modified single are of the RTS case. We include a brief description of the illustrative case study, the number of variables, constraints and nonzeros after the presolve that comprises the model, as it is shown in Table 3. These problems consider a time step equal to 4 (4-hour resolution) for a year of 8736 h and are solved using Gurobi optimizer version 9.1.2 with an academic licence, whose installation process is indicated in [1].
The full details of both cases can be found in the attached files. The illustrative case study is based on a case with 9 nodes that has been adjusted to represent the country of Spain. Some charts showing the final network expansion (showing new lines in purple) and the final hourly productions by technology are included below. The full information of the case study can be found in the attached files (see Figs. 2-5).
As can be seen, openTEPES is able to run detailed case studies and include all the relevant details for the generation and transmission models and present their results in a user-friendly, clear and detailed manner.

Impact
OpenTEPES allows to perform an optimal expansion of the transmission network and the generation system while considering the full detail of the operation of the system and the physics of power flows, using a DC model and considering discrete investment.
The range of models available to perform transmission expansion planning has increased in the last few years. Initially, the tools available for planning studies were focused on the detailed analysis of specific expansion plans which were defined manually by the planner. This includes software such as DSATools, PowerWorld , PSLF, PSS/E, PSAT and Matpower. These classical tools can calculate the resulting power flows and, in most cases, also contingency analyses, transient stability, signal stability or voltage stability. See [4] for a detailed review. However, they do not perform automatic, optimal TEP. The range of tools that undertake automatic TEP is very limited compared to the ones that carry out Generation Expansion Planning. However, in some cases there are integrated tools that combine GEP with a simplified version of TEP.
The most relevant ones are PLEXOS and TIMES. PLEXOS is a proprietary model which performs GEP, TEP and a version of a Security-Constrained Unit Commitment [9]. PLEXOS considers several investment horizons in a dynamic manner and captures hydro reservoir management. However, the version of TEP it includes considers only the expansion of the Net Transfer Capacity (NTC) of corridors among zones, which can be country-level regions or large regions defined within a country. The consideration of power flows is that of a transportation model: given the low granularity of the network modelling, it does not make sense to include a more sophisticated version of the power flow equations. TIMES, from the MARKAL family of models developed by IEA-ETSAP, is a very similar tool that can model the full energy system with a high level of detail in terms of the technologies included or the types of demand and their interactions [10]. TIMES is not open source, but it is freely available. However, Veda, the most commonly used interface with  TIMES, is proprietary software. In the same way as PLEXOS, the network model included in TIMES is a rough simplification based on a transportation model.
OSeMOSYS, is an open-source tool that was created with the energy modelling community as a target. It has a very similar profile to PLEXOS or to TIMES in its versatility but has the advantage of being open source [11]. Equivalently, its description of the network works at the NTC level, so that the tool is not sufficiently detailed to produce accurate transmission expansion plans. EMPIRE, created by SINTEF/NTNU [12], is another interesting example of energy planning which, along the same lines, considers GEP and storage investments. The consideration of TEP is also performed by an approximate approach, which considers, as in the other tools reviewed, the expansion of the NTC of corridors between regions and continuous investment. EMPIRE started being a proprietary model, but an open version was developed as part of the project openENTRANCE [13,14].
GENeSYS-MOD is another example of open software that has been included in the project openENTRANCE [14]. GenesysMod is an integrated model that considers electricity, heat and transportation, and performs optimal GEP and optimizes also the deployment of storage and some other infrastructure. The consideration of transmission is the same as in the previous models: the NTC between zones can be expanded in a continuous manner but more details about the physics of power flows are missing.
Switch-Model is a similar open-source tool with an emphasis on high shares of renewables [15]. Its description of the network is no more accurate than the previous ones.
At the other side of the spectrum, NetPlan, created by PSR [16] focuses on optimizing only the network without any consideration to generation or storage, but with a higher level of detail. It does consider nodes and discrete investment in lines among them, with a DCPF in a stochastic setting. However, this tool is proprietary.
As described in the literature review section, calculating accurate expansion plans in terms of transmission infrastructure is key when dealing with large increases in generation capacity far away of demand centres, when the penetration of renewables is high -as geographical imbalances in a zone can be balanced by exports and imports -or, simply, when grid congestions are relevant. If a good picture of transmission infrastructure is required, a DCPF and the consideration of discrete investment becomes necessary.
openTEPES is therefore the only tool that, in an open source context, can perform detailed transmission expansion planning, at a nodal level. It considers a discrete investment with a DCPF rather than merely increasing NTC between regions in a transportation model. In this, it is a model that is comparable to NetPlan, but it is open-source. Moreover, openTEPES also considers the expansion of generation and storage, which makes it more similar to other energy models such as EMPIRE or GENeSYS-MOD, which do not include a detailed description of the network. OpenTEPES is intended to be used for the community of energy modellers at the European Energy Modeling Platform, although we envision it. will be useful outside of this region (for instance, to perform co-ordinated GEP/TEP studies in the U.S.) TEPES/openTEPES has been used in a long list of projects over more than a decade. The list includes: openENTRANCE (H2020), SET-NAV (H2020), KSA as an energy exporter: the future of electricity networks (MIT), e-Highway (7FP), Estimating costs of renewable energies compared to conventional energy sources up to 2030 and beyond (Fraunhoffer ISI), Beyond2020 (7FP), Pre-feasibility analysis on power highways for the Europe-MENA region integration in the framework of the Dii Rollout Plan 2050 (Desertec Industrial Initiative).
openTEPES reflects the experience that Comillas has acquired through the projects above, and which have been reflected in the publications below. A full and periodically updated list of publications can be found at the model website.
In the following paper, we present the relevance of transmission expansion planning in the energy transition and discuss the main factors that affect it:

Conclusions
OpenTEPES is a flexible tool that provides access to a state-of-the-art energy transmission network planning tool, which can be used by modellers in a local, national or regional context in an efficient manner. The tool has been developed in the context of the H2020 project openENTRANCE and stems from a rich tradition of network planning work developed by Universidad Pontificia Comillas, which includes both academic contributions and the reality of practical projects.
Although several energy planning models are openly available, this is not true in the context of transmission expansion, where the existing tools either are very coarse grained, with no consideration of the details of the network and the physics of power flows, or are proprietary. OpenTEPES contributes an open-source tool that energy planners can use to plan the transmission network as well as the expansion of generation, together with other infrastructure such as storage. It considers a DCPF and discrete investment. In addition, it incorporates uncertainty in the form of long-term scenarios and short-term uncertainties, so that planning can be realistic also in its consideration of uncertainty.