Design and Operation Optimization of Distributed Solar Energy System Based on Dynamic Operation Strategy

: The rapid urbanization in Northwest China highlights the mismatch of increasing energy demand and limited local energy supply. Nevertheless, the remote areas in Northwest China are abundant with rich solar energy resources and land space resource. Therefore, establishing a distributed solar energy system (DSES) is a feasible solution to the energy supply problem in remote Northwest China. Due to the strong ﬂuctuations in the availability of solar energy, operation strategies based on ﬁxed parameters may not ensure optimal operation of DSESs. In this study, dynamic operation strategies that allocate surplus power from photovoltaic panels according to variable ratios were developed in both grid-connected and off-grid scenarios, a joint optimization model for optimizing the design and operation of a DSES was established based on the dynamic operation strategies, and a DSES of a residential building in Shaanxi Province was used as a case study. The analysis results indicate that: (1) The dynamic operation strategy can effectively reduce the operating cost of the DSES in both the grid-connected and off-grid scenarios, and the efﬁciency of the proposed strategy can be further enhanced by increasing the difference between peak and valley time-of-use electricity prices in the grid-connected scenario; (2) the difference between peak and valley time-of-use electricity prices has a signiﬁcant impact on the optimal capacity of the batteries in the grid-connected scenario when the dynamic operation strategy is implemented. The greater the difference between peak and valley time-of-use electricity prices, the greater the conﬁgured capacity of the batteries; (3) in terms of abandoned photovoltaic power in the off-grid scenario, the three operation strategies considered in this study can be arranged in an ascending order (i.e., strategy B, strategy A, and the dynamic operation strategy). The dynamic operation strategy achieves a reduction of 12.4% in abandoned photovoltaic power compared with strategy A and a reduction of 45.4% compared with strategy B.


Introduction
The rapid urbanization in Northwest China highlights the mismatch of increasing energy demand and limited local energy supply. As to the remote areas in Northwest China, the problems are even worse due to the poor energy infrastructure [1]. Nevertheless, the remote areas in Northwest China are abundant in rich solar energy resources and land space resources. According to [2], the annual total solar radiation range in Northwest China is 5850~8400 MJ/m 2 , and the daily radiation range is 4.5~6.4 kWh/m 2 . In comparison with other regions, the climate in Northwest China is colder and drier, resulting in great heating demands in winter [3]. As the most widely used renewable energy, solar energy is safe, clean, and convenient to exploit. Thus, developing distributed solar energy systems (DSESs) [4] could be a feasible solution to the local energy supply problem in remote Northwest China. However, solar energy also has some prominent shortcomings such as randomness, intermittency, and volatility [5]. By building a distributed energy system incorporating photovoltaic arrays, gas internal combustion engines, and fuel panels. They analyzed the multi-goal operation optimization of the system using the example of an ecological campus in Japan. In order to quantify the influence of the uncertainty in the energy demand and supply on the optimization of a distributed energy supply system, Zhou et al. [22] proposed a two-level stochastic programming model to convert the influence of this uncertainty into a two-level stochastic programming problem, which can be solved using a genetic algorithm (GA) in conjunction with the Monte Carlo method. They applied this model to optimize the design of a distributed energy system which supplied energy to a hotel. Mariaud et al. [23] proposed a comprehensive optimization model of the equipment selection and operation for distributed energy systems in commercial buildings. Using the example of a distribution center in London, UK, they used the steady-state MILP method to optimize the equipment selection, capacity configuration, and operation of a photovoltaic system with batteries as back-up. Ren et al. [24] applied the mathematical programming theory to construct a configuration optimization model that can be used to facilitate simultaneous optimization of the system structure, the number and capacities of devices, and the operation strategy for distributed multi-energy complementary systems. Luo et al. [25] proposed a bi-level optimization model to obtain optimal design, operation, and subsidies for a standalone multi-generation energy system situated on a remote island; the system incorporates solar energy, fossil energy, and storage. Herein, the social cost to the society is set as the upper-level objective, and the private cost to the residents is set as the lower-level objective. Production-based incentives of solar electrical energy and solar thermal energy jointly impact the design and operation of the energy system to minimize the social and private costs simultaneously.
Although joint optimization using the linearization method to approximate a nonlinear model can significantly improve the performance of the system, and it is the most appropriate from the viewpoint of accuracy, on-line operation optimization problems involving a large number of variables result in significantly increased requirements on the optimization algorithms and calculation tools. As a result, design optimization under predefined operation strategies is still a common practice. A compromise approach is to use flexible operation strategies. In the studies on the system optimization under flexible operation strategies, the operation strategies that follow the electric load (FEL) and the thermal load (FTL) strategies are more commonly seen. For example, Liu et al. [26] established a comprehensive evaluation index for a CCHP system combined with solar energy. The system was set to operate in FTL and FEL operating modes. Mago et al. [27] used the life cycle method to analyze the optimization of the FEL and FTL strategies of the distributed energy systems in high-rise buildings. Jing et al. [28] proposed an optimized operation strategy that responded to the changes in electricity-heating mixed load for improving the performance of the CHP system. Liu et al. [29] optimized the running strategy of a residential cogeneration system by introducing and discussing the effect of a hypothetical CHP system for a detached house. Based on the seasonally electricity and thermal load characteristics, several annual running strategies were established, considering the cogeneration equipment efficiency (electricity generation and thermal recover efficiencies). Then, the effect of the running strategy was evaluated from the perspective of energy saving, energy cost, and environmental effects. Considering the regular change trend of renewable energy output and user energy demand during the simulation cycle, it is also common to research on improving the overall performance of the system by switching operating strategies under different conditions. For example, Qiu et al. [30] designed day-time and night-time operation strategies for the distributed CCHP incorporating renewable energy. Hamdullahpur et al. [31] analyzed and evaluated three operating modes (solar energy direct heating mode, solar energy heating and storage mode, and solar energy heat storage mode) of a new type of distributed CCHP system incorporating a parabolic trough solar energy heat collector and an organic Rankine cycle system. The analysis results show that the maximum overall efficiency of the CCHP system is 94%, 47%, and 42% when the system operates in the above three modes, respectively. Moghadam et al. [32] studied the per- formance of three operation strategies of the micro CHP system (satisfying the minimum annual power consumption, satisfying the maximum annual power consumption, and maintaining constant power output) incorporating solar energy and dish Stirling engine in five cities in Iran with different climatic conditions, and evaluated the performance of each operation strategy in the context of energy, environment, and economy. Under the condition of varying load and energy price, Facci et al. [33] used the dynamic programming method to solve the daily optimal operating conditions of gas turbines, which effectively reduced the operating cost of the system compared with the basic operating modes of FTL and TEL. Zhao et al. [34] proposed a micro-grid optimization strategy that considered demand response. The strategy took into account the uncertainty of distributed renewable energy generation, power load, and daytime market prices. Liu et al. [35] proposed a structural configuration of the CCHP system with hybrid chillers, consisting of a combined electric and absorption chiller. A new operation strategy based on the ratio of the variational electric cooling to cool load was investigated. In addition, a case study was conducted to verify the feasibility of the proposed CCHP system structure and the corresponding optimal operation strategy.
The comparison between the above energy system design optimization methods is shown in Table 1. In real applications, the operation of most multi-energy complementary systems is still based on relatively fixed operation strategies in which the control logic remains unchanged during a long operation period, resulting in a large gap between the actual system design and the optimal system design. Although the switching of operation strategies can improve the operating accuracy of the system to a certain extent, there is still a large scope for improvement in the switching mechanism. For economically underdeveloped areas (e.g., the remote areas in Northwest China), the economics of the energy system is of great importance to the local government and residents. Thus, the reasonable and precise design is vital to the promotion and application of DSES, and the gap between the actual system design and optimal design cannot be ignored. In order to solve this problem, a joint optimization method for the design and operation of a DSES based on dynamic operation strategies is proposed in this study. The choice of dynamic operation strategies is based on the strong fluctuations of power output and complex energy coupling in such energy systems. A simulation is conducted to verify the effectiveness of the proposed method. This method can automatically adjust the operation strategy parameters in real-time according to the supply-demand situation of the system, thereby realizing the joint optimization of the design and operation of the system. Design and operation joint optimization Most appropriate from the viewpoint of accuracy, but need more computing time [38] [ [18][19][20][21][22][23][24][25]

System Configurations
The DSES in this study can be either grid-connected or off-grid. The grid-connected system consists of solar heat collectors, solar photovoltaic panels, air source heat pumps, water tank, and batteries. The off-grid system consists of solar heat collectors, solar photovoltaic panels, air source heat pumps, diesel generator, water tank (with electric heater inside), and batteries. The solar photovoltaic panels and auxiliary power systems work together to meet the electricity demand; the solar collectors, air source heat pumps, and electric heater meet the heating demand; and the water tank and batteries serve as energy storage devices. The grid-connected system (Figure 1a) is connected to the power grid. When the system's power output is greater than the power demand, the surplus power is sold to the grid; when the system's power output is less than the power demand, the gap is filled by the power grid. The off-grid system is separated from the power grid ( Figure 1b). When the system's power output is greater than the power demand, the surplus power is stored in the batteries; when the system's power output is less than the power demand, the gap is filled by the batteries and diesel generator.

System Configurations
The DSES in this study can be either grid-connected or off-grid. The grid-connected system consists of solar heat collectors, solar photovoltaic panels, air source heat pumps, water tank, and batteries. The off-grid system consists of solar heat collectors, solar photovoltaic panels, air source heat pumps, diesel generator, water tank (with electric heater inside), and batteries. The solar photovoltaic panels and auxiliary power systems work together to meet the electricity demand; the solar collectors, air source heat pumps, and electric heater meet the heating demand; and the water tank and batteries serve as energy storage devices. The grid-connected system (Figure 1a) is connected to the power grid. When the system's power output is greater than the power demand, the surplus power is sold to the grid; when the system's power output is less than the power demand, the gap is filled by the power grid. The off-grid system is separated from the power grid ( Figure  1b). When the system's power output is greater than the power demand, the surplus power is stored in the batteries; when the system's power output is less than the power demand, the gap is filled by the batteries and diesel generator.

Operation Strategies
This study assumed that the system's water supply temperature is 43 °C [39]. The control methods of solar thermal system include constant temperature control, tempera-

Operation Strategies
This study assumed that the system's water supply temperature is 43 • C [39]. The control methods of solar thermal system include constant temperature control, temperature difference control, photoelectric control, timer control, etc. The most common are constant temperature control and temperature difference control, in which temperature and temperature difference are, respectively, used as driving signals to control the system valve ports and circulating pumps. Compared with constant temperature control, which is usually used in direct current systems, temperature difference control is more widely used in forced circulation systems [40,41]. The proposed system in this paper assumed that the circulating pump is a forced circulation system; thus, temperature difference control is adopted. The on and off of the circulating pump are controlled by the temperature difference between the outlet water temperature of the solar collector and the water temperature in the water tank. This study set this control strategy: when the temperature difference is greater than 5 • C, the solar circulating pump is turned on; when the temperature difference is less than 2 • C, the solar circulating pump will automatically shut down [42][43][44]. The air source heat pump adopted fixed temperature control. When the water temperature of the water tank is lower than the lower limit of 43 • C, the heat pump is turned on; when the water temperature is higher than the upper limit of 53 • C, the heat pump is turned off. According to the above operation strategy, there may exist surplus photovoltaic power, DetaP, after a part of the power generated by the photovoltaic panels is used to meet the power demand, P load . In this study, DetaP will be allocated via different paths under grid-connected and off-grid scenarios:

Grid-Connected Scenario
In the grid-connected scenario, DetaP can be distributed in two ways: The first is to be sold to the power grid, and the second is to be stored in batteries. Figure 2 shows the flowchart of the operation strategy of a grid-connected DSES. In the dynamic operation strategy, γ was defined as the proportion of the surplus photovoltaic power, P ba , being stored to the batteries in the total surplus photovoltaic power, DetaP, at a certain time. The mathematical expression to calculate γ is shown as follows: As the photovoltaic power output, user energy demand, and cost of electricity of the system vary with time, dynamic allocation of surplus photovoltaic power can be achieved by optimizing the parameter γ in real-time; thus, improving the economic performance of the system. For comparison, this study chose two other operation strategies, namely strategy A and strategy B. Affected by the characteristics of photovoltaic power generation, photovoltaic output varies greatly and voltage control is difficult, which will cause a certain degree of harmonic pollution to the grid. Under the premise of large-scale photovoltaic grid-connected, the grid's capacity to absorb large-scale photovoltaic power is seriously insufficient. Considering the grid stability limit, the interaction between photovoltaics and the grid should be lower than the upper limit to maintain grid stability [45]. In strategy A, when the electricity sold to the grid exceeds the upper limit of system-grid interaction, the remaining DetaP will be stored into the batteries. In strategy B, DetaP will be stored to the batteries at first. When the batteries are fully charged, the remaining DetaP will be sold to the grid. When the photovoltaic power output in the system is insufficient, and the SOC of the batteries reaches the lower limit, the gap will be filled by the power purchased from the grid. Since the interaction power between the system and the grid is much smaller than the upper limit of the system-grid interaction, there is no power shortage in the system. As the photovoltaic power output, user energy demand, and cost of electricity of the system vary with time, dynamic allocation of surplus photovoltaic power can be achieved by optimizing the parameter γ in real-time; thus, improving the economic performance of the system. For comparison, this study chose two other operation strategies, namely strategy A and strategy B. Affected by the characteristics of photovoltaic power generation, photovoltaic output varies greatly and voltage control is difficult, which will cause a certain degree of harmonic pollution to the grid. Under the premise of large-scale photovoltaic grid-connected, the grid's capacity to absorb large-scale photovoltaic power is seriously insufficient. Considering the grid stability limit, the interaction between photovoltaics and the grid should be lower than the upper limit to maintain grid stability [45]. In strategy A, when the electricity sold to the grid exceeds the upper limit of system-grid interaction, the remaining DetaP will be stored into the batteries. In strategy B, DetaP will be stored to the batteries at first. When the batteries are fully charged, the remaining DetaP will be sold to the grid. When the photovoltaic power output in the system is insufficient, and the SOC of the batteries reaches the lower limit, the gap will be filled by the power purchased from the grid. Since the interaction power between the system and the grid is much smaller than the upper limit of the system-grid interaction, there is no power shortage in the system.

Off-Grid Scenario
In the off-grid scenario, DetaP can be distributed in two ways (i.e., storage directly in the batteries or conversion into heat energy before being stored in the water tank). When there is surplus power in the DSES, the air source heat pump will convert the electric energy into heat energy and store it into the water tank, if the water tank temperature T st is lower than 53 • C and the surplus power meets the rated power P hp of the heat pump. If the surplus power is less than the rated power, P hp , of the heat pump, the electric heating device will convert electric energy into heat energy and transfer it to the water tank for storage. Here, γ was defined as the proportion of the surplus photovoltaic power P p being converted into heat energy which is stored in the water tank at a certain time in the total surplus photovoltaic power DetaP. The mathematical expression is as follows: This study chose the fixed-parameter strategies C and D to serve as comparison control strategies. In strategy C, the surplus power will be stored in the batteries first. When the batteries are fully charged, the surplus power will be disposed of in different ways depending on the water tank temperature. If the T st is higher than 53 • C, the surplus photovoltaic power will be abandoned. If the T st is lower than 53 • C, the surplus power will be converted into heat by either heat pump or electric heater and stored in the water tank. In strategy D, the surplus power is converted into heat by either a heat pump or electric heater and stored in the water tank first. When the T st is higher than 53 • C, the surplus power will be stored in the batteries. When the batteries are fully charged, the photovoltaic power will be abandoned. In this study, the T st is not allowed to be higher than 80 • C. The control flowcharts of the three operation strategies are shown in Figure 3. be converted into heat by either heat pump or electric heater and stored in the water tan In strategy D, the surplus power is converted into heat by either a heat pump or electr heater and stored in the water tank first. When the Tst is higher than 53 °C, the surplu power will be stored in the batteries. When the batteries are fully charged, the photovo taic power will be abandoned. In this study, the Tst is not allowed to be higher than 80 °C The control flowcharts of the three operation strategies are shown in Figure 3.

Solar Collector
The energy balance equation representing the amount of effective heat collection of the solar collector is as follows [46]: where Q Co,h is the amount of effective heat collection of the solar collector, A Co is the solar heat collection area, F R (τα) e is the product of the heat transfer factor of the solar heat collector and the effective projected absorption product (set to 0.7843), I h is the solar irradiance, F R U L is the total heat loss coefficient of the solar heat collector (set to 5.5024 W/(m 2 · • C)), T Ci,h is the inlet temperature of the heat transfer medium, T a,h is the ambient temperature of the solar heat collector, T Co,h is the outlet temperature of the heat transfer medium, C f is the specific heat of the heat transfer medium, and m JR is the mass flow rate of solar collector.
(The solar collector used in this study is the P-Y/0.6-T/L/YH−1.86 reference flat plate collector of Siji Muge.)

Water Tank
In this study, it was assumed that the water temperature in the water tank is uniformly distributed. The energy balance equation is shown in Equation (5), where the heat loss of the water tank is determined by the tank's loss coefficient and the heat storage temperature difference [46,47]: where T st is the water temperature of the water tank, V st is the capacity of the water tank, Q hx is the amount of effective heat exchange between the heat collection system and the water tank, Q hp is the amount of heat supplied by the air source heat pump, Q L is the heat required by the building, Q E is the heat loss of the water tank, U st is the loss coefficient of the water tank, and T b is the ambient temperature of the water tank. In the study, ∆t is the time step and set to 0.5 h.

Solar Photovoltaic Panels
The power output of a solar photovoltaic panel is [48]: where P pv is the power output of the photovoltaic module (kW), P STC is the rated photovoltaic power under the standard test conditions, G is the solar irradiance, T is the working temperature of the photovoltaic module, T r is the ambient temperature under the standard test conditions (set to 25 • C), and k is the temperature coefficient of power (set to −0.47%/h) [47], G STC is the solar irradiance under standard test conditions (set to 1 kW/m 2 ).

Batteries
The SOC of the batteries is determined by the remaining battery power at the previous moment and the charging and discharging power at the adjacent moment [49,50].
where SOC is the state of charge of the batteries, δ is the self-discharge rate of the batteries (set to 0.01%/h), P c is the charging power of the batteries, P d is the discharge power of the batteries, η c and η d are the charging and discharging efficiencies of the batteries (set to 0.9) [49], E c is the rated capacity of the batteries, ∆t is the time step and equal to 0.5 h.

Air Source Heat Pump
The performance curve of a certain type of air source heat pump is fitted according to its dynamic parameters [51]. The heating capacity of the air source heat pump is determined by the ambient temperature and the power of the heat pump. The mathematical model is as follows: where COP is the coefficient of performance of the air source heat pump, P hp is the input power of the air source heat pump, β is the loss coefficient of frosting-defrosting [52].

Diesel Generator
The fuel consumption of a diesel generator is determined by the generator's rated power and actual operating power, which can be estimated using the following formula [53]: where f c is the fuel consumption of diesel generator, P rdie is the rated capacity of the diesel generator, and P die is the actual output power of the diesel generator, c and d are the coefficients of fuel consumption curve (c= 0.2461 L/(kWh)), d = 0.081451 L/(kWh)) [53].

Electric Heater
The relationship of electric heater's input power and output heat power can be simply described as the following formula [54]: where Q djr is output heat power of the electric heater, P djr is the actual input power of the electric heater, m is the denotes the electric-thermal conversion efficiency of the electric heater efficiency.

Objective Function
In the system optimization model, the optimization goal is minimizing the annualized total cost (ATC) of the DSES, and its function is expressed as the sum of the capital expenditure (CAPEX) cost and operating expenditure (OPEX) [55]: where i is the real interest rate (set to 4.35%, China's current real interest rate), and n is the service life of the equipment (set to 20 years). CAPEX is calculated as follows: where C co is the equipment cost per unit area of the collector; C st is the equipment cost per unit capacity of the water tank; C hp is the equipment cost per unit heating capacity of the air source heat pump; C rfj is the cost of system piping accessories, water pumps, etc.; C pv is the equipment cost of photovoltaic panels per unit power; and C die is the equipment cost of diesel generator per unit power. OPEX includes the annual maintenance cost, annualized equipment replacement cost, grid interaction cost, photovoltaic subsidies, fuel cost, and annual environmental governance cost. The calculation formula is as follows: where C w is the system maintenance cost, C c is the equipment replacement cost of the system, C g is the annual cost of interaction between the system and grid, C b is the photovoltaic subsidy, C f is the fuel cost of the diesel generator, and C e is the environmental governance cost.
The annual maintenance cost of the system includes the daily maintenance costs of solar photovoltaic panels, batteries, power distribution equipment, and diesel generator. The calculation formula is as follows: where C yxpv is the maintenance cost coefficient of photovoltaic panels, C yxbw is the daily maintenance cost coefficient of power distribution equipment, P bw is the interaction amount between the system and the grid, C yxba is the maintenance cost coefficient of the batteries, and C yxdie is the maintenance cost coefficient of the diesel generator. τ is the upper limit of the annual operating time, the value is 8760. The annual equipment replacement cost of the system is the average annual replacement cost of the batteries [56]. The calculation formula is as follows: where P rba is the rated power of the batteries, L is the number of replacements of the energy storage device during the service life of the system (set to four times), and C ba is the battery capacity cost coefficient. In China, the power generated by solar panels is subsided by the government. The formula to calculate the annual grid interaction cost are as follows: where C dj is the purchase cost per unit electricity, P bw1 is the input power of the system from the grid, C ts is the benchmark price of on-grid electricity that is generated by burning desulfurized coal and sold to the grid, P bw2 is the output power to the grid from the system, and C dt is the state subsidy per unit electricity generated by photovoltaic panels. By introducing the terms of emission governance, the environmental polluting effects of the carbon dioxide, sulfur dioxide, nitric oxide, and other gases emitted during the operation of a diesel generator can be converted into economic costs [57], as shown in Table 2. The corresponding formula is shown as follows: where k p represents the treatment cost coefficients of different pollutants, k e corresponds to the discharge coefficients of different pollutants, and j indicates the pollutant type (corresponding to CO 2 , SO 2 , and NO). The formula for calculating the annual fuel cost [57] incurred by the operation of a diesel generator is shown as follows: where C ful is the fuel cost per unit electricity generated by diesel generator.

Optimization Variables
The system optimization model contained two types of optimization variables: design optimization variables and the operation optimization variable. The design optimization variables included the solar heat collection area (A co ), rated input power of air source heat pump (P hp ), water tank capacity (V st ), rated power of solar photovoltaic panels (P STC ), rated capacity of batteries (E c ), and rate power of diesel generator (P rdie ) in the off-grid scenario. The operation optimization variable was the real-time distribution coefficient (γ) of surplus photovoltaic power. The real-time dynamic optimization of this coefficient enables real-time and reasonable distribution of surplus photovoltaic power of the system.

Constraints
The rated power of the air source heat pump and the capacity of the water tank should be within a certain reasonable range. The interaction power between the system and the grid should not exceed the upper limit of the interaction. The maximum available land area should be considered when determining the parameter value ranges of the grid-connected systems. The area limitation is not applicable to the off-grid systems because more land can be used. The batteries have the constraint of maximum charge (discharge) power P c.max (P d.max ). In addition, the SOC of batteries should be subject to a certain constraint so as to guarantee service life (in this study, the upper limit and lower limit were set to 0.9 and 0.1, respectively). The output power of a diesel generator should be less than their rated powers. The capacities and operation constraints of related equipment are as follows: At the initial moment, the water temperature of the water tank was 45 • C, the temperature of the heat transfer medium inside the solar heat collector was 10 • C, and the battery SOC was 0.5.

Optimization Algorithm
The optimization algorithm in this paper uses the genetic algorithm (GA), which is a random search algorithm that draws on the natural selection and natural genetic mechanism of the biological world. It does not rely on gradient information and searches for the optimal solution by simulating the natural evolution process [58]. First, a binary code is used to randomly generate an initial population, which contains several individuals, and each individual is represented by a set optimization variable (A co , P hp , V st , P STC , E c , P rdie , γ). The genetic optimization algorithm substitutes each individual into the fitness function to calculate its fitness value, and judges whether it meets the optimization criteria. If it meets the criteria, the best individual and the corresponding optimal solution are output, and the optimization process is ended; otherwise, it performs according to the fitness value selection that weeds out individuals with low adaptability, selects excellent individuals with high adaptability, and obtains a new generation of individuals through crossover and mutation operations. Then use the fitness function to calculate the fitness of the new individual until it meets the optimization criterion [59]. The flow chart of genetic algorithm is shown in Figure 4. the criteria, the best individual and the corresponding optimal solution are output, and the optimization process is ended; otherwise, it performs according to the fitness value selection that weeds out individuals with low adaptability, selects excellent individuals with high adaptability, and obtains a new generation of individuals through crossover and mutation operations. Then use the fitness function to calculate the fitness of the new individual until it meets the optimization criterion [59]. The flow chart of genetic algorithm is shown in Figure 4.

Case Study
In this study, a DSES of a two-story residential building in Shaanxi Province was used as a case study. As shown in Figure 5, the total building area is 178.2 m 2 , and the total heating area of the building is 136.8 m 2 . The main building has a length of 10.8 m, a width of 7.6 m, and a height of 7.4 m. The roof area is 82.1 m 2 . The building faces south. The calculation temperature of indoor heating is 18 • C. The C ts is 0.35 ¥/kWh, the subsidy per kWh of solar electricity is ¥ 0.08, and the maintenance cost is 0.009 ¥/kWh. The hourly heating load during the heating season was calculated using the Energy Plus software, and the daily electricity load of the residential building was obtained through a site survey. For the convenience of calculation, three typical weeks in the heating season (15 November to 15 March of the following year), transition season (16 March to 20 June; 22 September to 14 November), and summer season (21 June to 21 September) are chosen. Figure 6 shows the hourly heating and electrical load of the building in the three typical weeks.

Case Study
In this study, a DSES of a two-story residential building in Shaanxi Province wa used as a case study. As shown in Figure 5     In this study, the GA was used to optimize the DSES through the MATLAB software. The optimization variables and their value ranges are shown in Table 3, and the equipment costs are shown in Table 4. The photovoltaic and solar collectors in this study are arranged directly south. The azimuth angle of photovoltaic and heat collector is 0°, and the tilt angle is 34.1°. In this study, the GA was used to optimize the DSES through the MATLAB software. The optimization variables and their value ranges are shown in Table 3, and the equipment costs are shown in Table 4. The photovoltaic and solar collectors in this study are arranged directly south. The azimuth angle of photovoltaic and heat collector is 0 • , and the tilt angle is 34.1 • . Table 3. Ranges of optimization variables.

. System Equipment Capacities and Economic Analysis
When the system is connected to the grid, it is assumed that there are three time-based electricity pricing schemes (see Table 5). Table 5 shows the results of optimal system equipment capacities under different time-based pricing schemes and operation strategies. It can be seen from Table 6 that, under different operation strategies, the differences between the system equipment capacities in scenario 1 and those in scenario 2 are not significantly different. Compared with scenario 1 and scenario 2, the three strategies of heat pump rated power in scenario 3 have slightly increased. Compared with the control operation strategies, the implementation of the dynamic operation strategy in scenario 3 introduces the following differences: the system uses more solar energy to meet the heating demand of the building, it needs larger solar heat collection area and water tank capacity. In addition, the rated power of photovoltaic panels reaches the maximum value of the allowable range in all scenarios, which means the system can generate as much revenue from electricity sales as possible while meeting the electricity demand of the building and the system equipment.
It can also be seen from Table 6 that the difference between peak and valley time-of-use electricity prices has a significant impact on the configuration of the battery capacity in the system. In scenarios 1 and 2, the battery capacity is zero under all operation strategies. In scenario 3, the battery capacity is not zero under the dynamic operation strategy. This can be attributed to the fact that the difference between peak and valley time-of-use electricity prices is larger in scenario 3 than in scenarios 1 and 2. When the electricity price is at a valley, the system purchases electricity from the grid, and the surplus energy is used to charge the batteries; when the electricity price is at a peak, the batteries discharge if the power supply in the system is insufficient, reducing the power purchase from the grid. When the difference between peak and valley time-of-use electricity prices increases, the utilization of batteries in the system also increases, which necessitates larger battery capacity. Since the equipment capacities and operation strategy of the DSES in scenario 1 are roughly consistent with those in scenario 2, this study mainly analyzes the different effects of the three operation strategies on the system operation in scenario 3. Figure 7 shows the results of ATC after system optimization in scenario 3. It can be seen that in scenario 3, in which the difference between peak and valley time-of-use electricity prices is biggest, the dynamic operation strategy achieves a cost saving of 5.61% compared with strategy A and a saving of 3.94% compared with strategy B.
grid. When the difference between peak and valley time-of-use electric the utilization of batteries in the system also increases, which necessi capacity.
Since the equipment capacities and operation strategy of the DSE roughly consistent with those in scenario 2, this study mainly analyzes of the three operation strategies on the system operation in scenario 3. results of ATC after system optimization in scenario 3. It can be seen t which the difference between peak and valley time-of-use electricity p dynamic operation strategy achieves a cost saving of 5.61% compared w a saving of 3.94% compared with strategy B.  A detailed analysis was conducted on the optimal system operation in the heating season, transition season, and summer season in scenario 3. Analysis results show that, due to the battery discharge, the system's power purchase under the dynamic operation strategy is less than those under the comparison strategies. Compared with the comparison strategy, due to the larger area of the collector and the smaller rated power of the heat pump under the dynamic operation strategy, the system consumes less electricity and can sell more electricity to the grid. Therefore, increase the economic benefits of the system and improve the economic performance of the system. In addition, the depth of discharge of the batteries under the dynamic operation strategy is smaller, which helps reduce the loss of the batteries and prolong the service life of the batteries. In Figure 8, the quantity of electricity is negative, which means the energy storage battery is discharged, and the system purchases electricity from the grid. E bba is the amount of remaining photovoltaic energy allocated to the battery. E bw is the amount of remaining photovoltaic energy allocated to the grad. and improve the economic performance of the system. In addition, the depth of discharge of the batteries under the dynamic operation strategy is smaller, which helps reduce the loss of the batteries and prolong the service life of the batteries. In Figure 8, the quantity of electricity is negative, which means the energy storage battery is discharged, and the system purchases electricity from the grid. Ebba is the amount of remaining photovoltaic energy allocated to the battery. Ebw is the amount of remaining photovoltaic energy allocated to the grad.

Sensitivity Analysis
The fact that the subsidy (Cdt) for photovoltaic electricity has been decreasing gradually in recent years has a greater impact on the economics of DSESs. Under the assumption that other factors remain unchanged, this study used Cdt as a variable to conduct a singlefactor sensitivity analysis of the system. Since the equipment capacities and operation strategy of DSES in scenario 1 are roughly consistent with those in scenario 2, under all three operation strategies, this study conducted a sensitivity analysis based on scenario 3. The analysis results, shown in Figure 9, indicate that when Cdt fluctuates in the range of 0~0.16 ¥/kWh, the ATC under the dynamic operation strategy has the largest variation range, while the strategy A yields the smallest variation range. In terms of the impact of Cdt on the ATC, the three operation strategies can be arranged in the descending order as dynamic operation strategy, strategy B, and strategy A. Taking Cdt = 0.08 ¥/kWh as a reference, the sensitivity analysis shows that when Cdt fluctuates 25% upwards (downwards), the ATC of the system fluctuates 7.5%, 6.7%, and 5.3% downwards (upwards) under dynamic strategy, strategy B, and strategy A, respectively. When Cdt is less than or equal to 0.04 ¥/kWh, the ATC yielded by the dynamic operation strategy is relatively high. Under such circumstances, the most suitable operation strategy is strategy A rather than the dynamic operation strategy. When Cdt is greater than 0.04 ¥/kWh, the dynamic operation strategy yields an ATC much lower than that yielded by the other operation strategies, which means better economic performance. Under such circumstances, the dynamic operation strategy is the optimal strategy.

Sensitivity Analysis
The fact that the subsidy (C dt ) for photovoltaic electricity has been decreasing gradually in recent years has a greater impact on the economics of DSESs. Under the assumption that other factors remain unchanged, this study used C dt as a variable to conduct a singlefactor sensitivity analysis of the system. Since the equipment capacities and operation strategy of DSES in scenario 1 are roughly consistent with those in scenario 2, under all three operation strategies, this study conducted a sensitivity analysis based on scenario 3. The analysis results, shown in Figure 9, indicate that when C dt fluctuates in the range of 0~0.16 ¥/kWh, the ATC under the dynamic operation strategy has the largest variation range, while the strategy A yields the smallest variation range. In terms of the impact of C dt on the ATC, the three operation strategies can be arranged in the descending order as dynamic operation strategy, strategy B, and strategy A. Taking C dt = 0.08 ¥/kWh as a reference, the sensitivity analysis shows that when C dt fluctuates 25% upwards (downwards), the ATC of the system fluctuates 7.5%, 6.7%, and 5.3% downwards (upwards) under dynamic strategy, strategy B, and strategy A, respectively. When C dt is less than or equal to 0.04 ¥/kWh, the ATC yielded by the dynamic operation strategy is relatively high. Under such circumstances, the most suitable operation strategy is strategy A rather than the dynamic operation strategy. When C dt is greater than 0.04 ¥/kWh, the dynamic operation strategy yields an ATC much lower than that yielded by the other operation strategies, which means better economic performance. Under such circumstances, the dynamic operation strategy is the optimal strategy. Energies 2021, 14,

System Equipment Capacities and Economics
The goal of system design and operation optimization is minimizing the ATC regardless of whether the system is operating under the dynamic operation strategy, strategy C, or strategy D. In terms of economic performance, dynamic operation strategy yields the lowest ATC of ¥20,027, strategy D yields a slightly higher ATC of ¥20,246, and strategy C yields the highest ATC of ¥21,824. The dynamic operation strategy achieves a cost saving of 8.97% compared with strategy C and 1.10% compared with strategy D. Table 7 shows that the OPEX of the system under the dynamic operation strategy is much lower than those under the control strategies, indicating that the dynamic operation strategy delivers better economic performance.

System Equipment Capacities and Economics
The goal of system design and operation optimization is minimizing the ATC regardless of whether the system is operating under the dynamic operation strategy, strategy C, or strategy D. In terms of economic performance, dynamic operation strategy yields the lowest ATC of ¥20,027, strategy D yields a slightly higher ATC of ¥20,246, and strategy C yields the highest ATC of ¥21,824. The dynamic operation strategy achieves a cost saving of 8.97% compared with strategy C and 1.10% compared with strategy D. Table 7 shows that the OPEX of the system under the dynamic operation strategy is much lower than those under the control strategies, indicating that the dynamic operation strategy delivers better economic performance.

. Analysis of Optimal System Operations
Since the system only needs to meet both the electricity and heating demand in the heating season, this study chose to analyze the optimization results of the system operation in the heating season. The water tank temperature (T st ), the distribution of the remaining photovoltaic power (E p indicates the power allocated to electric conversion equipment, and E bba is allocated to batteries), charging/discharging state of batteries (SOC) within a week of operation (from 22 January to 28 January in heating season), and amount of abandoned photovoltaic power (E dump ) are shown in Figure 10. Since the system only needs to meet both the electricity and heating demand in the heating season, this study chose to analyze the optimization results of the system operation in the heating season. The water tank temperature (Tst), the distribution of the remaining photovoltaic power (Ep indicates the power allocated to electric conversion equipment, and Ebba is allocated to batteries), charging/discharging state of batteries (SOC) within a week of operation (from 22 January to 28 January in heating season), and amount of abandoned photovoltaic power (Edump) are shown in Figure 10.
Strategy C dictates that the surplus photovoltaic power is to be stored in the batteries at first and then be converted to heat energy and stored in the water tank. The storage of surplus photovoltaic power cannot proceed when the SOC of the batteries reaches the upper limit, and the water temperature of the water tank exceeds 53 °C, resulting in a large amount of abandoned photovoltaic power (see Figure 10a). Strategy D dictates that the surplus photovoltaic power is to be converted into heat energy and stored in the water tank until its temperature reaches 53 °C and then be stored in the batteries. After the system is optimized under strategy D, the surplus photovoltaic power is to be converted to heat energy and stored in water tank at first and then be stored in the batteries. Some photovoltaic power may be abandoned after the battery is fully charged. The dynamic operation strategy enables a reasonable distribution of the surplus photovoltaic power. When the temperature of the water tank is higher than 53 °C, and the SOC of the batteries reaches the upper limit, some photovoltaic power will be abandoned after system optimization, but the amount of abandoned photovoltaic power is significantly lower than that under the fixed strategies C and D (see Figure 10c).   In this case study, the variation patterns of the water temperature of the water tank under the three strategies are consistent. Under the limitations of the SOC of the batteries and the temperature of the water tank, some photovoltaic power will be abandoned no matter which operation strategy is implemented. During the one week operation period, the amounts of abandoned photovoltaic power in heating season, summer season, and transition season are shown in Table 8. During the heating season operation, strategy D has the largest amount of abandoned photovoltaic power and strategy C has the smallest amount of discarded photovoltaic power, the amount of abandoned photovoltaic power under the dynamic operation strategy is between the two. In the summer operation, the amount of photovoltaic power discarded by the system under strategy C is the largest, and the amount of photovoltaic power discarded under the dynamic operation strategy is the smallest. In the transition season, the smallest amount of photovoltaic power discarded is under the dynamic operation strategy, and strategy D has the largest amount of photovoltaic power discarded. In this study, it is assumed that there are 17 weeks in the heating season, 13 weeks in the summer season, and 22 weeks in the transition season in Strategy C dictates that the surplus photovoltaic power is to be stored in the batteries at first and then be converted to heat energy and stored in the water tank. The storage of surplus photovoltaic power cannot proceed when the SOC of the batteries reaches the upper limit, and the water temperature of the water tank exceeds 53 • C, resulting in a large amount of abandoned photovoltaic power (see Figure 10a). Strategy D dictates that the surplus photovoltaic power is to be converted into heat energy and stored in the water tank until its temperature reaches 53 • C and then be stored in the batteries. After the system is optimized under strategy D, the surplus photovoltaic power is to be converted to heat energy and stored in water tank at first and then be stored in the batteries. Some photovoltaic power may be abandoned after the battery is fully charged. The dynamic operation strategy enables a reasonable distribution of the surplus photovoltaic power. When the temperature of the water tank is higher than 53 • C, and the SOC of the batteries reaches the upper limit, some photovoltaic power will be abandoned after system optimization, but the amount of abandoned photovoltaic power is significantly lower than that under the fixed strategies C and D (see Figure 10c).
In this case study, the variation patterns of the water temperature of the water tank under the three strategies are consistent. Under the limitations of the SOC of the batteries and the temperature of the water tank, some photovoltaic power will be abandoned no matter which operation strategy is implemented. During the one week operation period, the amounts of abandoned photovoltaic power in heating season, summer season, and transition season are shown in Table 8. During the heating season operation, strategy D has the largest amount of abandoned photovoltaic power and strategy C has the smallest amount of discarded photovoltaic power, the amount of abandoned photovoltaic power under the dynamic operation strategy is between the two. In the summer operation, the amount of photovoltaic power discarded by the system under strategy C is the largest, and the amount of photovoltaic power discarded under the dynamic operation strategy is the smallest. In the transition season, the smallest amount of photovoltaic power discarded is under the dynamic operation strategy, and strategy D has the largest amount of photovoltaic power discarded. In this study, it is assumed that there are 17 weeks in the heating season, 13 weeks in the summer season, and 22 weeks in the transition season in the whole year. Therefore, the three operation strategies can be arranged in the following descending order in terms of the annual amount of abandoned photovoltaic power (i.e., strategy D, strategy C, and dynamic operation strategy). The dynamic operation strategy achieves a reduction of 12.4% in the amount of abandoned photovoltaic power compared with strategy C, and a reduction of 45.4% compared with strategy D.

Conclusions
In this study, this study constructed an optimization model of the DSES and developed a dynamic operation strategy, based on surplus photovoltaic power distribution, to facilitate joint optimization of the system design and operation. The proposed operation strategy was applied to the energy system of a typical two-story residential building in Shaanxi Province and was compared with comparison operation strategies with fixed operating parameters. The main conclusions are as follows: (1) The difference between peak and valley time-of-use electricity prices has a great impact on the selection of the optimal operation strategy for the grid-connected system. When the difference between peak and valley time-of-use electricity prices is large, the economic performance of the system under the dynamic operation strategy is significantly improved: In scenario 3, in which the difference between peak and valley time-of-use electricity prices is 0.75 ¥/kWh, the dynamic operation strategy achieves a saving of 5.61% in ATC compared with strategy A and a saving of 3.94% compared with strategy B.
(2) The difference between peak and valley time-of-use electricity prices has a great impact on the battery capacity configuration of the grid-connected system under the dynamic operation strategy. When the difference between peak and valley time-of-use electricity prices is large, as in scenario 3, batteries should be included in the system optimal capacity configuration so as to achieve the best economic performance of the system.
(3) In terms of the influence of the subsidy on the on-grid system cost under different operation strategies, the ATC of the system decreases with the increase of C dt . Taking C dt = 0.08 ¥/kWh as a reference, the sensitivity analysis shows that when C dt fluctuates 25% upwards (downwards), the ATC of the system fluctuates 7.5%, 6.7%, and 5.3% downwards (upwards) under dynamic strategy, strategy B, and strategy A, respectively. The three operation strategies of the grid-connected system can be arranged in descending order as dynamic operation strategy, strategy B, and strategy A. When C dt ≤ 0.04 ¥/kWh, strategy A is the most suitable for the system; when C dt > 0.04 ¥/kWh, the dynamic operation strategy yields an ATC much lower than those yielded by the control operation strategies, which means it is the best operation strategy.
(4) In terms of the economic performance of the off-grid system, the annual net cost of the three operating strategies, in increasing order, are dynamic operating strategy, strategy B, and strategy A. Compared with strategy A and strategy B, the ATC under the dynamic operating strategy saves 8.97% and 1.10%, respectively.
(5) In terms of the amount of photovoltaic power abandoned in the off-grid scenario, the three operation strategies can be arranged in descending order as strategy D, strategy C, and dynamic operation strategy. The dynamic operation strategy achieves a reduction of 12.4% in the amount of photovoltaic power abandoned compared with strategy C, and a reduction of 45.4% compared with strategy D.

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

ATC
annualized total cost CAPEX capital expenditure cost CCHP combined cooling, heating, and power DES distributed energy system DSES distributed solar energy system FTL follow the thermal load FEL follow the electric load GA genetic algorithm MILP mixed-integer linear programming OPEX operating expenditure PSO particle swarm optimization SOC state of charge Parameters A co solar collector area, m 2 COP performance coefficient of air source heat pump C b photovoltaic subsidy, ¥ C ba battery initial cost, ¥/kWh C c battery replacement cost, ¥ C co unit cost of collector equipment, ¥/m 2 C dj unit electricity purchase cost, ¥/kWh C dt photovoltaic power subsidy, ¥/kWh C die diesel generator initial cost, ¥/kW C e environmental management fees, ¥ C f cost of diesel generator fuel, ¥ C ful annual fuel cost diesel generator, ¥/kWh C g annualized interaction cost between the system and the grid, ¥ C hp unit cost of air source heat pump, ¥/kW C pv solar photovoltaic cell initial cost, ¥/kW C st unit cost of heat storage tank, ¥/m 3 C w system operation and maintenance costs, ¥ C yxbw annual maintenance costs of distribution equipment, ¥/kW C yxdie annual maintenance costs of diesel generator, ¥/kWh C yxba annual maintenance costs of battery, ¥/kWh C yxpv annual maintenance costs of photovoltaic cell, ¥/kW E c rated capacity of energy storage battery, kWh F R U L total heat loss coefficient of collector, W/(m 2 · • C) f c the fuel consumption of diesel generator, L G STC light intensity under standard test conditions, kW/m 2 G illumination intensity, kW/m 2 i real interest rate I h solar radiation intensity, W/m 2 j pollutant type k temperature coefficient of power k p the treatment cost coefficients of different pollutants k e discharge coefficients of different pollutants m JR heat collection flow, kg/m 3 n lifetime of system, years P c(d) charging and discharging power of energy storage battery, kW P bw power interaction between the system and the grid, kW P dump dumped electricity, kW P die power output of the diesel generator, kW P pv photovoltaic power output, kW P hp input power of air source heat pump, kW P STC rated photovoltaic power under standard test conditions, kW P rba rated power of battery, kW