Optimal Scheduling of IES Considering Thermal Transmission Delay Based on Modelica and Julia

The Integrated Energy System (IES) enables integrated control and coordinated optimization of multiple energy flows. Due to the complexity of dynamic characteristics of multiple energy flows and the significant differences in time scales, thermodynamic problems occur during the operation of the system. In this paper, we propose an IES operation method that comprehensively considers thermodynamics to reduce the impact of thermal transmission delay (TDD) on the system's operational strategy, including modeling, evaluation, and scheduling programs. Firstly, an IES model is established to describe the dynamic characteristics of the energy supply network. Secondly, a two-stage optimization scheduling model considering TDD is established to reduce the impact of TDD on the operation decisions of IES, and the thermal power imbalance rate index is proposed to measure the impact of thermodynamics. Finally, the proposed method's effectiveness is validated by utilizing a comprehensive energy system as an example and implementing it on the MWORKS platform using the Modelica and Julia languages.


Introduction
An IES integrates green and clean energy on the production side, couples energy conversion equipment with energy networks, and provides various forms of energy such as electricity, gas, heat/cooling to the consumption side, effectively reducing energy waste and improving energy utilization efficiency (Liu, et al., 2019;Song et al., 2022).Due to the different flow characteristics of in an IES, modeling IES is different from traditional energy systems.In the IES model, it is necessary to include modeling of the same type of energy transmission network (such as heat network or natural gas network) as well as modeling of the mutual conversion and coupling of heterogeneous energy sources, which increases the difficulty of modeling the IES (Cui, et al., 2022;Liu, et al., 2020;Pan, et al., 2016).The authors in (Zhai, et al., 2021) applied the characteristic method for hyperbolic partial differential equation analysis to analyze the dynamic changes of natural gas systems in IES.The authors in (Chen X, et al., 2020) established an IES model that comprehensively considers the dynamic characteristics of heat and gas transmission, which can be used for simulation analysis of IES and the synergistic optimization among different energy subsystems, providing a basis for improving the economic and security of IES services.The authors in (Liu et al., 2016) defined the meaning of multi-energy complementarity in different energy networks and conducted a comprehensive analysis of IES containing three types of energy networks, including electricity, gas, and heat, to achieve a comprehensive modeling and simulation of the three energy systems.In (Wang et al., 2019) the authors were inspired by the individual-based modeling method in bacterial ecology.An individual-based modeling method for IES was proposed by them, which decouples the entire system into multiple independent individuals and utilizes input and output sets for each individual to achieve uniform interaction.
In order to dig deeper into the dispatching value of electricity, heat/cooling, and gas loads on the demand side, plenty of research on integrated energy coordination control and dispatching optimization considering demand response has been conducted to realize the optimal utilization of various energy resources.In (Dou, et al., 2020), an elastic demand side response model in the electric-thermal coupling system is established to optimize the load scheduling, showing significant effect in cutting down the system operating cost and improving the absorption capacity of PVs.A multitime scale flexible resources coordination optimization scheme is presented in (Yan, et al., 2020), which considers the smart loads' participation and presents a multi-time-scale power dispatch model that considers coordination and interaction between resources and electrical loads.(Shen, et al., 2020) focused on regional IES and proposed a thermal-electrical coupling energy optimization method that includes virtual energy storage resources.This method effectively improves the matching degree between energy production output and user energy consumption demand, ensuring the economic and flexible operation of the system.In (Gu, et al., 2017), the thermal storage capacity of both the heating network and buildings is applied to participate in the dispatch of the IES to decrease the operational cost and increase the wind power consumption.Besides, the DOI 10.3384/ecp204561 Proceedings of the Modelica Conference 2023 October 9-11, 2023, Aachen, Germany flexible heating/cooling demand of buildings is also integrated with the flexible electrical and gas demand, to form an integrated demand response programs and participate in the energy management of energy systems, with the aim of improving economic performances and enhancing operational reliability (Wang, et al., 2017;Gu, et al., 2017).However, in almost all the existing researches, the slow heat dynamics in the heating network during the dispatch interval is usually simplified into a transient process.This simplification will result in considerable errors in the heat dynamics.It has not been investigated what impacts this simplification will bring about on the operation of the system and how to measure these impacts.Fundamentally, the heat dynamics in the heating network is governed by partial differential equations (PDE) (Jie, et al., 2012).Many numerical methods such as the finite difference method based on the characteristic path and the implicit upwind method are used to discretize the PDE into algebraic equations with proper time and spatial steps (Wang, et al., 2017).In summary, although there have been many advances in modeling, simulation, and optimization scheduling for IES, the dynamic transmission characteristics of the energy supply network are rarely considered in the research on optimization scheduling (Lu, et al., 2020).However, it has a significant impact on the operation of IES.Therefore, in this paper, we propose an IES operation method that comprehensively considers thermal dynamic, including modeling, evaluation, and scheduling programs.For the intra-day optimization scheduling of IES, we implemented the "operation decision-simulation evaluation" of IES on the same platform framework based on MWORKS (including Modelica and Julia).The main contributions of this paper are summarized as follows.(a) An IES model that considers network dynamics was developed in response to the dynamic transmission characteristics of the energy supply network.The dynamic characteristics of energy transmission in the network were simulated, and the possible impact of transmission delays on IES operational decisions was analyzed.(b) The thermal power imbalance rate was proposed as a metric to measure the impact of time resolution on IES operation.The index was calculated based on scheduling decisions and simulation results, and was used as a basis for making operational decisions.(c) An optimization scheduling model for IES considering TDD was proposed to reduce the impact of TDD on operational decisions.

Integrated Energy System Model
There are significant differences between different subsystems.Therefore, in analyzing the dynamic processes of the IES, mathematical models for each subsystem should be established.Furthermore, by combining these subsystem models with the coupling element models, equipment models and network models of various types can be coupled together to form a multienergy coupled IES model.

Natural Gas Network Model
The flow of natural gas in pipelines always follows the three laws of mass conservation equation, momentum conservation equation, and energy conservation equation (Vitaliy, et al., 2019).
Mass conservation equation: where A is cross-sectional area of pipeline;  is gas density; w is gas flow rate.Momentum conservation equation: (2) where  is the friction resistance coefficient of the gas pipeline; D is the inner diameter of the pipeline;  is the inclination angle of the pipeline.
Energy conservation equation: where Q is heat exchange; u is internal energy; H is enthalpy.

Heating Network Model
In order to study the dynamic changes in heat transfer processes inside heating system pipelines, a dynamic model of hydraulic-thermal coupling for the heating pipeline is formed by coupling a thermal calculation model with the hydraulic calculation model of the heating pipeline.
In Out The variation of heat transfer in the heating network can be expressed as the spatiotemporal distribution of the temperature and mass flow rate of the hot water in the system.Figure1 shows the process of heat transfer along the axial direction and radial loss in the hot water.The pipeline is discretized into several units, each of which has three associated heat flows that determine the energy storage change of each unit.The radial heat transfer of each unit is independent and the heat is dissipated to the external environment through the pipe wall and insulation layer.The axial flow is the connection condition of the radial temperature field of the entire pipe section, that is, the input of each unit is the output of the previous unit, and the output is the input of the next unit (Qiu, et al., 2022).
To describe the situation of considering both axial flow and radial heat dissipation simultaneously, a dynamic model of hydraulic-thermal coupling for the heating pipeline is established.The continuity equation and motion equation of pipeline flow are the same as those of gas pipelines, shown in Equations 1 and Equations 2, while the energy equation considers the radial heat dissipation of the pipeline on the original basis, as shown in Equation 4.
where m is the mass of the cell heating medium; m is the mass flow rate of the cell heat medium; r i Q is the radial heat dissipation of each unit, it can be expressed as where , i T  is the hot water temperature; 0 T is the ambient temperature; all R represents the total thermal resistance between hot water and the external environment.

Power System Load Flow Model
Compared with gas and heating systems, the power system responds quickly to disturbances, generally within milliseconds.Therefore, this paper ignores the dynamic changes in power system flow.In power system flow simulation, the power system flow simulation model can be established based on the node voltage equation, and then the solution of various state parameters of the power system can be achieved.
This article adopts a classic power flow calculation model, where the basic equation for power flow calculation is: where i P is the active power of the node i;

Coupling Element Model
Combined Heat and Power (CHP) unit is composed of gas turbines, waste heat boilers, internal combustion engines, and external combustion engines.It is a production method that combines heating and power generation, and it can produce both electricity and heat.The model of CHP unit can be expressed by the following formula.
The mathematical model for the output power of the CHP unit can be expressed as: where chp H  is the thermal power of CHP at time  ; chp P  is the electrical power of CHP at time ; load chp, m is the mass flow rate of natural gas consumed by CHP; chp  is the efficiency of the CHP unit; GV H is the high calorific value of natural gas.
The relationship between heat power and electrical power of CHP units can be expressed as: where chp k is the thermoelectric ratio of the CHP unit.The CHP unit outputs heat to the heating system, and its heat output and water temperature meet the following requirements: where s T  is the water supply temperature at the time  ; r T  is the return water temperature at the time  .

Optimization Scheduling Model for IES Considering Thermal Transmission Delay
Due to the multi-time scale characteristics of energy transmission in IES, such as electricity, gas, and heat, there is a delay in response to dispatch instructions.Compared with the power system and natural gas system, the heat dynamics of the heating system is a slowly changing process, and its response time to dispatch instructions is longer.In the determination of the operating strategy of the IES, the evolution process of heat dynamics cannot be ignored.In this paper, the framework of operation decision-making and simulation evaluation is adopted to study the optimization scheduling of IES.

Optimization Scheduling Model
The optimal dispatch of the IES aims to determine the short-term (typically, day-ahead) optimal output of devices in the system in order to minimize the cost.The dispatchable variables include the state and output of each device, the networkenergy power, and the energy power supplied to end users.The constraints include the operational constraints of the electrical power system, heating system, and nature gas system.
The total operating costs during the scheduling phase of the IES include the costs of purchasing and selling electricity, the costs of purchasing gas, and the costs of participating in the operation and maintenance of the energy supply equipment during the scheduling phase.The objective of the optimal dispatch model of the IES is as follows.
where power ex C is the costs of purchasing and selling electricity; gas buy C is the costs of purchasing gas; equi om C is the costs of participating in the operation and maintenance.
The Constraints of the optimal dispatch model of the IES is as follows.
Constraint on electrical power balance: where Load M is the natural gas load.In addition to satisfying the electricity, gas, and heat power balance constraints mentioned above, the IES scheduling model also needs to satisfy operational constraints such as energy storage device constraints, interconnection power transmission constraints, and CHP output constraints.Among these constraints, Equations 14-16 represent the energy storage device constraints, Equation 17 represents the interconnection power transmission constraint, and Equation 18 represents the CHP output constraint.

Influence of Thermal Transmission Delay
When performing optimization scheduling of an IES, the transmission delay of the heating pipeline often results in a significant time difference between our scheduling command response and the thermal load.In order to illustrate the impact of heating pipeline transmission delay on the day-ahead optimization scheduling of the IES, a simulation is performed using a specific heating pipeline (L=1000m, D=0.3m, m=50kg/s, T(start)=90℃) as an example.Three load demand changes are set for three time periods: ① T(t=0)=95℃, ② T(t=3600s)=80℃, ③ T(t=7200s)=90℃.The simulation model based on Modelica is shown in Figure 2. The simulation results are shown in Figure 3, where "T_in" represents the temperature of the heat source adjusted based on the load demand, which is numerically equal to the user's required water supply temperature."T_out" represents the actual temperature of the hot water supplied to the user.From the simulation results, it can be seen that heat network transmission delay can have a serious impact on supply-demand balance.The demand of the heat network is mainly met through the response of the heat source, and there is a delay of about one hour from the time the heat is emitted from the heat source to the time it reaches the load, leading to a serious supplydemand imbalance.Therefore, from the perspective of operating decision, it is necessary to consider heat network transmission delay in the day-ahead scheduling stage and control this supply-demand error within a certain range.The above results have verified the serious impact of heat network transmission delay.However, how to measure and overcome its impact has not yet been resolved.To address this issue, a further proposal is made for the heat power imbalance rate indicator and a twostage process method for operating strategy.

Two-Stage Optimization Scheduling Process for IES Considering Thermal Transmission Delay
The simulation results from the previous section indicate that errors in the heat power network will lead to a supply-demand imbalance of thermal energy in the IES 's day-ahead optimization scheduling.Therefore, this  It should be noted that when the heat power imbalance rate exceeds the limit, it indicates that the current operating strategy does not meet the thermal dynamic control accuracy.At this point, simulation evaluation is needed to determine the delay amount, and then reevaluate the thermal load and adjust the time resolution.The two-stage optimization scheduling process for the IES based on the "operating decision-simulation evaluation" framework is shown in

Case Studies
This paper investigates a IES with an integrated network of electricity, gas, and heat as a case study, whose topology is illustrated in Figure 5.The power grid, nature gas network, and heat network are interconnected through a CHP unit.The power grid comprises 30 nodes, which include a wind turbine, a photovoltaic power station, a small nuclear power station, and a battery unit.The gas grid comprises 17 nodes and 16 pipelines.The heat network includes 20 nodes, with 10 of them serving as user node.Building upon the aforementioned work, the scheduling strategy and system simulation model for the comprehensive energy system have been implemented using the Modelica and Julia languages.The program was developed utilizing the MWORKS.Sysplorer and MWORKS.Syslab software tools, along with their unified simulation capabilities.The system model is illustrated in Figure 6.From the figure, it can be seen that the simulation model consists of two parts: a simulation module and an optimization module.The electric power system part in the simulation module is developed based on the Julia language, while the other models are developed based on the Modelica language.The optimization module is developed based on the Julia language and the Julia code is included in the Sysplorer model through the SyslabFunction of the MWORKS platform, enabling the combination of simulation and optimization.Two optimization running strategies were simulated and compared, including a two-stage optimization scheduling method (TSOSM) that considers TDD and an optimization scheduling method (TOSM) that does not consider TDD.As shown in Table 1, the heat power imbalance, temporal resolution, and operating cost of the two methods were compared, and the heat power imbalance of TSOSM was significantly lower than that of TOSM, indicating a significant improvement in supplydemand balance, and thermal comfort is greatly improved.This is our primary focus.The cost calculation results indicate that considering thermal dynamics reduces operating costs by approximately ¥10400, which is significant when viewed from an annual perspective.However, using TSOSM requires a higher time resolution, which increases computational complexity.Figure 7 displays the heat demand of the most disadvantageous user node and the supply water temperature change curves of two methods.It can be clearly seen that TSOSM has a better response to the heat demand, while TOSM fails to meet the heat demand of users for a long period of time after the demand changes, which greatly reduces the users' thermal comfort and causes a very unfavorable impact.The comparison of the day-ahead scheduling results of the IES using TSOSM and TOSM is shown in Figure 8.For tie-line, the positive values indicate purchasing electricity, and the negative values indicate selling electricity.For the batteries, the positive value represents discharging (releasing), and the negative value represents charging (storing).The output of the battery under the two operating strategies is almost the same.The difference between the output of the CHP unit is evident in both cases.
The results indicate that considering TDD has a relatively small effect on the battery's output, but a significant impact on the CHP's output.In addition, under different operating strategies, the wind power, photovoltaic, and nuclear energy outputs are the same and equal to the predicted power generation.The power of the tie-line also varies in some periods under different operating strategies.In conclusion, considering TDD not only has a considerable impact on the thermal scheduling results, but also affects the power scheduling results, although the impact is relatively small.Substantially, TSOSM focuses on characterizing the thermal dynamic response, which leads to differences in the heat power injected into the heating network.Therefore, the scheduling results of equipment related to heat power (i.e., CHP units) will be directly affected.Under the framework of "operation decision-simulation evaluation", further analysis of the system's state can be conducted based on determining the operational decision, achieving precise control of the system, and providing a basis for scientific management in the intra-day scheduling stage.
The supply and demand response of the power system is shown in Figure 9.The CHP unit, wind power generation, photovoltaic, nuclear energy, and battery jointly provide electricity for the power system.Despite the system's high demand for electricity, it still needs to purchase electricity from the main grid to meet the shortfall in load.Under this operational strategy, the supply and demand of the system are balanced, and clean energy such as wind and photovoltaic provide most of the electricity, saving the system's operational costs.In addition, the battery discharges during periods of high load (such as 9:00-11:00 and 14:00-15:00) and charges during periods of light load (such as 23:00-4:00), to achieve peak shaving and valley filling.Changes in the state of the heating network can also trigger responses in the natural gas network, firstly affecting the load side, causing a rapid change in gas load, and then leading to the redistribution of pressure and transmission flow rate in each branch pipe.The mass flow rate changes of some sections of the natural gas network are shown in Figure 11, which shows that the flow rate of the pipe fluctuates with the load and reaches a stable state again after a period of time (about 10 minutes).In summary，the above case verify both the necessity of considering heat dynamics of the heating network and the effectiveness of the proposed dispatch procedure.The simulation results show that considering thermal dynamics has different degrees of impact on the scheduling results of the power system, heating system, and natural gas system.Since the essence of considering thermal dynamics lies in correcting the heat load, the impact on the heating system is the greatest.However, due to the characteristics of multi-energy coupling in IES, the impact on the heating system will also be coupled to the power system and natural gas system, but to a relatively lesser extent.

Conclusions
In this paper, we propose an IES operation optimization method that comprehensively considers thermal dynamics, including modeling, evaluation, and scheduling programs.The heat power imbalance rate index is introduced to evaluate the satisfaction level of heat demand.A twostage optimization scheduling model for IES considering transmission delay is proposed to reduce the impact of TDD on the system's operational strategy.Finally, the proposed method is validated using an IES.
Based on theoretical analysis and simulation results, the following conclusions can be drawn: 1) TSOSM can significantly mitigate the impact of thermal supply-demand imbalance caused by TDD, and improve users' thermal comfort.In addition, compared with the TOSM, the operating cost of TSOSM has been reduced.
2) The scheduling results of TSOSM have an impact on the heating system, power system, and natural gas system.During simulation evaluation, the dynamic characteristics of the system were also well simulated, such as when the load changes, the response time of the heating network is about 1.5 hours, and the response time of the gas network is about 10 minutes.
3) The integration of optimization scheduling of IES and multi-agent power flow analysis into a unified framework is achieved in this study.Effective methods and tools are provided for optimizing the operation and scientific management of IES.
of node j voltage; ij Y is the admittance between node i and node j.

Figure 3 .
Figure 3. Simulation results of a specific pipeline.
Figure 4.The Stage 1 is the dispatch decision process and the Stage 2 is the posterior evaluation of the supply and demand situation of thermal energy.The detailed steps are as follows: A. Initialization stage: Based on the IES model established in the second section, the IES simulation model is built.(using MWORKS.Sysplorer) B. "Operating decision" stage: Based on the established IES operation optimization model, the operating decision is made to obtain the operation optimization results.(using MWORKS.Syslab) C. "Simulation evaluation" stage: The operating decision results are input into the IES model for simulation calculation, and the heat power imbalance rate indicator is calculated based on the simulation results.(using MWORKS.Syslab and MWORKS.Sysplorer) D. Validation stage: Determine whether the operating strategy meets the thermal dynamic control accuracy requirements.If the requirements are met, the process ends; otherwise, update the day-ahead thermal load and time resolution and proceed to step B.

Figure 6 .
Figure 6.IES operating decision and simulation evaluation model.

Figure 7 .
Figure 7. Temperature comparison of the most unfavorable nodes.

Figure 8 .
Comparison of scheduling results.

Figure 9 .
Figure 9. Supply and demand response of the power system.

Figure 10
Figure 10 illustrates the temperature change curves of the supply and return pipes at the beginning and end of the heating network.As shown in the figure, the outlet temperatures of each supply and return pipe also change correspondingly with the variation of the heat load.Due to the influence of thermal inertia, the response time is about 90 minutes.Meanwhile, due to the coupling of hydraulic transmission and thermal transmission, there is a time delay of about 45 minutes between the response of the first pipe and the response of the fifth pipe, reflecting the delay characteristic of transmission, which is

Figure 11 .
Figure 11.Mass flow rate variation curve of natural gas pipeline network section proposes the heat power imbalance rate indicator to quantify the thermal dynamic errors in the operating strategy, reflecting the supply-demand imbalance of the heat network in each time period.The specific calculation formula is as follows:

Table 1 .
Comparison of results on heat power imbalance rate, time resolution, and operating cost.