Optimal Operation of the Campus Microgrid considering the Resource Uncertainty and Demand Response Schemes

Department of Electrical Engineering, University of Engineering and Technology, Taxila 47050, Pakistan Department of Electrical Engineering, Sukkur IBA University, Sukkur 65200, Pakistan School of Mechanical Engineering, Inner Mongolia University of Technology, Hohhot, Inner Mongolia 010051, China Inner Mongolia Key Laboratory of Advanced Manufacturing Technology, Hohhot 010051, Inner Mongolia, China


Introduction
Energy systems have been facing problems such as inflating consumption cost [1] and greenhouse gas (GHG) emission [2][3][4], as well as network overloading [2,[5][6][7][8][9][10][11]]. e conventional grid may not resolve these problems; however, a smart distribution system (DS) equipped with DGs and demand response (DR) has the potential to overcome these issues. A microgrid may be defined as a combination of DGs, well-defined load, and storage system. DR policies and energy storages are used to help reduce energy cost and network overloading, etc [12,13]. Microgrids with heavy load have a more pronounced impact on the stated problems. Among different types of high load µGs, institutional buildings falling under the class of commercial customers, need an optimal energy management strategy for consumption cost reduction. Microgrid facilitates bidirectional energy exchange with national power pool or may operate independently in islanded mode possessing enough on-site generation [14], while various energy management systems are given in [15]. For this purpose, researchers have already researched the following. e smart microgrid energy management system is implemented in various countries in the world due to its multibenefits [16]. In a conventional system, one way of energy flow was in practice and consumer act was a passive entity of the power system [17][18][19][20]. While, in microgrid, having some distributed energy resources and storages can operate in grid-connected and islanded mode [21,22]. In microgrid, prosumer which is a consumer can participate in the electricity market through the selling of surplus energy to the national grid or nearby customers [23]. Different types and levels of prosumers can operate in microgrid operation [24]. e commercial prosumers have high energy demand along with large-scale distributed resources. Prosumer stores surplus energy from various sources such as solar PV, wind, and biomass during off-peak hours and sells in peak hours [25]. Energy forms RERs, which are intermittent because they depend on weather and temperature [26]. So, the energy storage system [27] requires continual operation with multibenefits such as price arbitrage, frequency regulation, RE integration, and backup power [28]. Different types of storage systems are used in microgrid operation such as electrical, electromagnetic, electrochemical, mechanical, thermal, and chemical. Electrochemical energy storage can convert chemical energy to electrical energy, i.e., batteries [29]. Different types of batteries are used in microgrid operation for smooth function. As compared to other types of batteries the initial cost of lithium-ion batteries is high but more reliable with a competitive number of life cycles [30]. e degradation of battery energy storage system (BESS) depends on many factors, such as external temperature, internal resistance, depth of discharge (DOD), and a number of cycles [31]. e optimal scheduling of distributed energy resources in a microgrid is the proposed model considering system constraints.
Some other contribution of our work can be summarized as follows: (i) Campus microgrid nonlinear model is devised considering the battery degradation cost and demand response strategies (ii) Randomness in solar irradiance and load are modelled for day-ahead scheduling operation (iii) Grid support and grid outage-based modes are also considered for emergency operations to analyze the effects on the operational cost supply continuity e remaining paper is comprised of the following sections. Section 2 presents the literature review. In Section 3, the proposed system model is presented, while in Sections 4 and 5, problem formulation of day-ahead scheduling and proposed solution are presented. Results and discussion are given in Section 6. Section 7 concludes the findings of this paper.

Literature Review
Several kinds of literature have been working in resource management in a microgrid. Like other developing countries, Pakistan is also facing energy shortage and issues due to some regulatory and managerial reasons. Scheduled grid outage is in practice from 4 to 6 h per day [32]. Hassan et al. [33] proposed the model of a microgrid in Pakistani environment, considering the stability, power quality, and load tracking. Historical and real-time data of Islamabad was used to design an energy management system strategy for said goals. e proposed model is solved using power algorithm in MATLAB, which is popular software in optimization [34][35][36][37][38][39][40][41][42][43][44] and machine learning [45][46][47][48][49][50] literature as well. Waqar et al. [51] presented a microgrid model for Pakistani environment. A combined heat and power-(CHP-) based multitasking analysis of six cities was analyzed on HOMER and the most suitable city for CHP integration was found. Rehman et al. [52] devised the PV integrated microgrid model considering grid reliability. e feasibility analysis was carried out to find the optimal condition of available resources. Furthermore, greenhouse gas (GHG) emission was also investigated for on HOMER software. Zia and Shaikh [53] analyzed the economic and environmental impact of a microgrid in Baluchistan. e proposed model investigated on HOMER and the total amount for the initial investment was found. e system comprised of solar PV, wind, and diesel generators, and its net present cost (NPC) was found.
Energy systems and their related research are very popular and widespread among engineers [54][55][56]. Different types of microgrid models are introduced in the existing literature to improve the resilience and reduce the operational cost. A general proposed model of the microgrid system is given in Figure 1 which elaborates the microgrid energy and information flow system. Uncertainty of renewable energy resources, loads, and grid intermittency was incorporated in some microgrid models such as Gao et al. [57], who presented the model for microgrid cost reduction considering penalty factors and uncertainty of renewable energy resources (RERs). Rehman et al. [52,58] presented the PV energy storage system considering grid intermittency. Nasir et al. [59] presented the grid load reduction model considering the grid availability using linear programming in MATLAB. Low-cost hardware PV-storage solution was proposed in the Pakistani environment considering the various loads' shedding hours through online optimization technique. Li et al. [60] presented a probabilistic spinning reserve solution for isolated microgrid using chance constraint programming. e proposed problem was converted into MILP-based model and solved in GAMS by using the CPLEX solver. e proposed system reduced the cost and computation time and presented a trade-off strategy for cost and reliability. Similarly, in [61], the authors devised the scheduling of campus microgrid using the MIP however and ignored the uncertainties of DGs. Ahmad et al. [62] investigated the university campus in India. e HOMERbased analysis revealed that the optimal siting and sizing of DGs attract the investors for microgrid establishment. Soleja et al. [63] analyzed the economical analysis of the PV grid system. e payback period with other financial parameters was also calculated for South Asian Countries. However, the energy storage system was ignored, that is, the most important part of the energy management system. Liu et al. [64] explored the prosumer-based energy management system. e proposed model found that the scheduling of peer-topeer prosumer enhanced the energy trading potential of customers. In [65], the authors investigated the Korean campus to find the viability of microgrid implementation especially investors. e payback period revealed that the initial cost will cover within a few years and shifted the conventional system into a smart [66][67][68] power system. In [69], the authors analyzed a large number of customers in the US region.
e base system is investigated that the specific values of both PV and energy storage system (ESS) might attract the consumers to install the PV-storage system. e analysis discovered that the retail electricity price should be above $0.4/kWh and feed-in tariff below $0.05/kWh. Rodríguez-Gallegos et al. [70] devised the optimal scheduling, considering the economic benefits. e results revealed the importance of ESS in the microgrid operation system. Liu and Wang [71] investigated energy trading with national grid considering the operational cost.
Literature survey shows that placing the ESS in microgrids makes it robust, cost-effective [72], and capable to integrate large-scale RERs. e energy storage system which has microgrid energy management has many issues such as energy consumption cost reduction and maximizes the profit of utility grid. So, the resilient smart microgrid is the potential solution for developing countries [59]. In South Asia, Pakistan has great potential for solar PV and other renewable energy resources (RERs) [73], as discussed earlier.
Net metering was launched in 2016 which promoted the passive consumer to active prosumer. In this work, an institutional microgrid has been devised for optimal energy exchanges between a university campus building and the national grid. e existing literature addressed the microgrid considering uncertainties but ignored the battery life which is a very important factor. Optimal energy management system considered the mixed price-based/incentive-based demand response, and ESS life is incorporated in our proposed system.

Proposed System Architecture
e transition of the legacy power system into a smart power system is at the initial stage after the net metering installation.
e net metering has started in 2016 from the Government of Pakistan but needs regulatory system improvement. Given this step, we proposed UET Taxila as a campus microgrid to get the economic and environmental benefits. e Taxila city location has latitude and longitude as 33.70 and 72.840, respectively, and aerial view is shown in Figure 2. In the day time, the energy demand is high as compared to evening although evening classes are also offered on campus. To control the whole resources and storage scheduling, a scheduler is designed for optimal operation. In the control room, the signals are received from each entity through the Internet of ings (IoT). In critical situations, such as grid outages and other emergency events, the controller curtails the noncritical loads. e database has historical weather and load data for the last ten years and does the forecasting. e day-ahead scheduling considering the uncertainties of RERs is modelled in Section 4. In the proposed model, ESS stores surplus energy during the off-peak hours and sells the stored energy to the nearby consumer of the national grid in peak hours, as shown in Figure 3. Feed-in-tariff (FIT) is an important factor of energy-sharing willingness. Here, we assumed that the selling and purchasing energy prices are the same, which motivate the prosumers to sells its surplus energy to the national grid. e detailed layered structure of the proposed scheduler is resented in Figure 4 with its functions.

Problem Formulation
In this study, various types of distributed generation are integrated. Rooftop solar PV is taken in large scale with energy storage (ES). e proposed model comprised of the national grid, diesel generator, solar PV, and ESS. e ESS has many advantages over the single solar PV grid system such as backup storage, grid stability, and frequency regulation. e rooftop capacity of the campus is 4 MW, but we take only 2 MW. A mathematical model of day-ahead scheduling is presented in the next section following the network constraints. Initially, the deterministic model is analyzed for a proposed system. While in the second part, the real-time stochastic-based system is analyzed using historical data.

Objective Function.
To optimize the proposed model, a nonlinear objective function is modelled. As the real-time model of ESS is nonlinear, Scheduling signal e goal of this study is to investigate the resource scheduling considering the system constraints. e exchange energy with the grid is beneficial for both utility and customers. In equation (1), the first part is energy exchange with the grid, while the second part calculates the battery aging cost. e battery aging depends on some specific factors, i.e., the number of cycles, internal resistance, and depth of discharge (DoD). Exchange power with the grid is expressed as P g (t), while the unit prices' buying and selling rates K b (t) and Q s (t) are expressed, respectively. e state of energy (SOE) shows the battery energy state in percentage concerning its total capacity, with J as a weighting factor for the whole operation which is taken as 0.5 here. It is analyzed for 24 hours with one hour time interval. e undetermined variables are grid exchange power, state of charge, and storage output power.

Power Balance Equation.
To reduce the supply and demand gap, a power balance constraint is expressed as (2) e output power of storage P s (t) and the grid should be equal to the sum of all powers in the right-hand side, as prosumer load, contracted power P L (t) and P C (t), and the output power of solar PV P PV (t), respectively. e positive and negative storage output powers have expressed the discharge and charging of the battery system, respectively.

Energy Trading.
Prosumer can sell its surplus energy to the utility grid, especially in contracted hours. In emergency cases, the grid support mode is also carried out for peak shaving: Total selling and buying power are presented by the following equations, considering system limitations. In the prosumer market, the large commercial customer also exchanges energy with the utility grid which is allowed about 1 MW: e export energy mainly depends on the distributed generation utilization scheduling. As the solar PV irradiance gets in a normal pattern, extra energy is stored in the batteries. e lithium-ion batteries are utilized due to its competitive features. As the length of complete transmission lines is short, so considering only active power and neglected the line losses.

Constraints of Battery Storage.
Energy storage has some upper and lower bounds for smooth operation. As the life of the battery depends on many factors as discussed earlier, its output power also is controlled by the following constraints (6) and (7): e capacity of storage system Cap s is given by the manufacturer. ree modes of batteries are usually observed: charging state, discharging state, and standby position:  Mathematical Problems in Engineering e current state of energy is determined by equation (7), while the starting and ending of operation are controlled using equation (8) for next-day energy participation: In a one-time step, a specific amount of power can deliver and emit in the form of energy for the storage, which is expressed in equation (9) as a gradient of power: e national grid has some specific values for energy exchange given in (10). e storage upper and lower bound is represented in equation (11). To model the uncertainty of solar PV and loads, the following sections present the probability distribution functions.

Probabilistic Load and Solar PV Modelling.
e load of the campus is varying variable and change with time. In order to model the uncertainty of load, the normal distribution is used: where P L is the active power and μ L and σ are mean and standard deviation concerning P L [23]: Distributed generation such as solar PV is highly intermittent. Aside from its numerous advantages, the distribution function is used to model the uncertainty in solar irradiance. e beta distribution, as presented in equation (16), is the function of solar irradiance uncertainty. To generate the scenarios based on historical data, Latin hypercube sampling technique [74] is used. e generated samples are 545 which are reduced to about ten by fast forward reduction method [75], where α and β are parameters for the beta distribution function. ese parameters are determined by the following expressions (17) and (19). e mean and standard deviation are μ and σ, respectively, which are used to calculate parameters of the beta distribution function of the random variable irradiance "I." e output power of solar PV is calculated using the following expression [76]: where η pv,j is the efficiency of installed solar PV panels, β pv is the covered rooftop area (m 2 ) of solar PV panels, and I is the irradiance of solar (kW/m 2 ), respectively.

Demand Response Constraints.
Demand response is the branch of energy management which optimally reduces the peak load demand by involving the customers in the electricity market. For the system reliability, it is necessary to operate the system.

Real-Time Pricing.
In real-time pricing, the retail prices of electricity vary during the day and effect on the customer consumption cost. In our study, 0%, 10%, and 20% DR are analyzed using the optimal load curtailment, considering the following constraint:

Time of Use Pricing. e time of use model is expressed in (18)-(21):
where dr(t) and λ p are the energy demand and the pricing, respectively, in the peak and off-peak time.

Methodology
e proposed system is a single nonlinear objective, with linear constraints. As the mathematical differential technique, it generates an exact solution with some other features, so quadratic programming is used to solve the model. e general expression of QP is given in the following equation: Solver interior-point convex technique is used in MATLAB to solve the proposed system. In Section 6, the obtained results are presented. e interior-point convex algorithm of linear programming is used in MATLAB R2018a environment on Dell Latitude System with i5 4670 processor @3.4 GHz and 4 GB RAM.

Results
Optimal scheduling of reserves is analyzed to utilize the dispatchable and nondispatchable energy resources. A load of the campus is taken from nearby grid station and a model is proposed as presented above.
Demand response programs such as incentive and price based are analyzed. e exponential increasing energy consumption cost of the existing campus is shown in Figure 5.
e case study has been carried out to separately investigate the time of use (TOU) and real-time pricing (RTP). e exchange energy with the grid is based on the following flowchart steps.
6.1. Case Studies. As described earlier, the grid outage is also the problem of developing countries such as Pakistan. So, it is also considered here with a grid support case. Here, we suppose the energy exchange with the grid at the same unit prices. e basic parameters of the proposed model are given in Table 1.
Two types of pricing are analyzed, as shown in Figure 6: time of use (TOU) and real-time pricing [77]. AC loads are attached and are composed of air conditions, lighting, fans, and PCs, as shown in Figure 7, whereas solar PV output power is expressed in Figure 8. Furthermore, loads are divided into critical and noncritical loads. e critical loads cannot curtail and must run loads [78]. Figure 9 shows the flowchart of the proposed strategy.

Case 01 A (Real-Time Pricing Analysis/with 0% DR).
Case 1(a) (grid available mode (existing system)): in this case, the campus has only one energy source to supply the energy and operate all its loads. e total operational cost of this case is $2422.2 which will be considered as the base case. Case 1(b) (operational cost without scheduling): In this case, DG solar PV and ESS are utilized without any schedule. e result obtained is $1349.9. e installation and replacement cost is not included in this case.
Case 1(c) (cost after grid outage for two hours): in this case, the scheduled outage of the grid is analyzed as shown in Figure 10. e operational one-day cost is $1354.3. e predefined outage is compensated through BESS and solar PV, as a time of outage is 10 to 11 AM. e solar PV is available and can run the whole system smoothly at critical peak pricing [79].
Case 1(d) (grid support in emergency case): in this case, the consumer received a signal from the grid to support the grid. So, the consumer acts as energy importer to the grid through an aggregator. e operational cost, in this case, is $1332.4.
Case 1(e) (proposed scheduling mode): in this case, available resources are utilized optimally through pricebased scheduling. e contracted neighbour of prosumer power is also supplied at 15:00 to 16:00 PM for two hours, as shown in Figure 11. e total cost reduced about 65.3% compared to the base case is expressed in Table 2.

Case 1. B: With Load Curtailment (10% DR).
Case 1(f ) grid available mode (existing system): in this case, the campus has only one energy source to supply the energy and operate all its loads. e total operational cost of this case is $2422.2 which will be considered as the base case.
Case 1(g) (operational cost without scheduling): in this case, DG solar PV and ESS are utilized without any schedule. e result obtained is $1349.9. e installation and replacement cost is not included in this case.
Case 1(h) (cost after grid outage for two hours): in this case, the scheduled outage of the grid is analyzed, as shown in Figure 12.
e operational one-day cost is $1354.3. e predefined outage is compensated trough BESS and solar PV, as a time of outage is 10 to 11 AM. e solar PV is available and can run the whole system smoothly.
Case 1(i) (grid support in emergency case): in this case, the consumer received a signal from the grid to support the grid. So, the consumer acts as the energy importer to the grid through an aggregator. e operational cost, in this case, is $1332.4, as shown in Figure 13.     1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Figure 9: Flowchart for proposed energy storage scheduling, where the parameters P t ch is the ESS charging power, P t dc h is the ESS discharging power, P t ch, max is the maximum charging power of ESS, ±ΔP ch is the threshold ESS output power in one hour, P ch,av /P dch,av is charging and discharging available at time t, and D loss /C loss is losses during charging and discharging. Case 1(j) (proposed scheduling mode): in this case, available resources are utilized optimally through pricebased scheduling. e contracted neighbour of prosumer power is also supplied at 15:00 to 16:00 PM for two hours, as shown in Figure 14. e total cost reduced about 65.3% as compared to the base case as expressed in Table 2.   between the above Case 1(a) is significant and reduced from 2442.6 to 2290.5 which is 6%. Case 1(l) (total cost without scheduling with DR): in this case, the total operational cost is reduced to 1217.8 as solar PV and ESS are incorporated. e output power of solar PV and ESS utilized randomly without considering any constraints' schedule.

Mathematical Problems in Engineering
Case 1(m and n) (grid outage and grid support with DR): both cases have similar situations, as described in Case 1(c and d), besides its reduced cost. In grid support mode, cost is reduced from $1332 to $809.2. In this case, the storage output power supports the grid from 10:00 to 11:00 for two hours. e state of energy shifts in the discharging mode until the request is complete. In grid outage, that is, due to the energy shortfall, scheduled grid outage occurs at the same time any day from 10:00 to 11:00, as shown in Figure 15. e cost is reduced from $1354.3 to $1137.5, due to load curtailment during these hours.
Case 1(o) (proposed scheduling with DR): in this case, the scheduler considered the available resources and loads and generated a controlled signal for optimal operation. In this case, significant cost is reduced from $2290.5 to $809. 29, which is about 64% as compared to the base case. Similarly, the whole process with defined parameters is presented in Table 2.

Case 02: Time of Use-(TOU-) Based Analysis without
Demand Response. Case 2(a) (grid only (base case)): in this case, as discussed earlier in Case 1, the grid is an available source of energy. So, operational cost is calculated $1648.9, which is an existing system. Case 2(b) (without scheduling): in this case, solar PV and storage are available for backup. e solar PV output power is utilized for self-consumption that reduced the energy consumption cost from $1648.9 to $1325.7. e chargingdischarging of energy storage is randomly utilized and free from any bound. So, it is economical but needs proper usage for optimal operation, while Figure 16 shows the real-time pricing.
Case 2(c) (grid outage without DR): the scheduled grid outage hours are from 10:00 to 11:00 for two hours and PVstorage compensates the loss of grid. So, the cost is reduced as compared to the above two subcases and is found to be $1301.9.
Case 2(d) (grid support case): in this case, prosumer receives emergency signals from the grid for support due to peak hours, contract, or some incident. e cost is calculated after the fulfilment of grid requirement is about $1180.5, as shown in Figure 17.
Case 2(e) (proposed scheduling): in this case, cost reduced from $1325.7 to $990.6 which is about 39%, as shown in Figure 18. All parameters are representing in the graph  using different colours. As the load changes, PV-storage operates accordingly considering the time of use prices and contracted power.
Case 2(f ) (grid only (base case)): in this case, load curtails according to the peak hours and the load is shifted into off-peak hours. e cost is reduced from $1648.9 to $1620.2.
Case 2(g) (energy reserve utilization without scheduling): in this case, PV-storage is utilized with scheduling with the grid-connected mode. e cost is calculated as $1297, as   compared to without load curtail in previous case 2(b) which was high about 2%. is shows the benefits of load curtailment for economical operation. Case 2(h) (grid outage with DR): a scheduled grid outage is considered in this case and the result after analyzing the system is found. e grid outage in our case is from 11:00 to 12:00 for two hours. e obtained result is $1070 considering the 20% load curtailment scenarios, as shown in Figure 16.
Case 2(i) (grid support mode): in this case, the whole scenario will be like case 2(d), but, considering the load curtailment, the total cost is found to be about $961.59 which is 18% less than the case of 0% incentive-based demand response (IBDR). e detailed features of this case are presented in Figure 19.
Case 2(j) (proposed scheduling): in this case, all parameters are scheduled through a microgrid-proposed scheduler that optimally utilizes the energy reserves. e contracted power shows from 15:00 to 16:00 for two hours.
e state of charge and storage output power is expressed in black and hollow square symbols. When the prices are high, the storage power retains itself to more charging. Figure 20 shows the optimal scheduling of all parameters in time of use demand response environment. Table 3 presents all the results of TOU price-based demand response.

Discussion
Form the above analysis, it is deduced that both price-based and incentive-based demand response strategies are beneficial for the customer in the electricity market. e analysis is carried out for the Pakistani environment, which is a developing country. e renewable integration with the existing grid by optimal scheduling of the available resources is analyzed and a significant reduction in scheduled utilization is found. So, a microgrid scheduler is necessary for smooth and economical operation. Furthermore, the obtained results show that the RTP reduction is more as compared to TOU strategy.

Conclusion
Optimal scheduling of DGs and ESS are addressed in the literature; however, the storage degradation cost and some system constraints are missed. In this paper, we investigated the campus microgrid energy management system with realtime local problems such as grid outage, grid support, and demand response strategies. As the storage system is highly nonlinear in nature, a nonlinear model is solved using quadratic programming. Two price-based cases, TOU and RTP, are analyzed in incentive-/nonincentive-based environment which were not addressed earlier. e prosumerbased market model is presented and contracted with the utility and neighbour customer. Results reveal that operation cost and peak load reduced to serve both customer and utility. Combined heat and power MT: Microturbine RERs: Renewable energy resources DG: Distributed generation ESS: Energy storage system MILP: Mixed integer linear programming DR: Demand response DS: Distribution system EMS: Energy management system DSM: Demand-side management.
Data Availability e load grid data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that they have no conflicts of interest.