Modeling smart electrical microgrid with demand response and storage systems for optimal operation in critical conditions

. This study examines the issue in standard and operational scenarios of microgrids that arise during critical conditions. Initially, the ideal energy storage size and discharge depth are identi ﬁ ed for optimal microgrid planning under operating conditions. Subsequently, by utilizing the energy storage system and load response, the microgrid ’ s vulnerability is reduced and the cost of load shedding is minimized when in critical conditions, leading to the microgrid being disconnected from the main network and operating in island mode. This model aims to analyze how the system performance is in ﬂ uenced by the presence of storage systems and load response programs in a numerical scenario, particularly during severe weather events. In addition, the study examines the role of advanced control algorithms and communication systems in optimizing the operation of the microgrid. By implementing smart grid technologies, the microgrid can better manage its energy resources, anticipate ﬂ uctuations in demand, and respond quickly to changing conditions. This proactive approach helps to ensure the stability and reliability of the microgrid, even in the face of unforeseen challenges. Overall, this research contributes valuable insights into the challenges and opportunities facing microgrids in both normal and emergency situations. By identifying the most effective energy storage solutions, load response strategies, renewable energy integration methods, and advanced control systems, the study aims to enhance the resilience, ef ﬁ ciency, and sustainability of microgrid systems in the future. The results of the proposed approach in critical operational mode represent the optimal condition of the electrical microgrid with minimum cost and load shedding considering storage systems and load response programs.


Introduction 1.Aims
The climatic variations and natural occurrences are occurring swiftly on a global scale.Given the reliance of human daily routines on electrical energy, enhancing the electric energy infrastructure and network resilience is a matter of utmost significance [1,2].The government has consistently prioritized bolstering power systems against natural calamities and ensuring sustainable energy, as any disruptions in this regard can lead to numerous complications [3].The microgrids play a crucial role in enhancing the resilience of power systems [4].They have the ability to supply loads independently during crises by operating separately from the main network [5].Additionally, energy storage systems contribute to grid stability and help maintain balance in the power system, especially with the unpredictable generation of renewable energy sources [6].Resilience enables power systems to withstand unexpected conditions with minimal impact and downtime.Once the issue is resolved, the network can seamlessly return to its normal state [7,8].It is essential to have a robust system in place to ensure safe operation and reliability in a network during natural disasters [9,10].The network's high reliability enables it to provide power and withstand unforeseen events and disruptions without fail [11].However, when faced with natural disasters, the effectiveness of meeting reliability criteria is hindered due to their low probability of occurrence and high severity [12].In such cases, the focus shifts towards examining network resilience as a means of dealing with these incidents.There are multiple elements that impact the resilience of power systems [13].Among these, the cost and budget allocated for network resilience play a crucial role [14].Enhancing network resilience through strategies like energy storage systems, leveraging distributed production resources, network intelligence [15], will result in higher costs and budget requirements for network investments [16,17].To fully leverage the network and maximize the economic benefits of implementing various network resilience strategies, it is crucial to calculate the balance point for expenditure [18].The alignment of the cost of implementing these strategies with the improvement of resilience and reduction of blackout costs is guaranteed [19,20].Geographical conditions, weather conditions, and the desired network location are additional factors that impact the resilience of power systems.Consequently, the selection of various network resilience strategies is influenced by all these scenarios [21,22].

Contributions and background
The initial focus of this study is to analyze the standard performance of the microgrid.Subsequently, we determine the most suitable size for the storage systems within the microgrid to ensure optimal utilization in terms of both economic efficiency and network stability [23].By calculating the overall cost of the network, including the investment cost of the storage systems and the operational expenses of the microgrid, we aim to establish the minimum cost required to determine the ideal size for the storage systems [24,25].In a crucial operational scenario, the microgrid functions partially during extreme weather conditions, monitoring the impact of the load response program and storage systems, ultimately decrease the cost of load interruptions through effective planning [26].Enhancing microgrid resilience is a key objective of this research, focusing on planning and ensuring the safe operation of the system [27].The components of a sample microgrid are illustrated in Figure 1.

Related works
The studies on operation and modeling of the microgrids under various conditions are done by researchers in recent years.In this section some of them are studies.In [28], a cost-effective linear programming model is introduced, which incorporates a sliding time window to analyze and assess the most efficient configuration of biomass-based microgrids that produce both electricity and heat.This approach combines deterministic constrained optimization and stochastic optimization to address the uncertainties associated with microgrid operations.In reference [29], a solution to this issue involves utilizing evolutionary strategy for nonlinear integer minimization.This approach aims to reduce operating and maintenance expenses related to energy resources as well as overall capital costs.Additionally, factors like energy constraints, emissions limitations of energy resources, and the risk of potential microgrid power supply loss have been taken into account.A novel approach to demand response in smart grids is presented in [30].This approach combines the utilization of electric vehicles linked to the grid and renewable energy sources.To tackle the optimization problem, a distributed optimization algorithm is employed, which relies on the alternating direction of coefficients.The investigation in [31] focuses on the flexibility of a power grid incorporating a microgrid during crisis scenarios.The utilization of an islanded microgrid and independent load supply can improve the grid's adaptability.This study introduces four resilience indices to evaluate the consequences of extreme events.Additionally, the resilience indices are computed using the Monte Carlo method in this approach, and the Markov chain method is employed to demonstrate the state transitions of the power grid with microgrids.The paper [32] introduces a highly efficient approach to assess energy storage in a microgrid network, focusing on reliability and enhanced flexibility.This approach employs a two-level model to maximize the net profit.The stochastic multi-objective approach was introduced in [33] to optimize the scheduling of storage systems in microgrids.The method focuses on the microgrid's operating cost under normal circumstances and the load reduction index during faults and islanding events as the primary criteria.A novel battery operating cost model is introduced in [34], where the battery is treated as a generator to facilitate its integration into a unit commitment problem.Additionally, this approach takes into account uncertainties in renewable energy generation, load demand, and economic dispatch problems, potentially adopting a limited approach.In [35], an efficient strategy for planning a temporary microgrid is presented, taking into account the interconnections between the temporary microgrid, interconnected microgrids, and the main power grid in both grid-connected and islanded operations.This approach focuses on optimizing temporary microgrids while addressing uncertainties related to both physical and financial aspects.Investigation of microgrids in [36] focuses on operating in island mode to power critical loads during emergencies while also enhancing flexibility.The approach involves separating the

Microgrid mathematical modeling
This section covers the overall problem modeling and examines the problem under two scenarios: regular operation and critical operation during a severe accident.The initial step involves determining the ideal storage system size in the microgrid for efficient planning in normal operating conditions.The primary objective of this level is to calculate the optimal discharge depth of the storage system for load management, as well as determining the most suitable size for the microgrid.By minimizing the total cost of the microgrid, the ideal storage system size can be determined.The main goals of this stage include identifying the optimal storage system size and monitoring the collaboration between the storage system and load response software to enhance the microgrid's efficiency under normal operating conditions.Employing a storage system and load response at the second level can help minimize vulnerability and decrease the cost of load shutdown when an error occurs and the microgrid is disconnected from the main network, operating partially.The main objective of the second level in this model is to assess how the presence of a storage system and the load response program impact the system's performance during critical condition, ultimately enhancing the network's resilience.In this particular model, the objective function takes into account the investment in storage systems and the costs associated with microgrid operation during normal operating conditions.It aims to minimize load shutdown and reduce operating costs after disconnection from the upstream network in critical conditions.Moving on to the second level, the outage cost is represented by the lost load energy and the extent of the outage.The microgrid load is expected to remain constant in the future; therefore, the initial planning is focused on a oneyear timeframe, while the more intricate planning for the second level will only be necessary during times of disruption.In Figure 2, framework of proposed modeling is shown.

Objective function modeling
In this section, we present an overview of the fundamental optimization model for microgrid planning in both standard and critical scenarios.We delve into the model's nature, component characteristics, and the calculation of the ideal storage system size under typical operational conditions.Additionally, we provide objective functions, microgrid and production unit constraints, as well as operational constraints specific to each situation [37].Equation (1) showcases the objective function for the normal operating state, encompassing the total investment cost of the storage system and the anticipated performance cost of the microgrid on a daily basis throughout a year.
Each year, the one-time costs have been considered and distributed over the lifespan of the storage systems.The installation cost of storage systems is contingent upon the maximum power transmission and energy storage capacity.ICP represents the cost of determining rated power, while ICE represents the cost of determining rated power and energy.The investment cost is computed using equation (1) based on the rated power of the storage systems.The equation (3) demonstrates the total cost of microgrid operation (OC), which includes the fuel expenses for generating electric power using local microgrid units, the costs associated with purchasing and selling electricity, exchanging energy with the primary grid, and the expenses incurred from switching off microgrid loads.In this regard, the operating cost of fossil fuel units is calculated by F g P g s;t;h and P g s;t;h the production power of the existing unit g on day t at hour h in scenario s, P M s;t;h the power imported (or exported) from (or to) the network Main on day t, hour h in scenario s (the same power received and transmitted from microgrid to network), N g number of available units, N t several days, N h several hours, N s number of scenarios, N i number of available buses, x t,h electricity price, s scenario index, p T s scenario probability s, t day index, h hour index, g conventional unit index and i bus load index.The objective function in this scenario is represented by equation ( 3), aiming to minimize the projected cost of outage in the microgrid during critical operation conditions and after a failure occurs.
In this regard, Plsh s,t,h the power of the de-energized load of the microgrid at hour, VOLL t,h represents the cost of shutting down the load in the microgrid.

Constriants
Three states are employed to classify storage systems: charging, discharging, and idle.The charging and discharging relationships of the storage systems are represented in equations ( 6)-( 13).
Equation ( 6) quantifies the energy stored in the system.The energy stored each hour is calculated by combining the energy from the previous hour with the current hour's charge or discharge.The energy stored at day t and hour h is denoted by, while the charge and discharge powers are denoted by and, respectively.Additionally, represents the efficiency of charging and discharging.The charging and discharging powers are constrained by equations ( 7) and (8).The storage's nominal power is determined by equation ( 9), where k is the depth of discharge.Equation (10) sets a limit on the energy stored.Equations ( 11) and (12) restrict the energy at the start and end of each day.Equation (13), which also limits the initial investment budget, significantly constrains the system's size.

Power dispatch modeling
The powers dispatch of the proposed microgrid is modeled as follow: The real power produced by the sources of wind turbines and solar cells in bus i is shown by P wind s;t;h and P solar s;t;h , respectively.Plsh s,t,h is the received and transmitted power from the microgrid to the main grid.In the critical operation situation, due to the microgrid's outage from the main grid and its isolated operation, the value of this power is zero.PL DRP s;t;h represents the off-load power of the microgrid, which is equal to zero in regular operation.The load demand of the microgrid in these equations must equal the instantaneous load demand of the microgrid and represents the total production power of the nearby power generating units, the power transferred between the microgrid and the main grid, and the charging or discharging power of the storage system.The balance between demand and production is represented by equation (14).Equation (15) expresses the upper and lower bounds of the production power of unit g for every scenario s on day t and hour h.In that P g min the minimum production power of unit g, P g max the maximum production power of unit g, and UX g s;t;h the binary variable RU g is the status of unit g being in orbit on day t at hour h in scenario s.Relationships 16 and 17 control the increase or decrease of production power between two consecutive hours.RU g shows the ascending limit of power (increasing step) of unit g, and P M s;t;h shows the descending limit of power (decreasing step) of unit g.Equation ( 18) sets a restriction on the amount of electricity that may be transferred between the microgrid and the main grid.It is positive when it receives power from the primary grid, negative when it sells power, and zero when the microgrid is separated from the grid.P M max is the limit of importing (or exporting) power, and UY M s;t;h is the binary variable of the connection status of the line connected to the main network on day t at hour h in scenario s, which will be one if connected to the network and zero otherwise.Equation (19) is the microgrid's transient load in each case serve as load shedding limits.

Demand response modeling
This study utilizes the Time of Use (TOU) load response program for load management.The accountability program aims to shift electricity usage from costly peak hours to The Author(s): Science and Technology for Energy Transition 79, 55 (2024) more affordable low-load hours, thereby decreasing energy generation during high-load periods and procuring energy from the grid during peak-load times.The involvement of responsive loads is crucial reduces electricity consumption during critical hours.In accordance with the concept of a time-of-use response program, equation (20) provides the statement's mathematical representation [38,39] Equation (20) shows the updated load of the microgrid, factoring in the load response program, as the sum of the initial microgrid load and a variable.This variable can either be positive, indicating an increase in load, or negative, indicating a decrease in load, forming the foundation of the time-of-use load response program.Essentially, the smart grid technology enables the transfer and redistribution of a portion of the load from peak load periods to off-peak periods or from high-cost periods to low-cost periods, as represented in equation ( 21).The technical constraints associated with the load response program are outlined in equations ( 21) and ( 22) [40,41].
In equation ( 21), it is stated that the load response program must have a load change that is smaller than a certain percentage of the base load.It is important to mention that this percentage is set at 10% for the purpose of this research.Additionally, equation (22) demonstrates that the load does not actually increase or decrease, but rather shifts from costly intervals to more affordable ones.In simpler terms, the decrease in load must be equal to the increase in load over the course of a day.

Case studies and numerical simulation
In this section numerical simulation of approach considering several scenarios is implemented.The information and data of microgrid such as resources data are extracted from references [42,43].The Beta and Weibull functions are considered for power generation modeling of the photovoltaic and wind turbine systems, respectively.The average energy demand of microgrid in one year is shown in Figure 3.In Figure 4, average energy price in one year in 24 h in electrical market is listed.Also, data of storage system such as investment costs, efficiency, discharge and charge powers are extracted in references [44][45][46].The two scenarios considering participation of the storage system and demand response in critical condition are provided as follow: Scenario A) Modeling operation of microgrid without demand response and storage system.Scenario B) Modeling operation of microgrid with demand response and storage system.

Scenario A
In this scenario, the microgrid is being operated under critical circumstances, without the involvement of demand response and storage system.In the case of a severe and inevitable disruption, and taking into account the fundamental mode in the critical operation scenario, the microgrid is designed without a storage system and responsive loads.During the incident, the total expenses for the disconnection loads, production, purchasing electricity from the upstream network, and the microgrid were significant.The cost of $12 438.3 for disconnection loads highlights the impact of the incident on the overall expenses.Additionally, the cost of $4223 for production and $3448 for purchasing electricity from the upstream network further added to the financial burden.The microgrid played a crucial role in maintaining power supply during the incident, but it also incurred costs amounting to $4767.The need for an increase in thermal unit production during the 6-h period when the microgrid operated independently further emphasized the importance of careful planning to minimize outage costs.To ensure that the microgrid can independently meet the load requirements and minimize outage costs in the future, it is essential to implement effective strategies and contingency plans.This may include investing in renewable energy sources, improving energy efficiency, and enhancing the resilience of the microgrid infrastructure.By taking proactive measures and planning ahead, the impact of incidents like the one illustrated in Figure 5 can be mitigated, ultimately reducing expenses and ensuring reliable power supply.

Scenario B
In this scenario, such as power outages or high demand periods, the microgrid relies on demand response and storage systems to ensure its functioning.The demand response system allows the microgrid to adjust its electricity consumption in response to changes in the grid's supply and demand conditions.This helps to balance the load and maintain stability in the microgrid.The storage system plays a crucial role in the microgrid's functioning during these crucial situations.The ideal capacity for the storage system, determined during regular operations, is 19.731MWh.This means that the storage system can store up to 19.731 MWh of excess electricity generated by the microgrid or from the main grid.The storage system has a discharge depth of 0.225, which means that it can discharge up to 22.5% of its total capacity.This allows the microgrid to use the stored power when needed, such as during power outages or periods of high demand.The rated power of the storage system is 4.44 MW, which indicates the maximum power that can be discharged from the storage system at any given time.The charging and discharging schedule for the storage system is depicted in Figure 6 on an hourly basis.This schedule shows when the storage system is being charged, either from excess electricity generated by the microgrid or from the main grid.It also shows when the stored power is being discharged, either to fulfill the load demand within the microgrid or to sell electricity back to the main grid.The profitability of the  microgrid network increases when the stored power is discharged.This can happen in two ways: firstly, during a fault or power outage, the microgrid can rely on the stored power to continue supplying electricity to its consumers, ensuring uninterrupted power supply.Secondly, the microgrid can sell the stored power back to the main grid during periods of high demand, when electricity prices are higher.This allows the microgrid to generate revenue and offset its operating costs.Overall, the functioning of the microgrid during crucial situations heavily relies on the demand response and storage systems.These systems ensure the stability and reliability of the microgrid, while also providing opportunities for revenue generation through the use of stored power.
After incorporating storage systems, the production cost amounts to $4235, while the expenditure on purchased power totals $3853.Additionally, the investment cost for the storage systems is $1.081 per day.Unfortunately, due to the outage, the microgrid will not generate any income from selling power to the upstream network.Taking all these factors into consideration, the cost of the loads that were switched off during the outage decreases to $2.834, resulting in a total operational cost of $12.3 for the microgrid on that particular day.The cost reduction in the second mode, compared to the first mode, is attributed to the utilization of the power stored in the microgrid's storage systems during island mode.The dispatchable units in the scenario B is illustrated in Figure 7.
Table 1 displays the objective function values for scenarios A and B during operation mode.The optimal level of the microgrid, taking into account technical and economic factors, is achieved with the involvement of the storage system and demand response.

Conclusion and future studies
This research investigated the challenges faced by microgrids in both standard and emergency situations.It begins by determining the most suitable energy storage capacity and discharge level for efficient microgrid planning under normal circumstances.Subsequently, through the use of energy storage systems and load response mechanisms, the vulnerability of the microgrid is decreased, and the cost of load shedding is minimized during emergencies, resulting in the microgrid operating independently in island mode.This model seeks to assess how the performance of the system is impacted by the presence of storage systems and load response strategies in a numerical setting, especially in extreme weather conditions.The outcomes of this method in critical operational mode demonstrate the optimal state of the electrical microgrid with minimal expenses and load shedding, taking into account storage systems and load response strategies.Furthermore, this research also explores the integration of renewable energy sources into microgrid systems to enhance their resilience and sustainability.By incorporating solar panels, wind turbines, and other renewable sources, the microgrid can reduce its reliance on traditional fossil fuels and decrease its carbon footprint.The study evaluates the impact of renewable energy integration on the overall performance and reliability of the microgrid, particularly during times of high demand or when the main grid is unavailable.Overall, this research aims to provide valuable insights into the challenges and opportunities faced by microgrids in both normal and emergency situations.By optimizing energy storage capacity, implementing load response mechanisms, and integrating renewable energy sources, microgrids can become more efficient, reliable, and resilient in the face of various challenges.The findings of this study can inform future microgrid planning and design strategies to ensure the continued success and sustainability of these innovative energy systems.
In this area, recommendations are given for upcoming studies such as integrating electric vehicles with energy storage to enhance the efficiency of microgrid by reducing reliance on renewable energy sources.Introducing an efficient method for rapid network restoration.Given the significance of prioritizing electricity supply to consumers like hospitals, industries, commercial establishments, and residential buildings during load recovery, future studies could explore categorizing these consumers based on importance.Emphasis should be placed on restoring critical loads promptly.

Fig. 6 .
Fig. 6.Power dispatch of storage system in microgrid in scenario B.

Funding
Zhejiang Provincial Department of Education "Exploration of EMS Talent Base Based on the Integration of Industry and Education" (202107175) Ministry of Education "Construction of Electronic Technology Practice Teaching Base" (202101232027). .

Table 1 .
Value of objective function in scenarios A and B in operation mode.