Two-Cored Energy Management System for Industrial Microgrid

Energy systems have to deal with energy cost and environmental concerns such as greenhouse gas emission. Industrial buildings considered as Microgrid ( μ G) with heavy load worsen these issues even more. Further, cyber-attacks on the data communication channel between utility and customer is also a potential threat and may alter the data as well as the confidentiality of it, resulting in an inaccurate result. To address these problems, this paper proposes two-cored Building Energy Management System (BEMS) for Industrial Microgrid (I μ G) with first cored termed as the energy layer concentrating on energy cost and emission reduction, while second cored termed as security layer provides the un-authorized intrusion detection and prevention system (IDS/IPS) for cyber secure communication of data. The μ G under consideration contains national grid, Natural Gas (NG), solar Photovoltaic (PV) as input carriers; electrical energy at output ports; electric vehicle (EV) fleet; battery bank; solar PV panel as non-dispatchable Distributed Energy Resources (DERs) and Internal Combustion Engine (ICE), Fuel Cell (FC) and Micro Turbine (MT) as dispatchable DERs. Energy layer optimization problem has been solved in MATLAB using flower pollination algorithm for µG energy consumption cost and emission reduction. To develop and analyze the security layer, Linux operating system based Smooth-sec software has been used. Devised security layer continuously monitors the network traffic between customers and BEMS as well as BEMS and utility server. During monitoring it distinguish the licensed user or malicious attacker to detect and prevent possible internal and/or external intrusions in the communication channel. Results show that EMS reduces energy cost and emission in addition to cyber security from internal threats. Proposed two-cored control may be manufactured for utilities to realize its benefits for industrial customers in a smart energy distribution system.


INTRODUCTION
ising fuel cost, imbalance in ecological system and overloading of energy resources need appropriate solutions. Among various options, Distributed Energy Resources (DERs) and Demand Response (DR) strategies may effectively be used to solve these problems. The DERs reside in a µG as onsite generation to serve the connected load and sell excess power to national grid using net metering.
Lokeshgupta et al. [2] proposed a multi-objective Energy Management System (EMS) for residential consumers' to minimize their energy cost and load fluctuations. The building contains utility grid, Battery Energy Storage System (BESS) and shift-able and critical appliances. The problem is solved in MATLAB using mixed integer linear programming for four buildings. The results show that the customers can recover their BESS investment within three years with total saving of about 565.75 $/year. Senemar et al. [3] proposed optimal sizing strategy of combined heat and power unit, gas boiler, PV panel, and storages for residential energy hub under minimization of energy cost as objective function. The energy cost contains the capital investment and operation and maintenance charges. Devised framework has been validated under deterministic and random solar irradiance. Scenario generation and reduction is carried out using Monte-Carlo simulation. Proposed model is solved in General Algebraic Modeling System (GAMS) using CONOPT solver. Cost increases from 48083$ to 48115$ with and without solar irradiance uncertainty respectively.
Rosales-Asensio et al. [4] considered an office building located in the city of Palmdale, California, as large microgrid containing PV system and electrochemical energy storage systems, life cycle cost of energy, and electrical network. The model is formulated as mixed integers linear programming problem. The simulations show that proposed framework results in energy cost saving of 112,410 $ over the 20-year life cycle.
Mbungu et al. [5] proposed a model predictive based energy management and control framework for a commercial building in Tshwane, South Africa. Building contains photovoltaic system, utility grid and battery storage. The proposed technique is solved in MATLAB. The result manifests that cost of energy import decreases by 46%.
Liang et al. [6] proposed a DR strategy for a commercial building to optimally schedule heating, ventilation, air conditioning systems, electric water heaters and plug-in electric vehicles. Building consists of power grid, battery, EV, solar PV penal, electric water heater and heating ventilation and air conditioning system. The objective is to minimize total energy cost and maximize customers comfort level. Monte Carlo method is used to generate scenarios of solar irradiance. The results demonstrate that household comfort level increases from 40% to 100% by sacrificing 20% of energy cost.
Blake et al. [7] proposed an IµG equipped with wind turbine, Combined Cooling, Heating and Power (CCHP) unit in addition to battery for a manufacturing facility in Ireland. Load and wind speed have been forecasted using neural networks. Linear optimization problem aims at to solve cost and emission of µG using MATLAB. Results show that CCHP and wind turbine reduce cost by 69%, while the emission reduces by 88%.
Li et al. [8] presented an optimal energy management strategy for economic operation of wind, PV, diesel generator and vanadium redox flow as well as lithiumion batteries in an IμG situated in Beijing, China. Performance objectives include fuel cost, maintenance charges and power purchasing cost reduction along with revenue maximization. Simulation is performed in regrouping particle swarm optimization algorithm.

Two-Cored Energy Management System for Industrial Microgrid
Results have been compared with the existing algorithms available in literature. Simulations show that the proposed energy storage strategy reduces the desired cost along with rise in revenue.
Golmohamadi et al. [9] proposed a multi-agent optimization structure to quantify the flexible load in cement and aluminum smelting industrial buildings for energy cost reduction. The proposed approach has been tested on the Danish sector of the Nordic Electricity Market. The stochastic programming approach is coded in GAMS while the results are imported in MATLAB. The simulations show that energy cost decreases by adding renewable energy by 18% and 34% for cement and smelting industries respectively.
Naderi et al. [10] proposed a μG in Shad-Abad industrial estate, Tehran, Iran. Microgrid contains wind turbine, battery, PV penal, FC, diesel generator and electrolyzer for production of Hydrogen. The objectives are stability enhancement of the network as well as energy cost reduction and emission minimization. Proposed problem has been solved in HOMER Pro. The results show that the net cost and CO2 emission have been minimized by $1.87M and 90000 kg/year. Mehta [11] proposed a group of commercial and industrial microgrids while considering various options such as diesel generator, BESS and solar PV generation for a glass factory in India. Proposed problem is solved in HOMER Pro. Results demonstrate that fuel cost and energy consumption cost reduce by 45% and 19% respectively.
Choobineh et al. [12] considered a cluster of μGs in an industrial park. Energy price and plant production have been taken as uncertain variables using robust optimization technique. Each μG consists of diesel generators. Proposed problem has been solved using goal programming technique. Devised central controller reduces energy cost of individual industrial buildings using game-theoretic approach.
Khripko et al. [13] presented a polymer processing factory equipped with CCHP unit, solar PV, gas boiler, electric boiler, absorption chiller, heat exchanger, thermal oil system, printing machine, dryer, blow film extruder, air compressor, compression chiller and water storage. The proposed linear optimization framework has been solved in GAMS. Results show that energy demand reduces by 23.19% after inclusion of renewable energy resources.
Helin et al. [14] offered an EMS for mechanical pulp production process in the Nordic power market. The microgrid contains natural gas-based CCHP, district heating system and electricity as inputs and electricity and heat as output carriers. Devised methodology generates an optimized operational plan for pulp production. Framework has been solved in CPLEX solver. Results demonstrate that industrial Demand Side Management (DSM) has sufficient flexibility to ensure network stability and energy consumption cost minimization.
Tan et al. [15] proposed time series simulations for a period of ten years in HOMER Pro software to evaluate the long-term impact of multiple energy sources in an IμG. The proposed model consists of diesel generator, wind turbine and national grid to analyze economic benefits and carbon emission reduction. The proposed scheme with emission proves more economical having total energy cost of 6.5744 × 10 7 $, however, cost rises to 6.6827 ×10 7 $ without inclusion of emission. Results show that the total carbon emission is 10,946,355 kg/yr.
Abdulaal et al. [16] developed a multi-objective GAbased optimization solver from quadratic, stochastic, and evolutionary programming, to solve a DR-based two-stage energy management system for IμG in Florida. In stage-1, the optimizer shifts the shift-able load, whereas, the stage-2 control continuously manages the controllable loads. Simulation showed a reduction in utility costs from 2% to 6% for Pareto optimal sets. Apart from research work on energy layer of BEMS a cyber security strategy also needs to be developed to detect and prevent malicious attacks. Such attacks may modify weather as well as tariff data and customer preferences causing BEMS to malfunction, resulting in erroneous energy cost and emission. The cyberattack on the data communication channel between the  796 IμG and the utility may alter the data as well as its confidentiality.
The literature survey related to cyber security is described in detail as: Anuebunwa et al. [17] analyzed the impact of cyberattack on load scheduling applications in a residential building. Attacker interferes with the critical data such as dynamic pricing information and load profile etc. Objective function includes impact on occupant comfort, cost and load variations. Proposed framework has been solved in Genetic Algorithm (GA). Devised scheme detects the false data injection to warn the system administrator to take remedial measures.
Yılmaz et al. [18] proposed rule based testbed in Smooth-sec software to detect the active attacks on programmable logic controllers in an industrial control system by using the mirroring technique. Under this strategy system compares the attack log file with the signature file residing in snort library to discriminate between the normal and obnoxious data to generate a warning massage for system administrator.
Otuoze et al. [19] highlighted various security challenges and threats i.e. physical attacks, cyberattacks or natural disasters which could lead to infrastructural failure, blackouts, energy theft, customer privacy breach and endangered safety of operating personnel etc. Authors also proposed a framework that can identify the security level, source and cause of threat and the impact of attack. The devised technique identifies and clears the threat.
Literature survey shows that EMS modules for residential and commercial buildings have already been devised to attain objectives such as energy cost and emission reduction. Likewise, EMS frameworks for small and medium scale industrial μGs have already been proposed. However, EMS capable of optimally handling of bidirectional energy transaction with the national grid by scheduling the sources, load and storages for large scale industrial μGs, have not been proposed. Further, EMS communicates with the building owner as well as utility via communication channels. Such wireless or wired links remain under the threat of continuous unauthorized intrusion from external and/or internal intruders that may alter the parameters for instance weather and tariff data resulting in non-optimal schedule of μG components. Non-optimal schedule of industrial process leads to major economic losses. To address such undesirable scenario, a cyber security-based strategy needs to be devised for IμG. This paper proposes two-cored EMS for this class of customers. First core termed as energy layer optimizes energy consumption cost and emission whereas second core termed as security layer secures the communication channel from internal and external intrusion. Such cyber secure communication link masks the EMS to avoid malfunction. The following novel contributions have been made in this paper. The rest of the paper is organized as: section-2 presents the proposed two-cored energy management system for an IμG, section-3 presents first core i.e. energy layer, section-4 presents second core i.e. cyber security layer and section-5 draws the conclusion.

Proposed Two-Cored Energy Management System for Industrial Microgrid
Proposed two-cored EMS for IμG has been shown in Fig. 1. In this architecture, load automation layer receives data from customer, network and weather servers. Communication layer consists of a wired or wireless link to transmit data to the BEMS optimization layer. Scheduling layer contains optimization core to generate optimal dispatch signals for components in service layer. Service layer serves

Implementation of Proposed Control
Building energy management module resides in the customers premises to provide internal load automation and subsequent energy cost and emission reduction as shown in Fig. 3. The Building Energy Manager (BEM) communicates with the appliances, sources and storages via radio frequency wireless link to take boundary limits of the building components and customer preferences. Currently Bluetooth and Zigbee have been in use to establish the communication link. In response to this an optimal dispatch signal routes back through smart meter via same communication media for optimum dispatch.
The BEM also communicates with utility for mutual sharing of relevant information.

Mathematical Modeling of Industrial Microgrid Components
This section presents the mathematical modeling of the first layer of μG components [20].

Generation Sources in Industrial Microgrid
Mathematical modeling of energy generation sources in IμG is presented as below: Stationary Storage System: Mathematical model of station battery residing in the building is given below: where i, e , t , φ , τ, p , # , p , # , η and η # are number of μGs, stored energy in kWh, energy storage losses (%), time interval (h), charging and discharging power (kW) and charging and discharging efficiencies (%), respectively.
Upper and lower State of Charge (SOC) limits on battery are as follows: where SOC ,' ( , SOC ,'+, and E are minimum and maximum SOC limits and total capacity of energy stored (kWh), respectively.
Initially energy stored will be equal to the value at the end of the scheduling horizon T as below: The charging and discharging limits of battery are as follows: where P , u , t and u , # t are the maximum storage capacity, charging and discharging operational modes, respectively.
The station batteries cannot be in charging and discharging modes simultaneously as shown below: The charging and discharging start-up flags are as: where v , t , v , # t , u , t , and u , # t are start-up flags for charging and discharging modes, and binary variables representing charging and discharging states, respectively.
The battery operational and maintenance (O&M) cost is; where C # and C ' are degradation and O&M costs. The minimum and maximum limitations of the energy stored in the EV lot are as follows: where SOC ' ,'+,, and SOC ' ,' (, are the maximum and minimum SOC limits (%), respectively, while E ' t is maximum energy stored at time t in kWh.
Connected and disconnected energy capacity may be calculated as follows: The EVs charging and discharging constraints are as follows: where p ' t is maximum power stored (kW) in EV lot that is expressed as: The charging and discharging cycles can be expressed as below: The O&M cost of EV lot is modeled as:

Solar Energy Generation:
Power from the PV panels is given as: where Ω J, , η J, and I are the area (m 2 ), efficiency (%) and solar irradiation (kW/m 2 ).

Internal Combustion Engine:
The maximum power from the ICE can be expressed as: where p ,M , p ,M andu ,M t are minimum and maximum limits and ON/OFF status of j ICE in O PC μG at time t.
The minimum up and down time specified by an IMG owner using following constraints is as follows: where Fuel Cell: Fuel cell provides base load due to its high starting time. The operational cost can be expressed as:

Maximum Power Flow Limit Between Microgrid and National Grid
The IμG can operate grid-connected as well as in islanded modes. In on grid connected mode, it takes part in SR market and to support utility.
Maximum IμG power demand can be expressed as: where p # and p , t are required maximum power (kW) for IμG and power trade, respectively.

Spinning Reserve:
To avoid stability issues due to unexpected variation in load, SR equal to 10 % of the total building load will always be available for internal usage. The SR in excess of 10% will be sold out to utility.

Grid Connected Mode:
Microgrid procures/exports energy from/to the utility grid.
where Pi,g(t) and Pi,D(t) are energy trade and IμG load demand (kW), respectively.

Grid Connection:
The utility grid imposes energy transaction limits that are modelled as: −p , ≤ p , t ≤ p , where −p , and p , are the minimum and maximum limits (kW) respectively.
where C # t , C t , C _n t and cst are peak demand charges ($/day) and energy charges ($/day) for utility grid, SR cost ($/day) and power consumption cost ($/day), respectively.
Emissions of the IμG in kg/day are: (40) ξ vwv shows the rate of GHG emission in kg/h.

Solution Methodology, Results and Discussion
Flower Pollination Algorithm (FPA) shows superiority in terms of locating the global optimum and speed with low functional complexity over fuzzy logic, cuckoo search, particle swarm optimization, differential evolution particle swarm optimization, random search and neural network [20]. The proposed mathematical framework is a linear optimization model solved in MATLAB. Keeping such efficient performance in view the proposed framework has been solved in FPA. Mathematical structure of FPA may be found in [20]. The flowchart of the algorithm is provided in Fig. 4. Switching probability, lambda, alpha and number of iterations in our cases are 0.8, 1.5, 0.1 and 1000, respectively. Since FPA processes the information randomly therefore the best result in 10runs is presented in case studies.

Fig. 4: Flower Pollination Algorithm
This following section discusses the results of first core: the energy layer.

Proposed Energy Layer Results and Discussion
The hourly energy demand of each sub-process in a cement factory situated in Taxila, Pakistan, is shown in Fig. 5. Manufacturing facility functions daily in two shifts of 12 h each. Load pattern reveals that the most of processes such as finishing work carries out during day time.

Fig. 5: Hourly Energy Demand of Element Plant
The peak demand price, energy and SR charges, total and net EV capacity connected to the IμG, parameters of the IμG, DERs, and energy storages are taken from the study by Raza and Malik [20]. Table I shows that subcases 1(i), 2(i), 3(i), 4(i) optimize total energy cost of the IμG. Likewise 1(ii), 2(ii), 3(ii), 4(ii) reduce the total emission. Case-5 analyses the bi-objective scenario minimizing emission and cost concurrently.

Case-1:
In subcases 1(i) and 1(ii) SR and EV lot are not considered. As can be witnesses in Table 2 that total energy cost of the IμG reduces down to -273.041$ whereas emission minimizes to 5122.1kg. Reason of decline in cost has been the presence of onsite generation. Results encourage the building owners to install distributed generation for transformation from passive consumers into active prosumers.

Case-2:
In subcases 2(i) and 2(ii) building takes part in ancillary services such as the SR market, however does not consider the EV lot. For both subcases, total energy cost of μG and emission are -414.523$, 6681.6kg and 391.8721$, 5615.2kg, respectively. As may be witnessed that total energy cost of μG minimizes by 51.8172% from -273.041$ to -414.523$. Similarly, GHG emission reduces by 1.8682% in subcase 2(ii) compared to 1(ii). Results prove a fact that presence of SR bilaterally benefits the microgrid owner in terms of energy cost reduction and environment. Main reason of improvement in performance has been that SR acts in the form of energy reserve for μG during high tariff hours thereby minimizing total energy cost of the costumer and environmental pollution. Furthermore, SR serves as a source of energy for building load during loss of enhancing the resilience of μG. Loss of energy carrier may occur due to natural disasters such as floods, hurricanes, tornados, earth quakes, tsunami and harsh weather changes and technical faults such as outages on generation, transmission and distribution system.

Cae-3:
In sucases 3(i) and 3(ii) building does not participate in the SR market, however, contains EV lot. Total energy cost of μG increases in 3(i) compared to the subcases 1(i) and 2(i). Similarly, emission in subcase 3(ii) increases in comparison to subcases 1(ii) and 2(ii). Results unravel that energy storage in the form of EV lot without building's participation in SR market has unfavorable outcome. These results entice the buildings to participate in ancillary services to feed energy carrier or abrupt increase in demand, thus internal and external energy networks to earn revenue and attain green energy targets.

Case-4:
The subcases 4(i) and 4(ii) consider SR and EV lot. Microgrid earns maximum revenue of -1408.1$ in 4(i) with the lowest emission 5302.8kg per day in subcase 4(ii). Comparison of case-2 and case-4 demonstrate that concurrent presence of EV lot and SR plays important role in total energy cost of μG and emission minimization.
Case 5: Case 5 is bi-objective with SR and EV lot. Total energy cost and emission of the building rise compare to subcases 4(i) and 4(ii) respectively. Figs.   803 6-9 show μG energy sources, μG load and transections with national grid, μG spinning reserve and Pareto optimal sets [21] of cost and emission.

Risk Analysis Using Monte Carlo Simulation
To analyze the impact of random solar PV presence and unpredictable electric and NG outages, risk is carried out using Monte Carlo simulations [30]. Probability density function for network outages is modeled as exponential distribution [31]. To improve the accuracy, large number of scenarios are generated. For this purpose, 8000 outage scenarios are generated using two state Markov chain process [32]. To lessen the computations, scenarios are reduced to 100 using K-Means [33] technique. To generate random scenarios of solar irradiance, normal distribution [34] is used. Fast forward technique [35] is used to create 8000 scenarios and subsequently reduced to 100 by K-Means technique.
Results show that random solar PV presence has more meaningful impact on building energy cost and emission. Witnessing these outcomes, random solar PV presence is ranked as 1. To alleviate such situation, electric and thermal energy storage devices are suggested to the utility owners.

SECOND CORE: CYBER SECURITY LAYER
Energy management system controls customer's stakes such as energy consumption cost and emission by taking tariff, weather data and customer preferences as input through communication links between user and EMS as well as EMS and utility. User-EMS link may be developed by using either Bluetooth or Zigbee. Any intrusion to this channel to change the information may be termed as internal intrusion, however, unauthorized access to EMSutility link is termed as external intrusion. Optimal operation of EMS depends on the accuracy of information flowing to the control module. However, external or/and internal intruders may change the accuracy resulting in an in-optimal scheduling of μG components. To overcome this threat, a cyber security mechanism is developed to detect and prevent unlicensed internal access.
Literature [22] shows that there are various types of attack named as: ( In denial-of-service attack [23], individual or multiple attacker(s) transmit flood of information to a target server/ router either from within customer premises or from outside. Under such conditions, system either crashes or denies service to the authorized user resulting in inconvenience to the customers and malfunction of EMS module. In man-in-the-middle attack [24], an unlicensed intruder intermeddles or eavesdrops the communicating parties to alter the information, thereby, modifying the actual meaning of the message. Such an attacker may reside inside or outside of the μG. Under such condition, EMS may receive erroneous energy prices from utility server (external intruder), weather data from meteorology department (external intruder) and customer preferences (internal intruder). In drive-by attack [25], either external or internal intruder accesses and install a malicious malware in EMS module. Under such situations, intruder controls the EMS to improperly schedule the μG components and reach in-optimal decisions. Under password attacks [26], internal or external intruders decrypt the password to gain access to the EMS to alter its operational behavior to reach in-optimal solution. In SQL injection attack [27], intruder access the database to act as system administrator and may either change or wipeout the entire data. In zero-day exploit [28], cybercriminal scans the weaknesses or vulnerability of the EMS software and develops tools to exploit them.
Among the above-mentioned attacks, DoS and change of password have been the most commonly occurring [29]. Therefore, this paper proposes a cyber security technique to detect and prevent these attacks for secure operation of EMS. Literature shows [18] that internal intrusion proves more threatening compared to external attacks therefore scope of devised technique has been limited to secure EMS from internal intrusions within local area network of the μG. The technique of covering both internal and external intrusion will be devised in future. Rest of this subsection discusses the implementation details of devised technique.
For validation of proposed IDS/IPS scheme, system shown in Fig. 10 is designed in smooth-sec software [14]. Smooth-sec functions in two modes: 1) as sensor representing the cyber security part of EMS module and 2) as console. Energy management system acts as a target of an attacker, whereas, console functions as an antivirus capable of detecting and eliminating the attack. Both sensor and console having different IP addresses reside in two separate computers as shown in Figs.10-12. The computer shown in Fig. 10 with IP address 10.8.20.60 acts as an internal intruder/attacker. Linux based operating system termed as Kali Linux 4.18.10 is installed to generate malware data packets as shown in Fig. 13. The window shown in Fig. 14  The proposed technique has three steps: attack, detection and prevention as shown in Fig. 15. In the first step, an intruder launches an attack at the input ports of EMS module. In second step, the IDS/IPS residing in EMS continuously monitors data parts to differentiate between normal and abnormal packets.  For this purpose, template of data packet is created. This template contains the IP address and decoded version of the information. Differentiation between normal and abnormal data is carried out by: 1. comparing the IP address of the arrived packet with the IP addresses of the authorized persons. These authorized IP addresses reside in the console library. Whenever, IP address does not match with any of the authorized IP addresses, an alarm triggers and prevention system subsequently blocks the attacker's port as shown in Fig. 16.
2. However, if the attacker copies the IP address of authorized persons residing in the console library, through IP spoofing [14] and impersonates to be the privileged individual; the impersonated IP address matches. In such a case, attacker gains access to the EMS of the μG and tries to enter in the control module through a password. In response to this, the smooth-sec installed as sensor in the EMS informs the system administrator that an unauthorized person is trying to enter into the EMS by impersonating as authorized person. Under such situation, the attacker will be blocked by the sensor as shown in Fig. 17.

CONCLUSION
This paper proposes a two cored EMS for large scale IμG. Energy core aims to optimally track total energy cost and emission, whereas security core secures the EMS from an internal intruder having access to the local area network to the μG. A realistic IμG containing ICEs, MTs, FCs, BESS and EV lot was modelled. Electric grid, NG and solar PV are considered as input energy carriers. Building takes part in ancillary service market by selling the SR to the national grid. Results show that presence of onsite DERs, BESS, EV lot and SR reduces the energy cost as well as emission, thereby resulting in bilateral benefits of customer and environment. Moreover, simulations encourage the building owners to invest on DERs and batteries to actively and effectively participate in an energy distribution system. Security of EMS has been extremely vital as invasion of an internal or external intruder negatively affects the optimal performance of the energy management module. In comparison to external intruders, internal ones may be more destructive. Therefore, the second part of this work proposes an IDS/IPS scheme. Proposed security approach is validated in smooth-sec software. Simulations show that DoS and password attacks are successfully detected and prevented. Outcome of this work provides a justification to practically implement a cyber secure to cored EMS for large scale industrial microgrid.

ACKNOWLEDGEMENT
The work has been executed under the worthy guidance of Prof Dr Tahir Nadim Malik and Dr Aamir Raza. Proposed control may be manufactured by utility companies for cyber secured consumption management of large-scale manufacturing facilities.