IoT-Based Digital Twin for Energy Cyber-Physical Systems: Design and Implementation

: With the emergence of distributed energy resources (DERs), with their associated communication and control complexities, there is a need for an efficient platform that can digest all the incoming data and ensure the reliable operation of the power system. The digital twin (DT) is a new concept that can unleash tremendous opportunities and can be used at the different control and security levels of power systems. This paper provides a methodology for the modelling of the implementation of energy cyber-physical systems (ECPSs) that can be used for multiple applications. Two DT types are introduced to cover the high-bandwidth and the low-bandwidth applications that need centric oversight decision making. The concept of the digital twin is validated and tested using Amazon Web Services (AWS) as a cloud host that can incorporate physical and data models as well as being able to receive live measurements from the different actual power and control entities. The experimental results demonstrate the feasibility of the real-time implementation of the DT for the ECPS based on internet of things (IoT) and cloud computing technologies. The normalized mean-square error for the low-bandwidth DT case was 3.7%. In the case of a high-bandwidth DT, the proposed method showed superior performance in reconstructing the voltage estimates, with 98.2% accuracy from only the controllers’ states.


Introduction
Future power distribution systems consist of multiple entities that interact with each other in real time.The increased adoption of distributed energy resources (DERs) and active prosumers in the power network will result in more data sharing and processing.A microgrid represents the basic building block of future power systems, where a microgrid's agent/operator should ensure loadgeneration balance in its territory while interacting with other microgrids' agents or the distribution system operator [1].From a holistic perspective, the future active distribution system can be viewed as a network of interconnected microgrids.The emergence of these interconnected microgrids can increase the efficiency of the system and ensure the reliable operation of the power grid during normal and extreme conditions.However, with such interconnected networks, there will be much more complexity, data communication and processing.
To mitigate these kinds of issues and to harness the usage of the insights available from the collected data, Industry 4.0 has emerged as the next industrial revolution, with internet of things (IoT) and cloud computing as cornerstones of its deployment [2].In that domain, many researchers have started to investigate the potential of IoT in different applications.Among these different applications is the energy-cyber-physical system.The deployment of IoT in that domain can be used to converge the current power system into the synergetic cyber-physical system that is the smart grid [3,4].In [5], an IoT high-level framework for the design of information and communication technologies systems for smart microgrids was proposed.The authors described the different applications that can be realized when the power system becomes a part of an IoT framework and the potential information flow associated with different applications.
Turning the current power grid into an IoT technology-dependent one means that a large number of data are harvested from the physical assets' sensors and the cyber assets' controllers.This will greatly affect our current understanding of the energy sector [6][7][8][9][10][11][12].An example of the sensors and data shared in a microgrid can be found in [13], where energy management as a cloud service was explored to provide a control platform for a residential microgrid.With the incoming stream of data and operational real-time requirements as well as the potential cyber-attacks on the communication network, there is a need for a conceptual framework that can monitor, collect, harness and interact with the physical components to ensure their optimal operation.The digital twin (DT) concept arises as a promising solution that can provide such a framework and unleash many opportunities and gains that are associated with the flow of data and real-time interaction.The digital twin concept was first introduced publicly by NASA in 2010 [14].
A digital twin can be defined as a digital replica/model that includes the last information matching a thing.The information provided by a DT can provide numerous optimization possibilities for a cyber-physical system.The DT was successfully applied recently in industry for the manufacturing, power plants, healthcare and automotive sectors [15,16].In addition, several industrial enterprises are devoting efforts to developing digital replications of power grids, such as General Electric (GE, Boston, MA, USA) or Siemens (Munich, Germany) [17,18].
Many studies in the literature have started developing and describing conceptual designs and applications of digital twins.A description of the expected main building blocks for a general cyberphysical system was introduced in [19].In [20], the authors presented a digital twin architecture for the security of an industrial automation system, where they proposed a security-oriented digital twin for the Programable Logic Control (PLC) software update process.In [21], the author provided a cloud-based digital twin for a cyber-physical system with an application to the social internet of vehicles for driving assistance application.
Few researchers have started to deploy and implement the digital twin for power system applications.To date, and to the best of our knowledge, there is not much literature that describes an actual design and implementation of a digital twin in the electric power-grid domain.In [22], the authors provided a general first-steps description of the implementation of a digital twin of a single microgrid.No details or implementation are provided.Therefore, this draft tries to cover this gap by providing a detailed explanation and implementation of a low-cost, open-source-based and close-tomarket proof of concept for a digital-twin framework for power system applications.The proposed framework can be used in many applications of power systems, ranging from the simple monitoring of the system and actual control and interaction with the physical system to attack detection on the communication layer.Therefore, the main contributions of this paper are: 1. Describing a methodology for how digital twins of the different power resources in the power system can be modelled on the cloud.2. Providing an IoT-based digital twin of an interconnected system of microgrids.3. Developing an IoT-based digital twin model of the communication topology that can serve a cluster of microgrids.4. Providing a proof of concept case study where controllers/agents interact with each other and the cloud.
The rest of the paper is organized as follows: Section 2 provides a general description of the proposed architecture, while Section 3 explains the proposed digital twin models.Section 4 describes the cloud utilization, Section 5 provide case studies and Section 6 concludes the research work.

Architecture Description
In modern power systems, the microgrid is a vital infrastructure that enables higher renewables penetration in the deep distribution grid.The microgrid contains different distributed generation resources (DERs), energy storage systems (ESSs) and flexible loading, which transform the distribution grid into a fleet of virtual power plants.At this level of the networked microgrids, a huge number of assets, sensors, meters, actuators and controllers will be connected to the Internet through heterogenous IoT communication networks.Figure 1 shows the proposed cloud-based digital twin architecture, which could be the strategic technology that coordinates, facilitates, aggregates and provides centric oversight guidance for the new distribution system infrastructure.The proposed digital twin is illustrated as a virtual replica for both the physical and cyber layers of the networked microgrids.The physical layer consists of many assets (things) such as DERs, ESSs, fixed loads, flexible loads, DC/DC converters, DC/AC inverters, cables, transmission lines, transformers and circuit breakers.The power electronic converters are considered as the main vital actuators that fully control the distribution grid.It can flexibly route the power flow in the power lines and guarantee proper power sharing among DERs and ESSs inside a microgrid or between the networked microgrids.The interconnected microgrids forms clusters that are connected to the power system point of common coupling (PCC) through an and a step-up transformer.The edge cyber system space contains networked sensors/intelligent electronic devices (IEDs) that communicate with each other through an internet protocol such as transmission control protocol/internet protocol (TCP/IP).The sensors monitor the physical assets by widespread current transformers, voltage transformers, temperature and weather transducers, micro-phasormeasurement units ( ), fault locators and protective relays.In addition, the cyber system makes decisions using the networked controllers as a distributed secondary control system that is responsible for voltage regulation, frequency synchronization, and active and reactive power sharing control.On top of the secondary controllers is the tertiary control system, which is responsible for the energy management, market operations and the major global control/optimization object.The cyber control layer and its communication network take the power system automation control and protection decisions during the normal and abnormal conditions based on the feedback from the networked sensors.With this level of complex transactions among the cyber things and between the physical and cyber things, centric oversight is required to autonomously monitor, operate, analyze and understand the cyber-physical energy system.The virtual space is proposed as a centric oversight layer, which can deal with such complex systems using multiple coordinated cloud services.
The Amazon Web Services (AWS) cloud system is utilized to implement the proposed virtual space.The physical things are monitored by the sensors' measurements and hosted in AWS IoT GreenGrass (GG).Each microgrid's measurements are accommodated in the GG group.The AWS GG can act locally on the data and respond quickly to events and has a low cost, especially for a large number of data points.The AWS GG is proposed here because it helps to preserve privacy and maintains efficient computing inside each microgrid.Regarding the control system in the cyberspace, the controllers' states are hosted as cyber things in the AWS IoT core.The last states of both the cyber and physical things are kept as a shadow on the cloud.
For both the cyber and physical things, a serviceless computing function-which is a low cost, simplified microservice-is used to monitor the data activity and take/activate local actions or launch another computing service/application according to pre-defined logic settings.The IoT shadow states are considered as the shadow twin for the energy cyber-physical system (ECPS).The shadow twin contains the metadata and the last states for the physical and the cyber assets.This shadow can be used for different power system applications, even with intermittent measurement updates.Additionally, the cyber twin state-space model and the physical twin state-space model are used to enhance the digital replica of the ECPS.Multiple services are deployed to manage, filter, analyze and store data for better utilization among the energy system applications and solutions.The proposed digital twins are cooperatively utilized to represent the actual ECPS, which could extend the virtual space capabilities for many different applications in the future.For instance, energy management, security auditing, distributed control guidance, power system state estimation, what-if scenarios, predictive maintenance for energy assets, outage management, wide area fault tolerance and power system restoration are promising applications that could enhance future distribution grid reliability and security.Additionally, the scalability feature of the IoT in the energy systems will provide an incentive for power system designers, operators and researchers to better understand the new distribution grid capabilities.

Digital Twin Formulation
Generally, the DT consists of three main components: the DT shadow, the DT model and the DT updating.The original features and state updates of an asset are collected to form the live digital replica of a physical or a cyber asset.The behavioral characteristics and the dynamical features of a thing are mathematically modelled, and the model is enhanced by the last shadow states.The DT model is updated based on the working states and conditions of a thing.

Digital Twin Shadow
To represent a thing digitally in the virtual space, many immutable and mutable attributes related to different aspects such as features, capabilities, structures, working states and operating conditions can be utilized to describe this thing.In the ECPS, a physical thing or a cyber thing has the metadata ℳ = { , , … ., } that contains a set of immutable properties .The contents of these metadata involve the design characteristics, standard limitations and the recommended rating conditions.For instance, a physical thing of DERs has power ratings, ramping capabilities, thermal withstand characteristics, voltage limitations, manufacturing information, etc.Additionally, a cyber thing as the controller has specific bandwidth, data model structure, processing capabilities, functional blocks, etc.The knowledge of the metadata is vital for DT formulation, as it provides the virtual space with the ability to be aware of a thing's original specifications, which impact the physical thing's lifetime and the cyber thing's security.
On the other hand, the working live states of an asset are updated in the virtual space when a change happens in the real space to provide the DT last update.The information is collected from sensors and controllers to update the physical asset by setting the last reported set of states = { , , … , }, which contains reported states for a thing.Furthermore, the DT holds the required target of the states by recording the desired states in the DT shadow by setting the reported states = { , , … , }.The DT recognizes the reported state compliance with the desired state by calculating the difference between the desired state and the reported state, ∆ = − .

Physical System Digital Twin Model
By combining the last sensory/control updates and the model, the DT can replicate the real system digitally.The model is mathematically formulated to describe the static and dynamic features of the thing, and enhanced by full or partial information from the edge.The DT can simulate the normal and abnormal behaviors of an asset.In addition, the data-driven models leverage data analytics to describe, understand and predict the dynamical activity numerically.Exploiting the historical knowledge data, event logging and their counteractions in the deep-learning technologies can equip the DT model with the capability of recommending corrective actions during a contingency and effectively operating the ECPS during normal healthy operation.
The ECPS is assumed to contain a set of subsystems that are physically interconnected to balance the generation and demand mix and controlled through coordinated multi-agents that are linked using a cyber communication graph to ensure a common goal.The degree of the complexity of the DT model depends on the nature of the application, the possible actions and the physical asset itself.
As an example of a physical ECPS, a networked DC microgrid system DT model is introduced.Mathematically, suppose a number of physical things has a state vector and are monitored by a set of sensors .The state-space representation is proposed to emulate the physical thing's characteristics with the parameter's matrices , , , .The physical twin has an output vector that responds to the effect of an input vector and can be described as The proposed ECSP DT model is divided according to the application nature into two models: a low-bandwidth DT model and high-bandwidth DT model.On one hand, the applications that require the low-bandwidth model are energy management, market operation, situational awareness monitoring and predictive maintenance.These applications are performed periodically every large time span, and they usually depend on long-term historical data to predict long-term future operation strategies and management actions.On the other hand, the high-bandwidth applications are realtime outage management, what-if contingency analysis, secondary control guidance and system restoration.The following subsections present the proposed DT model.

Low-Bandwidth Physical Model
Suppose a distribution grid has interconnected energy units.These energy units can be distributed generation (such as a solar, wind or conventional generator), Energy Storage Systems (ESSs) such as a battery storage system or thermal storage system, fixed loads or flexible loads (such as an electric vehicle parking garage or nanogrids).Figure 2 shows the low-bandwidth physical model of an energy unit [23].Generally, the energy unit can be represented as a generic energy node with an original infeed source from the energy resource as the solar irradiance or the required demand.If the infeed energy is storable with capacity ℋ, the node can represent an ESS or flexible load.If the energy cannot be stored, the node represents a generation or the fixed load and ℋ = 0.In the case of representing the renewable resource as solar or wind and where excessive power is present, the power curtailment can be represented by < 0. In the case of representing the loading, represents the load shedding and > 0. When the generic node has = 0, it represents a generation mode.Additionally, if the generated power = 0, the unit represents the load.If both the generation mode and loading mode exist, the node represents an ESS.The generic mathematical formulation of the energy unit representations is: where and ( ) are the state of charge and the initial state of charge of the energy unit.In addition, and, are the efficiency of the generation and loading operation, and is a variable that represents the flexible load controllability.Table 1 shows possible mathematical formulations for different energy unit types according to Equation (3) and from applying the energy unit constraints.

High-Bandwidth Physical Model
The purpose of the DT is to represent the power system's dynamics and the effect of the networked microgrids on the distribution grid's point of common coupling.The DC microgrid mainly consists of four components: sources, a DC/DC converter, loads and distribution cables.The large-signal dynamical equations that represent the transient response are derived as a linear timeinvariant differential equation.The main focus of this physical model is to represent the transactions among the networked microgrids.Therefore, the intra-microgrid transactions are ignored here, as they are already covered in the low-bandwidth model.Each microgrid contains several interconnected sources and loads that can be characterized by a Thevenin equivalent circuit.Thus, the individual microgrid is modelled by a controllable voltage source and its passive components of resistance, inductance and capacitance, which are denoted as , and , respectively.Commonly, the networked microgrid dynamics of the microgrids can be described by: where is the microgrid converter average inductor current and * is the reference voltage at the microgrid.The microgrid is considered as two-way power flow; accordingly, is the current transmitted from/to microgrid to/from distribution grid node .
Figure 3 illustrates a networked DC microgrid that is under study.The grid contains two clusters of microgrids: the first cluster has five microgrids, and the second one has three microgrids.Usually, the practical DC power system is connected to the major grid via a point of common coupling (PCC).The equivalent model of each microgrid's equivalent voltage sources is shown in the bottom of Figure 3, which identifies the primary control system of the DC/DC converter.Since the control objective of the secondary controllers in the cyberspace is power sharing, the voltage and the current references are formulated in the model to make the power sharing factor the reference of the controlled microgrid output.
In order to represent the power-sharing of the primary control system in the physical twin, the equivalent microgrid reference voltage can be expressed as: where * and , are the reference voltage and maximum power of the microgrid converter, is the constant control gain and * is the sharing factors that are commanded by the secondary controllers to the primary controllers.Therefore, Equation (4) can be rewritten as:

Equivalent
The distribution grid interconnection can be represented as: where is the voltage of the grid connection node, and is the bus admittance matrix of the grid topology.

Cyber System Digital Twin Model
The cyber control edge contains the secondary distributed controllers at each power node and the tertiary controller at the PCC.As shown in Figure 4, the cyber control edge includes a number of distributed controllers with control states that are shared through a communication cyber graph to reach an agreement with a steady-state control law , , which is obtained from the tertiary controller at the PCC with the state.Thus, the tertiary control objective is to satisfy , = * .The control objective state can be the bus voltage , .= * and the power sharing factor , = * , where = , ⁄ , and = , ⁄ and , , , are the maximum power sharing capabilities at the PCC and controllers.The cyber system can also be represented similarly to the physical system by the state-space equations as follows: where , , and are the cyber system model parameters and and are the cyber twin input and output vectors.
The PCC control agent is considered to be the main leader of the microgrid clusters' leaders.The graph can be described by the triplet ( , , ), where is the communication graph edges, where ⊆ × , is the graph vertices and ∈ ℝ (∑ )×( ∑) is an adjacency matrix, which is a weighted matrix of the links.If an agent can send/receive information to an agent , then the pair ( , ) ∈ and the connection can be weighted by a factor according to the following: Each cluster leader is connected to a number of followers' controllers.Typically, the distributed secondary control system is performed by the consensus protocol.The dynamics of the consensus protocol can be formulated as a graph that has In-neighbors degrees, which can be denoted as = { }.The consensus protocol can be formulated in terms of state-space representation in terms of the Laplacian matrix , where = − , and the distributed consensus can be characterized as: = −( + ).+ where is the node that has an accessible path to an agent , = { } represents the pinning matrix and is the leader connection weighting factor.Cluster#m Followers 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 0

Digital Twin Model Hybridization
The digital twin model is proposed to be a multi-purpose function.It can be used by many applications.According to the required solution, the DT model is defined by the sampling time, the known inputs and the desired outputs.The previous ECPS physical and cyber twins can be hybridized to replicate the cyber-physical system's behavior as follows: where is the hybrid twin model output.Using the hybrid twin models, the unknown states and the forecasted behavior can be predicted based on the present shadow states.The digital twin implementation in the cloud virtual space and its data transactions are clarified in the next sections.

ECPS Things-To-Cloud Service Transactions
To implement the digital twin, the model's degree of complexity should be carefully considered to avoid adding extra complexity to the system.The proposed digital twin uses the state-space representation of the ECSP by aggregating the individual microgrid resources into a single equivalent model.That will reduce the communication and the computational burden without reducing the benefits of the potential applications and solutions.As shown in Figure 5, the IoT GG makes decisions locally within the microgrid, but it will be kept aware of the global centric objective with regular overthe-air programming (OTA) updates of its settings.
The ECSP is represented in the cloud by the sensor measurements from the physical assets and the control states from the cyber assets .Figure 5 depicts the AWS cloud hosting the energy IoT, computing services and their transactions.Suppose the distribution grid has microgrid ( ) clusters, each cluster has microgrids and the has assets.Each asset is connected to the microgrid main bus by an interlinking power electronics converter , and each is linked to the distribution grid by an interlinking converter .On one hand, the microgrid physical assets can be classified into four main types, the distributed generator (DG), ESS, fixed load (LD) and flexible loads (FLD).An asset is monitored by a current transformer C.T and voltage transformer V.T, which are used to calculate various physical power system states using .The asset physical state is represented by a set of calculated parameters = { , , , } that are the active power, reactive power, power frequency and voltage, respectively.
On the other hand, the cyberspace is a set of distributed controllers, which are communicating with each other to cooperatively satisfy a control objective .The control objective can be active/reactive power sharing, voltage regulation and/or frequency synchronization.This is cooperatively performed by the interlinking converters' secondary distributed controllers .The ICCs are connected via cyber communication links, and the control states interpret the cyberspace transactions alongside the interactions with the physical assets.The AWS GG is used to extend the cloud system functionality to the IoT devices ( , ) to perform the data gathering and analysis and act locally on the cyber edge.The IoT GG channels are proposed to perform higherspeed calculations locally to be able to act quickly in the case of a critical power system status.The data transaction between the sensors, controllers' edge and cloud is implemented based on the message queuing telemetry transport (MQTT) protocol.To preserve privacy and reduce the complexity and computational burden, the data pipelines service is used to filter and prepare the data for the cloud computing services.The IoT core along with the lambda serviceless functions is implemented to easily and securely interact with various cloud computing applications.
Besides the DT functions, different services on the cloud are proposed to build different applications.For instance, the AWS SageMaker is used to build, train and test the deep-learning models that are launched on the edge cyberspace.Data filtering, routing and management services are implemented to prepare the data for each application according to the requirements.AWS SageMaker is also used to build applications for the centric guidance to the distributed controllers; what-if contingency scenarios for outage management provide security auditing based on the anomaly detection functionality.In addition, IoT data analytics and data storage are used to implement offline applications for power system planning and physical assets' predictive maintenance.The cyber things can be used to coordinate between different applications.
Figure 6 illustrates the cyber/physical thing registration process on the IoT core on the AWS cloud.The IoT Software Development Kit (SDK) is launched on the physical or the cyber asset.The asset registry contains the asset policy, which is used to authorize the device to perform the IoT connectivity.Each asset has the required certificates and keys that are required to initiate the message transactions.The communication is implemented by the asset gateway using MQTT WebSocket or hypertext transfer protocol secure (HTTPs) protocols, and it should be authorized by the IoT core to verify the thing's identity.Then, the gateway sends the message to the rule engine, which is responsible for assessing the incoming messages published into the IoT core.That determines the action of structured query language (SQL) filtering or rerouting the data to different cloud services based on pre-defined settings.The vital process of the DT is the update process for the device shadow.The shadow state of an asset is a JavaScript object notation (JSON) file that is used to store/retrieve the last state of a thing.The shadow can be accessed regardless of whether the thing is connected to the Internet or not.It contains the shadow desired and reported states, immutable metadata, updated version, transaction token and timestamp.
The Lambda serviceless function automatically executes a predefined logic function when required without provisioning.The messages are used later for different cloud computing solutions and end-user/operator applications.The IoT application programming interface is used to interact with the data different applications.

Digital Twin Implementation and Results
The ECPS DT is demonstrated by implementing the physical and the cyber layers of the networked microgrids (MG) using interconnected embedded computers as a multi-agent platform.Figure 7 shows eight microgrids' agents and a single PCC agent that are executed on nine Raspberry Pis™ and communicate using Wi-Fi.The Data Distribution Service (DDS) communication middleware is used to launch the data sharing among the distributed controllers/sensors as a cyber layer.The DDS uses the publication/subscription mechanism without a message broker for the data sharing, which guarantees high-speed connectivity among the networked microgrids, and communication configuration is performed in extensible markup language (XML) files for each agent.The Python programming language is used beside the AWS cloud system.The ECPS-to-AWS communication is performed via the Message Queuing Telemetry Transport (MQTT) protocol, and the data are initially hosted on the AWS IoT core [16].
Figure 8 shows the distributed consensus control algorithm that is implemented on each control agent in the cyber system and its interaction with the DT on the AWS cloud.Firstly, the agent is initialized with the adjacency weighting factors.Then, DDS communication is used to listen to the agent's neighbor and continuously check for an event that requires a consensus on new sharing power.
After the agent neighbor's data are accepted, the local control objective is updated based on the consensus rule that is discussed in Figure 4 to agree on the leader steady state.Finally, the pre-event and post-event states are reported by using the MQTT update function on the AWS cloud.Moreover, the desired state or DT-based guides are submitted to the edge via the MQTT get function.These signals can be configured according to the applicable nature of the DT.
Figure 9 shows the implemented DT on the cloud system.Practically, the AWS SageMaker is used to perform the required computations and DT functions.This service can hold parallel instances of computation by utilizing the IoT core shadow data or the data stored in the database.The parallel instances can be implemented and scaled according to the required application.The state-space modelling of the physical and cyber twin model is implemented and imported as functions to implement the low and high-bandwidth physical DT alongside the cyber DT models on the AWS SageMaker.These models acquire the up-to-date shadow from the AWS IoT core service to update their estimations and configuration every certain time.
To reduce the communication bandwidth and minimize the computational burden, the AWS Lambda function is used to trigger the application by continuously monitoring the detected event.
Using the models previously discussed in (3), ( 7)-( 8) and ( 12)-( 15), the digital replica of the energy cyber physical system is constructed to be utilized by different applications.Both the reported sensor measurements (voltages and injected power ) and the reported post-event cyber states ( , ) are ported to the online Digital Twin models.According to the applicable nature, the desired commanding and decisions can be submitted back to the edge to achieve the requirements.
In the same way, after the application decisions are made, the desired commands are set back to the desired shadow state on the IoT core.The controller on the edge gets the desired states as centric oversight guidelines, which are used to guarantee the global system operation objectives.Thus, the DT creates digital parallel environments for the safe application of the control command on the twin before giving the edge controllers the final guides.3), ( 12)-( 15) ,

ECPS high-bandwidth
Twin Model Eq.( 7)-( 8), ( 12 The first case study is implemented using the low-bandwidth model.Two clusters of microgrids are implemented on MATLAB/SIMULINK as a detailed physical model, and the CPS data are sent to the AWS cloud IoT core in terms of shadow states.The system contains a collection of diesel generators (conventional generators), PV-wind mixtures (renewable generators), ESSs and loads (fixed and flexible).On the other hand, the AWS has the state-space representation as shown in Table 1 to construct the physical twin and the system in ( 12)- (15) to represent the cyber model.The model uses the loading profile and the forecasted renewable power to estimate the dispatching of the resources.
Figure 10 shows matching between the DT model and the physical states.The low-bandwidth model has a 15 min time slot for the AWS shadow update rate.Figure 10a depicts a close relationship between the digital twin estimated states and the physical states of first cluster states, which are the aggregated demand, conventional generation, renewable generation, aggregated ESS charge/discharge power and state of charge.The second cluster, which is shown in Figure 10b, presents the ability of the DT to mimic the physical response.The high-bandwidth twin model is evaluated as shown in Figures 11 and 12.
In the second case study, the secondary distributed control system controls the microgrids' interlinking converters to share the power among the microgrids to support the voltage at the PCC.The implemented control agents on the embedded computers send their information (sharing factors) to the AWS cloud.The implemented DT in AWS SageMaker uses the sharing factor shadows to estimate the voltage at each bus in the interconnected microgrids.The figures show that the DT can replicate the actual system.A comparison is made between the cyber states and the AWS shadow updates, which is updated every 5 s. Figure 11 illustrates the power sharing factor consensus under two consecutive changes (0.5 and 0.85 per unit in the reference at the PCC.The delay between the cyber edge states (black) and the shadow updates (red dots) is due to the Wi-Fi communications.The provisioned shadow states are used to drive the high-bandwidth model to mimic the physical voltage measurements at each bus, which show a very close response as illustrated in Figure 12.

Conclusions
This paper provides a methodology for the design of digital twin models for the power system components and the communication topology.The power system sources, as well as clusters of interconnected microgrids that represent the main building blocks of future power systems, were modelled.The implementation of the models on the Amazon Web Service and their interactions with the physical components were demonstrated.The results showed the ability of the proposed models to be a live digital replica of future power systems.The authors are currently developing a combination of deep learning and the DT to implement a wide-area situational awareness system by considering the stability, reliability and resiliency of the globally interconnected power system.The proposed DT aims to guarantee to mimic the dynamics and events in real time.Although the DT's purpose is not the accuracy of reconstructing states, both the low-bandwidth DT and the highbandwidth DT were able to accurately replicate the cyber-physical system's live states, as shown by the average error not exceeding 4% and the maximum error being 9.2%.

XML
Extensible Markup Language

Figure 1 .
Figure 1.The architecture of the proposed energy cyber-physical system (ECPS) digital twin.

Figure 2 .
Figure 2. Low-bandwidth physical model of the digital twin (DT).

Figure 3 .
Figure 3. Networked microgrid equivalent circuit for physical twin model.

Figure 4 .
Figure 4.An example of a cyber edge space model.

Figure 5 .
Figure 5. Data transactions between ECPS and cloud services.

Figure 6 .
Figure 6.Physical/cyber thing registration on the IoT core.

Figure 10 .
Figure 10.A comparison between the low-bandwidth physical DT model and the physical measurements: (a) MG cluster 1; (b) MG cluster 2.

Figure 11 .
Figure 11.A comparison between the cyber states and the shadow states on the AWS.

Figure 12 .
Figure 12.A comparison between the high-bandwidth cyber DT model and the cyber states.

Table 1 .
Energy unit mathematical formulation.
Distributed controller algorithm on the edge interaction with the DT on the AWS cloud.
PublishConsensus on the leader state , =