**2. Modeling of RIESs**

#### *2.1. Basic structure of RIESs*

RIESs can not only realize efficient energy conversion but also gratify the cooling, heating, and electricity needs of users simultaneously. In the RIES shown in Figure 1, the input energy mainly comes from grid electricity, municipal gas, and regional renewable energy (such as solar and geothermal energy). Energy conversion equipment is used to realize the conversion of input energy to output energy, mainly including the transformer, photovoltaic (PV) arrays, CHP unit, gas boiler, GSHP, and absorption chiller (ABC). Therefore, the power, heating, and cooling hubs are introduced in the modeling idea of EH to realize the collection and distribution of different energies and ensure the balance of the supply and demand for energy. In addition, to explore the influence of energy storage devices on the optimal design and operational performance of RIESs, three RIESs with different energy storage devices are considered, and their energy storage configurations are shown in Table 2.

**Figure 1.** The basic structure of RIESs.

**Table 2.** Three RIESs with different energy storage devices.


#### *2.2. Equipment Mathematical Model*

2.2.1. Energy Conversion Device

The equipment model is the basis of system design and operation optimization. In the RIES shown in Figure 1, the PV arrays are one of the effective ways to utilize solar energy, and its power generation is usually affected by the ambient temperature, solar irradiation intensity, and power generation efficiency. Compared with PV arrays, the CHP unit can not only generate electricity, but also the waste heat can be used to meet the cooling and heating needs of buildings. Other than that, the rest of the building's cooling and heating loads are met by the GSHP and gas boiler. When constructing mathematical models for the CHP

unit and cooling and heating equipment, relevant studies generally adopt the black-box model based on energy efficiency. The model is usually divided into two types: the static equipment model and the dynamic equipment model. The static model assumes that the operating efficiency of the equipment is constant. The dynamic equipment model considers the influence of equipment partial load rate on its efficiency. To accurately describe the operation performance of the equipment, the dynamic equipment model will be established in this paper, and the specific expressions for different equipment dynamic models are shown in Table 3.



#### 2.2.2. Energy Storage Devices

On the basis of System 1, this paper investigates the impact of energy storage devices on the optimization and operation of RIESs by sequentially configuring TES and EES devices in System 2 and System 3. Different from the energy conversion equipment, the source-load duality of energy storage devices allows it to achieve the time-series transfer of energy to meet the supply-demand balance of RIESs. Therefore, the mathematical model of energy storage devices can be expressed by the charging and discharging state and power, and its specific expression is shown as follows [40]:

$$S\_k(t+1) = S\_k(t) + \left(P\_{ch,k}(t)\eta\_{ch,k} - \frac{P\_{dis,k}(t)}{\eta\_{dis,k}}\right)\Delta t\tag{1}$$

where *Sk*(*t* + 1) and *Sk*(*t*) are the energies stored in energy storage device *k* at time *t* + 1 and t, respectively; *ηch*,*<sup>k</sup>* and *ηdis*,*<sup>k</sup>* are the charging and discharging efficiency of energy storage device *k*; and *Pch*,*k*(*t*) and *Pdis*,*k*(*t*) are the charging and discharging powers of energy storage device *k* at time *t*.

#### **3. Bi-Level Optimization Model**

Energy storage devices not only affect the optimal design of RIESs but also affect their operational performance. To explore the impact of energy storage devices on the optimal design and operation of RIESs, a bi-level dynamic optimization model is established in this paper. In this model, the upper-level optimized configuration model takes the system's total cost as the optimization objective to determine the equipment capacity of RIESs. The lowerlevel optimal scheduling model takes the operating cost as the optimization objective to determine the reasonable scheduling scheme. To facilitate the understanding of the solution process of this model, the optimization process is drawn in Figure 2. Firstly, based on the outdoor design parameters, the design and operating loads of the building are calculated by Energy Plus. Secondly, the constraints of the upper-level and lower-level optimization models are established according to the design loads and the EH model. Among them, the main constraints of the upper-level optimized configuration model include the maximum equipment capacity and the design load in winter. And the constraints of the lower-level scheduling model include energy conservation and equipment operating power. Finally, the design load, outdoor parameters, and economic parameters are imported into the bi-level optimization model for solving to obtain the equipment capacity of three RIESs. With the equipment capacity known, this paper uses the lower-level scheduling model to optimize the operation of three RIESs and analyzes the impact of energy storage devices on their operational performance.

**Figure 2.** Flow chart of system optimization configuration and operation analysis.

#### *3.1. Upper-Level Optimal Configuration Model*

#### 3.1.1. Optimization Objective

To determine the equipment capacity of the three RIESs, this paper optimizes them with the minimum total cost as the optimization objective. In this study, the total cost mainly includes the system equipment cost, operating cost, and carbon tax. The specific calculation expressions are shown below:

$$\min \mathcal{C}\_{total} = \mathcal{C}\_{equ} + \mathcal{C}\_{\text{farx}} + \mathcal{C}\_{op} \tag{2}$$

where *Ctotal* is the total cost; *Cequ* is the equipment cost; *Ctax* is the carbon tax; and *Cop* is the operating cost, the values can be obtained from the lower-level scheduling model.

The system equipment cost mainly includes the initial investment and equipment maintenance cost. The initial investment in equipment depends on its capacity and the initial unit investment. The initial unit investment in the RIESs, showed Figure 1, is listed in Table 4. Under the condition that the initial unit investment of equipment is known, the initial investment of RIESs on the design day can be determined by the following formula [41].

$$\mathbb{C}\_{inv} = \sum\_{k=1}^{k} (\frac{i(1+i)^n}{(1+i)^n - 1} \cdot \mathbb{C}ap\_k \cdot \mathbb{C}\_k) / 365 \tag{3}$$

where *i* is the annual interest rate, which is 0.08 in this paper; n is the planning period, which is 20 years; *Capk* is the design capacity of the equipment *k*; and *Ck* is the initial unit investment in the equipment *k*. As the initial investment in the system's equipment is known, the maintenance cost of the system's equipment can be estimated at 2% of its initial investment [42].


**Table 4.** The initial unit investment in equipment Reproduced from [43,44].

In the context of peak carbon dioxide emissions and carbon neutrality, carbon tax compensation has become an effective means to limit greenhouse gas emissions. In the RIESs shown in Figure 1, CO2 emissions mainly come from grid power and gas, so the carbon tax cost can be calculated by the following formula.

$$\mathbf{C}\_{\text{tax}} = \theta\_{\text{tax}} \sum\_{t=1}^{24} \left( P\_{\text{grid}}(t) \cdot \lambda\_{\text{CO}\_2, \text{grid}} + P\_{\text{gals}}(t) \cdot \lambda\_{\text{CO}\_2, \text{gas}} \right) \tag{4}$$

where *ϑtax* is the carbon tax price; *λCO*2,*grid* and *λCO*2,*gas* are the equivalent CO2 emissions of coal power and gas, which are 0.968 kg/kWh and 0.220 kg/kWh, respectively [45]; and *Pgrid*(*t*) and *Pgas*(*t*) are the consumption of grid power and gas at time *t*, which can be obtained from the lower-level scheduling model.

#### 3.1.2. Optimization Variables and Constraints

In the upper-level optimization model, the optimization variable is the capacity of the candidate equipment. Considering the equipment installation conditions and building loads, its optimization variables must satisfy the following constraints.

$$0 \le \mathsf{C}ap\_k \le \mathsf{C}ap\_k^{\max} \tag{5}$$

where *Capmax <sup>k</sup>* is the maximum design capacity of equipment *k*, whose value is usually the maximum value of the corresponding load.

In addition, this study uses the design-daily load in summer as the design parameter. To gratify the load demand in winter, the maximum heat production capacity of the system must be greater than the maximal heating load.

$$P\_{\text{g-shp,h}}^{\text{max}} + P\_{\text{chp,h}}^{\text{max}} + P\_{\text{g,h}}^{\text{max}} \ge L\_{\text{user},h}^{\text{max}} \tag{6}$$

where *Pmax gshp*,*<sup>h</sup>* is the maximum heat production of the GSHP; *<sup>P</sup>max chp*,*<sup>h</sup>* is the maximum heat production of the CHP unit; *Pmax gb*,*<sup>h</sup>* is the maximum heat production of the gas boiler; and *Lmax user*,*<sup>h</sup>* is the maximum heating load in winter.

#### *3.2. Lower-Level Optimal Scheduling Model*

#### 3.2.1. Optimization Objective

To achieve flexible scheduling, the minimum operating cost is used as the optimization objective to optimize the operation of three RIESs. The operating cost mainly comes from the electricity and gas costs, whose values can be determined by the following formula:

$$\text{minC}\_{op} = \sum\_{t=1}^{24} \left( P\_{\text{grid}}(t) \cdot \theta\_{\text{grid}}(t) + P\_{\text{gas}}(t) \cdot \theta\_{\text{gas}} \right) \tag{7}$$

where *ϑgrid* is the time-of-use (TOU) electricity price; and *ϑgas* is the gas price.

#### 3.2.2. Optimization Variables and Constraints

In the lower-level optimization model, the main optimization variable is the operating power of the equipment. The operating power should not only gratify the capacity constraints of the upper-level equipment but also meet the supply-demand balance constraints of the EH.

1. Equipment operating power constraints

#### (1) Energy conversion equipment

The operating power of the energy conversion equipment is both restricted by the capacity of the upper-level equipment and affected by the start-up and shutdown of the equipment. Therefore, the operating power is a semi-continuous variable whose range is shown in the following formula:

$$\begin{cases} 0 & PLR\_k < PLR\_k^{min} \\ P\_k^{min} \le P\_k \le P\_k^{max} & PLR\_k \ge PLR\_k^{min} \end{cases} \tag{8}$$

where *PLRk* is the part-load ratio of equipment *k*; *PLRmin <sup>k</sup>* is the minimum part-load ratio for the start-up of equipment *k*; and *Pmin <sup>k</sup>* and *<sup>P</sup>max <sup>k</sup>* are the minimum and maximum output power of equipment *k* in the operating state.

#### (2) Energy storage equipment

Different from energy conversion equipment, energy storage devices should not only gratify the charging and discharging power constraints but also the charging and discharging state constraints, which are specifically expressed as follows:

$$0 \le P\_{\rm cl,k}(t) \le \mu\_k \cdot \gamma\_{\rm cl,k}^{\rm max} \cdot S\_k \tag{9}$$

$$0 \le P\_{dis,k}(t) \le (1 - \mu\_k) \cdot \gamma\_{dis,k}^{\max} \cdot S\_k \tag{10}$$

$$
\mathfrak{a}\_k^{\min} \cdot \mathcal{S}\_k \le \mathcal{S}\_k(t) \le \mathfrak{a}\_k^{\max} \cdot \mathcal{S}\_k \tag{11}
$$

where *uk* is a variable of 0 or 1, which is introduced to ensure that the charging process and discharging process will not happen simultaneously; *γmax ch*,*<sup>k</sup>* and *<sup>γ</sup>max dis*,*<sup>k</sup>* are the maximum charging and discharging ratios of energy storage device *k*; *αmin <sup>k</sup>* and *<sup>α</sup>max <sup>k</sup>* are the minimum and the maximum energy storage ratios of energy storage device *k*, respectively; and *Sk* is the capacity of energy storage device *k*.

#### 2. Energy balance constraint

During the operation of RIESs, the EH is only used for energy collection and distribution. Therefore, the three energy hubs must maintain a balance between supply and demand, with the balance constraint shown below.

$$P\_{grid}(t) + P\_{chip}(t) + P\_{pv}(t) + P\_{dis,ces}(t) = L\_{user,\varepsilon}(t) + P\_{gshp,\varepsilon}(t) + P\_{ch,res}(t)\tag{12}$$

$$P\_{\text{gshp,c}}(t) + P\_{\text{abc,c}}(t) = L\_{\text{user,c}}(t) \tag{13}$$

$$P\_{\rm chp}(t) + P\_{\rm gb}(t) + P\_{\rm dis.tes}(t) = L\_{\rm user,h}(t) + P\_{\rm abc,h}(t) + P\_{\rm ch.test}(t) \tag{14}$$

where *Pgshp*,*<sup>e</sup>* is the electricity consumption of GSHP; *Pgshp*,*<sup>c</sup>* is the cooling power of GSHP; *Pabc*,*<sup>c</sup>* is the cooling power of ABC; *Pabc*,*<sup>h</sup>* is the heat consumption of ABC; and *Pgb* is the heat production of the gas boiler.
