Summary
With the increasing interdependency of electricity and gas, it is necessary to simultaneously investigate electric power system and natural gas system from the perspective of an electricity‐gas integrated energy system (EGIES). As an extension and integration of both optimal power flow (OPF) and optimal gas flow (OGF), optimal energy flow (OEF) is regarded as the cornerstone of the EGIES and lays an essential foundation for further research on the EGIES's operation and analysis considering stochastic conditions and contingency states. The objective of this paper is to develop a generalized mathematical model and a universally applicable simulation tool for the OEF problem. First, natural gas system is modeled in a way similar to electric power system according to electricity‐gas analogy analysis, where gas admittance, gas nodal admittance matrix, and the nodal equation of gas flow conservation are derived. Then, a generalized accurate OEF model is formulated by simultaneously integrating the OPF model and the OGF model as well as their coupling constraints in a unified modeling framework. Furthermore, an available hybrid optimization approach consisting of whale optimization algorithm, MATPOWER, hydraulic calculation iterative program, and nonstationary penalty function method is put forward to solve the OEF problem. The accuracy, feasibility, and applicability of the proposed modeling and solution method is finally demonstrated by analyzing Belgian 20‐node gas system combined with IEEE 30‐bus test system.