scieee AI-readable full text Open interactive document viewer

Power flow tool for active distribution grids and flexibility analysis

Ferran Aymamí, Marçal,Ferran Aymamí

Abstract

The effects of the energy transition are leading towards energy models in which decentralized generation is a reality and a source of debate at the time of planning, assessing the risks and optimizing its performance. One of the implications of this trend is the need to test multiple scenarios and configurations in the environment in which the decentralized generation is being deployed: the distribution network. This thesis is aimed at dealing with such need by proposing a tool based on the pandapower library (python) to offer more automation, customization and graphic capabilities during the process of creating networks, testing different scenarios using power flow analysis and obtaining a clear visual output via graphs and heatmaps. It has been sought to use open source code, as python and its libraries are, not tied to any commercial restrictions and making the tool as generic as possible. However, a comparison against Matpowerpackage (Matlab), endorsed with decades of use, is carried along the thesis to provide more robustness to the output. The tool will be able to read separate network elements’ data in a standard format (.csv) and assembling them internally as a network, making the tool independent in terms of size. In the same direction, it will include different menus to allow fast addition of elements or flexibility measures providing easiness of use and saving time for the user. Finally, it will account with heatmaps and schematic representations of the network that will help to identify common flexibility issues such as overloaded lines or voltage deviations

Full text

Master Thesis Master in Energy Engineering (MUEE) Power flow tool for active distribution grids and flexibility analysis Autor: Marçal Ferran Aymamí Directors: Íngrid Munné Collado i Mònica Aragüés Peñalba Call: 04/2021 Escola Tècnica Superior d’Enginyeria Industrial de Barcelona Power flow tool for active distribution grids and flexibility analysis 3 Abstract The effects of the energy transition are leading towards energy models in which decentralized generation is a reality and a source of debate at the time of planning, assessing the risks and optimizing its performance. One of the implications of this trend is the need to test multiple scenarios and configurations in the environment in which the decentralized generation is being deployed: the distribution network. This thesis is aimed at dealing with such need by proposing a tool based on the pandapower library (python) to offer more automation, customization and graphic capabilities during the process of creating networks, testing different scenarios using power flow analysis and obtaining a clear visual output via graphs and heatmaps. It has been sought to use open source code, as python and its libraries are, not tied to any commercial restrictions and making the tool as generic as possible. However, a comparison against Matpower package (Matlab), endorsed with decades of use, is carried along the thesis to provide more robustness to the output. The tool will be able to read separate network elements’ data in a standard format (.csv) and assembling them internally as a network, making the tool independent in terms of size. In the same direction, it will include different menus to allow fast addition of elements or flexibility measures providing easiness of use and saving time for the user. Finally, it will account with heatmaps and schematic representations of the network that will help to identify common flexibility issues such as overloaded lines or voltage deviations. Power flow tool for active distribution grids and flexibility analysis 5 Table of contents MASTER IN ENERGY ENGINEERING (MUEE) ........................................................................................ 1 ABSTRACT .................................................................................................................................................... 3 TABLE OF CONTENTS ................................................................................................................................ 6 1. INTRODUCTION ................................................................................................................................. 11 1.1. OBJECTIVES..........................................................................................................................................12 1.2. SCOPE ..................................................................................................................................................12 1.3. STATE OF THE ART ...............................................................................................................................12 2. COMMON ELECTRICITY POWER SYSTEM DESCRIPTION ........................................................ 15 2.1. BRIEFING ON ELEMENTS AND SCHEME .................................................................................................15 2.1.1. GENERATION ........................................................................................................................................16 2.1.2. DEMAND AND CONSUMPTION ..................................................................................................................18 2.1.3. TRANSMISSION AND DISTRIBUTION ...........................................................................................................19 3. ELECTRIC POWER SYSTEM FLEXIBILITY .................................................................................... 22 3.1. STORAGE ..............................................................................................................................................23 3.2. DEMAND-SIDE MANAGEMENT ..............................................................................................................25 3.3. ADDITIONAL RESERVE CAPACITY ........................................................................................................26 3.4. RETROFITTING OF EXISTING FACILITIES ...............................................................................................26 3.5. ANCILLARY SERVICES ...........................................................................................................................27 3.6. FLEXIBILITY IN DISTRIBUTION NETWORKS ............................................................................................28 3.6.1. DISTRIBUTED ENERGY RESOURCES PENETRATION IN THE MV LAYER ...........................................29 4. POWER FLOW ANALYSIS ................................................................................................................ 32 5. SELECTED APPROACH AND ANALYSIS TOOLS ........................................................................ 37 5.1. PANDAPOWER ......................................................................................................................................37 5.1.1. ELEMENTS MODELS’ AND DESCRIPTION ...........................................................................................40 5.2. BRIEFING ON OTHER ANALYSIS TOOLS .................................................................................................45 5.3. CASE COMPARISON ..............................................................................................................................47 6. TOOL PROPOSAL FOR AUTOMATION AND CUSTOMIZATION OF BASIC SCENARIO TESTING ...................................................................................................................................................... 58 BUDGET ....................................................................................................................................................... 83 ENVIRONMENTAL IMPACT ...................................................................................................................... 84 CONCLUSIONS ........................................................................................................................................... 85 ACKNOWLEDGEMENTS ........................................................................................................................... 86 BIBLIOGRAPHY .......................................................................................................................................... 87 Power flow tool for active distribution grids and flexibility analysis 7 List of figures Fig. 1: EPS overall scheme [2]. ............................................................................................................. 15 Fig. 2: a) Conventional thermal plant shceme. [10] b) General wind turbin system and control scheme. [11] ......................................................................................................................................................... 17 Fig. 3 a,b,c: double-circuit towers of 110-150, 220-275, 400-500 kV respectively. d,e,f: single-circuit towers in triangular, delta and horizontal formation respectiely [12]. .................................................... 19 Fig. 5: European transmision system. ENTSO-E. ................................................................................. 20 Fig. 4: Example of a meshed configuration. [17] ................................................................................... 20 Fig. 6: Example of a radial configuration. [17]. ...................................................................................... 21 Fig. 7: Inherent primary (potential) source of flexibility by country with the maximum share of wind power (red). Source: [29] Citing Yasuda, Y. 2013. “Flexibility Chart: Evaluation on Diversity of Flexibility in Various Areas.” .................................................................................................................. 22 Fig. 8: Storage technologies by discharge capacity and discharge time. Source: [21] ......................... 23 Fig. 10: Sources of flexibility by type and cost. Source: [20]. ................................................................ 28 Fig. 10 Example network composed by 5 buses (numbers 1 to 5) with 2 generators (buses 1 and 5) and 4 loads (buses 2, 3, 4 and 5).[11] ................................................................................................... 32 Fig. 11 Power flow initial variables briefing. Source: [20] ...................................................................... 33 Fig. 13: Addmitance mattrix shape ........................................................................................................ 35 Fig. 14: Line parameters stored in a table type structure. ..................................................................... 38 Fig. 15: Schematic example of the pandapower network stored data tables. Source: [16]. ................ 39 Fig. 16: Net dictionary containing result data from a PF. ...................................................................... 39 Fig. 17: Bus equivalent circuit Source: [17]. .......................................................................................... 40 Fig. 18: Minimal defining parameters for bus creation in pandapower. Source: [17] ............................ 41 Fig. 19: From left to right and downwards; ‘T’ model transformer, ‘Pi’ model transformer and three 2- winding transformers in ‘wye’ connection. Source: [17] ........................................................................ 42 Fig. 20: Load as PQ bus scheme represented in pandapower. ............................................................ 43 Fig. 21: Generator as PV bus scheme. Note the phasor is pointing inversely as the injection sign is negative. Source: [17]. ........................................................................................................................... 44 Fig. 22: Summary table of key features about pandapower and other tools. Source: [15]. .................. 45 Fig. 23: Matpower casefiles power flow speed comparison .................................................................. 46 Fig. 24: Case4gs briefing and bus data. ................................................................................................ 47 Fig. 25: Plot of the case4gs net using Plotly library. ............................................................................ 47 Fig. 26: Loading an included case with Pandapower. ........................................................................... 48 Fig. 27: Definition of the elements and parameters to replicate case4gs. ............................................ 48 Fig. 28: Bus and external grid results after pf........................................................................................ 49 Fig. 29: Generation and load results after pf. ........................................................................................ 49 Fig. 30: Line results after pf. .................................................................................................................. 50 Fig. 31: Expanded view of the line results dataframe. .......................................................................... 50 Fig. 32: Bus and external grid results for the inbuilt Case4gs after pf. ................................................. 52 Fig. 33: Generation and load results for the inbuilt Case4gs after pf. ................................................... 52 Fig. 34: Line results for the inbuilt Case4gs after pf. ............................................................................. 52 Fig. 35: Matpower case structure of case4gs() showing bus data. ....................................................... 55 Fig. 36: Matpower bus results data structure. ....................................................................................... 55 Fig. 37: Change of resolution to carry deviation analysis. ..................................................................... 55 Fig. 38: Matpower bus results after pf with 9 decimal positions. ........................................................... 56 Fig. 39: Matpower branch results after pf with 9 decimal positions. .................................................... 56 Fig. 40: Structure of the element creation automation. ......................................................................... 59 Fig. 41: CSV example where ‘X’ contains the parameters of the element and ‘Y’ contains each different element of the same type. ....................................................................................................... 60 Fig. 42: Use of the net reader tool to replicate save the structure of the c4gs net. The time is recorded at the bottom of the figure...................................................................................................................... 60 Fig. 43: Heatmap with legend showing the line loading, the losses and the power injected in evey line. ............................................................................................................................................................... 62 Fig. 44: Isolated heatmap showing the line loading (%) avoiding scale interference with other different magnitudes. ........................................................................................................................................... 62 Fig. 45: Case 4gs network plotted with and without geocoordinates (left and right respectively). ........ 63 Fig. 46: Case IEEE 24-bus rts network plotted with and without geocoordinates (left and right respectively). ......................................................................................................................................... 63 Fig. 47: Power flow results plotted over network scheme. .................................................................... 64 Fig. 48: Example of the menu implemented. ......................................................................................... 65 Fig. 49: IEEE-33 Network data. ............................................................................................................. 66 Fig. 50: IEEE-33 Network scheme. ....................................................................................................... 66 Fig. 51: IEEE-33 bus results power flow. .............................................................................................. 67 Fig. 52: IEEE-33 Branch/line results . ................................................................................................... 68 Fig. 53: Heatmap showing line loading percent, losses and power through line. ................................. 68 Fig. 54: Active and reactive losses of the system under nominal conditions. ....................................... 69 Fig. 55: Heatmap of bus voltage (pu) over bus index ........................................................................... 70 Fig. 56: Power flow bus results with increased scattered loads and voltage violated buses (5% threshold). .............................................................................................................................................. 71 Fig. 57: Line results with increased scattered loads scenario. .............................................................. 72 Fig. 58: Power flow results over network scheme. ................................................................................ 72 Fig. 59: System losses (scattered increased loads scenario). .............................................................. 73 Fig. 60: Heatmap of active losses (MW) per line index. ........................................................................ 73 Fig. 61: Menu to enhance the speed at testing with shunt capacitors. ................................................. 74 Fig. 62: Power flow before applying shunt capacitors (left) and power flow after shunt capacitors have been deployed (right) ............................................................................................................................. 75 Fig. 63: Power flow bus results after DER penetration scenario. .......................................................... 76 Fig. 64: Power flow bus results after DER penetration scenario. .......................................................... 77 Fig. 65: Heatmap showing line loading percent, losses and power through line. ................................. 78 Fig. 66: Heatmap showing line loading percent at scale. ...................................................................... 78 Fig. 67: Heatmap showing active power losses at scale. ...................................................................... 78 Fig. 68: Power flow results over topological shceme showing the overloading in line 0. ...................... 79 Fig. 69: Menu implemented for automatic allocation of storage systems. ........................................... 80 Fig. 70: Heatmap showing net status after placing 5 MW storage systems. ........................................ 80 Fig. 71: Power flow results over topological shceme showing restored lines overload after storage deployment. ........................................................................................................................................... 81 Fig. 72: Line losses with adapted scale. ................................................................................................ 81 Power flow tool for active distribution grids and flexibility analysis 9 List of tables Table 1: : Briefing with some of the storage technologies’ characteristics. Source: [21] ...................... 24 Table 2: Average execution time of the case4gs from scratch. ............................................................ 51 Table 3: Average execution time of the inbuilt case4gs. ....................................................................... 53 Table 4: Bus results deviation. .............................................................................................................. 53 Table 5: Ext. grid results deviation. ....................................................................................................... 54 Table 6: Line results deviation. .............................................................................................................. 54 Table 7: Results’ relative deviation. ....................................................................................................... 54 Table 8: Average execution time of the inbuilt case4gs. ....................................................................... 56 Table 9: Bus and generation results deviation (Matpower vs Pandapower). ........................................ 57 Table 10: Branch results defiavion (Matpower vs Pandapower). .......................................................... 57 Table 11: Time records (avg.) as nº of buses increase and efficiency.................................................. 61 Table 12: Distributed loads data. ........................................................................................................... 70 Table 13: Distributed generation data. .................................................................................................. 75 Table 14: Project associated costs. ....................................................................................................... 83 As seen in Fig. 1, the generation plants produce an output which will be raised in voltage as soon as it leaves the facility to be transmitted with the least possible losses. However, some consumers will be fed directly in such High Voltage (HV) layer due to the energy intensity of their own activities (metallurgic foundry, construction material facilities, etc) which require a high power demand. The same happens to the Medium Voltage (MV) consumers, which are fed at their own interest between 1 and 45 kV or, even some specific generation technologies such as Photo Voltaic (PV) plants, wind farms or Combined Heat and Power (CHP), which can inject their distributed power generation directly in the MV layer due to its proximity and size [8]. The power lines of both layers (HV and MV), despite carrying the same task have different configurations as their approach is slightly different. In one hand the HV layer’s primary task is to transmit high amounts of power to long distances with reliability, thus meshed configurations are chosen to reach that goal rather than radial, which are used in MV layers to spread along the territory to reach the maximum number of users as its voltage and power steps down across the different transformation spots. These configurations will be briefly commented on the section “Transmission and distribution”. 2.1.1. Generation The electricity production relies on different kind of centers that include classic (conventional) power plants which transform primary sources such as coal, gas, nuclear fuel or residues into electric energy via thermodynamic cycles involving steam or/and gas turbines. Along with the classic or traditional technologies we found a range of renewable or cleaner stations, in growing pressence in the power systems around, which rely on renewable sources such as sunbeams, wind, geothermic energy or tidal energy among others to provide the electricity supply. Both of them, conventional and renewable power stations must provide its electric output in a very specific magnitudes of waveform (sinusoidal), three-phase signal with standarized frequency and amplitude (which have to be controllable) [8]. Generally, the conventional power plants which produce a large thermal inertia on their boilers, reactors or turbine exhausts have longer times of readiness and cannot be disconnected and reconnected with ease for demand matching purposes [16]. They rely on primary, secondary and tertiary control blocks which allow different time responses to demand variations, nonetheless with scale limitations (e.g. a combined cycle power plant with 3 turbines of 100 MW each will not be able to produce 112 MW sustained, but 40 to 102 Power flow tool for active distribution grids and flexibility analysis 17 MW x 3 approximately). The layout of a conventional thermal plant (the common part Fig. 2) is generally formed by a boiler or heat source, the piping network, the pumping system, the steam or/and gas cycle (containing the turbine stage and the condenser) and, finally, the generator. Fig. 2: a) Conventional thermal plant shceme. [10] b) General wind turbin system and control scheme. [11] The main differences will rely on the heat source, be it coal, nuclear energy, gas-fired or even solar concentration technologies, which accounts for renewable sources but, in essence, share the same thermodynamic cycle and elements. On the other hand, the hydro technologies are classified also as conventional but rely on water turbines which take advantage of the head 3 of rivers and dams to transform the energy of the water flow into mechanical energy and electrical output at the generator terminals [8]. In the renewable technologies side, the layouts can vary notably due to the fact that there are plants using thermal cycles, others relying on photochemical processes, potential energy and so on. Mainly, from wind farms to photovoltaic installations, all of them usually count with a 3 Water pressure under the column of fluid. Expressed in length units. strong presence of converters, filters and power electronics in general, aimed to accommodate either the variable nature of the sources they use or the electric output in DC which would be the case of photovoltaic stations. The range of power scalability in renewable sources is higher due to both, the composition of the systems itself in smaller generators (e.g. wind farm composed by fifty 3 MW wind turbines, photovoltaic station with 400 panels of 300 W each) and the multiple strategies that allow to regulate power output (apart from the integrated power electronics) such as tilt angle modification of wind turbines, 2-axis tracking in the case of solar PV or solar thermal and flow regulation in geothermal facilities [10]. 2.1.2. Demand and consumption The ultimate aim of the power system is supplying the end-user with, as mentioned before, a reliable, uninterrupted and quality service. In contrast to generation, the demand is distributed along the territory and the users can be of multiple kinds and requirements. As shown in fig. 1, there are consumers ‘pinned’ in different subsectors of the transmission layer according to their needs. For instance, an intensive metallurgic factory will need of a greater demand of power to feed their arc furnaces than a common household, therefore, the factory transformers will be directly connected to a substation from the distribution or even transmission layer (e.g. 132 kV busbar) [8]. Loads such as the above commented metallurgic factory produce serious disturbances to the power quality and demand variation like flickers 4 , which are hard to be controlled for being attributable to the side of the consumer. Despite this, in general terms the demand curves are able to be solidly forecasted due to the fact that the main parts of the curves take fixed patterns over time. Normally, showing an offset minimum value during low demand periods which raises in value and variability around the peaks when the consumption is higher and there are more services active and thus, more uncertainty (statistically). The power quality requirement has also to be continuously addressed as many widely used appliances like computery, televisions or any other utilities which need for a certain power stability to work correctly. Aside from flickers, other power quality issues that are dealt with (more emphatically in the developed countries) are supply outages which are interruptions in the power supply, overvoltages which are surges that can damage and even burn equipments and can be caused by lightnings, voltage drops that can be caused by faults or 4 Fluctuations in the voltage amplitude. Power flow tool for active distribution grids and flexibility analysis 19 peak load startups (specially rotating machines demanding an overconsumption when starting), voltage harmonics which are deviations from the fundamental frequency of the voltage wave, and so on. 2.1.3. Transmission and distribution To interconnect the production power stations with the consumption clusters there are two main layers, one devoted to long the distance transportation (transmission), which can be identified by the higher voltage levels, as well as the wire sizes and configuration; and another layer aimed to spread around the territory, normally in radial configurations to reach and feed the end users. As commented above, the voltage levels of the transmission system are higher to cross greater distances with fewer losses, such voltage levels would be in a range within 800 kV to 132 kV, being 220, 400 and 500 kV common standards for transmission voltages. The HV lines are usually configured in meshed layouts to provide more than one path to the energy flow in case of service interruption or other maintenance issues. The dominant type of transport medium in such lines is overhead wires attached to towers with different Fig. 1 a,b,c: double-circuit towers of 110-150, 220-275, 400-500 kV respectively. d,e,f: single-circuit towers in triangular, delta and horizontal formation respectiely [12]. d) e) f) a) b) c) configurations (fig. 3). Typical line parameters such as inductance strongly depend on these relative geometric positions of the three phases on the tower. Even though underground lines in HV voltages can be found nearby some city areas they are scarce, as the price of the insulation needed due to its proximity to the ground is very high in comparison to overhead configurations [6]. The transmission lines are commissioned to reach the distribution or subtransmission substations, which will decrease its voltage in the transformation nodes to feed the distribution networks. Alongside transformation tasks, the substations carry out measurements, protection and interruptions of the line, all of them necessary to synchronize different activities like isolation of an area due to blackout, maintenance tasks, disconnection operations among others. Fig. 5: European transmision system. ENTSO-E. Fig. 2: Example of a meshed configuration. [17] Power flow tool for active distribution grids and flexibility analysis 21 The distribution grids are, as mentioned above, devoted to ‘spread’ the power transmitted by the HV lines over the different consumers around. There’s normally a ‘frontier’ layer between distribution and transmission (still accounted as the lower part of transmission grid) which still operates in quite high voltages, from 45 to 132 kV (depending on the country) and its mission is to step down the voltage to the nominal MV distribution values, which are for instance 20, 15 or 6.6 kV[8]. Such ‘frontier’ still operates partially in a meshed structure or with an open loop configuration. When it reaches the mentioned reduction substations (MV and LV levels) the structure and operation becomes, in broad terms, radial (Fig. 6). The voltage reduction reasons are the safety for the end-users as well as the reduction of the insulation requirements in the electric appliances [16]. Such voltages are standardized by the IEC60038 5 , which states that the MV for three-phase systems are 3.3, 6.6, 11, 22, 33 kV, within the 1-35 kV margin. The radial networks structure commonly used in distribution grids have simple and cheap topologies with easy implementations of voltage compensation techniques. The distribution system operator (DSO) must ensure the security and reliable operation requirements. a with the drawback of disconnection of all lines in case a upstream line or node fails. 5 International Electrotechnical Comission. Fig. 3: Example of a radial configuration. [17]. 3. Electric Power System flexibility In order to tackle with the instabilities and uncertainties entailed with Variable Renovable Energy Resources (VREs), there is a range of options which enhances the flexibility of the systems and subsystems involved. Such strategies can be classified according to the layers in which they are operating or the economic suitability according to technical and market variables. In this work, the assessment will be focused in technical reasons and of feasibility. In the actual power systems worldwide there is an inherent level of flexibility composed by the already existing control techniques to adjust an already uncertain demand of supply; which can consist of short dispatch time power plants, spinning inertial blocks among others. An example of such variability across systems can be seen in Fig. 7, where the red pentagon depicts the maximum share of wind power in an hour of relative demand (data prior to 2013) and the area highlighted in green shows the installed capacity of potential flexibility sources. However, as there still are external factors that can impact on these sources such as market variables, in the case of interconnection-oriented systems, or capacity issues regarding hydro-pumped, as well as issues in the gas supply in the case of CCG; there’s not a direct translation into the reality and that’s why they are still ‘potential’ sources in this kind of diagrams. Following this chapter, ways of flexibility enhancing in power systems will be listed and briefly discussed. Fig. 4: Inherent primary (potential) source of flexibility by country with the maximum share of wind power (red). Source: [28] Citing Yasuda, Y. 2013. “Flexibility Chart: Evaluation on Diversity of Flexibility in Various Areas.” Power flow tool for active distribution grids and flexibility analysis 23 3.1. Storage One of the most well known, stable and deployed source of flexibility. Storage systems provide a wide range of discharge rates, capacities and times of response which allow them to adapt quickly and durably to unpredicted load changes (when mixed and deployed efficiently). In the event of excess renewable generation and/or during low-demand periods, energy can be stored through pumped hydro, compressed air (CAES) or in electrochemical batteries to cite a few of them. In the same way, in the event of low share of cheap/renewable sources they can dump in the grid their stored energy to provide a costeffective and environmentally friendly solution [21]. Fig. 8: Storage technologies by discharge capacity and discharge time. Source: [21] Although some of the listed technologies are mature, there are still many of them in early stages of development (superconducting technologies, advanced chemical storage) and some others carry with expensive variables which brake an efficient and wide deployment. In the same direction, pumped hydro or CAES present difficulties at choosing suitable locations to be deployed as well as issues regarding the environment, due to its harsh impact on a wide area. In the recent times, research on an efficient combination (and layering) of storage technologies has been made to reduce costs and apply optimal time-capacity response in the distribution and transmission networks. Deploying large scale technologies in the HV layers and distributed smaller facilities with faster response in the MV side has proven to increase the system flexibility. Sizing the appropriate storage system output and capacity ends up with the assessment within a set of different technologies and allocated costs (€/kW, €/kWh). In the next Table 1, basic technical and associated cost characteristics are attached. Table 1: : Briefing with some of the storage technologies’ characteristics. Source: [21] The usually high capital cost of storage facilities makes it challenging to deploy certain amounts of it without the appropriate policies. Furthermore, some of the benefits provided by the energy storage systems can also be reached by other measures such as Demand-Side Management (DSM) or additional reserve capacity, making it necessary to compare it with Power flow tool for active distribution grids and flexibility analysis 25 other options before its implementation. 3.2. Demand-Side Management The range of mechanisms devoted to intervene and partially change the magnitude of the end-user electricity consumption profiles as a mean of enhancing network flexibility is baptized as Demand Side Management (DSM) [23]. Mainly, it can be splitted into three different categories depending on whether they are reducing, increasing or rescheduling the energy demand. The primary source of flexibility among the three types, should be the rescheduling (load shifting) preferably, which in contrast with the others don’t necessarily compromise any final product/service nor its continuity due to lack or excess of energy (switchable loads with less than 100% utilization rate). Otherwise, DSM with load shifting may need indirect ways of storing energy, using for example building heating/cooling inertias, rotating machines such as milling machines or washing lines which can swap timetables, and so on. DSM proves to be useful in the timescale of the VREs variability disturbances (1-12h) as well as playing an important role in the deployment of energy efficiency through the implementation of control and measurement equipments in households and secondary sector levels [23]. This paves the way to a more active role in the market by the consumers and can help reducing the use of power in peak periods as well as reducing the average spot price of energy. Many field studies and surveys have reported positive results about the potential of DSM measures, either implemented via policies and market mechanisms or via load control (requiring a still incipient ICT deployment). Such studies shown, as an example, a 13-16% of peak-hours consumption reduction in Finland during a dynamic pricing test (4:1 peak-to- normal price ratio) or 25-28% using a 12:1 ratio [33]. On average, according to P.D. Lund et al., studies on VRE-DSM joint strategies report a 20% cost reduction and a increase of 10- 20% VREs consumption. 4. Power flow analysis When projecting or planning the performance of a determined electric network as well as assessing expansions of the grid, there are analysis methods that allow obtaining useful information such as losses, lines loading, reactive power flows among others, that be the case of the power flow analysis. Fig. 10 Example network composed by 5 buses (numbers 1 to 5) with 2 generators (buses 1 and 5) and 4 loads (buses 2, 3, 4 and 5).[11] Given an electric network, the power flow analysis target is to determine the power to be transmitted from every generation unit to every charge or demand point given some defined constrictions. In addition, it also provides the resulting voltage in every network node, the active power in every element of the network, the reactive power in every element of the network, the aforementioned generation to be produced in each unit, the performance of the network and overcharges or contingencies produced. This information is necessary for studies of security, planning or stability. As a result, some assumptions related to the real environment where the network operates have to be taken into account: I. Every network element has boundaries and limits to the power they can generate or transmit. II. The voltage in the network nodes have to be kept in a certain ranges, to grant safe and reliable operation. III. Any power demand can be satisfied by any combination of generation points, giving an infinite number of possible combinations. Power flow tool for active distribution grids and flexibility analysis 33 After considering those assumptions, the full analysis can be divided into 3 main parts: The mathematical model formulation, describing the relation between voltages and power in the grid; the resolution of the node voltages involving numeric calculations; finally the power flow and the load share between generator units. The working variables can be classified as follows in Fig. 12, and the differences between PV,PQ and Slack buses will be detailed as well as the variables coupled with every kind of bus. The buses can be classified as PV, PQ or Slack depending on whether there’s generation of power or not in a bus itself. In the PV buses there is generation and thus, the active power is known. In this kind of buses it is common to control the voltage using reactive power regulation for that reason both power and voltage are known and reactive power to generate is the unknown value. The PQ buses or load buses are buses without power generation. As the active and reactive power demand are known variables for every bus but and, in this case, the tension and the angle are missing or unknown, they are called PQ buses. Finally the Slack bus is used as a reference to set the phase angle magnitudes of the rest of the buses, as the angle in each bus is found by difference. Consequently in the Slack bus δ=0 and also as a reference bus it is useful to set it in a node where the tension will be controllable, so the module and arguments of the voltage are known being the active and reactive power the only unknowns left [13]. Bus type Voltage Real power Reactive power Magnitude Angle Gen. Load Net (Pi) Gen. Load Net (Pi) Slack Known Known Unk. Known Unk. Unk. Known Unk. PV Known Unk. Known Known Known Unk. Known Unk. PQ Unk. Unk. Known Known Known Known Known Known Fig. 11 Power flow initial variables briefing. Source: [20] However, the amount of variables can be reduced to 4 if it is used the ‘bus power’ concept [6], which is the balance between demand and generation for every bus that injects and acts as a load at the same time. The bus power can be expressed in units of reactive and active power as follows: (Eq. 1) (Eq. 2) At that point, the power and current equations in every node (or bus since now) can be expressed as: (Eq. 3) (Eq. 4) Being Yik the elements of the admittance matrix. Which is used to build the power equations that can be expressed as a function of the voltage in all the network buses. (Eq. 5) Using the following forms, the apparent power can be expressed as its active and reactive components: (Eq. 6) (Eq. 7) Then, replacing the admittance and tensions terms for every bus and changing the complex notation into the trigonometric form are obtained the following two expressions for active and reactive power: Power flow tool for active distribution grids and flexibility analysis 35 (Eq. 8) (Eq. 9) As the two equations ((Eq. 8 and (Eq. 9)) are related to a single bus and the range of different variables is of four, there is the need to specify at least 2 of them in every bus. At this point, when the nodes have been classified the following logic step or more commonly used will be the calculus of the admittance matrix. The admittance is expressed as the reciprocal of the impedance and thus is a measure of how easily will a current flow though a load, a wire or a network element (or sum of them) [13]. The calculation of the matrix will depend on the study to be made and the elements involved. Therefore, such calculations are included in algorithms used by code toolboxes or libraries to save time and put ease to the analysis. As an example, an admittance matrix calculation of a network without magneting coupling can be easily done by the addition of all the admittances of the connected branches to every bus and placing it on the matrix diagonal (Yii): Fig. 13: Addmitance mattrix shape The calculation of the rest of the mattrix elements is done by addition of the addmitances of the elements between 2 nodes coincident with the element subindex and with the sign changed (e.g. admittance between nodes 1 and 2 = Y12). The next step will be the calculation of the voltage module and argument in every bus (if unknown). To calculate the resulting non-lineal complex equations it is necessary the use of numerical methods such as Newton-Raphson (NR) or Gauss-Seidel (GS) algorythms among others untill the error value reaches the desired accuracy. The higher the number of elements in the network the more evident is the need to automatize the process. As an example, the application of the NR method provies the following algorythm: (Eq.10) Where X is the compact formk of non lineal algebraic equations ( (Eq. 8 and (Eq. 9) and J the Jacobian matrix of the equation system: (Eq.11) The iterative process is initiated by a preliminary estimation of the vector X(0) (the vector of unknowns) mixing the already specified values (operation conditions), it follows with the calculation of the F vector value and if the magnitude of its vector is lower than the required accuracy the method ends here. If not, the Jacobian matrix is recalculated with the exiting values and a new unknowns vector is provided to fill step 2 until the stopping criterion is met. Although the mentioned methods are valid, there’s an extension of the Newton-Raphson method (called fast decoupling method) which allows a faster convergence and easiness which is widely used in power transmission calculations. However it may present inconvenient in MV grids due to the R/X relation. Power flow tool for active distribution grids and flexibility analysis 37 5. Selected approach and analysis tools Beyond the need to use a software to work efficiently on PF analysis, one of the main goals of the present work is to provide an open source based tool that can put ease to the preliminary analysis and be extensively available that can help any DSO or user in the decision making of initiatives as: grid expansion, improvement/substitution of elements (transformers, capacitor banks, lines..), renewable sources implementation and so on. The objective is to find an open source option that allows more flexibility of customization than its commercial counterparts and, at the same time, without losing the reliability they provide. To ease the analysis, it is needed that the tool can read and asses multiple datasets in a common format (e.g. csv) containing the network information and automatically creating the node elements and connections for then analyzing the system performance using the PF integrated in the library in use. To do so, the selected tool has been the pypower based toolbox pandapower, a reliable open source aimed at automation of analysis and optimization in power systems. The focus has been to use pandapower’s aim to close the gap between commercial and open source analysis tools to generate a code that can be used with ease of use and customization capabilities that will be expanded in this work as well as the aforementioned automation aim to allow working without sizing restrictions of the networks to analyze. 5.1. Pandapower Pandapower’s scope reaches the static analysis of balanced power systems and thus, allowing the analysis of transmission and subtransmission systems which are typically operated symmetrically, as well as symmetric distribution systems commonly found in Europe[15]. It provides power flow, optimal power flow, state estimation, topological graph searches, and short-circuit calculations according to IEC 60909[16]. In terms of network models, the common bus-branch model (BBM) used in other tools is replaced by an element-based model (EBM) in pandapower, where an element is connected to one or multiple buses and defined by its characteristic parameters. This allows defining the network with nameplate information such as impedance and length for lines or short circuit voltage and rate apparent power for transformers[16]. Its structure is tabular, which means it stores all the element’s data in tables created by functions. Every table can be expanded or customized without interfering Panda’s functionality, which helps at the time of extracting or combining information before and after the analysis methods performed on the grids tested. Fig. 14: Line parameters stored in a table type structure. The data stored can include not only defining parameters but also metadata such as names or descriptions as well as coordinates that allow the position of the different elements in the space in order to be plotted in a shape of a scheme if needed. After carrying any of the analysis included, the results are stored in tables as well, with different ways of calling them but keeping the same indexes and names of every element previously created. The tables defining the grid elements as well as the result tables are grouped by element types (bus, generator, line, trafo…) under the net dictionary, which includes all the design parameters, results, and elements stored Fig. 14. Power flow tool for active distribution grids and flexibility analysis 39 Fig. 15: Schematic example of the pandapower network stored data tables. Source: [16]. As can be seen in Fig. 13, the pandapower net, which is the dictionary holding all the network data as mentioned before, also includes the standard type data libraries, which are predefined types of elements included in pandapower that are validated by nameplate characteristics and against other softwares to be used directly by the user. There’s also the option for the user to define its own standard types to add more flexibility to the design capabilities of the tool. Fig. 16: Net dictionary containing result data from a PF. 5.1.1. Elements models’ and description As mentioned before, pandapower is an EBM tool, and thus the element models need to be processed with the appropriate equivalent circuits to derive a mathematical description of the network. The different elements are created by functions (create_element or create_element_from_ parameters) and here will be briefly described the main elements that will be in use in the PF. Buses They work as the nodes of the network and are defined by a nominal voltage in per unit system (pu), and the bus type, although the default type in case no value is introduced is ‘b’ (busbar). Normally it is needed to add further optional parameters such as maximum admitted voltages or geodata (coordinates) to meet the design requirements in every case. The function used to create the buses is pp.create_bus(). Using the variable explorer and entering the auxiliary net dictionary, all the introduced parameters and elements are available to check as tables, alternatively, by printing net.bus() it is possible to see directly on the console the summarized parameters introduced by the function. The equivalent circuit scheme of the bus used in pandapower is presented as an earthed node with the nominal bus tension and n power branches corresponding to every different bus attached. It can be depicted as follows: Fig. 17: Bus equivalent circuit Source: [17]. Power flow tool for active distribution grids and flexibility analysis 41 Parameter Datatype Value Range Explanation NAME string Any name of the bus vn_kv* float > 0 rated voltage of the bus [kV] type string naming conventions: “n” - node “b” - busbar “m” - muff type variable to classify buses Fig. 18: Minimal defining parameters for bus creation in pandapower. Source: [17] Transformers (2 and 3 windings) There are two types of transformers available to be used (or defined) in the pandapower libraries, the two winding and three winding transformers. The function creation of the 2- winding transformer requires as minimum inputs the net (in which the transformer will operate), the high voltage part bus (where the primary will be attached to), the low voltage part bus (where the secondary will be attached too) and the standard type used from the library (just in the case the user is using the standard library instead of parameterization). For the three-winding case, the same obligatory inputs are required except in the parameterized form in which the medium voltage side values have to be defined by the user. The transformer models used by pandapower are both T-Equivalent and π-Equivalent circuits for the two-winding transformer, and a three two-winding transformers in wye connection for the three-winding transformer. In that last case, the conversion is carried out internally. The electric schemes for both transformers are shown below: In this case, the c4gs’ data is already contained in both Pandapower and Matpower as well as some other typical study cases from IEEE, books and publications. In order to load the net data we will have to use the following commands: Fig. 26: Loading an included case with Pandapower. However, we also opted to create the case from scratch and testing it as well, which will be useful proximately to concoct the tool. Then, via the command pp.create_empty_network() it is possible to initialize an empty pandapower object where to link all the buses, loads, lines and other elements that will define the c4gs. Fig. 27: Definition of the elements and parameters to replicate case4gs. Note that it has been needed to reset the frequency to 60 Hz to make it match with the conditions of the c4gs. Also, and just to avoid any deviation, the standard type libraries from the c4gs’ lines have been loaded, (though unnecessary because the introduction of the line parameters are manually entered at the time of creating the net from scratch). As a reminder from section 6.1, the standard types libraries hold normalized data about lines insulation, thermal limits, section, impedance per distance unit and so on. Once all the data conforming the c4gs has been entered, a power flow analysis is performed Power flow tool for active distribution grids and flexibility analysis 49 using the default algorithm which for pandapower is Newton-Raphson. The basis in which the comparison will be done is in terms of average speed of convergence and error between power flow results. Despite the fact that other sources have performed similar comparisons, as we cited in previous sections, the need to obtain our own results is aimed to assure that the same scenario with the same conditions can be recreated element by element, as one of the main assets of the tool will be the ability to automatically build nets from scratch by using data not loaded as a case inside pandapower. The comparison will be carried between pandapower loaded case against pandapower created case and, after that, pandapower created case against matpower loaded case. Once the power flow analysis have been carried, the result tables are called as follows: Case4gs() from scratch: Fig. 28: Bus and external grid results after pf. Fig. 29: Generation and load results after pf. Fig. 30: Line results after pf. To begin with, the fields shown by the bus results data are (from left to right) the voltage magnitude in p.u. where the slack bus (external grid) takes, as expected, the reference value and the generator in bus 3 takes the other value above 1 pu. The other two buses, which receive reactive power injection, have relative voltage values under the unit (4th column). As a reminder, the system reference for buses in pandapower is opposed to the generator point of view (even if they have generation attached to), that’s why in the bus data briefing, the consumer point of view is used and thus, the power injections are negative. The second column refers to the voltage angle (δ), where lagging angles in buses 1 and 2 coincide with the active power injections from buses 0 and 3 (3rd column). Just below, the external grid results show the power delivered to supply the necessary amount to match with the loads and the local generation plus the losses in the lines. The load results show the active and reactive power demands after scaling and considering voltage dependences, in MW and MVar respectively. As there’s none of the previous considerations, the result remains equal. Finally, the line results criterion states that the “from” values are power flows entering the line from the bus allocated as the starting point when defining the line (e.g. linexy from busx to busy). The opposite happens with the “to” values for both active and reactive power. That’s why as none of the lines have bus 3 as a starting point, the generator injection is shown as negative in the “from” column (opposite direction as the line definition). Fig. 31: Expanded view of the line results dataframe. Power flow tool for active distribution grids and flexibility analysis 51 The following columns (Fig. 29) stand for the power losses in the line, calculated as the sum of p_from_mw and p_to_mw for active and reactive components, the next columns as currents “from” and “to” the buses at the edges of the line, the i_ka for the maximum current among the two previous fields and the two following columns of data existing already in the bus results dataframe. The last column, which appears in Fig. 28, is the loading percent of the line, calculated from the defined thermal limits introduced when defining the line as the parameter max_i_ka. Following the power flow conclusions, it is also relevant to check the speed of execution. In order to make sure that hidden background processes aren’t affecting the measurement, we will take an average of 10 execution times. Execution nº Time (s) Case4gs()=1 0.586 Case4gs()=2 0.572 Case4gs()=3 0.618 Case4gs()=4 0.584 Case4gs()=5 0.580 Case4gs()=6 0.611 Case4gs()=7 0.573 Case4gs()=8 0.748 Case4gs()=9 0.589 Case4gs()=10 0.779 AVG10 0.624 Table 2: Average execution time of the case4gs from scratch. With an average execution time of 0.624s we will compare it with the time used by the inbuilt c4gs below. Furthermore, we will check the error in the resulting values form the power flow, comparing again the raw execution of c4gs (loading directly the case and running a power flow) against the results above. Case4gs() inbuilt: Fig. 32: Bus and external grid results for the inbuilt Case4gs after pf. Fig. 33: Generation and load results for the inbuilt Case4gs after pf. Fig. 34: Line results for the inbuilt Case4gs after pf. Power flow tool for active distribution grids and flexibility analysis 53 Execution nº Time (s) Case4gs()=1 0.408 Case4gs()=2 0.396 Case4gs()=3 0.444 Case4gs()=4 0.431 Case4gs()=5 0.418 Case4gs()=6 0.431 Case4gs()=7 0.404 Case4gs()=8 0.444 Case4gs()=9 0.405 Case4gs()=10 0.420 AVG10 0.420 Table 3: Average execution time of the inbuilt case4gs. As can be seen in Table 2, there’s a 32.7% time reduction in contrast with the scratch version of c4gs. One of the driving factors is the unnecessary execution of the functions to create every element. Following the speed test, the output of the results will be compared below. The error sources between both cases can be due to the length of the decimal queue introduced when defining the parameters (sensibility) or for small variations in the starting conditions. A basic deviation calculation will be carried to rate the relevance of such error. Bus results deviation vm_pu va_degree p_mw q_mvar 0 0 0 0 4E-06 1 0 0 0 0 2 0 0 0 0 3 0 0 0 9E-06 Table 4: Bus results deviation. Ext grid results deviation p_mw q_mvar 0 0 -4E-06 Table 5: Ext. grid results deviation. Line results deviation p_from_mw q_from_mvar p_to_mw vm_to_pu va_to_degree loading_percent 0 0 2E-06 0 0 0 -1.2E-05 1 0 -6E-06 0 0 0 -2.8E-05 2 0 -2E-06 0 0 0 -3.5E-05 3 0 -2E-06 0 0 0 -2.8E-05 Table 6: Line results deviation. Results relative deviation Bus (q_mvar) Ext_grid (q_mvar) Line (q_from_mvar) Line (loading%) 0 -0.0000048% -0.0000035% 0.0000090% -0.000059% 1 0.0000000% - -0.0000098% -0.000058% 2 0.0000000% - 0.0000027% -0.000057% 3 -0.0000068% - 0.0000033% -0.000057% Table 7: Results’ relative deviation. As can be seen, the deviations between the inbuilt and created case can be neglected and translate only in a limited range of fields. It is still needed to compare the results with a widely used tool such as Matpower to verify the outcome. Matpower Matpower is an open-source tool based on Matlab language devoted to solve steady-state power system simulation and optimization problems [24], developed by the Power System Engineering Research Center (PSERC)[25]. It has a two decade applied experience with a positive outcome, what it makes a good suitor for testing against. In Matpower the data is presented in a sets of matrices packaged as the fields of a Matlab struct (Matpower case). With the command mpc=loadcase() the data stored for an specific inbuilt scenario can be loaded and edited, as the sets of data matrices are editable on the mfile. Below there’s an example of the data matrices. Power flow tool for active distribution grids and flexibility analysis 55 Fig. 35: Matpower case structure of case4gs() showing bus data. Having loaded the case, a default power flow analysis is performed. As the default algorithm is also the Newton-Raphson approach, the matching conditions of the test are not altered at this point and the results should part from an equal starting point as of pandapower. Fig. 36: Matpower bus results data structure. Note that the resolution of the results come by default with 2 decimal positions, we can expand such resolution by accessing the printpf.m file in the Matpower files and modify the ‘x’ value in %9.xf to establish the desired number of decimal positions. Fig. 37: Change of resolution to carry deviation analysis. The results after modifying the decimal marker are shown as follows: Fig. 38: Matpower bus results after pf with 9 decimal positions. Fig. 39: Matpower branch results after pf with 9 decimal positions. Execution nº Time (s) Case4gs()=1 0.287 Case4gs()=2 0.286 Case4gs()=3 0.283 Case4gs()=4 0.290 Case4gs()=5 0.287 Case4gs()=6 0.297 Case4gs()=7 0.273 Case4gs()=8 0.288 Case4gs()=9 0.297 Case4gs()=10 0.282 AVG10 0.287 Table 8: Average execution time of the inbuilt case4gs. Power flow tool for active distribution grids and flexibility analysis 57 The time of execution is a 31,6% lower than the same inbuilt case executed with pandapower. In this work we have been comparing execution times rather than only convergence times or conversions from EBM to BBM models as other sources do. That’s one of the main factors why the time difference is not that higher. About the numeric output of the power flow, we can see the expected complete match among pandapower and Matpower. The error calculations don’t include, of course, all the possible data that can be obtained from a power flow, but the most significant from where other datasets are constructed with (e.g. the losses, current). Bus and generation results deviation Voltage (pu) Generation (deg) P (MW) Q (Mvar) 1 0.000000 0.000000 0.000000 0.00000 2 0.000000 0.000000 - - 3 0.000000 0.000000 - - 4 0.000000 0.000000 0.000000 0.00000 Table 9: Bus and generation results deviation (Matpower vs Pandapower). Branch results deviation Bus From (MW) Bus From (Mvar) Bus To (MW) 1 0.000000 0.000000 0.000000 2 0.000000 0.000000 0.000000 3 0.000000 0.000000 0.000000 4 0.000000 0.000000 0.000000 Table 10: Branch results defiavion (Matpower vs Pandapower). The experience has been useful to test at what extent the EBM conversions, standard type libraries and parameter definition of pandapower are reliable to start building a tool that can allow extra automation and customization capabilities as well as graphic support to enhance the ease in which new and bigger nets are tested in terms of problems detection, flexibility measures and so on. The length of the lines is also a driving variable for plotly to spatially locate the nodes so the differences are not meaningful enough to drive the user into confusion at the time of visualizing the network even without geocoordinates available. In addition, there’s the option to check the power flow results upon the network scheme, using another plotly function. The result is a 2-axis heatmap for buses and lines, rating the bus voltage and the line loading respectively. The following figure is an example using IEEE 24-bus rts inbuilt network. Fig. 11: Power flow results plotted over network scheme. Power flow tool for active distribution grids and flexibility analysis 65 Menu addition When testing different scenarios by adding new elements or modifying its parameters it can be useful to have a small menu system to quickly perform such additions, at least in a broad manner. Later on, the user can always adjust the parameters using loc commands. An example of this has been implemented with generation, where the menu allows to select a bus and a discrete rated generation to be added (active power). Then the element is automatically created and allocated to the selected bus. The range of the menus can be expanded and modified. As commented, there’s much leeway to expand this concept and bring more options such as tree menus, element modifiers, assessment options and so on. IEEE-33 Bus test The 33 bus case is a proper example of a distribution grid system of 12.66 kV of nominal voltage that can be used to perform power flow analysis and scenario testing with the tool. The aim of the tests is to check the output provided by the tool and the capabilities it offer to visualize the behavior of the system after applying different changes that can compromise the stability of the system. Afterwards, some measures will be applied (e.g. shunt capacitors Fig. 12: Example of the menu implemented. to correct voltage drops, storage deployment to avoid overloadings, etc), and the response of the system visualized via the graphic support of the tool. The system contains 33 buses in a radial distribution connected by 37 lines and containing 32 scattered loads of low consumption ranging from half MW to 45 kW (e.g. small low density residential areas, fine environment for DER deployment). The external grid connection is placed at node 0. In the following figures it can be seen the contained network data and its distribution in space, neglecting geocoordinates. Fig. 49: IEEE-33 Network data. Fig. 50: IEEE-33 Network scheme. Power flow tool for active distribution grids and flexibility analysis 67 The first step will be loading/calling the case as it is inbuilt in pandapower and running a power flow without any modification (unless enabling service for all the line switches). That way we will check the current status of the network in the given conditions. Note that there are no generators, so all the power to supply the loads will come from the feeder connection at bus 0. Fig. 13: IEEE-33 bus results power flow. Fig. 14: IEEE-33 Branch/line results . Fig. 15: Heatmap showing line loading percent, losses and power through line. Power flow tool for active distribution grids and flexibility analysis 69 As shown in both, results and graphics, the loading in the lines is low and, as expected, the maximum values are taken upstream near the main feeder connection where it reaches 6.8%. The nodes with positive active power consumption (consuming) are the farthest from the service point. After setting the voltage limits warnings’ in ±5%, the voltage violation vector appears empty, so there’s no node with over or undervoltage. As there are not generators, the danger of reverse power flows in weak (far) nodes is not of concern yet. The system active and reactive losses have been added to the tool through the following commands. The results of the losses are 0.123 MW and 0.088 MVar, accounting a total of 3.21% and 3.69% respectively. As moderate currents are circulating, the losses are low for a distribution system. Fig. 16: Active and reactive losses of the system under nominal conditions. The voltages, as commented above, are decreasing as the nodes get farther from the injection point. From 0 where the connection is attached from 16 and 17 which are the most remote buses in the system. Note that bus 18 has a voltage relatively close to the unit because it is placed in the first bifurcation, very close to the external grid and, in fact, adjacent to bus 1. Scenario 1 – Scattered increased load (IEEE 33-Bus system, radial) Once the system in nominal conditions has been tested, a first scenario of load increase will be tested. A range of scattered loads will be deployed to observe the system response and the voltage levels in especially weak nodes. The load distribution will be of household type, basically non inductive loads with a PF close to 1. It will depict a hypothetical increase in housing capacity in a near future. Bus ID Load P (MW) Load Q (Mvar) 5 1.5 0.1 6 1 0.07 7 0.9 0.09 12 1.1 0.05 13 1 0.04 14 1 0.06 Table 12: Distributed loads data. Fig. 17: Heatmap of bus voltage (pu) over bus index Power flow tool for active distribution grids and flexibility analysis 71 After the loads have been modifyed by the loc commands, a power flow analysis is ran over the system and the results are displayed. Looking at the voltage levels, it can be seen a significant drop in many buses caused by the load consumption. A great majority of those cases are under the voltage limits for distribution networks as the voltage violation vector shows. Again, as there are no generators, the extra power is supplied by the connection in bus0, which will mean an increase in the line loading close to the slack. It can be checked in both the line/branch results or more visually in the hetmaps or topological maps implemented. Fig. 18: Power flow bus results with increased scattered loads and voltage violated buses (5% threshold). Fig. 19: Line results with increased scattered loads scenario. Fig. 20: Power flow results over network scheme. Power flow tool for active distribution grids and flexibility analysis 73 The lines loading have increased in the surroundings of the slack but still in a safe value of around 16.5% (the calculations are done with the current against the thermal ratings). In the lines result tables we can also see the amount of power injected by the slack, which amounts 10.4 MW and 3.09 MVar. Along with the power supplied there are the losses, which are greater in the lines 1 and 18 (the bifurcation after the external grid connection). Fig. 59: System losses (scattered increased loads scenario). As seen, the reactive power losses had a considerable increase over the total reactive power supplied, that is due to the fact that reactive energy is still needed to be supplied over the length of the lines (as there’s small reactive demand in every bus) and for small amounts of energy, the share of the losses to transmit is quite higher. Fig. 60: Heatmap of active losses (MW) per line index. In the same way as for the shunt capacitors, for greater sized networks will be appropriate to automate the way in which elements are added. To that effect, another menu to deploy storage elements has been implemented in the tool. This time, we obtain the vector or list of bus indexes where generation is attached and use this vector to allocate the storages of discrete sizes to those nodes. The ideal would be to associate the storage capacity vector with the generation capacity data, but as the creation functions in pandapower don’t allow iterating over dataframes or lists inside, the solution of discrete values plus afterwards automatic adjustment seems an acceptable shortcut. Fig. 69: Menu implemented for automatic allocation of storage systems. When all the 2 MW storage systems have been created, a power flow analysis is ran over the system and it shows we need increased storage power capacity to reach lower levels than 86% of the line loading. Updating and increasing this parameter into 5MW, we obtain the desired results. Fig. 29: Heatmap showing net status after placing 5 MW storage systems. Power flow tool for active distribution grids and flexibility analysis 81 As the currents involved have reduced due to storage, the overall losses did as well. The problem of the reverse power flow still accounts for a big injection upstream but has diminished notably. Other techniques that could be implemented are the DSM, enabling utility loads that can store energy indirectly (e.g. building heating) or generation side management as a last resource, via curtailing the renewable output by tilting the panels to less favorable inclinations or changing the duty cycle of the MPPT in the inverters. As said, the ideal response will always be to accommodate the surplus output and, be the case, curtailing upstream more pollutant sources such as coal-fired, CCPP and so on. Fig. 30: Power flow results over topological shceme showing restored lines overload after storage deployment. Fig. 31: Line losses with adapted scale. Power flow tool for active distribution grids and flexibility analysis 83 Budget The costs of this project will take into account a standard junior engineer salary and allowances during its time of completion, the equipment cost and the licenses. The time devoted to the project have been scattered along a year with periods of intense dedication, in total, an approximate sum of 320 h have been dedicated to it. Concept Unitary Cost (€/h, €/u) Weighted (%, HH) Cost (€) Salary 30 €/h 320 h 9600 Allowances (diet, transport, life6) 5110 € 42 % 2146.2 PC 400 € 33 % 132 License 1 (MS) 50 € 33 % 15 License 2 (Matlab) 800 € 3.6 % 28.8 License 3 (UPC libraries) 2000 € 3.6 % 72 Total - - 11994 € Table 14: Project associated costs. The costs have been calculated from the point of view of the client, so the only taxes applied are the VAT over the consumption tariffs and services (no retentions from salary). The costs of the License 3 are approximated, taking into account the number of resources and data bases in which the university is subscribed and applying a standard tariff of 10€/y which is a common price for most accessible resources. 6 Includes energy tariffs for the use of equipments. Environmental Impact The consumptions are calculated over the total time of duration of the project unless the transport, which is calculated only along the normal routines taken personally during lockdown, with an electric vehicle. Concept Total consumption (kWh) Unitary kgCO2/kWh emissions7 Total emissions (kgCO2-eq) PC 16 0.19 3.04 Lighting demand8 896 0.19 170.2 Heating demand9 640 0.19 121.6 Ventilation demand 19.2 0.19 3.6 Transport 57.6 0.19 10.9 Total - - 309.34 kg kgCO2 7 Grid emissions. REE 8 Include cooling for food and wiffi 9 Include heating (electricity) for cooking Power flow tool for active distribution grids and flexibility analysis 85 Conclusions The use of the python-based open source analysis library pandapower has permitted to take advantage of its customization and automation capabilities to fulfill the great majority of the objectives proposed at the beginning of this thesis. The tool has proven to be able to reduce drastically the time devoted to create and save networks parameterized from data obtained from third parties, making possible to read vast sized csv formatted files and creating automatically the network to be tested from that data. Besides, without losing reliability, as the output results from base cases have been tested with Matpower with positive outcome. The addition of menus in the tool has enhanced its automation capabilities, by making it possible to add elements such as generators, storage, loads, etc to the desired network bus without the need to manually introducing it with the time loss it entails. Again, during the tests, the option to ‘tackle’ with basic flexibility demanding scenarios (overvoltages, line overloadings) by automatically selecting the desired measure from the menus (shunt capacitor addition, storage deployment) have been an interesting asset that permits, in an easy and fast way, to obtain status of the network after applying such flexibility measures. The use of plotly library for charts and graphic support made it easier and visual the identification of weak spots or nodes in the networks, allowing through heatmaps and network schemes to print a better picture of the status of the network after and before the tests. Of course, there is much potential to enhance the tool by, for example, implementing algorithmic procedures in order to perform deeper flexibility analysis or performing optimal distribution of energy resources. Positively, the tool is scalable and modular and the addition of new features can be done with ease by any user. Acknowledgements To the directors, for their patience, good advice and willingness in a project done under harsh conditions. Also to my family, for their comprehension and unconditional support on what I was doing and to my friends, who managed to make everything easier. Power flow tool for active distribution grids and flexibility analysis Bibliography [1] Luiz Barroso and Hug Rudnick, The future of the power system, guest editorial, 2019. [2] IRENA. Energy transition. Available at: https://www.irena.org/energytransition [3] IEA Reports on power systems transition. Available at: https://www.iea.org/reports/power-systems-in-transition [4] BP, Statistical Review of World Energy 2020, 69th edition. [5] Kotilainen, Kirsi. (2020). Energy Prosumers' Role in the Sustainable Energy System. [6] Bin Chen, Rui Xiong, Hailong Li, Qie Sun, Jin Yang. Pathways for sustainable energy transition,Journal of Cleaner Production,Volume 228, 2019. [7] Barney L. Capehart PhD, Distributed Energy Resources (DER), College of Engineering, University of Florida, 2016. [8] Gómez-Expósito, Electric Energy Systems: Analysis and Operation, Taylor & Francis group, 2009. [9] Bin Chen, Rui Xiong, Hailong Li, Qie Sun, Jin Yang. Pathways for sustainable energy transition. [10] Kai Heussen, PhD Thesis: Control Architecture Modeling for Future Power Systems, Technical University of Denmark, 2011. [11] Modelling of a PMSG Wind Turbine with Autonomous Control, Chia-Nan Wang, Wen-Chang Lin and Xuan-Khoa Le, National Kaohsiung Universtity of Applied Sciences, Hindawi Publishing Corporation, 2014. [12] J.F. Adam, J.Bradbury, W.R. Charman, G. Orawski, M.J. Vanner, Overhead lines – some aspects of design and construction, IEE Review, 1984. [13] Juan A. Martínez Velasco, Sistemas eléctricos de potencia, Publicacions d’Abast S.L.L., 1994. [14] K. Prakash, A. Lallu, F. R. Islam, K.A. Mamun, Review of Power System Distribution Network Architecture, 3rd Asia-Pacific World Congress on Computer Science and Engineering, 2016. [15] Seyed Abbas Taher and Seyed Ahmadreza Asfari, Optimal Location and Sizing of UPQC in Distribution Networks Using Differential Evolution Algorithm, Hindawi Publishing Corporation, 2012. [16] Roberto Villafáfila, The Power System, MUEE-UPC documentation, 2018. [17] Islam, F. & Prakash, Krishneel & Mamun, Kabir & Lallu, Avneel & Pota, Hemanshu. (2017). Aromatic Network: A Novel Structure for Power Distribution System. IEEE Access. [18] C. Mateo, G Prettico, T.Gómez, R. Cossent, F. Gangale, P. Frías, G. Fulli, European representative electricity distribution networks, Elsevier, 2018. [19] National Program on Technology Ehanced Learning (NPTEL). Available: https://nptel.ac.in/ [20] Mohammed Albadi (March 1st 2019). Power Flow Analysis, Computational Models in Engineering, Konstantin Volkov, IntechOpen, DOI: 10.5772/intechopen.83374. Available from: https://www.intechopen.com/books/ computational-models-in-engineering/power-flow-analysis [21] “Addmitance”, Wikipedia. Available at: https://en.wikipedia.org/wiki/Admittance [22] L. Thurner, A. Scheidler, F. Schäfer et al, pandapower - an Open Source Python Tool for Convenient Modeling, Analysis and Optimization of Electric Power Systems, in IEEE Transactions on Power Systems, vol. 33, no. 6, pp. 6510-6521, Nov. 2018. [23] Pandapower main webpage. Available at: http://www.pandapower.org/about/ [24] L. Thurner et al., "Pandapower—An Open-Source Python Tool for Convenient Modeling, Analysis, and Optimization of Electric Power Systems," in IEEE Transactions on Power Systems, vol. 33, no. 6, pp. 6510-6521, Nov. 2018. [25] Pandapower detailed documentation. Available at: https://pandapower.readthedocs.io/ [26] A. Scheidler, M. Kraiczy, L. Thurner, M. Braun. Automated Grid Planning for Distribution Grids with Increasing PV Penetration. IWES Fraunhofer University and University of Kassel, 2017. [27] O.M. Babatunde, J.L. Munda, Y. Hamam, Power system flexibility: A review, Energy Reports,Volume 6, Supplement 2,2020. Available at: https://www.sciencedirect.com/science/article/pii/S2352484719309242 [28] National Renewable Energy Laboratory, University College, Northwest Power and Conservation Council, Energinet.dk, VTT Technical Research Centre of Finland, Power System Operation Corporation, et al. “21st Century Power Partnership: Accelerating the transformation of power systems”. 15013 Denver West Parkway. Available at: https://www.nrel.gov/docs/fy14osti/61721.pdf [29] RES-E-NEXT: Next Generation of RES-E Policy Instruments, IEA-RETD, july 2013, M. Miller, L. Bird, J. Cochran, M. Milligan, M. Bazilian National Renewable Energy Laboratory E. Denny, J. Dillon, J. Bialek, M. O’Malley Ecar Limited K. Neuhoff DIW Berlin. Available at: http://iea-retd.org/wp-content/uploads/2013/07/RES-E-NEXT_IEA-RETD_2013.pdf Power flow tool for active distribution grids and flexibility analysis [30] N.Voropai and C. Rehtanz, Flexibility and Resiliency of Electric Power Systems: Analysis of Definitions and Content, FREPS 2019 EDP Sciences. Available at: [31] https://www.researchgate.net/publication/336555666_Flexibility_and_Resilien cy_of_Electric_Power_Systems_Analysis_of_Definitions_and_Content [32] Peter D. Lund, Juuso Lindgren, Jani Mikkola, Jyri Salpakari, Review of energy system flexibility measures to enable high levels of variable renewable electricity, Renewable and Sustainable Energy Reviews, Volume 45, 2015. Available at: https://www.sciencedirect.com/science/article/abs/pii/S1364032115000672 [33] Hongbo Sun, Yishen Wang, Daniel Nikovski and Jinyun Zhang Mitsubishi Electric Research Laborato. Flex-Grid: A Dynamic and Adaptive Configurable Power Distribution System. Available at: https://www.researchgate.net/publication/308836152_Flex- Grid_A_dynamic_and_adaptive_configurable_power_distribution_system [34] Matpower official site. https://matpower.org/about/ [35] Buayai, Kittavit & Chinnabutr, Kittiwut & Intarawong, Prajuap & Kerdchuen, Kaan. (2014). Applied MATPOWER for Power System Optimization Research. Energy Procedia. 56. 10.1016/j.egypro.2014.07.185. Available at: https://www.researchgate.net/publication/275533772_Applied_MATPOWER_for_Pow er_System_Optimization_Research/citation/download