# Building Cyber-Resilient Smart Grids with Digital Twins and Data Spaces
## 2 Digital Twins and Data Spaces
### Data Spaces
FIWARE's suite of data models caters to various sectors, offering specialized solutions tailored to each domain. Pertinently, within the energy domain, we leverage the CIM-compliant data model provided by FIWARE, which we have identified as the most suitable for our case study. The CIM is typically implemented in XML or RDF syntaxes, which are both highly structured file formats. These formats are designed to be comprehensive and extensible, capable of representing the complex relationships and attributes of electrical systems. However, the level of detail and the strict schema adherence required can make CIMs somewhat rigid and cumbersome for rapid integration and real-time data exchange. On the other hand, the NGSI-LD (Next-Generation Service Interface-Linked Data) model is a modern and context-aware API specification for context information management. It builds upon the legacy of NGSI v2 by incorporating linked data, which enables the data to be fully interoperable and machine-understandable. NGSI-LD uses a JSON-LD format, which is inherently more flexible and web-friendly than the XML/RDF formats typically used with the CIM. This flexibility allows NGSI-LD to support more dynamic and real-time applications, making it well-suited to smart applications that require rapid processing and integration of data from various sources. The main differences between CIM and NGSI-LD are reported in Figure 3, and can be summarized as follows:

Figure 2: Framework architecture. * Syntax and Format: CIM's XML/RDF formats are document-centric and can be more verbose, whereas NGSI-LD's JSON-LD format is data-centric, lighter in weight, and more conducive to web transmission. * Flexibility: The CIM is schema-driven and can be less flexible in accommodating changes, whereas NGSI-LD is designed to be more adaptable to the evolving needs of smart applications. * Interoperability: While CIM ensures interoperability within the energy sector, NGSI-LD's use of linked data principles extends interoperability across different domains and applications. * Real-time Processing: NGSI-LD is optimized for real-time context awareness and processing, which is essential for dynamic environments like smart cities, whereas the CIM's traditional use cases involve more static data exchanges. In the context of smart grids, converting CIM-formatted data into NGSI-LD format is a transformative step that aligns the static, heavily modeled data with the dynamic, real-time operational needs of modern energy systems. This conversion facilitates the transition from a traditional grid management approach to a more agile and intelligent smart grid paradigm, where data are not only exchanged but also understood and utilized in a context-aware manner. Orion DT and Data Management. The construction of the digital twin is facilitated through the FIWARE Orion Context Broker, which serves as the central hub for managing real-time contextual information about the infrastructure. Within this framework, entities are meticulously defined by specified data models and are enriched with detailed interrelationships. The Orion Context Broker operates via a RESTful API, allowing for operations to be executed through standard HTTPS methods. Table 1 provides a comprehensive summary of the available operations along with their corresponding expected payloads. \begin{table}
\begin{tabular}{c c c} \hline
**HTTP Method** & **Operation** & **Description** \\ \hline GET & Retrieve Entity & Retrieves the current state of an entity based on its ID. \\ POST & Create Entity & Creates a new entity with the provided attributes and values. \\ PUT & Update Entity & Updates an existing entity with new or modified attributes. \\ PATCH & Partial Update & Partially updates attributes of an existing entity. \\ DELETE & Remove Entity & Deletes an entity from the Context Broker. \\ \hline \end{tabular}
\end{table} 
Table 1: Summary of Orion Context Broker operations. Figure 3: Comparative visualization of CIM (XML/RDF) and NGSI-LD (JSON-LD) syntax structures.