Flexible Dispatch for Integrated Power and Gas Systems Considering Power-to-Gas and Demand Response

: Aiming at the problem of insufﬁcient ﬂexibility of the power system caused by large-scale wind power grid integration, a ﬂexible economic dispatch model of the electricity-gas integrated system that considers power-to-gas and demand responses is proposed. First, it elaborates on the scheduling ﬂexibility and demand response model. Secondly, the power system and the natural gas system are regarded as different stakeholders; with the goal of minimizing their respective operating costs, a two-tier distributed coordination optimization model of electricity and gas system is established. In order to achieve the coordination and optimization of the upper and lower systems, slack variables are introduced to describe the infeasible part of the power system scheduling results in the natural gas system and are used for interactive iterative solution of the model. The numerical results of the revised IEEE 30-node power system and 10-node natural gas system illustrate the effectiveness and necessity of the proposed model, as well as the superiority of comprehensively considering power-to-gas and demand response in improving the ﬂexibility and economy of the power system.


Introduction
With the increasingly prominent energy and environmental problems, renewable energy power generation has attracted wide attention from all over the world [1]. As a kind of typical renewable energy resources, wind power has been developed rapidly in recent years. However, the uncertainty and volatility of wind power challenge the flexibility of power systems, resulting in a large amount of wind power curtailment [2]. In 2017, the total wind power curtailment rate was over 20% in the north of China [3]. Therefore, it is urgent to improve the power system flexibility to benefit the accommodation of wind power while ensuring the secure operation of power systems.
Nowadays, many measures can be taken to improve the flexibility of power systems with high penetration of wind power. From the generation side, more gas-fired generators are built due to their high generation efficiency, fast ramp rate, and low CO2 emission intensity [4]. From the load side, the demand-side response can contribute to changing the hourly load profile to add the power system flexibility [5]. From the energy conversion, power-to-gas (P2G) facility is an effective way that has recently been widely studied to provide the flexibility of power systems with large-scale wind power in China [6]. Since the large-capacity power storages still face challenges, excessive wind power has to be curtailed. Thanks to the P2G technology, the excessive wind power can be converted into hydrogen (H2) by water electrolysis and further converted into methane (CH4) via Sabatier reaction. Afterwards, methane can be stored via the natural gas systems or storage devices [7].
To address these gaps, a flexible economic dispatch model for the integrated power and gas systems (IPGS) is proposed in this paper, which considers the P2G facilities and demand response under high wind power penetration level. In addition to the total operation cost of integrated power and gas systems, the flexibility margin of the power system is also considered in the objective function, where this flexibility is mainly provided by adjustable generators, P2G facilities, and demand response. Furthermore, considering the actual situation of power system and natural gas system, the whole model is solved by using a distributed coordinated optimization method. Briefly, the major contributions of this paper are summarized as follows.
(1) A flexible and economic dispatch model for the electricity-gas interconnection system that incorporates P2G and demand response is proposed to improve system flexibility and economy, as well as the system's ability to cope with uncertainty.
(2) The two scheduling methods of separate optimization and coordinated optimization of power and natural gas systems are compared and analyzed. To improve the overall resource utilization level of the system, it is necessary to implement coordinated optimization dispatch.
(3) A two-level optimization model is developed and slack variables are introduced to solve the power system and natural gas system interactively and iteratively.
The rest of this paper is organized as follows. Section 2 analyzes the flexibility of the IPGS and demand response model. The flexible economic dispatch model is formulated in Section 3. Section 4 presents the solution methodology for the proposed bi-level coordinated optimization model. A case study is presented in Section 5 to show the effectiveness of the proposed approach. Finally, the conclusions are drawn in Section 6.

Scheduling Flexibility for Grid-Connected Wind Power
After a large-scale wind power grid-connected, the net load changes more dramatically, which makes it difficult to effectively respond to the rapid change of net load through reserve capacity allocation alone and brings a severe test to the safe operation of the system. Dispatch flexibility has become a key indicator to measure the system operation performance by optimizing the allocation of various flexible resources in a certain time scale and responding to the change of net load at a certain cost.
Whether the dispatch flexibility is adequate depends on two aspects. One is the adjustable capacity that the system can provide. The other is the demand of the adjustable capacity for uncertainties in the system. Therefore, quantitative description is made from these two sides.

Adjustable Capacity Supply
In wind power grid-connected system, adjustable capacity is mainly provided by various flexible resources. Since the generator unit has a certain adjustable ability, it has been regarded as the main undertaker of dispatch flexibility. In addition to generator unit, the P2G facility, wind power curtailment and load reduction in the day-ahead stage are also considered as flexible resources to provide adjustable capacity for the system.
When the net load changes, the generator unit provides adjustable capacity for system according to its output range and ramp rate limit. The maximum upward and downward adjustable capacity it can provide is as follows: From the perspective of flexibility, the P2G facility can also be compared to "conventional generator set", that is, to provide the system with adjustable capacity up and down under specific operating range and climbing constraints. The expression is as follows: In terms of demand response, through reasonable incentives, users can flexibly change their own power needs, thereby providing upward and downward adjustable capacity, as follows: During peak load hours, upward adjustable capacity f u plcur,t can be provided through load shedding, and when excess wind power cannot be absorbed, downward adjustable capacity f d pwcur,t can be provided through wind power curtailment. The expression is as follows: Therefore, the upward and downward adjustable capacity provided by the IGPS is shown in the following formula:

Adjustable Capacity Demand
Adjustable capacity demand mainly comes from uncertainties of net load. To address the uncertainties in assessing the power system flexibility, f u D,t and f d D,t are expressed as the upward and downward net load uncertainty. Flexibility margin indicators FM u t and FM d t are defined to describe the upward and downward flexibility at the time period t with the consideration of uncertainties. The expression is as follows: Obviously, if FM u t and FM d t are positive, the system will have enough upward and downward flexibility; otherwise, the flexibility is insufficient.

Demand Response Model
According to different response methods, demand response is mainly divided into price-type demand response and incentive-type demand response [33]. Since the incentive demand response can participate in the power system reserve capacity service, this paper focuses on the incentive demand response to provide the power system with upward and downward flexibility adjustable capacity, and the expression can be expressed as f u dr,m,t = ∆P dr,m,t+1 (7a) where f u dr,m,t and f d dr,q,t , respectively, represent the upward and downward flexibility adjustable capacity provided by the incentive demand response supplier during the period t; ∆P dr,m,t+1 and ∆P dr,q,t+1 are the response capacity of the incentive demand response supplier during the period t + 1.

Flexible Economic Dispatch Model
Considering that the real-life power system and natural gas system are managed by different operators, the flexible economic dispatch model of IPGSs is actually a bi-level optimization model by using distributed cooperative optimization. Among them, the upper layer is on the power system and the lower layer is on the natural gas system. The day-ahead economic dispatch model for power systems is to minimize the total operation costs. Including system operating costs C main1 (the operating and startup/shutdown costs of coal-fired units; the gas fuel and start-up/shutdown costs of gasfired units; the P2G facility operation cost; the wind power curtailment cost; the load shedding cost) and adjustable capacity allocation costs C main2 (generator units; P2G facility; demand respond):

Constraints
The constraints of the power system are as follows.

Power System Constraints
In the above formula, f u0 p2g,p,t−1 and f d0 p2g,p,t−1 , respectively, represent the start-stop and output values of the P2G facility p obtained from the main problem.

Modeling for the Natural Gas System
The economic dispatch model for natural gas system mainly considers two objectives. One is to ensure the economical operation of the natural gas system. The other is to verify the feasibility of the adjustable capacity provided by gas-fired units and P2G facilities. The minimum total operation cost of the natural gas system over the given number of time periods is taken as the optimization goal:

Natural Gas System Constraints
Natural gas system constraints should include the operational limits of gas wells, pipelines, compressors, P2G facilities, storage facilities, and gas loads.

Coupling Constraints of the IPGS
The coupling elements of the IPGS include gas-fired units and P2G facilities. The gas-fired units consume natural gas to provide power generation for the power system, while the P2G facilities convert electric power into natural gas.
The amount of the gas fuel is a quadratic function to the power generation output, such that The amount of the gas generation is proportional to the power consumption, yielding

Solution Methodology
The flexible economic dispatch model of the IPGS has two sub-problems for optimally dispatching the individual power system and gas system. Furthermore, two sub-problems are coordinated by introducing slack variables to adjust the maximum output of gas-fired units and P2G facilities.

Flexible Economic Dispatch for the Power System
The flexible dispatching model of the power system is given in Part A, Section III. It belongs to a two-stage mixed integer nonlinear optimization problem. In order to simplify the solution process, this paper first uses a linearization method to deal with the non-linear function and constraints in the model, which are converted into a two-stage mixed integer linear optimization problem. The linearization method has been studied in many papers, so this article will not repeat them. On this basis, the Benders decomposition method is used to iteratively solve the two-stage flexible economic dispatch model. Specifically, for the main problem and the sub-problem, considering that both are linear programming problems after the transformation, the CPLEX commercial solver with high efficiency is directly used for solving.
The optimized solution is obtained through the v-th iteration of the main problem.
Mainly the following variables: f wcur,k,t . Bring these results into the sub-problem to obtain the up and down adjustable capacity deficits f in each scenario of the v-th iteration. And judge whether to add Benders cut by (47): where ε is a sufficiently small real number. If the adjustable capacity shortages obtained in each scenario satisfy Equation (47), it indicates that the power generation plan and adjustable capacity allocation in the main problem have sufficient flexibility, no Benders cut is generated, and the obtained optimization solution of v-th iteration is the final optimization result. Otherwise, add Benders cut:

Economic Dispatch for the Gas System
The constraints of gas system are all linear constraints except for the pipeline flow equation. To facilitate the computation, the piecewise linear techniques can be employed to linearize the nonlinear parts. At first, take square for both sides of the Equation (38), which gives Then, the big-M method in [35] is adopted to eliminate the sgn( • ) function from the equation, giving where ν ij,t is a binary variable and M is a sufficiently large number that can be taken as the maximum value of the pipe flow. The equivalent pipeline flow equation only contains the nonlinear element of the square term. Therefore, f 2 ij,t , p 2 i,t and p 2 j,t can be processed by the incremental linearization model with the best calculation efficiency. The specific process can be found in [35].

Coordinated Optimization of Two Systems
In order to realize the coordination between the two systems, two slack variables s GT,i,t and s P2G,p,t are introduced to, respectively, represent the infeasible part of gas-fired units consumption and P2G facilities production under the operation constraints of natural gas system.

Slack Variable s GT,i,t for Gas-Fired Units
When the gas system fails to meet the gas demand of gas-fired units, the load shedding will occur and f NL,i,t > 0. Therefore, the slack variable of gas-fired unit can be expressed as follows: In order to reduce the non-served gas loads of the natural gas system to zero, adjust the maximum output of the gas-fired unit according to the Equation (53) to achieve the coordinated optimization of the two systems.

Slack Variable s P2G,p,t for P2G Facilities
The slack variable s P2G,p,t is to ensure that the gas produced by the P2G facility can be fully used by the gas system, so it is calculated according to the following formula: when s P2G,p,t is greater than zero, adjust the maximum output of P2G facility according to the Equation (56), so that the two systems can achieve coordinated optimization.
where h −1 2 (x) is the inverse of Equation (46). Figure 1 shows the flowchart of the proposed bi-level coordinated optimal dispatch of the IPGS. The main steps are as follows: (5) By solving the natural gas system optimal dispatch model, the output of the gasfired units and P2G facilities as well as the upward and downward adjustable capacity are verified. If both slack variables are zero, the solution is used as an effective solution to the optimization problem of the power system. Otherwise, the maximum output of the gas-fired units and P2G facilities is updated, and the upper power system dispatch model is resolved.

Simulation Results
In this work, an IPGS was adopted by a modified IEEE 30-bus power system [36] and a 10-node natural gas system [37] was used to demonstrate the effectiveness of the proposed flexible economic dispatch model and its advantages in enhancing the flexibility and economy of the power system. (1) Solve the main problem of power system unit commitment and adjustable capacity allocation.
(2) Solve the sub-problem of the adequacy test of adjustable capacity in power system.
(3) Check if (47) is satisfied, if not, add Benders cut and return step 1.
(4) According to the output of the gas-fired units and P2G facilities as well as the upward and downward adjustable capacity, the respective natural gas variation range are determined by (45) and (46).
(5) By solving the natural gas system optimal dispatch model, the output of the gasfired units and P2G facilities as well as the upward and downward adjustable capacity are verified. If both slack variables are zero, the solution is used as an effective solution to the optimization problem of the power system. Otherwise, the maximum output of the gas-fired units and P2G facilities is updated, and the upper power system dispatch model is resolved.

Simulation Results
In this work, an IPGS was adopted by a modified IEEE 30-bus power system [36] and a 10-node natural gas system [37] was used to demonstrate the effectiveness of the proposed flexible economic dispatch model and its advantages in enhancing the flexibility and economy of the power system.

System Description and Data Source
The topology of the test system is shown in Figure 2 The entire system includes six generating units with a total installed capacity of 540 MW. The main parameters are shown in Table A1. The bus 15 and the bus 22 are, respectively, connected to a wind farm with a rated output of 150 MW, and the penalty for wind power curtailment is set at 500 $/(MWh). The gas-fired units G5 and G6 are connected to node 6 and node 10 of the natural gas system respectively. The two P2G facilities are also installed at the bus 22 and bus 15. The maximum/minimum conversion power is 30 MW and 5 MW, and the operating cost is set to 80 $/(MWh). In the gas system, there are two gas wells W1 and W2, two storage facilities S1 and S2, three compressors, six pipelines, and five gas loads. The detailed parameters of the gas sources and storage facilities can be obtained from Tables A2 and A3. The P2G operation cost, and penalty cost of not-served gas loads are set as 80 $/(MWh) and 200 $/kcf, respectively. Forecast values of electrical load, gas load and wind generation are shown in Figure 3 with peak values of 504.73 MW, 12,816.52 kcf, and 175.84 MW, respectively.
Energies 2021, 14, x FOR PEER REVIEW

System Description and Data Source
The topology of the test system is shown in Figure 2 The entire system inclu generating units with a total installed capacity of 540 MW. The main parame shown in Table A1. The bus 15 and the bus 22 are, respectively, connected to a wi with a rated output of 150 MW, and the penalty for wind power curtailment is se $/(MWh). The gas-fired units G5 and G6 are connected to node 6 and node 10 of ural gas system respectively. The two P2G facilities are also installed at the bus 22 15. The maximum/minimum conversion power is 30 MW and 5 MW, and the op cost is set to 80 $/(MWh). In the gas system, there are two gas wells W1 and W storage facilities S1 and S2, three compressors, six pipelines, and five gas loads. tailed parameters of the gas sources and storage facilities can be obtained from Ta and A3. The P2G operation cost, and penalty cost of not-served gas loads are s $/(MWh) and 200 $/kcf, respectively. Forecast values of electrical load, gas load an generation are shown in Figure 3 with peak values of 504.73 MW, 12,816.52 kcf, an MW, respectively.

Analysis of the Impact of P2G on Flexible Economic Dispatch of Power System
The emergence of P2G facilities have made the connection between power and natural gas systems increasingly close. At the same time, as the load of the system, the P2G facilities also provide a new way for the consumption of wind during the trough of the electrical load, which greatly improves the downward sch

System Description and Data Source
The topology of the test system is shown in Figure 2 The entire system inclu generating units with a total installed capacity of 540 MW. The main parame shown in Table A1. The bus 15 and the bus 22 are, respectively, connected to a wi with a rated output of 150 MW, and the penalty for wind power curtailment is se $/(MWh). The gas-fired units G5 and G6 are connected to node 6 and node 10 of ural gas system respectively. The two P2G facilities are also installed at the bus 22 15. The maximum/minimum conversion power is 30 MW and 5 MW, and the op cost is set to 80 $/(MWh). In the gas system, there are two gas wells W1 and W storage facilities S1 and S2, three compressors, six pipelines, and five gas loads. tailed parameters of the gas sources and storage facilities can be obtained from Ta and A3. The P2G operation cost, and penalty cost of not-served gas loads are s $/(MWh) and 200 $/kcf, respectively. Forecast values of electrical load, gas load an generation are shown in Figure 3 with peak values of 504.73 MW, 12,816.52 kcf, and MW, respectively.

Analysis of the Impact of P2G on Flexible Economic Dispatch of Power System
The emergence of P2G facilities have made the connection between power and natural gas systems increasingly close. At the same time, as the load of the system, the P2G facilities also provide a new way for the consumption of wind during the trough of the electrical load, which greatly improves the downward sch

Analysis of the Impact of P2G on Flexible Economic Dispatch of Power System
The emergence of P2G facilities have made the connection between power systems and natural gas systems increasingly close. At the same time, as the load of the power Energies 2021, 14, 5554 13 of 25 system, the P2G facilities also provide a new way for the consumption of wind power during the trough of the electrical load, which greatly improves the downward scheduling flexibility and operating economy of the power system.
In order to discuss the impact of P2G facilities on flexible and economical dispatching of the power system, the part on demand response is deleted here, and the following two schemes are set for comparison and analysis: Case1: Does not include P2G facilities. Case2: P2G facilities participate in power scheduling and adjustable capacity configuration. The scheduling results of the power system under the two cases are shown in Table 1, and the corresponding unit output curve is shown in Figure 4. And Figure 5 shows the downward adjustable capacity of the power system configuration under the two cases.     It can be seen from Figure 4 that during the trough period of the electric load (1:00-6:00), due to the large wind power output, only the coal-fired units G1 and G3 are in working state in the Case1, and the output is close to the minimum output. The Case1 is similar to the Case2, but considering that the P2G facilities participate in power dispatching and adjustable capacity allocation, they increase the load of the power system during the trough period, and also provide a part of the adjustable capacity for the unit. As a result, in the process of formulating the power generation plan of the units, the coal-fired units G1 and G2 with lower power generation costs are preferentially used to provide power services. Comparing the scheduling results of the two cases in Table 1, it can be found that the generating cost and adjustable capacity allocation cost of the units in Case2 are, respectively, reduced by 606$ and 450$ compared with Case1, which ultimately reduces the total cost of the power system by 4.15%.
Observing Figure 5a, it can be seen that Case1 does not include P2G facilities. During the low load period (1:00-6:00), the system's downward adjustable capacity is mainly provided by units G1 and G3. Since the adjustable capacity provided by units G1 and G3 cannot meet the fluctuations and randomness of wind power and load. As a result, the downward adjustable capacity of 7.48 MWh and 7.08 MWh was provided to the power system through wind power curtailment at 3:00 and 6:00, respectively. In Figure 5b, Case2 provided 6.96 MW and 6.16 MW of downward adjustable capacity to the power system through the P2G facility during these two periods, so that the wind power curtailment of the power system was reduced to 0.
From the above results, it is not difficult to see that P2G facilities have advantages that cannot be ignored in improving dispatching economy and renewable energy consumption, while providing the system with flexible adjustable capacity. With the largescale grid integration of wind power, it is necessary to improve the flexibility and economy of the power system through P2G facilities. It can be seen from Figure 4 that during the trough period of the electric load (1:00-6:00), due to the large wind power output, only the coal-fired units G1 and G3 are in working state in the Case1, and the output is close to the minimum output. The Case1 is similar to the Case2, but considering that the P2G facilities participate in power dispatching and adjustable capacity allocation, they increase the load of the power system during the trough period, and also provide a part of the adjustable capacity for the unit. As a result, in the process of formulating the power generation plan of the units, the coal-fired units G1 and G2 with lower power generation costs are preferentially used to provide power services. Comparing the scheduling results of the two cases in Table 1, it can be found that the generating cost and adjustable capacity allocation cost of the units in Case2 are, respectively, reduced by 606$ and 450$ compared with Case1, which ultimately reduces the total cost of the power system by 4.15%.
Observing Figure 5a, it can be seen that Case1 does not include P2G facilities. During the low load period (1:00-6:00), the system's downward adjustable capacity is mainly provided by units G1 and G3. Since the adjustable capacity provided by units G1 and G3 cannot meet the fluctuations and randomness of wind power and load. As a result, the downward adjustable capacity of 7.48 MWh and 7.08 MWh was provided to the power system through wind power curtailment at 3:00 and 6:00, respectively. In Figure 5b, Case2 provided 6.96 MW and 6.16 MW of downward adjustable capacity to the power system through the P2G facility during these two periods, so that the wind power curtailment of the power system was reduced to 0.
From the above results, it is not difficult to see that P2G facilities have advantages that cannot be ignored in improving dispatching economy and renewable energy consumption, while providing the system with flexible adjustable capacity. With the large-scale grid integration of wind power, it is necessary to improve the flexibility and economy of the power system through P2G facilities.

Analysis of Comprehensive Consideration of P2G Facilities and Demand Response
The demand response analysis is further added here, the upward and downward demand response is divided into three levels, and the responsiveness of each level is specified. Bus 4 and Bus 21 access the incentive demand response providers DRu1 and DRu2 to provide upward adjustable capacity, and Bus 7 and Bus 19 access the incentive demand response providers DRd1 and DRd2 to provide downward adjustable capacity. The specific parameters are shown in Table A4.
In order to show the advantages of comprehensive consideration of P2G facilities and demand response in improving the flexibility and economy of the power system, the following two cases are also set here for comparative analysis: Case3: Coordination optimization of IPGS considering only P2G facilities. Case4: Coordination optimization of IPGS considering P2G facilities and demand response. Figure 6 shows the output curves of the two cases. Figure 7 shows the upward adjustable capacity of the power system configuration in the two cases.
Energies 2021, 14, x FOR PEER REVIEW Case4: Coordination optimization of IPGS considering P2G facilities and dem sponse. Figure 6 shows the output curves of the two cases. Figure 7 shows the upwa justable capacity of the power system configuration in the two cases.   Comparing the two cases of Figure 6, it can be seen that, during the peak load period, Case4 considers the P2G facilities and demand response to participate in the adjustable capacity configuration, the higher cost gas unit G6 is avoided, and the start time of the gas unit G5 is delayed from 9:00 to 10:00, which plays a role in reducing the number of online generating units and generating costs of generating units.
It can be found in Figure 7 that, in order to meet the upward scheduling flexibility requirements of the power system, Case3 uses gas-fired units with higher configuration costs during peak load hours (10:00-11:00 and 17:00-20:00) to provide adjustable capacity. However, due to the limited adjustable capacity that the unit can provide, at 11:00 it is necessary to provide a 4.30 MW upward adjustable capacity for the power system through load shedding. The Case4 considers demand response and participates in the upward adjustable capacity configuration. Both the adjustable capacity provided by the gas unit G5 at 10:00 and 19:00 and the adjustable capacity provided by the gas unit G6 at 17:00 are changed to demand respond with lower configuration costs, so that the adjustable capacity allocation cost of the power system is effectively improved. More notably, the participation of demand response provided more sources of adjustable capacity for the power system, reducing the adjustable capacity provided by load shedding at 11:00 to 0.17 MW, and optimizing the output of the unit by reducing the adjustable capacity of the G4 unit at 18:00 and 20:00.
It is obvious that, compared with Case3, Case4 considers the demand response and participates in the upward adjustable capacity allocation during the peak load period, which can provide more adjustable capacity sources for the power system, thereby achieving a wider range of optimized resource allocation. Through the coordination between the unit and demand response, it can better cope with the problem of insufficient upward scheduling flexibility of the power system caused by large-scale wind power grid integration.
The various costs of the two cases as shown in Table 2. Observing Table 2 and combining the previous flexibility analysis, we find that Case4 considers the demand response and participates in the adjustment of the capacity allocation based on the P2G facilities. The cost of adjustable capacity allocation and the penalty of load shedding are reduced by 2287$ and 4130$ respectively compared to the Case3. At the same time, due to the reduction of the adjustable capacity of the unit configuration, the power system preferentially uses the units with lower power generation costs to provide power services during the formulation of the output plan, which reduces the unit's power generation costs by 8728$ compared to Case3.
In the end, the total cost of the power system was reduced by 6.45% compared to Case3. It can be seen that comprehensive consideration of P2G facilities and demand response can improve the power system's scheduling flexibility, while also reducing the power system's operating costs.

The Proposed Coordinated Optimization of IPGS
In this part, take Case2 in Part B as an example to compare the individual optimization and coordinated optimization, and analyze the advantages of coordinated optimization in optimizing adjustable capacity allocation and economy. Figures 8 and 9 show the output of the units and the conversion of active power by the P2G facilities.

The Proposed Coordinated Optimization of IPGS
In this part, take Case2 in Part B as an example to compare the individual optimization and coordinated optimization, and analyze the advantages of coordinated optimization in optimizing adjustable capacity allocation and economy. Figures 8 and 9 show the output of the units and the conversion of active power by the P2G facilities. Observing Figure 8, it can be found that during the peak load hours (11:00-14:00 and 17:00-20:00), the coal-fired units G1, G2 and G3 with lower power generation costs all operate near the maximum power point, the adjustable upward capacity that can be provided is almost zero. In order to meet the upward scheduling flexibility requirements of the power system during these periods, both scheduling methods have started the gas unit G5 with rapid adjustment capabilities to provide electrical power services. Unlike the separate optimization, however, the coordinated optimization also started the gas unit G6 to participate in power dispatch and adjustable capacity allocation during peak load hours. It can be seen from Figure 9 that during the period of low power load (1:00-7:00), when the power system is individually optimized, the P2G1 with adjustable capacity allocation and lower cost is preferentially used. While the coordinated optimization, when the natural gas produced by P2G1 cannot be fully utilized, its maximum conversion power is adjusted, so that P2G2 is involved in power scheduling and adjustable capacity Observing Figure 8, it can be found that during the peak load hours (11:00-14:00 and 17:00-20:00), the coal-fired units G1, G2 and G3 with lower power generation costs all operate near the maximum power point, the adjustable upward capacity that can be provided is almost zero. In order to meet the upward scheduling flexibility requirements of the power system during these periods, both scheduling methods have started the gas unit G5 with rapid adjustment capabilities to provide electrical power services. Unlike the separate optimization, however, the coordinated optimization also started the gas unit G6 to participate in power dispatch and adjustable capacity allocation during peak load hours.
It can be seen from Figure 9 that during the period of low power load (1:00-7:00), when the power system is individually optimized, the P2G1 with adjustable capacity allocation and lower cost is preferentially used. While the coordinated optimization, when the natural gas produced by P2G1 cannot be fully utilized, its maximum conversion power is adjusted, so that P2G2 is involved in power scheduling and adjustable capacity allocation from 2:00 to 3:00.
In order to further illustrate the advantages of coordinated optimization in optimizing the adjustable capacity allocation, the upper and lower adjustable capacities of the power system configuration are analyzed. The upward adjustable capacity of the power system configuration under the two scheduling modes is shown in Figure 10. It can be seen from Figure 9 that during the period of low power load (1:00-7:00), when the power system is individually optimized, the P2G1 with adjustable capacity allocation and lower cost is preferentially used. While the coordinated optimization, when the natural gas produced by P2G1 cannot be fully utilized, its maximum conversion power is adjusted, so that P2G2 is involved in power scheduling and adjustable capacity allocation from 2:00 to 3:00.
In order to further illustrate the advantages of coordinated optimization in optimizing the adjustable capacity allocation, the upper and lower adjustable capacities of the power system configuration are analyzed. The upward adjustable capacity of the power system configuration under the two scheduling modes is shown in Figure 10. With reference to Figure 8, it can be seen that during the peak period of electric load (10:00-20:00), the upward adjustable capacity of the power system when independently optimized is mainly provided by the coal-fired power unit G4 and the gas unit G5. As the natural gas system node 6 connected to the gas unit G5 is also in the peak gas consumption period, it is not feasible for G5 to have adjustable capacities of 125.20 kcf, 119.55 kcf, and 123.94 kcf in 11:00, 17:00, and 18:00, respectively. In practice, the power system may experience load reduction during these periods. However, the coordinated optimization reduced the adjustable capacity provided by G5 by starting the gas unit G6 at 16:00, and at the same time increased the upward adjustable space of G4, so that the availability of the adjustable capacity configuration in actual operation was guaranteed. In addition, due to the start-up of the G6 unit, the upward adjustable capacity at 17:00 through load shedding With reference to Figure 8, it can be seen that during the peak period of electric load (10:00-20:00), the upward adjustable capacity of the power system when independently optimized is mainly provided by the coal-fired power unit G4 and the gas unit G5. As the natural gas system node 6 connected to the gas unit G5 is also in the peak gas consumption period, it is not feasible for G5 to have adjustable capacities of 125.20 kcf, 119.55 kcf, and 123.94 kcf in 11:00, 17:00, and 18:00, respectively. In practice, the power system may experience load reduction during these periods. However, the coordinated optimization reduced the adjustable capacity provided by G5 by starting the gas unit G6 at 16:00, and at the same time increased the upward adjustable space of G4, so that the availability of the adjustable capacity configuration in actual operation was guaranteed. In addition, due to the start-up of the G6 unit, the upward adjustable capacity at 17:00 through load shedding configuration was also reduced from 3.59 MW to 0.
The downward adjustable capacity of the power system configuration under the two scheduling modes is shown in Figure 11. optimized is mainly provided by the coal-fired power unit G4 and the gas unit G5. As the natural gas system node 6 connected to the gas unit G5 is also in the peak gas consumption period, it is not feasible for G5 to have adjustable capacities of 125.20 kcf, 119.55 kcf, and 123.94 kcf in 11:00, 17:00, and 18:00, respectively. In practice, the power system may experience load reduction during these periods. However, the coordinated optimization reduced the adjustable capacity provided by G5 by starting the gas unit G6 at 16:00, and at the same time increased the upward adjustable space of G4, so that the availability of the adjustable capacity configuration in actual operation was guaranteed. In addition, due to the start-up of the G6 unit, the upward adjustable capacity at 17:00 through load shedding configuration was also reduced from 3.59 MW to 0.
The downward adjustable capacity of the power system configuration under the two scheduling modes is shown in Figure 11. Based on the analysis of the downward adjustable capacity of the power system configuration under the two scheduling modes in conjunction with Figures 9 and 11, it can be found that during the low load period (1:00-7:00), When individually optimized, the downward adjustable capacity of the power system is mainly provided by the coal-fired power units G1, G2, and P2G1. During the formulation of the scheduling plan, the pressure limit of the natural gas system node 6 and the constraints of the gas intake of the gas storage equipment were not considered. As a result, the natural gas generated by P2G1 was 10.64 kcf and 25.46 kcf at 2:00 and 3:00, respectively, which could not be accepted by the natural gas system. The coordinated optimization adjusts the maximum conversion power of P2G1 in these two periods based on the amount of excess natural gas, so that the downward adjustable capacity provided by P2G1 at 3:00 is changed to be provided by P2G2.
In order to compare the economics, the flexible scheduling costs of the two methods are given, as shown in the Table 3. From the data in Table 3, it can be seen that under the same scheduling flexibility requirements, when the IPGS is individually optimized, the unit's generation cost and adjustable capacity allocation cost are lower than the coordinated optimization, and since the natural gas system does not consider the effect of the conversion of active power and adjustable capacity of the P2G facilities, the adjustable capacity allocation cost of the P2G facilities is also reduced by 187$ compared to the coordinated optimization, which ultimately reduces the total cost of the power system by 1.65%. However, it also caused a gas load reduction of 368 kcf during the scheduling process of the natural gas system, which caused the total cost of the natural gas system to increase by 15.16% compared to the coordinated optimization. At the same time, due to the constraints of natural gas system operation constraints, 36 kcf of natural gas generated by the P2G facilities cannot be accepted by the natural gas system. The coordinated optimization of the IPGS reduces the gas load reduction to zero by adjusting the maximum active output of the gas-fired units and the P2G facilities, and the natural gas produced by the P2G facilities is also fully utilized.
From the above data, it can be seen that with the increase of the proportion of gas-fired units, the scheduling scheme based on the constraints of the power system alone cannot give full play to the synergistic effect of the two energy sources. In order to improve the overall resource utilization level of the two energy systems, it is necessary to implement coordinated optimization scheduling.

Conclusions
This paper proposes a flexible economic dispatch model under the constraints of power and natural gas systems. To reduce system operation cost and enhance its response capability for uncertainty as much as possible, both the P2G facility and demand response have been considered. The co-optimization model is decomposed into a flexible economic dispatch of upper power system and an economic dispatch of lower natural gas system to realize the distributed co-optimization of power and natural gas system. Moreover, slack variables are introduced for the coordinated optimization of the upper and lower systems. Simulation results demonstrate that the proposed flexible economic dispatch model can improve the power system flexibility better than the economic dispatch model. Considering P2G facilities and demand response at the same time can effectively improve the downward flexibility during the trough period and the upward flexibility during the peak period. Compared with considering the P2G equipment alone, the total operating cost of the electricity-gas system can be reduced by 6.45%. Furthermore, the hourly unit commitment and adjustable capacity of the power system are affected by the natural gas system transmission constraints. The coordinated optimization of the power and natural gas systems can improve the optimal allocation of resources, thus reducing the operation cost of the two systems.
Author Contributions: All authors have made substantial contributions to this paper. Among them, J.D. mainly did supervision and review; F.L. and Y.Y. mainly wrote and revised this paper; Z.J. mainly did simulation calculations. All authors have read and agreed to the published version of the manuscript.

Data Availability Statement:
Most of the data supporting the results of this study have been stated in the article or appendix, and the rest can be obtained from the corresponding author upon reasonable request.

Conflicts of Interest:
The authors declare no conflict of interest.

Nomenclature
A. Indexes and Sets i, p, k, m/q Indices of units, P2G facilities, wind farms, demand response users. l, b, t Indices of branches, buses, and hours. Ω G , Ω P2G , Ω W , Ω DR Set of adjustable generator units, P2G facilities, wind farms, demand response users. s Wind power scenarios B. Constants P i,t,max , P i,t,min Max/Min output power of unit i at time t. P p2g,p,t,max , P p2g,p,t,min Max/Min power consumption of P2G facility p at time t. P DRE,m,t,max , P DRE,m,t,min Max/Min load reduction of demand response user m at time t. P l,max Power flow limits of branch l. R u,i , R d,i Up/Down ramp rate of unit i. su i , sd i Start-up/shutdown cost of unit i. Upward and downward adjustable capacity allocation costs of demand response. C well,w , C P2G,p , C storage,s Operation cost of gas well w, P2G facility p, storage facility s. C pena Penalty cost of non-served gas loads. f w,max , f w,min Max/Min gas injection of gas well w. p i,max , p i,min Max/Min pressure of gas node i. R c,max , R c,min Max/Min pressure ratio of the compressor c. E s,max , E s,min Max/Min gas storage capacity of the storage facility s. ∆t Scheduling period interval.

C g f ij
A constant depending on the characteristics of pipeline, such as temperature, length, diameter, and friction factor.

C l p ij
A constant related to the characteristics of pipeline.