Contingency analysis for gas transport networks with hydrogen injection

Novel methods for contingency analysis of gas transport networks are presented. They are motivated by the transition of our energy system where hydrogen plays a growing role. The novel methods are based on a specific method for topological reduction and so-called supernodes. Stationary Euler equations with advanced compressor thermodynamics and a gas law allowing for gas compositions with up to 100%\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\%$$\end{document} hydrogen are used. Several measures and plots support an intuitive comparison and analysis of the results. In particular, it is shown that the newly developed methods can estimate locations and magnitudes of additional capacities (injection, buffering, storage etc.) with a reasonable performance for networks of relevant composition and size.


Introduction
Hydrogen plays a growing role in approaches for transforming the overall energy system. In particular, power-to-gas (PtG) plants, which can convert electrical power to hydrogen by means of electrolysis, are considered as an important ingredient for employing excess power from renewable ressources. Hydrogen can be injected to existing networks for transport of natural gas, or separate hydrogen networks could be used. However, such approaches need intense planning and optimization based on This work is supported by the German Federal Ministry for Economic Affairs and Energy in the project "MathEnergy" with its subproject 0324019A. B Tanja Clees tanja.clees@h-brs.de 1 simulations for several reasons. Among them, impacts of injecting larger amounts of hydrogen to systems which were originally designed for transporting and compressing natural gas have to be analyzed thoroughly. One of these impacts might be less security. Hence, intense contingency analysis should be performed to estimate locations of probable failures and magnitudes of additional capacity needed.
Contingency analysis is widely used for electrical networks. A so-called N − 1 analysis is standard. For each of the N decisive components, impacts of its failout or breakdown are analyzed (based on simulation). N − k with k = 2 or even more would be better, but is often regarded as computationally too expensive, especially for networks with many elements.
For gas transport networks or coupled networks, a comparable analysis can be performed, but is not standard.
A certain simulation-free, very restricted variant, the so-called gas N −1 standard of the EU Regulation, is necessary for assessing security of the gas supply of a European country. "The N-1 formula is used to estimate whether the gas infrastructure of the country or area of study has enough technical capacity as to satisfy the total gas demand in the event of disruption of the single largest gas infrastructure during a day of exceptionally high gas demand occurring with a statistical probability of once in 20 years" Rodríguez-Gómez et al. (2018). In Rodríguez-Gómez et al. (2018), it is discussed that a hydraulic simulation of the N − 1 scenario shall be used for assessing security, not only the N − 1 formula. Results for two neighboring (smaller) countries prove their proposition numerically.
For an overview of literature on contingency analysis for power grids, gas networks and coupled networks, see Sect. 2. To summarize findings, contingencies are modeled as outages of supply nodes or (certain) single network edges. Alternatively, an N − k problem with a low k is studied. To our knowledge, constructive approaches to set up multi-element contingencies, avoiding optimization, are not available for power as well as gas networks yet.
Distributors and collectors are not explicitly addressed in the literature. Within the typical graph representation of an energy network, such elements can be described by so-called supernodes. In particular for gas networks, they should be analyzed as well, as explained in Sect. 2.3.
In this paper, novel methods for contingency analysis based on topological reduction and so-called supernodes are introduced, among them CONT-S. They use stationary simulations, but are free of optimization, both for the time being. Novel features compared to available methods as mentioned above are -So-called supernodes are introduced as a way to determine a reasonable set of elements for an adapted N − 1 analysis as well as an analysis of multi-element contingencies. This way, not only the breakdown of one or just a few decisive components is analyzed, but all compressor stations, regulator stations, pressure and flow supplies, as well as distributors and collectors are taken into account. -Several measures and respective plots support an intuitive analysis. -Simulation is based on a full set of Euler equations including enthalpy, advanced compressor thermodynamics, and an accurate gas law, particularly allowing to analyze networks with up to 100% hydrogen. The CA column indicates coverage by contingency analysis for power grids -Even larger, realistic network models can be solved efficiently due to topological reduction methods.
The paper is organized as follows. After an overview on methods for contingency analysis of power, gas and some cross-sectoral scenarios in Sect. 2, modeling and simulation of gas transport networks as relevant for this paper are summarized in Sect. 3. TREERED is introduced in Sect. 4, the three new methods for contingency analysis, namely CONT-C, CONT-1 and CONT-S, in Sect. 5. A summary of the demonstrator used for testing the methods can be found in Sect. 6. To be more specific, based on the so-called partDE data set, a coarse version of a decisive part of the long-distance gas network of Western Germany, and an own study on existing PtG projects with (planned) injection of larger amounts of hydrogen, a demonstrator called partDE-Hy was recently assembled. In this paper, this demonstrator is used to present and discuss results of the methods developed. In particular, it is shown in Sect. 7 that the newly developed CONT-S method can estimate locations and magnitudes of additional capacities (injection, buffering, storage etc.) with a reasonable performance for networks of practical relevant composition and size. A new concept for contingency analysis is proposed at the end of Sect. 7. The paper closes with a summary and an outlook.

Energy networks and contingencies
The topology of a network for transporting power, water (drinking or sewage water, district heating or cooling) or gas is modeled by means of a graph. There are physical analogies between the fundamental through and across variables -current and voltage for power grids, flow and pressure (as well as temperature) for water and gas networks. Several analogies between decisive network elements can be found as well, see Table 1.
Remarks: Prosumers and storages can be modeled as flexible generators or supplies, respectively. Resistors etc. might be modeled standalone or as part of other elements. Gas or water networks can contain heaters, coolers or heat exchangers, in addition. Note that there are elements which are modeled as subnets containing basic elements and/or subnets. For instance, a three-winding transformer can be formed by three two-winding transformers. A compressor station can be composed of one or more compressor machine units as well as resistors and valves; a compressor machine unit can consist of a compressor, drive, regulator(s), cooler, resistors, valves, and a regulator station of a heater, regulator, resistors, valves.

Power grids
Contingency analysis is widely used for power grids. Most often, at least TSOs (transmission system operators, i.e. entities entrusted with transporting energy on a national or regional level) are enforced to perform contingency analysis based on simulations.
Note that contingency analysis is typically carried out for intermeshed networks only. Purely radial networks can obviously not fulfill an N − 1 criterion. Grids on national or regional level should be intermeshed. Distribution grids, however, might be radial only.
The principal arrangement and coverage of a contingency analysis for power grids depends on (super)national rules, see e.g. 1 and. 2 According to, 1 Articles 3 and 33, "'contingency analysis' means a computer based simulation of contingencies from the contingency list", "The contingency list shall include both ordinary contingencies and exceptional contingencies ...", "'exceptional contingency' means the simultaneous occurrence of multiple contingencies with a common cause", and "'ordinary contingency' means the occurrence of a contingency of a single branch or injection".
Such ordinary contingencies entering the contingency list are marked in Table 1. An N − 1 analysis is then based on such a list. According to, 3 the fulfillment of the respective " "N − 1" [criterion] means that the grid shall be capable of experiencing outage of a single transmission line, cable, transformer or generator without causing losses in electricity supply. N − 1 takes no account of the probability of such outages, and fails to distinguish between which, and the magnitude of, areas that may be impacted by power losses." Whether or not switches (and maybe other edge elements such as resistors) enter the list, is not specified. Transformers are typically included, see e.g. Hedman et al. (2010). For their N − 1 analysis, they take into account "the loss of any single element in the system: a transmission element or generator". Note that a transmission element is a line or transformer. However, several authors consider transmission lines only, see e.g. Wong et al. (2014) discussing a large American benchmark case.
There is critism of the N − 1 criterion, see e.g. Ovaere (2016): "the N − 1 criterion lacks transparency and flexibility, and ignores the economic trade-off between costs and benefits. Hence, scholars are developing reliability criteria that respond to these criticisms". Iver Bakken et al. (2020) discusses impacts of flexible resources in distribution systems on the security of electricity supply more generally. Probabilistic reliability criteria are developed and discussed in Sperstad et al. (2021), for instance.
Exceptional contingencies can be modeled as simultaneous outage of several elements or as a cascade of events. For instance, Abul'Wafa et al. (2019) considers N − 1 − 1 events. The so-called N − k problem asks whether there exists a set of k or fewer elements whose simultaneous outage will cause the system to fail. Many variants for solving this optimization problem can be found in the literature. For an overview, see Bienstock and Verma (2010) and Sundar et al. (2018). Other approaches are discussed as well. For instance, Mendes et al. (2010) solves contingency problems in distribution networks, which are radial due to the current switching configuration, by means of an optimization method for a reconfiguration via switching operations. Their number is only restricted by the network. However, an exact procedure to specify exceptional contingencies is not available.

Gas networks and cross-sectoral applications
Typical reasons for contingencies in gas networks are discussed in Groos et al. (2018) for Germany, showing that appropriate countermeasures have reduced the number of critical events due to corrosion or incidents at construction sites considerably. However, technical defects, extreme weather events as well as attacks have to be analyzed routinely. This is particularly true due to the ongoing integrations of gas and power networks. A survey on models for integrated power and natural gas networks coordination is presented in Farrokhifar et al. (2020).
Power-to-gas scenarios are a prominent example here. Both, hydrogen injections to networks for natural gas as well as pure hydrogen networks are discussed intensily. Müller-Syring and Henel (2014)  The recent Ahumada-Paras et al. (2021) presents a method for so-called N − k interdiction modeling for natural gas networks, also motivated by applications integrating gas networks with power systems. They use "convex relaxations for natural gas flow equations to yield tractable formulations for identifying sets of k components whose failure can cause curtailment of natural gas delivery".
To summarize, N − 1 is only applied to some most critical elements in case of gas networks (supplies, compressors) or the gas subsystem of a cross-sectoral application (supplies, compressors and gas-fired power plants). A constructive approach to set up multi-element contingencies for a gas network is not available yet.

Critical components of a gas network
Analogously to power grids, gas transport networks have a hierarchical structure. A country possesses at least one national grid with typically several regional and/or distribution grids coupled to it. For instance, in Europe, also the national gas networks are coupled to form a large European infrastructure. Gas networks on the national level are intermeshed to a certain extend, similar to power grids. See Figs. 3 and 8 for an example. Realistic models of them should reflect this and also contain details of regional grids, either as more or less detailed network models or at least as demand nodes, possibly including the respective regulator station.
Typically, a regional or distribution model is coupled to a national model by means of (at least) one t-piece. A t-piece is modeled by means of a node with three edges attached to it. A grid might also possess other nodes with more than two edges attached to it.
One reason is its intermeshed structure. Important pipeline systems such as TENP (see Fig. 8) or MEGAL, both being part of the German gas grid and also present in the partDE demonstrator, possess two or three parallel threads which are interconnected at several places.
Also, compressor stations can possess such nodes. On long onshore pipelines, a compressor station is typically installed every 100 to 200 km. Such a station typically contains two or more compressor machine units in serial, parallel and/or mixed operation modes to achieve a sufficient performance and/or redundancy.
All nodes with more than two edges attached to them, regardless of flow direction, are called supernodes in this paper. The number of edges attached is called degree. Such nodes can be interpreted as collectors and/or distributors depending on the flow directions of the attached edges.
A contingency can now occur due to leaks (holes, cracks, ruptures), congestion or other blockages of pipes, t-pieces, larger distributors or collectors or malfunction of other network elements.
Supply nodes and compressor machine units are the most critical components, storages (if present) and regulators should be considered as well. In realistic models, their overall number is small compared to the number of elements. Damages to an edge of a supernode sufficiently close to this node might influence the whole supernode, in particular in case of leaks. Due to this and their special importance for coupling of different grid levels and building up the intermeshing, supernodes should be seen as critical network components as well.
Note that contingency analysis could simulate a leakage. However, the respective part of the network is assumed to be cut off in the literature cited above and also in this paper, analogously to typical analysis scenarios for power grids. In practice, a (considerably) larger part of the network might have to be disconnected by means of valves.
This gives rise to the question whether (more or less) all edges of non-radial parts should be considered for outage, as it is usually done for power grids (see Table 1). On the one hand, realistic gas network models can easily possess several ten thousands of elements nowadays (roughly half of it are edges). On the other hand, compressor Different cases considered by TREERED: gray boxes indicate supply nodes or supernodes (with a degree ≥ 3 as shown in the box). A gray box with cyan filling indicates a supernode which is additionally a root for a tree-like structure. A cyan box marks a root of a tree which is upgraded to a supernode again machine units, regulator stations, supply nodes, supernodes and their principal connections already characterize a transmission network to a large extent. For realistic models, their number is considerably smaller than the number of edges. The connecting pipelines might "just" possess additional demands -directly modeled "on" the pipeline or at its end, see Fig. 1 for an illustration -, valves and/or flaptraps.

Modeling and simulation of gas transport networks
In the following, the fundamental equations modeling gas transport networks are described, and their numerical solution by our simulator MYNTS is outlined. Principally, any other simulator or optimizer suitable for long-distance gas transport networks might be employed for the contingency analysis introduced in this paper, among them the open-source pandapipes simulator. 4 However, if larger amounts of hydrogen are to be considered, a simulator offering a suitable gas law such as GERG2008 as well as an adequate modeling of compressors is needed, see below.
Also note that the topological reduction method TREERED introduced in Sect. 4 and employed for the contingency analysis discussed here is separate from potentially used reduction methods for speeding up simulations. For instance, methods described

Euler equations
The Euler equations are a system of nonlinear hyperbolic partial differential equations. In the stationary case and (one-dimensional) space x for gas flowing through a pipe, they read with ρ = ρ(x) being the density, p = p(x) the pressure, e = e(x) the specific energy, the friction coefficient, T S the surface temperature (temperature of the soil, assumed to be constant here) and c h = c h (x) the heat transfer coefficient of the pipe w.r.t. its surroundings (weather-dependency neglected here), and g the constant of gravitation. Note that equation (3) can be reformulated in terms of the specific enthalpy h = e + p/ρ. An additional equation is necessary. In our case, it is a so-called gas law. AGA8-DC92 International Standard: ISO 12213-2 (2016) is often used in simulation software and can be used for typical compositions of natural gas with some constraints. For our purposes, the most important ones are: a minimum of 70% methane and a maximum of 10% hydrogen is allowed. Nowadays, GERG2008 Kunz and Wagner (2012) is the most accurate gas law and can be used for all compositions of the 21 typical components of natural gas including compositions with up to 100% hydrogen. It has a much more complex description then AGA8-DC92. Here, z is modeled based on the Helmholtz free energy, split into parts for ideal gas and residual fluid. A large amount of measurement data for different combinations of gases is used to fit the considerable number of coefficients. See Kunz and Wagner (2012) and ISO 20765-2/3 for details. GERG2008 (or at least one of its predecessors) is used in a few (commercial) software products already, among them MYNTS. Clees et al. (2021a) shows that it should be used instead of AGA8-DC92.
Kirchhoff's laws are used for connecting the components of the network (pipes, compressors, regulators, valves, heaters, coolers, etc.).
Sources (supplies) and sinks (demands) are necessary to complete the system. At one or more nodes, input pressure, gas temperature and composition are prescribed (pressure supplies), and consequently at at least one, but typically many nodes power output is prescribed (flow demands). One can additionally allow for supplies with prescribed power input and gas composition (flow supplies). For more details on modeling gas transport networks and their components, see Domschke et al. (2017) and the references given therein.

MYNTS software
For simulation and analysis of gas networks, we develop a (commercial) software called MYNTS. It has been compared to a widely used simulator intensively. In particular, we developed a theoretical background (see Clees et al. (2018b) for basics and Clees et al. (2018a) for compressors) which guarantees existence and uniqueness of solutions in relevant situations and a corresponding numerical method, employ-ing IPOPT and an own nonlinear solver. For speeding up simulations, topological reduction methods are available Clees et al. (2018a), Baldin et al. (2020), and modelorder techniques are investigated (see e.g. Grundel et al. (2014)). They can be used in addition to TREERED.
MYNTS solves (stationary as well as instationary) Euler equations with advanced models for compressor thermodynamics and mixing of currently 21 gas components. As discussed in Clees et al. (2021b, a), MYNTS uses a semi-coupled approach; isothermal Euler equations, namely eqs. (1) and (2) and the GERG2008 gas law are iterated with equation (3), taking the spatially (and temporally) resolved gas composition ξ and temperature changes into account. As discussed in Clees et al. (2021a), compressor map shifting is used to model the dependency of characteristic maps from ξ .

TREERED-a method for topological reduction
In order to determine meaningful supernodes and, at the same time, clean up the network to be analyzed, a novel method for topological reduction is developed and built into MYNTS. It preserves simulation results of the respective scenario (massconservative), but represents the scenario with fewer nodes and edges. In particular, radial parts that serve for pure gas delivery purposes, are collapsed. This method called TREERED, is described in the following. Necessary terms and definitions are summarized first.

Basic graph-related terms and definitions
In MYNTS, a gas network is modeled as a directed graph G = (N , E) of its elements, namely nodes N and edges E ⊆ {(x, y) | (x, y) ∈ N 2 and x = y}. Directions are discussed below. Note that mixed graphs (with directed and undirected edges) could be used alternatively. This is not discussed here.
Pipes, compressors, regulators, resistors, valves, shortcuts, flaptraps, heaters and coolers are modeled as edges. The set of nodes consists of supplies, demands and inner nodes.
MYNTS allows for a hierarchical representation. Subnets can be set up. They can contain basic elements as mentioned above and, in addition, already defined subnets. A compressor station is a subnet and consists of basic elements (for describing all routes) and (compressor) machine units. A regulator station is a subnet and consists of basic elements (for describing all routes) and regulator units. Machine units (one compressor with its drive and cooler, valves, etc.) and regulator units (one heater, one regulator, etc.) are subnets consisting of basic elements only.
In the following, we assume that stations are resolved one step, so that the set of edges consists of machine units, regulator units, pipes, resistors, valves, shortcuts, and flaptraps only.
Let the subset E u ⊆ E consist of all pipes, resistors, valves and shortcuts and E d ⊆ E of all other types of edges considered here, i.e. machine units, regulator units, and flaptraps. The direction of all edges in E u can be chosen arbitrarily, but their specification is necessary for interpreting the sign of flow values. The direction of all edges in E d has to be modeled in the technically meaningful way, i.e. from inlet to outlet.
In addition, each element possesses properties. For the following, states of machine units, regulator units and valves are important. For a description of TREERED, it is sufficient to distinguish between "closed" and "open" (not closed). Let E i ⊆ E consist of all machine units, regulator units and valves with closed state each (inactive edges). Then, E a := E \ E i denotes the set of "open" (i.e. non-inactive) edges, and A path P(n, m, N ,Ẽ) is a connected subgraph ofG with non-recurring k > 1 nodes and k − 1 edges so that the nodes can be listed in an order n 1 , n 2 , ..., n k with n = n 1 and m = n k such that the edges are the (n i , n i+1 ) ∈Ẽ where i = 1, 2, ..., k − 1. Analogously, a path ofG a is defined. It is also called an open path ofG. Let C n (V) := {{x, y} | (x, y) ∈ V and (n = x or n = y)} denote the set of "edges treated without direction" (i.e. direction is removed, and edges of E u are not counted twice) attached to a node n w.r.t. a set V of edges. The degree of a node n w.r.t. V is |C n (V)| then.

Important definitions for TREERED
-Dead parts do not have a topological connection w.r.t.G to a pressure supply. To be more specific: An edge e (a node n) is called dead ifG does not possess a path containing e (n) starting from a pressure supply. Note that a flow supply would not be enough to feed a connected component ofG since pressure would not be defined for that part.
Here, the state of an element is ignored, i.e. if there is a connection via a closed valve etc., the part is not dead. In practice, simulation models can contain dead parts, even if they are (currently) useless for simulation. Typically, this happens during the step-by-step extension or reconfiguration of a model. -Inactive parts are not dead, but cut off from pressure supplies w.r.t.G a due to closed valves, regulator or machine units. In other words: they cannot be reached via open pathes starting from pressure supplies.
To be more specific: An edge e (a node n) is called inactive if it is not dead, but G a does not possess a path containing e (n) starting from a pressure supply.
-A (directed rooted) out-tree structure (N T , E T ) with N T ⊆ N and E T ⊆Ẽ a denotes a connected subgraph ofG a which fulfills the following property: This node n r which can act as as the starting node of unique pathes to each other node is called a root. The root might not be unique. -A radial end denotes an out-tree structure ofG a with a root n r and a set of edges E T Note that C n (E a ) = C n (Ẽ a ) for all nodes n ∈ N . Hence, only the root is allowed to have connections to the remainder ofG a . Note that if such connections are cut from n r , the radial end does not necessarily become an out-tree since it can possess edges belonging to E u , i.e. the physically undirected edges. In practice, such edges are most often pipes. -A simple radial end (SRE) denotes a radial end ofG a which does not contain machine units, regulator units, and supplies (of all kinds). In other words, a SRE is a part of the network for radial gas delivery and/or with blind alleys.

An algorithm for constructing radial ends
An out-tree structure cannot possess loops. Therefore, end nodes n e of the longest possible pathes P(n r , n e , N T , E T ) have a degree C n e (E T ) = 1. Vice versa, radial ends and their roots can be constructed by the following algorithm starting with such end nodes: 1. Set k = 0 andẼ a (0) :=Ẽ a .
2. Start from nodes n e with a degree of 1 w.r.t.Ẽ a (k) , and travel back to the starting node n s of the only edge (n s , n e ) connected to it. 3. Remove all such edges (n s , n e ) and also (n e , n s ), if it belongs toẼ a as well, from the graph to constructẼ a (k+1) . -For all n s with a degree of 1, continue with step 2.
-If n s does not have a degree of 1, it is a root.
6. This iterative process stops at a setẼ a (k e ) if all of its nodes do not have a degree of 1 w.r.t.Ẽ a (k e ) .
Depending on the actual implementation, it is sufficient to mark respective edges and nodes for deletion and treat them appropriately during the algorithm. The radial ends ofG a start at the roots found during the algorithm. In a natural way, this algorithm can be restricted to find SREs only.

TREERED algorithm
TREERED removes dead and inactive parts and collapses simple radial ends. To be more specific: 1. Determine all dead and inactive parts ofG, and mark them for deletion. 2. Collapse all SREs ofG a by marking respective edges and nodes for deletion, and aggregate all demands on the fly. For that purpose, the algorithm sketched in Sect. 4.3 has to be extended in its step 3: The aggregated power demand is stored as an additional property of this node. If the root is a supply or demand itself, this aggregated value is the surplus from the respective SRE. 3. Create a new network (with a graph K along with properties of its nodes and edges) by copying only the nodes and edges of the original G which have not been marked for deletion. 4. Check each of the roots n r found above: if its aggregated power value is nonzero, compute its degree |C n r (E a )| w.r.t. the original set of edges, and store this number as a property of the node. It is used later on for a possible update of this node to a supernode. See Fig. 1 for an illustration: three nodes are marked as a supernode, one (upper left) not.
Note that the above algorithm can be modified for ensembles and/or time-dependent runs by determining edges which are open in at least a part of the simulation runs of the ensemble and/or the time. Activate them all temporarily, and run TREERED to obtain a basic reduction which can be used for all runs planned. For the specific simulation runs / during the time progression, the states of the edges are reset if necessary.

Remarks on solutions of original and TREERED-compressed networks
For instance, Ríos-Mercado et al. (2002), Clees et al. (2018a, b) contain proofs that a gas network simulation model (at that time with fixed temperature and composition), with a prescribed pressure and one or more flow demands has a unique solution (which might be infeasible physically). In Clees et al. (2018a, b), it is also described how this can be employed to reduce tree-like substructures of a network to arrive at equivalent, but shorter network models with an explicit reconstruction process for solution values of the reduced parts. Baldin et al. (2021) extends all findings of Clees et al. (2018a, b) to cases with advanced compressor modeling and changing temperature and gas compositions and describes a constructive solution approach, implemented in MYNTS. Note that solutions might be physically infeasible. They have negative pressure values for some parts of the network then and can be classified easily. Consequences for TREERED are as follows: -TREERED is a loss-free compression, it does not alter the simulation results. In particular, if the overall model has a unique solution, the reduced network provides the same solution. -After TREERED, a detailed analysis of pressure distributions behind root nodes is not possible directly. However, after a simulation with a TREERED-tackled network, for all tree-like substructures, flow values can be computed starting from the final nodes of the leaves. Vice versa, starting from its root node, pressure drops along the leaves of the tree can be computed then. -Respective simulations for the trees can be performed in parallel in order to compute the missing details (not considered in this paper).
Note that simulation scenarios with non-unique solutions can exist in practice, particularly for large models. In such a case, a simulation result after TREERED can differ from results for the original model by more than round-off differences. Results of a successful simulation run will particularly satisfy pressure/flows at pressure/flow supplies and flows at demands, but flow-shifts in one or more parts of the network can appear.

Contingency analysis
Contingency analysis comprises an ensemble of scenarios which are analysed and/or simulated. For each member of the ensemble, one or more elements are "destroyed" (here: deleted from the network) prior to the analysis/simulation step and restored afterwards. Classically, such elements comprise compressor machine units and important supply nodes at least, as discussed in Sect. 2.3. In the following, three methods for contingency analysis are presented. All are extensions or adaptations of the classical procedure. All work with a list of nodes N 0 ⊆ N as well as a list of edges E 0 ⊆ E.
For the methods described in the following, the list of edges contains compressor machine units, regulator units, valves, pipes, resistors, shortcuts, and flaptraps. Hence, compressor stations and regulator stations are resolved one step as for TREERED.

CONT-C: a classical method for N − 1 contingency analysis
This method extends the concept described in the few N − 1 methods seen for gas networks so far (see Sect. 2.2). There, compressor machine units and important supply nodes are considered. CONT-C is based on that. It adds regulator units, all pressure supply nodes, and those flow supply nodes for which the estimated averaged supply exceeds a threshold τ P . Here, τ p = 500 MW. To be more specific, CONT-C proceeds as follows: 1. set up N 0 from all pressure supply nodes, and the flow supply nodes with an estimated averaged supply above the threshold. 2. set up E 0 from all compressor machine units and regulator units, and all edges connected to a node from N 0 . 3. in parallel: ensemble simulation based on E 0 : (a) for each edge of E 0 , one ensemble member is created by deleting the respective edge from the original scenario (which is not changed during the process) (b) perform simulation for this ensemble member 4. collect simulation results and compute residuals to supply and demand settings for original scenario 5. visualize and analyze (see Sect. 5.5) CONT-C can be applied to all networks. An application after TREERED (and/or other reduction methods) speeds up the process. A detailed analysis of the collapsed tree structures could then be performed as indicated in Sect. 4. However, in most cases, it is sufficient to analyze the aggregated power demand values, see Sect. 5.5.

CONT-1: an adapted method for N − 1 contingency analysis based on supernodes
The CONT-1 method extends CONT-C. Here, TREERED is a prerequisite to form the scenario to work with: the network is cleaned from unwanted parts, and particularly pure distribution trees are excluded -this includes their inner supernodes which would be meaningless for a contingency analysis. Remaining supernodes then represent branches to distribution trees, the intermeshed structure, and compressor-station complexity (see also Sects. 2.3 and TREERED). For each node, its degree n g is calculated. If this number is higher or equal to k, the node is regarded as a supernode of degree n g and enters N 0 . Here, we use k = 3. Note that original degrees of roots, as stored by TREERED, are taken into account in all CONT-methods presented here.
This way, all nodes acting as distributors or collectors (depending on the flow direction) are considered. In addition, all flow supply nodes are considered now (τ P = 0) and enter N 0 as well.
With the respective N 0 , CONT-1 can proceed analogously to CONT-C, steps 2 to 5. Obviously, the ensemble is (much) larger, but also more realistic compared to CONT-C, since supernodes (distributors/collectors) can be regarded as critical infrastructure as well, as explained in Sect. 2.3. However, just a single edge connected to a supernode is taken out at a time. Overall, CONT-1 is still an N − 1 method.
The result of the supernode computation for a simple case is shown in Fig. 1. In Sect. 6, results for the demonstrator are presented and discussed.

CONT-S: supernode contingency analysis
As CONT-1, the CONT-S method focusses on supernodes, supplies, compressor machine units and regulator units. Again, a topological reduction as provided by TREERED is a prerequisite to form the scenario to work with (called RED-scenario below).
However, the princple idea differs from CONT-1. As explained in Sect. 2.3, supernodes are reasonable candidates for multi-element contingencies. More specifically, CONT-S focusses on complete outages of four types of nodes, namely supernodes and supplies, as well as inlet nodes of compressor machine units and regulator units.
To be more specific, CONT-S proceeds as follows: 1. set up N 0 from all supernodes and all pressure and flow supplies. 2. Add the inlet nodes of all compressor machine units and regulator units to N 0 . 3. in parallel: ensemble simulation based on N 0 : (a) for each node n of N 0 , set up its E n by finding all edges connected to this node. (b) one ensemble member is created by deleting all edges of the current E n from the RED-scenario (c) perform simulation for this ensemble member 4. collect simulation results and compute residuals to supply and demand settings for original scenario 5. visualize and analyze (see Sect. 5.5) Table 2 summarizes the edges that are considered in the contingency methods discussed in this paper.

Visualization and analysis
For an analysis, several measures have to be computed from the simulation results. Let n s denote the number of ensemble members and, hence, simulation runs. Then, the aggregated r agg and maximum power residuals r max at a node n are defined as follows for each nonzero demand or flow supply with P k (n) being the power output and P set,k (n) the power demand at node n for run k. Note that negative values are used for flow supplies, consequently.

Fig. 2
The partDE-Hy network (in green) with larger power-to-gas projects (cyan) and hydrogen supply nodes (blue, brown) Hy was assembled by Clees et al. (2021b) for analyzing gas networks with hydrogen injection. The partDE data set is a coarse version of a decisive part of the long-distance gas network of Western Germany (cf. the public dashboard 5 and map of OGE 6 ). Compared to Clees et al. (2021b), the topology has been extended in Clees et al. (2021a) by publicly available data (websites of TSOs); several hydrogen injection points have been added, and realistic transient scenarios (for the granularity considered here) have been developed. Currently, it contains 1204 elements (nodes plus edges), including 25 compressor machine units. See Table 3 and Fig. 2 for the version used in this paper.

The BA and HY scenarios
In order to calculate effects of hydrogen injection, realistic input profiles are necessary. Given the current granularity of the partDE-Hy network, it seems appropriate to estimate an input profile for the 11 federal states of Germany close to the network (see Fig. 3). Transient profiles for all federal states of Germany are derived by the method introduced in Clees et al. (2021a), based on publicly available data from 50Herz Transmission GmbH, Amprion GmbH, TenneT TSO GmbH, TransnetBW GmbH (2019), Fraunhofer-Institut für Solare Energiesysteme ISE (2020), BDEW Bundesverband der Energie-und Wasserwirtschaft e.V. (2017), Föderal Erneuerbar (2019), Deutsche Energie-Agentur (2019). Since analysis is based on stationary scenarios here, for each transient profile an estimated average is used: Base scenario (S-BA) For each hydrogen injection node for a federal state, a low value is used as described in Clees et al. (2021b). Eemshaven and Elten have a fixed flow supply of 1000 MW each. The injection setup is depicted in Fig. 4 (left). The MYNTS simulation model for the BA scenario is shown in Fig. 3. This scenario shall demonstrate distribution of hydrogen in case of a low to moderate injection mainly from two realistic locations. Here, it represents a moderate case for contingency analysis since gas injection, composition, temperatures etc. vary moderately. Scenario with more hydrogen (S-HY) For each hydrogen injection node, its power average over a day is calculated for the "Average Saturday in Winter" profile, see Clees et al. (2021a). Eemshaven and Elten have a fixed flow supply of 5000 MW each. The injection setup is depicted in Fig. 4 (right). This scenario shall demonstrate distribution of hydrogen in case of a moderate to high injection with a realistic magnitude and direction, mainly from North to South. Here, it represents a more challenging case for contingency analysis due to the larger amount of injection nodes and amounts.

Numerical results
With CONT-C, consequences of breakdowns of the most important elements of a network can be analyzed. However, with an increasing amount of volatile gas sources -whether this will be hydrogen or methane injected to a pure hydrogen network, a network on a transition path or a pure methane network -, more points of failure have to be analyzed. CONT-1 and, moreover, CONT-S shall provide a basis. In the following, this is demonstrated by means of the partDE scenarios described in Sect. 6.
For the original network and its base scenario ("orig BA") as well as the network after TREERED with the BA and the HY scenarios, all three CONT methods explained above are applied. Runs with "orig BA" are mainly performed to compare run times and compute speedup factors. Afterwards, the BA and HY scenarios are compared in more detail in order to find weaknesses and estimate locations and magnitudes of additional capacities (injectors, buffers, storages).

TREERED
Statistical results of TREERED applied to partDE-Hy are shown in Table 3. A comparison of the topologies and simulation results for the original partDE-Hy and the reduced net for the base scenario can be found in Figs. 5 and 6. Since the original simulation scenarios have a unique solution each, simulation results are the same up to numerical tolerance, as explained in Sect. 4. See also Table 4. Run times are compared in Table 5. Note that each compressor machine unit includes one or more regulators, coolers, resistors, and valves; each regulator unit includes a heater, resistors, and valves. Then, "valves" mean all outside these stations

Supernodes
The result of the supernode computation is shown in Fig. 7. Especially on the TENP (large part to Switzerland, see also Fig. 8), one can see many supernodes of degree 3 and, on top of it, some of degree 4, due to the highly intermeshed structure of this two-thread pipeline system. One might think that such supernodes would add too many elements to E 0 . However, as 7 summarizes, starting in 2017 and planned to end in September 2020, several problematic parts of the TENP had to be switched off  Not only supply and demand nodes, but all nodes and edges, which are present in both networks are considered. Note that a medium tolerance of 1e − 5 is used for the solver, as typical in practice. The maximum differences are then as expected (not all at a time though). Problems were due to corrosion resulting from insufficient, old coating (cf. Sects. 2.2 and Groos et al. (2018)). As a consequence, capacity on the TENP was reduced by a factor of around 50%. A more detailed analysis of all possible fail-outs has been asked for. As explained in Sect. 2.3, supernodes provide a basis for that.

Comparison of performance
Performance of the methods is shown in Table 5 and Fig. 9. Obviously, CONT-1 needs significantly more runs than CONT-C, but CONT-S considerably reduces this again. Overall, even without any parallelization, the methods are efficient enough. TREERED speeds up each method considerably. One should note that the network considered has already a relevant constitution and size for practical purposes.  "orig" means original network before TREERED. All others are after TREERED Fig. 9 Overall run times in comparison for the three scenarios and methods

Rough analysis with CONT-C
For S-BA and S-HY in combination with CONT-C, only locations of failed runs are visualized in Fig. 10 since they are only a part of CONT-1 results. A comparison of locations already gives rough guidelines though: it can already be seen for CONT-C, that the HY scenario is much more demanding than the BA scenario with its much smaller hydrogen injections. The largest gas supply of both scenarios is located in the North and (together with the two hydrogen injectors) responsible for the large security of the BA scenario.
The HY scenario suffers from much larger variations due to the considerable hydrogen injection. Even if the sum of input power from hydrogen injectors (cf. Fig. 4) covers just a part of the overall power demands of HY, the gas composition varies already substantially, because calorific values of hydrogen (ca. 3.5 kWh/Nm 3 ) and e.g. methane (ca. 11.0 kWh/Nm 3 ) differ substantially. As a consequence, pressure drops, temperature and velocity changes are larger, for instance. Moreover, compressors are not able to reach pressure ratios of more than 1.04 in case of hydrogen, whereas they can reach T. Clees

More detailed analysis
For S-BA and S-HY in combination with CONT-1 and CONT-S, results are visualized as explained above in Figs. 11,12,13,14. Results clearly reveal the larger security of BA compared to HY. Since a transition from BA to HY demonstrates a possible future scenario, countermeasures shall be discussed exemplarily. Usage of CONT-1 and CONT-S is compared for this task.
As can be seen from Figs. 11 and 12 for the BA scenario, the locations of failed runs are roughly contained (geographically) in the larger set produced by CONT-S. Small deviations are present, in particular for scenarios ending with a warning (yellow). Analogously, this is true for the HY scenario, see Figs. 13 and 14. In addition, CONT-S estimates a few more severe runs compared to CONT-1. Both effects are to be While the locations of failed runs indicate zones with higher need of action, the residuals quantify sensitivity of regions. Maximum residuals for successful runs provide "worse"-case data for the failouts considered -the worst case would be shown by data from the failed runs. However, they cover the whole supply scenery for CONT-1 and CONT-S, and just serve as an overview of the scenario (cf. Fig. 4).
The two remaining plots visualize aggregated residuals for successful and failed runs. They estimate probability of missing power supply at the respective location. Maxima of both estimate magnitude of additional capacities. Such values can be used for determining priority of actions as well. CONT-S estimates higher values compared to CONT-1 and should be favored for such tasks.
Solutions might be provided by additional sources or storage facilities or other extensions/changes of the network. Note that linepack buffering might already help, but need transient analysis. In the scenarios, BA should obtain additional capacities T. Clees first in the South on the TENP, then on the MEGAL (connecting France and the Czech Republic), whereas HY should obtain additional capacities in the South and North (more or less) simultaneously, before additional actions on the MEGAL and other locations in between shall be considered.

A concept for TSOs
All CONT-methods have their range of applicability: -CONT-C allows a quick analysis of the most critical elements of a gas network. -CONT-1 provides a realistic subset of N −1 contingencies due to the introduction of supernodes (after TREERED). Note that a consideration of all network elements for the contingency list is computationally too expensive for realistic network models and not necessary -just a few demands, valves, flaptraps might be left over in between the critical elements of the contingency list. It seems most efficient to add them manually to the list. -CONT-S is computationally considerably more efficient and allows for analyzing multi-element contingencies. As argumented in the paper, these should be more realistic compared to single-edge outages, at least for transmission gas networks considered here. Heuristically, one can see that both methods find a comparable set of most problematic network locations. Therefore, CONT-S should be preferred.
Note that even CONT-C for the partDE-scenarios reveals critical cases. Therefore, partDE does not even fulfill the N − 1 criterion. For gas networks, it is currently not enforced and might be problematic economically (cf. also criticism of N −1 for power grids indicated in Sect. 2.1). The goal here is to allow for an efficient analysis of critical cases and provide a basis for planning and comparing possible countermeasures. For this purpose, a TSO can employ results of a contingency analysis with one of the CONT-methods as follows: -failed runs: -They provide an overview on most critical network components and should be analyzed completely (also as part of staff trainings, cf. Groos et al. (2018)).
-Aggregated power residuals for such failed runs can be used to localize deficacies of the current network (model) and optimize it: • compressor stations: operation modes, power of machine units, number of machine units, interplay with regulator operation • supply nodes, t-pieces: add capacities (increased injection of renewable ressources, storages, larger pipelines and/or diameters for buffering), add routes (redundancy, buffering) -Since the runs were failed, new simulation (optimization) runs have to be performed in order to arrive at valid numerical values to assess countermeasures proposed. -Changes to operation modes and capacities have an impact on other runs of the CONT ensemble. Hence, the contingency analysis should be repeated with the new model.
-successful runs: -Identify critical network components: • rank contingencies by their aggregated power residuals -they estimate probability of missing power supply at the respective location. • decide on a threshold -(at least) for contingencies above this threshold, identify locations and magnitudes of new/enlarged storage capacities: • re-calculate maximum values if set of contingencies is restricted due to the threshold • rank maximum power residuals • use them as a basis for planning (optimization) of additional capacities (more renewable ressources, storages, larger buffering) and routes (redundancy, buffering) Note that countermeasures discussed in Groos et al. (2018), such as cathodic corrosion protection and enhancement of organisatorial measures for protection against thirdparty intervention, have to be implemented anyway.

Conclusion and outlook
Novel methods, CONT-C, CONT-1 and CONT-S for an adapted N − 1 contingency analysis of gas transport networks are presented, the efficiency of CONT-S discussed for the partDE-Hy demonstrator, and a new concept for TSOs proposed. The novel methods are based on the TREERED method for topological reduction and supernodes. Stationary Euler equations with advanced compressor thermodynamics and a gas law allowing for gas compositions with up to 100% hydrogen are used. Several measures and plots support an intuitive comparison and analysis of the results. In particular, it is shown that CONT-S can estimate locations and magnitudes of additional capacities (injection, buffering, storage etc.) with a reasonable performance for networks of practical relevant composition and size.
Future work shall extend the method in several aspects. Among them are probabilistic methods, analogously to methods for power grids (cf. Sect. 2.1), transient cases, incorporation of model-order reduction as well as N − k interdiction modeling (cf. Sect. 2.2).
As indicated in Sect. 2, power, water and gas networks are similar to a certain extend. A transfer of the new methods proposed in this paper to district heating, power networks and especially cross-sectoral applications (e.g. coupled gas-power networks or power-heat-gas-networks) shall be analyzed in future work. Some concepts might be useful for railway systems or big data network topologies as well.