# Assessment of Solar Energy Generation Toward Net-Zero Energy Buildings
## 2 System Models
### Mathematical Models  
In this section, a detailed MILP-based mathematical model is presented with a multi-objective function aimed at minimizing building energy operation costs and reducing dependency on the utility grid. Additionally, the operational constraints of DGs, ESSs, and energy balances, including electrical, heating, and cooling systems, are also presented in detail.  
The following multi-objective Equation (1) is utilized in the optimization model for optimal operation of energy building. The first term of the objective function presents the operation cost of the entire building network, and the second term shows the dependence of the building on the external utility grid.  
\[Min\sum_{t=1}^{T}\alpha.\Big{\{}C_{1}*P_{1}(t)+C_{2}*P_{2}(t)+p_{Grid}(t)* \Big{(}P_{Grid}^{buy}(t)-P_{Grid}^{ell}(t)\Big{)}\Big{\}}+\beta.\Big{\{}P_{ Grid}^{buy}(t)\Big{\}} \tag{1}\]  
\[\text{where}:\ \alpha+\beta=1\]  
This multi-objective function not only aims to minimize the operation cost of the entire building energy system but also to reduce the building's dependency on external energy systems. The cost of power produced by DGs and the cost/profit of trading power with the utility grid are calculated at every time step. When the objective function is minimized, the optimal values for the decision variables are determined. This ensures efficient and cost-effective usage of our building energy system, along with encouraging the use of sustainable energy.  
There are various constraints that must be fulfilled during the operation of buildings. The given Equations (2)-(6) show the operational constraints and energy balance of a system involving DGs, ESS, and energy flows between various components. The operation boundary of DGs is given in (2), ensuring that their output stays within the minimum and maximum limits. Equations (3) and (4) describe the charging and discharging power constraints of the ESS. Equation (3) ensures that the charging power does not exceed the maximum allowable charging rate considering the current SOC and the charging loss. Similarly, Equation (4) shows the discharging power based on the current SOC and discharging loss. SOC update is given in Equation (5), where the SOC at the next step depends on the current SOC and the actual amount of charging and/or discharging power. Finally, the power balance within the system is ensured by Equation (6), where the total power generated from PVs, DGs, ESS discharging, and grid purchases must meet the total load, including the building load, electric consumption by the heat pump, boiler, and electric chiller, along with the amount of power exported to the utility grid.  
\[P_{i}^{min}\leq P_{i}(t)\leq P_{i}^{max} \tag{2}\]  
\[0\leq P_{ESS}^{char}(t)\leq P_{ESS}^{max}.\frac{(1-SOC(t))}{\eta_{c}} \tag{3}\]  
\[0\leq P_{ESS}^{dis}(t)\leq P_{ESS}^{max}.SOC(t).\eta_{d} \tag{4}\]  
\[SOC(t+1)=SOC(t)+P_{ESS}^{char}(t)-P_{ESS}^{dis}(t) \tag{5}\]  
\[P_{PV}(t)+P_{1}(t)+P_{2}(t)+P_{ESS}^{dis}(t)-P_{ESS}^{char}(t)+P_{Grid}^{buy}(t)- P_{Grid}^{bell}\]  
\[=P_{L}(t)+P_{HP}(t)+P_{Bl}(t)+P_{EC}(t) \tag{6}\]  
Similarly, the heat generated by the HP and boiler should balance the heat load and the heat supplied to the AC, as shown in Equations (7)-(9). The electric-to-heat ratio of the HP and boiler are \(\eta_{\epsilon 2h}^{HP}=2\) and \(\eta_{\epsilon 2h}^{BI}=3\), respectively.  
\[H_{HP}(t)+H_{Bl}(t)=H_{L}(t)+H_{AC}(t) \tag{7}\]  
\[H_{HP}(t)=\eta_{\epsilon 2h}^{HP}\times P_{HP}(t) \tag{8}\]  
\[H_{Bl}(t)=\eta_{\epsilon 2h}^{BI}\times P_{Bl}(t) \tag{9}\]  
Finally, the cooling load should always be fulfilled by the cooling generated by the AC and the EC, as expressed in Equations (10)-(12). The heat-to-cooling and electric-to-cooling ratios are selected as \(\eta_{\epsilon 2c}^{AC}=2.5\) and \(\eta_{\epsilon 2c}^{EC}=2.5\), respectively.  
\[C_{AC}(t)+C_{EC}(t)=C_{L}(t) \tag{10}\]  
\[C_{AC}(t)=\eta_{\epsilon 2c}^{AC}\times H_{AC}(t) \tag{11}\]  
\[C_{EC}(t)=\eta_{\epsilon 2c}^{EC}\times P_{EC}(t) \tag{12}\]