Digital Twin - Quick Guide
Introduction of Digital Twin
Digital Twin is one of the building blocks of the metaverse concept connected with virtual reality. Digital Twin works in a variety of enterprise applications. It is a virtual model of physical object or process to simulate real-world counterpart.
The following block diagram depicts a very basic model of how a Digital Twin works −
Digital Twins are used in different purposes. Some of the key points are listed below −
- Predict Performance − Digital Twin is used to simulate and predict the performance of physical product.
- Detect Errors − Digital Twin takes real-time data from sensors and monitor operations and detect the errors.
- Decision Making − Digital Twin simulates real situations. It helps organization to take better decisions.
- Machine Learning Algorithms − Digital Twin uses machine learning algorithms and process large quantities of sensor data.
- Remote Monitoring − Digital Twin allows you to control and monitor the dangerous industrial equipment.
- Preventive Maintenance − Digital Twin is used to model on individual equipment or manufacturing process to identify the need for preventive maintenance.
- Interoperability − Digital Twin technology is used in different enterprise applications. Some of the applications are CAD,PLM,ERP etc., Enterprise asset system is used to manage and monitor the integration of digital twins.
Types of Digital Twins
Digital Twins are used in different representations, such as −
- A Product Twin is a digital representation of a product.
- Data Twin is an example of Google Maps link with real-time data.
- A System Twin is a model which can interact between physical and digital processes.
- An Infrastructure Twin is a representation of physical infrastructure like highways, buildings, etc.
History of Digital Twin
During the year 1969, NASA augmented training simulators used to diagnose the problem of damaged spacecraft. It was a Digital Twin that exactly replicated a version which was used for study and simulation purpose by NASA.
Digital Twin - Sample Project
To create digital twins, companies use specific software that allows to run the complex monitoring. Some of the most popular digital twin software include the following −
- Azure Digital Twin
- IBM Digital Twin Exchange
- AWS IoT TwinMaker
In this chapter, we will explain how to create a simple digital twin instance using Azure.
Creating a Digital Twin Instance using Azure
Let us understand how to setup and create an instance in Azure with simple CLI commands.
Prerequisites
You must have an Azure subscription otherwise create a free account.
Setup CLI session
First, we have to login and set CLI context to subscription for this session. Command is defined below,
az login az account set --subscription "<your-Azure-subscription-ID>"
Register Azure Digital Twins Namespace
Use the following command to register Azure Digital Twins namespace.
az provider register --namespace 'Microsoft.DigitalTwins'
Add IoT Extension
Let us upgrade the latest version of IoT services to enable commands to interact with Azure digital twins,
az extension add --upgrade --name azure-iot
After executing this command, we are ready to connect with Azure digital twins. To verify the digital twin commands,
az dt --help
Azure Digital Twins Instance
We need to set the required permissions for using Azure Digital Twins instance. It is defined below −
az dt show --dt-name <Azure-Digital-Twins-instance-name>
That's all. You have now understood how to configure a simple Azure digital twin instance. Similarly, you can download any existing models and give input to this instance in order to develop new models.
Digital Twin - Architecture
Digital Twin Technology supports complex solutions to build and manage R&D. Let us understand the simple architecture. It is depicted below −
Let us understand the levels one by one in brief.
Level 1: IoT Enabled Physical Asset
This is the first level of architecture. IoT enabled physical assets are like sensors, software programs to connect and exchange the data through the Internet.
Level 2: Data Collection
Collecting data is the second level of architecture. Data is collected from different devices like sensors, IoT devices, and old records. This will be helpful for real-world scenarios.
Level 3: Data Synchronization
Synchronizing the data is third level of process. It is a virtual representation of real time entities and process synchronized with specific frequency level.
Level 4: Data Process and Analytics
Processing the data and analyzing it constitutes the fourth level of architecture. Digital Twin performs multiple simulations to identify the process in different circumstances. Virtual models helps to simulate the data behavior and performance.
Level 5: User Interface
A friendly User Interface is last level of the architecture. It is used to interact with the user and collect feedback from real world data as input to digital twins. It is a continuous process.
Digital Twin - CLI
Digital Twins are created based on the model definitions. We have already understood how to configure Azure Digital Twin instance. In this chapter, we will explain how to execute simple client application commands. Let us understand the commands one by one in brief.
Create Command
Use the following Create command is used to create a digital twin −
CreateDigitalTwin dtmi:example:Floor;1 floor0 FloorName string First
After executing the command, you could see the follwing respnse on your console,
CreateDigitalTwin dtmi:example:Floor;1 floor0 FloorName string First Preparing.. Submitting.. Twin 'floor0 created successfully!
Update Command
If you want to update any changes for the digital twin, then use the following command. For example −
UpdateDigitalTwin floor0 add /FloorName string Second
After executing this command, you could see the following response on your console,
twin was updated successfully.
If you want to verify the changes, then run the following command −
GetDigitalTwin floor0
The above command will reflect the updated name on your console.
Twin Graph
We can create relationships between two twins using Twin graph. It is used to represent an entire environment. Lets create one more twin now,
CreateDigitalTwin dtmi:example:Room;1 room0 RoomName string FirstRoom
After executing the command, you could see the following response on your console −
CreateDigitalTwin dtmi:example:Room;1 room0 RoomName string FirstRoom Preparing.. Submitting.. Twin 'room0 created successfully!
Now, we have added one more twin. Let us combine both twin now using the following command −
CreateRelationship floor0 contains room0 relationship0
The above command add a "contains" relationship from floor twin corresponding to room twin.
After executing the command, you could see the following response on your console −
CreateRelationship floor0 contains room0 relationship Submitting.. Relationship relationship0 of type contains created successfully from floor0 to room0
We can verify the relationships with the below command,
GetRelationships floor0
The following block diagram depicts the relationship between the two twins −
Query Command
To list out all the environment questions in twin graph, we can execute the below command,
Query
The above command displays each digital twin with its details. To list out all the digital twins instances use the below command,
Select * from digitaltwins
Clean Up Resources
If you want to clean up resources in digital twins, run the following command −
az group delete --name <'your-resource-group>
Digital Twin - DTDL
Digital Twin technology uses design, engineering, and IoT enabled sensors to collect and process data in ML models. It allows user to create and manage digital twin models.
Digital Twin Definition Language (DTDL)
Microsoft developed the Digital Twin Definition Language (DTDL) to help you create physical assets and systems in a standardized manner. It uses a variant of JSON. It allows you to link with JSON objects.
DTDL Metamodel Classes
Metamodel classes are used to describe the state and behavioral attributes of physical entities. It is a digital template that describes the structure and rules of how elements are associated with physical entity.
Property Metamodel Class
Property class enables you to represent elements that do not change the frequency. Lets understand simple property element for Vehicle.
"@type": "Property", "name": "vehicleNumber", "schema": "string"
Here, @type is used to define the kind of information. name is userdefined name element, schema is data type of the element.
DTDL Telemetry Metamodel Class
Telemetry class enables you to describe the data emitted by physical entity. For example, Vehicle telemetry elements like airLevel,liquidLevel etc.,
"@type": "Telemetry", "name": "airLevel", "schema":"integer"
DTDL Command Metamodel
Command class enables you to describe a function or operation performed by physical entity. Simple command model is defined below,
"@type": "Command",
"name": "reboot",
"request":{
"name":"rebootTime",
"schema": "dateTime"
}
"response":{
"name":"scheduledTime",
"schema": "dateTime"
}
Here, CommandRequest describes the input to a command and CommandResponse describes the output from a command.
DTDL Relationship Metamodel
It is used to describe how physical entities are linked together. Simple Relationship model is defined below,
"@type": "Relationship", "name": "floor", "target": "dtmi:com:example:Floor;1"
DTDL Interface
An interface describes the contents of any digital twin. Interfaces are reusable and schema for components in another interface. Within an interface, complex schemas are defined for reusability across telemetry, properties and commands.
DTDL Array
Array describes a collection of data where each element is defined in the same schema. Also, the schema may be defined as primitive or complex schema. Simple example is defined below,
"@type": "Telemetry",
"name": "fruits",
"schema":{
"@type":"Array",
"elementSchema": "string"
}
A Digital Twin is a virtual representation of physical objects. These virtual models are used to digitally represent performance and design solutions to improve their physical counterparts.