A Framework for an Indoor Safety Management System Based on Digital Twin

With the development of the next generation of information technology, an increasing amount of attention is being paid to smart residential spaces, including smart cities, smart buildings, and smart homes. Building indoor safety intelligence is an important research topic. However, current indoor safety management methods cannot comprehensively analyse safety data, owing to a poor combination of safety management and building information. Additionally, the judgement of danger depends significantly on the experience of the safety management staff. In this study, digital twins (DTs) are introduced to building indoor safety management. A framework for an indoor safety management system based on DT is proposed which exploits the Internet of Things (IoT), building information modelling (BIM), the Internet, and support vector machines (SVMs) to improve the level of intelligence for building indoor safety management. A DT model (DTM) is developed using BIM integrated with operation information collected by IoT sensors. The trained SVM model is used to automatically obtain the types and levels of danger by processing the data in the DTM. The Internet is a medium for interactions between people and systems. A building in the bobsleigh and sled stadium for the Beijing Winter Olympics is considered as an example; the proposed system realises the functions of the scene display of the operation status, danger warning and positioning, danger classification and level assessment, and danger handling suggestions.


Introduction
With the rapid digital revolution in the 21st century, an increasing amount of information technology has been applied to human residential space to improve its comfort, energy saving, and safety. The concepts of smart cities [1], smart buildings [2], and smart homes [3] are being increasingly researched. These studies are mainly focused on environmental, energy, and safety issues [4][5][6][7]. Safety is an important research direction for realising smart living spaces with real-time monitoring, real-time interaction, and automation [6]. To achieve these functions, many studies have been performed on the use of the Internet of Things (IoT), the Internet, and machine learning in safety management [2,8,9]. However, at present, safety systems are independent and cannot realise integrated information analysis or the automatic auxiliary processing of danger. Additionally, the overall connection between the safety system and the building information is poor. Furthermore, the safety management staff cannot quickly formulate a targeted treatment strategy in the case of danger, because they cannot quickly and

Artificial Intelligence of Things (AIoT)
With the development of information technology, IoT technologies are playing increasingly important roles in various industries [19]. IoT technologies, including sensors, robots, network facilities, and intelligent devices, are innovated and developed to satisfy the needs of various industries [20]. There have been many such innovations with regard to safety in the construction operation stage. In [21], indoor positioning technology was combined with BIM, and an environment-aware beacon deployment algorithm based on positioning and BIM information was designed to improve the indoor positioning accuracy and reduce the work required to deploy sensor networks, which improves the robustness of sensor networks in buildings in emergencies. In [22], BIM was combined with wireless sensor networks to integrate personal positioning information, Bluetooth-based evacuation/rescue route optimisation information, and mobile navigation equipment information, yielding an intelligent, two-way fire disaster-prevention system framework. Additionally, the mining of large amounts of data collected by the IoT using artificial intelligence (AI) to integrate AI and the IoT for obtaining the Artificial Intelligence of Things (AIoT), which enhances the intelligence level of the residential space, is an important research topic. In [8], an SVM was used to mine data for realising the automatic and rapid judgement of the indoor danger level on the basis of the collection of indoor environmental information by the IoT. In [23], an intelligent disaster-prevention hard hat was developed according to the concept of the AIoT to improve the safety of personnel in high-risk rescue sites and home environments. In [24], machine learning algorithms were used to automatically classify the indoor environment based on the indoor environment data collected by the Internet of Things.

Dynamic BIM
BIM technology has been widely used in building design, construction, and operation management. It can not only provide an intuitive 3D visual model of buildings but also realise the information storage and management of the entire lifecycle of buildings. BIM is widely used in the design and construction stage of the construction industry. Therefore, buildings are completed with the formation of BIM models. These models can be directly applied to solve the problems in the operation stage. It is no longer necessary to build a new database or 3D model for the operation stage [25]. Therefore, BIM is ideal for scene-based building safety management. In general, BIM can provide an information hub for building safety management, but it is a static hub which cannot realise the real-time automatic updating of building safety management information. For realising the real-time updating of information, the combination of BIM and the IoT is a feasible solution. Studies have increasingly combined the two to solve problems in the architecture, engineering, and construction (AEC) industry [26]. For example, in [27,28], a dynamic 3D visualisation method was presented for dealing with fire danger by combining an indoor positioning system with BIM, which improved the emergency-handling capacity of buildings. In [29], a visual and persuasive energy-saving system was constructed by combining the IoT with BIM to improve the comfort degree of the indoor space and the energy-saving performance. In [30], the construction level of prefabricated components was improved by combining long-range radio (LoRa) technology with a cloud-based BIM model. In [31], machine-learning algorithms were used to comprehensively analyse the data from BIM and the data collected by the IoT for monitoring and predicting the operating status of construction equipment; this method realised the early warning of equipment operation faults and proposed equipment replacement and maintenance schemes predictably.

DTs
The concept of DTs was first used by National Aeronautics and Space Administration (NASA) and the United States Air Force (USAF) to predict the residual life and health maintenance of spacecraft [32]. The use of DTs introduces a new approach for synchronising the real physical world with the virtual digital world. The development of emerging information technology allows DTs to be applied in various industries, including aviation [33], energy [34], mining [35], shipping [36], and transportation [37]. To promote the application of DTs in related fields, according to the 3D model of DTs proposed by Professor Grieves a five-dimensional model of DT was proposed. Ten major potential application fields for the model were discussed. Besides this, construction and safety were also considered as potential application areas for digital twins [38]. As a technique for realising a cyber-physical system [38,39], the DT method integrates multiple new information technologies such as the Internet, the IoT, artificial intelligence, and digital modelling to achieve interaction between the real physical world and the virtual digital world, which helps systems in various industries to achieve high-level intelligence and automation [40]. In [41], the applications of BIM were reviewed to pave the way for construction DT, and the areas for future research in the AEC industry were elaborated. At present, Sensors 2020, 20, 5771 4 of 20 digital twins have been applied in the field of smart cities [42], building construction, maintenance, and strengthening operations [43,44]. Furthermore, there have been studies using the combination of the BIM model and the IoT to construct a digital twin model of the building [17,18].

Research Gaps and Novelty
Although there are many information-technology applications in the field of indoor safety [45], few studies have been performed on the application of DT technology in the field of indoor safety. Moreover, because of the independence of the safety systems in the building, it is impossible to conduct a comprehensive automatic analysis of various dangers. Additionally, the geolocation of the danger remains at the level of text or two-dimensional drawings, because the safety system cannot be combined with the 3D layout of the building; thus, the building environment in which the danger is located cannot be directly displayed. To solve these problems, in the present study BIM, the IoT, and the Internet were used to build a DT model for indoor safety. The model was employed to conduct meaningful investigations as follows: (1) According to the indoor safety data collected by the IoT, the comprehensive data management of different types of dangers was realised. (2) The feasibility of automatic danger classification and level evaluation using SVM was proven. (3) According to the comprehensive data analysis of safety, this study proposes a method for automatically generating danger-handling suggestions to guide safety management staff in dealing with indoor dangers. (4) The 3D scene management of indoor safety is realised to help the safety managers quickly understand the indoor layout around the location with danger. This innovative method, which integrates technologies such as the IoT, the Internet, machine learning, and BIM, improves the management level of indoor safety and is of great significance for future research.

Concept of ISMS Integrating with DT Model
To solve the aforementioned problems, the concept of indoor safety management based on DTs is proposed. Here, the exchange of data-including building layout information, indoor environment information, indoor personnel information, and building operation information-between physical buildings and virtual buildings through perception and simulation is realised.This information characterises the safety situation of real physical buildings synchronously in the virtual digital world. In the virtual digital world, algorithms are used to analyse and process data for realising functions such as the visual data management of physical buildings, visualised building danger alarm and positioning, danger classification and level assessment, and danger response suggestions, which help safety management staff deal with danger in real physical buildings. In this concept, the improvement of the real-world safety situation is realised with the help of the DTM in the virtual digital world. The concept is illustrated in Figure 1.

Methodology and System Framework
According to the proposed concept, a systematic framework for the development of an ISMS based on the DT method is proposed, as shown in Figure 2. In this framework, the BIM model is developed by engineers during the construction process. The operation information of the building is collected by the IoT, and the sensors in the IoT are included in the BIM model. The light-weighted BIM model is carried on the webpage so that the 3D visualisation of the building model and sensor model is realised on the webpage. Additionally, the operating data of the building collected by the sensor are transmitted to the webpage to realise data visualisation. Then, data-processing methods such as machine learning are used to analyse the data on the webpage. Finally, visual safety status monitoring, danger alarm and positioning, danger classification and level assessment, and danger response suggestions are realised on the web platform to assist the safety management staff in taking danger-handling measures. The safety management staff access the network using computers, smartphones, tablets, and other

Methodology and System Framework
According to the proposed concept, a systematic framework for the development of an ISMS based on the DT method is proposed, as shown in Figure 2. In this framework, the BIM model is developed by engineers during the construction process. The operation information of the building is collected by the IoT, and the sensors in the IoT are included in the BIM model. The light-weighted BIM model is carried on the webpage so that the 3D visualisation of the building model and sensor model is realised on the webpage. Additionally, the operating data of the building collected by the sensor are transmitted to the webpage to realise data visualisation. Then, data-processing methods such as machine learning are used to analyse the data on the webpage. Finally, visual safety status monitoring, danger alarm and positioning, danger classification and level assessment, and danger response suggestions are realised on the web platform to assist the safety management staff in taking danger-handling measures. The safety management staff access the network using computers, smartphones, tablets, and other devices to obtain information and decision-making suggestions, which are helpful for dealing with dangerous events in the real world.

Information Needed to Characterise DTM
In the management system framework, a DTM corresponding to a real physical building must be built in the virtual digital world through modelling by engineers, the IoT, Internet, etc. In order to achieve the scene monitoring of the safety status and danger positioning with the scene, the 3D geometric information of buildings must be depicted. The information on the building materials, material manufacturers, and other aspects does not need to be depicted. Additionally, the DTM must contain information generated during building operation, including the indoor temperature, oxygen concentration, carbon-monoxide concentration, smoke concentration, opening and closing statuses of doors and windows, number of indoor personnel, and time.

Processing of BIM Model
To realise the flexible access of the system using different terminals, including personal computers, tablets, and smartphones, a B/S structure was used for the proposed system. The BIM

Information Needed to Characterise DTM
In the management system framework, a DTM corresponding to a real physical building must be built in the virtual digital world through modelling by engineers, the IoT, Internet, etc. In order to achieve the scene monitoring of the safety status and danger positioning with the scene, the 3D geometric information of buildings must be depicted. The information on the building materials, material manufacturers, and other aspects does not need to be depicted. Additionally, the DTM must contain information generated during building operation, including the indoor temperature, oxygen concentration, carbon-monoxide concentration, smoke concentration, opening and closing statuses of doors and windows, number of indoor personnel, and time.

Processing of BIM Model
To realise the flexible access of the system using different terminals, including personal computers, tablets, and smartphones, a B/S structure was used for the proposed system. The BIM model must be uploaded so that users can access it on the webpage via the Internet and browse the indoor layouts of buildings. The BIM model of a building contains many types of professional information, such as geometric information, structural information, equipment information, and material information. The objective of this study was to use a BIM model for building layout information. It does not need structural, electrical, or other such information; therefore, this information was excluded, and only the building geometric information was retained in the BIM model. Additionally, the model was exported into an IFC file. Then, the file was read in a JavaScript environment to realise a light-weighted BIM model for improving the loading and running speeds of the BIM model on the webpage. The lightweight BIM model was loaded on the webpage through WebGL technology, which realised the 3D visualisation of the building layout and provided a 3D scene for the safety monitoring and danger positioning. The 3D visual effect of the building layout on the webpage is shown in Figure 3.

Construction of IoT Structure
For the collection of operating data, this paper proposes an IoT system which comprises a perception layer, a transport layer, a service layer, and an application layer, as shown in Figure 4. This study uses Low-Power Wide-Area Network (LPWAN) to build an IoT system. LPWAN is a form of IoT with a lower power consumption and wider transmission range than the traditional IoT. In this study, LoRa technology was used in the LPWAN, which is essentially a spread spectrum modulation technology. Spread spectrum modulation technology has been widely used in the military and aviation fields, and LoRa technology is a low-cost wireless communication solution for manufacturing and other civil fields. In China, LoRa works in the 470/510-MHz ISM bands and can achieve long-distance coverage, with bit rates ranging from 0. 37

Construction of IoT Structure
For the collection of operating data, this paper proposes an IoT system which comprises a perception layer, a transport layer, a service layer, and an application layer, as shown in Figure 4. This study uses Low-Power Wide-Area Network (LPWAN) to build an IoT system. LPWAN is a form of IoT with a lower power consumption and wider transmission range than the traditional IoT. In this study, LoRa technology was used in the LPWAN, which is essentially a spread spectrum modulation technology. Spread spectrum modulation technology has been widely used in the military and aviation fields, and LoRa technology is a low-cost wireless communication solution for manufacturing and other civil fields. In China, LoRa works in the 470/510-MHz ISM bands and can achieve long-distance coverage, with bit rates ranging from 0.37 to 46.9 kbps [30].
The perception layer includes sensors that are used to measure the operating conditions. The network layer is constructed using LoRa wireless communication technology in an LPWAN, which is used for data transmission. The service layer uses Structured Query Language (SQL) to build a database on the web and uses an SVM algorithm for data analysis and processing to realise safety status monitoring and danger alarms, danger categorisation and classification, and other functions, as well as assisting in the intelligent management of safety. With the help of these functions, the safety management staff can take action to handle danger; thus, the intelligent management of indoor safety in the application layer is realised. of IoT with a lower power consumption and wider transmission range than the traditional IoT. In this study, LoRa technology was used in the LPWAN, which is essentially a spread spectrum modulation technology. Spread spectrum modulation technology has been widely used in the military and aviation fields, and LoRa technology is a low-cost wireless communication solution for manufacturing and other civil fields. In China, LoRa works in the 470/510-MHz ISM bands and can achieve long-distance coverage, with bit rates ranging from 0.37 to 46.9 kbps [30].  The perception layer includes sensors that are used to measure the operating conditions. The network layer is constructed using LoRa wireless communication technology in an LPWAN, which is used for data transmission. The service layer uses Structured Query Language (SQL) to build a database on the web and uses an SVM algorithm for data analysis and processing to realise safety status monitoring and danger alarms, danger categorisation and classification, and other functions, as well as assisting in the intelligent management of safety. With the help of these functions, the safety management staff can take action to handle danger; thus, the intelligent management of indoor safety in the application layer is realised.
For the perception layer, indoor environment information acquisition terminals based on the LoRa transmission protocol were developed. The terminal consists of various sensor modules, a LoRa module, a microcontroller unit control module, and a power module. Its structure is shown in Figure 5. According to the needs of indoor information collection, five types of sensing terminals were developed for sensing the oxygen concentration, carbon-monoxide concentration, smoke concentration, temperature, and opening and closing statuses of doors and windows. The sensor terminals can realise the real-time measurement of the indoor operating information of the building and wirelessly transmit this information to the LoRa gateway. The sensor parameters selected in this study are presented in Table 1. The terminal that senses the opening and closing of the doors and windows employs changes in potential. The structure of the sensing terminal is shown in Figure 5. Some of the developed sensor terminals are shown in Figure 6. In addition to using and developing LoRa-based sensing terminals, the perception layer employs cameras to obtain indoor images, along with image-recognition technology to automatically determine the number of people in the images, as shown in Figure 7. Additionally, to realise the visualisation and information storage of the corresponding position of the sensor terminal in the BIM model, family library models of different sensor terminals were established to realise terminal visualisation in the BIM model. For the perception layer, indoor environment information acquisition terminals based on the LoRa transmission protocol were developed. The terminal consists of various sensor modules, a LoRa module, a microcontroller unit control module, and a power module. Its structure is shown in Figure  5. According to the needs of indoor information collection, five types of sensing terminals were developed for sensing the oxygen concentration, carbon-monoxide concentration, smoke concentration, temperature, and opening and closing statuses of doors and windows. The sensor terminals can realise the real-time measurement of the indoor operating information of the building and wirelessly transmit this information to the LoRa gateway. The sensor parameters selected in this study are presented in Table 1. The terminal that senses the opening and closing of the doors and windows employs changes in potential. The structure of the sensing terminal is shown in Figure 5. Some of the developed sensor terminals are shown in Figure 6. In addition to using and developing LoRa-based sensing terminals, the perception layer employs cameras to obtain indoor images, along with image-recognition technology to automatically determine the number of people in the images, as shown in Figure 7. Additionally, to realise the visualisation and information storage of the corresponding position of the sensor terminal in the BIM model, family library models of different sensor terminals were established to realise terminal visualisation in the BIM model.    as shown in Figure 7. Additionally, to realise the visualisation and information storage of the corresponding position of the sensor terminal in the BIM model, family library models of different sensor terminals were established to realise terminal visualisation in the BIM model.     as shown in Figure 7. Additionally, to realise the visualisation and information storage of the corresponding position of the sensor terminal in the BIM model, family library models of different sensor terminals were established to realise terminal visualisation in the BIM model.     (2) Transport layer.
A wireless transmission network based on LoRa technology was constructed. The LoRa wireless network had a star network structure. LoRa technology has the advantage of a high capacity, allowing it to realise the connection of a large number of data-collection terminals with the LoRa gateway. The sensing terminal transmits the indoor safety information obtained by the built-in sensor to the LoRa gateway through the LoRa module. The LoRa gateway then uploads the information to the cloud server through the 4G network, and the local server accesses the cloud server through the Internet to obtain the indoor safety information. A schematic of the network deployment based on LoRa technology is shown in Figure 8. (2) Transport layer. A wireless transmission network based on LoRa technology was constructed. The LoRa wireless network had a star network structure. LoRa technology has the advantage of a high capacity, allowing it to realise the connection of a large number of data-collection terminals with the LoRa gateway. The sensing terminal transmits the indoor safety information obtained by the built-in sensor to the LoRa gateway through the LoRa module. The LoRa gateway then uploads the information to the cloud server through the 4G network, and the local server accesses the cloud server through the Internet to obtain the indoor safety information. A schematic of the network deployment based on LoRa technology is shown in Figure 8.  (3) Application layer. The application layer mainly includes the following functional modules: (1) safety status monitoring with a scene, (2) danger classification and level assessment, (3) danger alarm and positioning with a scene, and (4) danger handling suggestions. Each module is described below.
(1) Safety status monitoring with a scene. This module uploads the data collected by the sensing terminal to the webpage and associates it with the sensor. The model is associated with the camera, whereby the actual situation at the corresponding position in the building can be viewed. The perspective of the camera is fixed, while the layout of the building can be viewed from different directions through the roaming function of the BIM model on the web. When the safety management staff view different rooms from a 3D (3) Application layer. The application layer mainly includes the following functional modules: (1) safety status monitoring with a scene, (2) danger classification and level assessment, (3) danger alarm and positioning with a scene, and (4) danger handling suggestions. Each module is described below.
(1) Safety status monitoring with a scene. This module uploads the data collected by the sensing terminal to the webpage and associates it with the sensor. The model is associated with the camera, whereby the actual situation at the corresponding position in the building can be viewed. The perspective of the camera is fixed, while the layout of the building can be viewed from different directions through the roaming function of the BIM model on the web. When the safety management staff view different rooms from a 3D perspective, the rooms can be monitored by the cameras installed inside. Thus, virtual reality, a fixed perspective, and a mobile perspective are combined in a complementary manner. Additionally, when the model is associated with the sensing terminals, not only can the position of the terminals be observed, but also the collected data can be viewed. The data can be updated with the information collected by the sensing terminal to monitor the environmental data of the building. The interface rendering is shown in Figure 9. (3) Application layer. The application layer mainly includes the following functional modules: (1) safety status monitoring with a scene, (2) danger classification and level assessment, (3) danger alarm and positioning with a scene, and (4) danger handling suggestions. Each module is described below.
(1) Safety status monitoring with a scene. This module uploads the data collected by the sensing terminal to the webpage and associates it with the sensor. The model is associated with the camera, whereby the actual situation at the corresponding position in the building can be viewed. The perspective of the camera is fixed, while the layout of the building can be viewed from different directions through the roaming function of the BIM model on the web. When the safety management staff view different rooms from a 3D perspective, the rooms can be monitored by the cameras installed inside. Thus, virtual reality, a fixed perspective, and a mobile perspective are combined in a complementary manner. Additionally, when the model is associated with the sensing terminals, not only can the position of the terminals be observed, but also the collected data can be viewed. The data can be updated with the information collected by the sensing terminal to monitor the environmental data of the building. The interface rendering is shown in Figure 9. (2) Danger classification and level assessment. (2) Danger classification and level assessment. At present, the evaluation of the level and types of dangers mainly depends on the evaluation of safety management staff; thus, it is highly dependent on people and inefficient. This paper proposes a method where an SVM is used to analyse the collected building operating data for realising automatic danger assessment. The assessment includes the classification of danger types and the determination of danger levels. This study focused on three types of dangers-illegal invasion, overcrowding, and fire-which were divided into three levels: safe, potentially dangerous, and dangerous.
(3) Danger alarm and positioning with a scene. To achieve the warning function for the danger victims and manufacturers, this function module is responsible for sending out alarm signals on the webpage and transmitting the signal to the alarm device in the corresponding room to sound an alarm when the room is in danger. When the BIM model of the terminal corresponding to the real position is established, a unique number is assigned to the terminal. The 3D layout of the room and the corresponding video surveillance screen can be automatically searched according to the terminal number in the room when the room is in danger to identify and locate the danger.
(4) Danger-handling suggestions. According to the different types and levels of danger, this module provides specific suggestions for danger response, as shown in Table 2.

Potentially dangerous
There is a risk of illegal invasion in a certain room, please pay attention to observe the room situation and eliminate potential danger in time.
The number of people in a room has reached x (x is the number of people), and there is a risk of overcrowding. Please pay attention to the gathering of people.
There is a fire risk in a room. Please pay attention to the situation of the room and eliminate the potential danger in time.

Dangerous
A certain room has been invaded, and a certain door and/or window opened abnormally.Please deal with it in time.
The number of people in a certain room has reached x, and the crowd is too dense. Please guide and evacuate.
Fire has broken out in a room. Please rescue immediately.
The system sends the danger-handling suggestions (together with the 3D scene of the location of the danger) to the safety management staff through the webpage to guide the staff in taking correct measures for dealing with the danger.

SVM for Intelligent Classification and Level Assessment of Danger
The relationship between danger parameters is complex and cannot be easily characterised with a reliable mathematical expression. For example, in the early stage of fire development, smoke is relatively thick, but the temperature is not high and the danger is relatively small; however, with the development of the fire, the smoke gradually decreases and the temperature increases. Moreover, many factors affect the fire parameters; thus, it is difficult to establish a reliable mathematical relationship between the types of danger, the level of danger, and the parameters.
Machine-learning methods can find complex correlations between independent variables and dependent variables through large amounts of calculations based on a series of samples, leading to reliable classification and regression. Therefore, the use of machine-learning methods to achieve the classification and rating of dangers is one of the methods that can be considered. In this study, to realise the automatic classification and level evaluation of dangers, an SVM was employed to mine the safety data collected by the IoT, and a mature SVM model was trained. Using this model, the automatic classification and level assessment of indoor dangers were realised. For each danger type, an SVM model was used to determine whether it has occurred. The danger level was evaluated using a danger coefficient predicted by an SVM model. A larger danger coefficient corresponded to a higher level of danger.
The specific steps for the intelligent classification and level assessment of dangers are shown in Figure 10.
The data used in this study for the factors influencing the danger level were from the BIM model and the operating data collected by the IoT. Information regarding the room area, room space relationship, number, and locations of doors and windows was mainly collected from the BIM model. The operating data, including information regarding the opening and closing statuses of doors and windows, temperature, carbon-monoxide concentration, oxygen concentration, smoke concentration, and number of personnel, were mainly collected by the IoT.
(2) Data processing. The data were divided into numerical data and logical data. The logical data were quantised into numerical data. Numerical data "0" and "1" were used to represent the logical data as "false" and "true", respectively. The time data were transformed into corresponding numerical data using Equation (1). Time = hour/24 + minute/1440 + second/3600/24.
Owing to the different dimensions of the influencing parameters, the value ranges of the transformed numerical data differed significantly. The dispersion standardisation method was used to normalise all the transformed numerical data. The transformation equation was as follows: (3) Selection of training and test sets. Because the number of samples with danger was significantly smaller than the number of samples without danger, the use of these data for training directly influenced the training effect of the SVM, owing to data skew. Therefore, it was necessary to pre-process the sample. The under-sampling of samples without danger was used to reduce the difference between the numbers of samples with and without danger [46]. Then, the samples without danger from under-sampling and all the samples with danger were randomly scrambled [47]. A total of 80% of these samples were randomly selected for model training, and the remaining 20% were used for model testing [48].
Sensors 2020, 20, x FOR PEER REVIEW 11 of 20 automatic classification and level assessment of indoor dangers were realised. For each danger type, an SVM model was used to determine whether it has occurred. The danger level was evaluated using a danger coefficient predicted by an SVM model. A larger danger coefficient corresponded to a higher level of danger. The specific steps for the intelligent classification and level assessment of dangers are shown in Figure 10. (1) Data collection for influencing factors.
The data used in this study for the factors influencing the danger level were from the BIM model and the operating data collected by the IoT. Information regarding the room area, room space relationship, number, and locations of doors and windows was mainly collected from the BIM model. The operating data, including information regarding the opening and closing statuses of doors and windows, temperature, carbon-monoxide concentration, oxygen concentration, smoke concentration, and number of personnel, were mainly collected by the IoT.
(2) Data processing. The data were divided into numerical data and logical data. The logical data were quantised into numerical data. Numerical data "0" and "1" were used to represent the logical data as "false" and "true", respectively. The time data were transformed into corresponding numerical data using Equation (1). Time = hour/24+ minute/1440 + second/3600/24 .
(4) Model training. The key to model training is to select the proper parameters and kernel functions. In this study, the radial basis function (RBF) was selected as the kernel function because its accuracy and calculation performance are better than those of other kernel functions [49,50]. K-fold cross-validation was used to determine the kernel-function parameter and penalty coefficient.
(5) Test and effect evaluation. Classification of danger types: The test set selected in step 3 was used to test the prediction effect of SVM. Through a comparison between the prediction results and the actual danger of classification, the prediction accuracy was calculated (using Equations (3)-(5)). A higher accuracy corresponded to the better prediction effect of the model.
In the prediction of the danger classification, the calculation of the classification accuracy, precision, and recall rate with the help of a confusion matrix is a common method for evaluating the classification effect. Higher values of these indicators correspond to a better classification effect [51]. The confusion matrix is shown in Figure 11, and the accuracy, precision, and recall are calculated using Equations (3)- (5).
Recall = TP TP + FN . (5) to determine the kernel-function parameter and penalty coefficient. (5) Test and effect evaluation. Classification of danger types: The test set selected in step 3 was used to test the prediction effect of SVM. Through a comparison between the prediction results and the actual danger of classification, the prediction accuracy was calculated (using Equations (3)-(5)). A higher accuracy corresponded to the better prediction effect of the model.
In the prediction of the danger classification, the calculation of the classification accuracy, precision, and recall rate with the help of a confusion matrix is a common method for evaluating the classification effect. Higher values of these indicators correspond to a better classification effect [51]. The confusion matrix is shown in Figure 11, and the accuracy, precision, and recall are calculated using Equations (3)-(5).

TP TN TP FN FP TN
Precision Recall Prediction of danger level: In this study, according to the danger level of the experiment, the danger coefficient α was evaluated artificially and recorded. A larger danger factor corresponds to a higher danger level. When there is no danger, α ≤ 1; when there is potential danger, 1 < α ≤ 2; when Prediction of danger level: In this study, according to the danger level of the experiment, the danger coefficient α was evaluated artificially and recorded. A larger danger factor corresponds to a higher danger level. When there is no danger, α ≤ 1; when there is potential danger, 1 < α ≤ 2; when there is danger, α > 2. The predicted coefficient is classified into the corresponding grade and compared with the actual coefficient. Consistency between the two indicates that the prediction is correct. The prediction accuracy was used to evaluate the prediction effect of the SVM model. A higher accuracy rate corresponded to a better prediction effect. Additionally, in regression prediction, the squared correlation coefficient R 2 is an important indicator for evaluating the prediction effect. An R 2 value closer to 1 corresponds to a better prediction effect. R 2 is calculated using Equation (6).
where y i represents the true value, f i represents the predicted value, and y represents the average of all the true values. When the accuracy of the classification and level division is low, step 4 and step 5 should be repeated. The parameters are adjusted until the accuracy is increased.

Case Background and Scenario Simulation
A case study of a building in the bobsleigh and sled stadium for the 2022 Winter Olympic Games in Beijing is examined. The building is built on a hillside, with a total of three floors above the ground. The internal layout of the building is complex because of the complex function of the building; it serves as the starting site for the competition. There is expected to be a large flow of people and important competition supplies, such as bobsleigh sleds, which have very high safety requirements. During the design and construction stages of the stadium, a BIM model that are very consistent with the actual building was established, which contained information regarding the geometry, materials, and equipment of the building, as shown in Figure 12.
serves as the starting site for the competition. There is expected to be a large flow of people and important competition supplies, such as bobsleigh sleds, which have very high safety requirements. During the design and construction stages of the stadium, a BIM model that are very consistent with the actual building was established, which contained information regarding the geometry, materials, and equipment of the building, as shown in Figure 12.

Processing of BIM Model
In this study, the information in the BIM model that was not related to the building layout was removed from the model. The new BIM primitives for all types of terminals installed in the rooms were added to the BIM, at positions identical to their positions in the real world. Then, the model with terminal primitives was transformed into a lightweight model, which was implemented online using webGL technology.

Terminal Layout
A terminal layout method based on LoRa technology is proposed herein. Taking the second floor of the building as an example, a smoke-concentration terminal was installed at the centre of the ceiling of each room. In principle, a temperature terminal, an oxygen-concentration terminal, and a

Processing of BIM Model
In this study, the information in the BIM model that was not related to the building layout was removed from the model. The new BIM primitives for all types of terminals installed in the rooms were added to the BIM, at positions identical to their positions in the real world. Then, the model with terminal primitives was transformed into a lightweight model, which was implemented online using webGL technology.

Terminal Layout
A terminal layout method based on LoRa technology is proposed herein. Taking the second floor of the building as an example, a smoke-concentration terminal was installed at the centre of the ceiling of each room. In principle, a temperature terminal, an oxygen-concentration terminal, and a carbon-monoxide concentration terminal are installed in the central position of the wall in each room. If the room is large, two temperature terminals, oxygen-concentration terminals, and carbon-monoxide concentration terminals are installed in the room. Gate magnetic terminals for sensing the opening and closing of doors and windows are installed on each door and window of each room. The layout of some of the indoor terminals on the second floor is shown in Figure 13. If the room is large, two temperature terminals, oxygen-concentration terminals, and carbonmonoxide concentration terminals are installed in the room. Gate magnetic terminals for sensing the opening and closing of doors and windows are installed on each door and window of each room. The layout of some of the indoor terminals on the second floor is shown in Figure 13.

Danger Simulation and Data Acquisition
A stairwell was used as an example to simulate three types of danger: illegal intrusion, overcrowding, and fire. The room area was approximately 26 m 2 , and the room contained a door and a window. The eight parameters of the independent variables in the SVM used for category judgement were the time, opening and closing of the door and window, number of people, carbonmonoxide concentration, oxygen concentration, and smoke concentration. An SVM model was used for predictive training for each danger type. Each SVM model judged whether a danger occurred, so that each type of danger was considered separately when the danger occurred. After the danger-type judgement was complete, these judgements were used as new independent variables to train a new SVM for evaluating the danger level of indoor safety together with the previous parameters, as shown in Figure 14.
Types of indoor danger

Danger Simulation and Data Acquisition
A stairwell was used as an example to simulate three types of danger: illegal intrusion, overcrowding, and fire. The room area was approximately 26 m 2 , and the room contained a door and a window. The eight parameters of the independent variables in the SVM used for category judgement were the time, opening and closing of the door and window, number of people, carbon-monoxide concentration, oxygen concentration, and smoke concentration. An SVM model was used for predictive training for each danger type. Each SVM model judged whether a danger occurred, so that each type of danger was considered separately when the danger occurred. After the danger-type judgement was complete, these judgements were used as new independent variables to train a new SVM for evaluating the danger level of indoor safety together with the previous parameters, as shown in Figure 14.
A stairwell was used as an example to simulate three types of danger: illegal intrusion, overcrowding, and fire. The room area was approximately 26 m 2 , and the room contained a door and a window. The eight parameters of the independent variables in the SVM used for category judgement were the time, opening and closing of the door and window, number of people, carbonmonoxide concentration, oxygen concentration, and smoke concentration. An SVM model was used for predictive training for each danger type. Each SVM model judged whether a danger occurred, so that each type of danger was considered separately when the danger occurred. After the danger-type judgement was complete, these judgements were used as new independent variables to train a new SVM for evaluating the danger level of indoor safety together with the previous parameters, as shown in Figure 14. A room in the building was taken as an example to simulate the three danger types: illegal invasion, overcrowding, and fire. The simulation method was as follows.
(1) Illegal intrusion: The illegal-intrusion behaviour was simulated by entering the simulation room through a door or window from 20:00 p.m. to 7:00 the next day. When the people opened the A room in the building was taken as an example to simulate the three danger types: illegal invasion, overcrowding, and fire. The simulation method was as follows.
(1) Illegal intrusion: The illegal-intrusion behaviour was simulated by entering the simulation room through a door or window from 20:00 p.m. to 7:00 the next day. When the people opened the door or window, the operating data collected by the IoT was marked as "illegal intrusion." At this time, the danger coefficient of the situation was evaluated by safety management staff.
(2) Overcrowding: Many people entered the room together to simulate the overcrowding situation. Video data were collected during the simulation. The number of people in the video was automatically determined via image recognition. The experimenter judged whether there was a danger of overcrowding according to the area of the room and the number of people and recorded the judgement. At this time, the danger coefficient of the situation was scored by the safety management staff.
(3) Fire: A fire was set in the room during the experiment. The operating data were collected during the simulation and were marked as "fire." At this time, the danger coefficient of the situation was scored by the safety management staff.
(4) Normal: The operating data collected at other times (without a danger simulation) were marked as "normal." The danger coefficient of the situation was scored at this time.
The simulation experiment lasted 15 d. Different combustion materials were used to simulate fire 10 times, illegal invasion 13 times, and overcrowding 9 times. The data from the sensors were set to update data every 20 s. A total of 64,800 groups of operating data were collected, including 566 datasets with fire danger, 567 datasets with illegal invasion danger, and 241 datasets with overcrowding danger; the rest were normal data.

Division Effect of Danger Types and Levels
Because the number of samples with danger was far smaller than the number of samples without danger, the training effect of the SVM was affected by data skew. Therefore, the sample information was pre-processed. The training effect was improved by under-sampling the samples without danger. All the samples with danger were combined with 1300 randomly selected samples without danger. A total of 2674 sets of samples were collected. The sample numbers for the different danger types are presented in Table 3. The data collected and quantified are presented in Table 4. The dangers considered in this study were illegal invasion, overcrowding, and fire. An SVM model was trained for each type of danger. Then, using the method described in Section 3.2, the samples were scrambled; 80% were randomly selected for model training, and the remaining 20% were used for model testing. The test confusion matrices for different danger types are shown in Figure 15. The indices used for evaluating the classification effect are presented in Table 5. The results indicate that the SVM had a reliable effect on the classification of the danger types.  In this study, according to the danger level of the experiment, the danger coefficient α was Figure 15. Test confusion matrices for the different danger types. In this study, according to the danger level of the experiment, the danger coefficient α was evaluated by the safety management staff. A larger danger coefficient indicated a higher danger level. The coefficient was set as follows: no danger, α ≤ 1; potential danger, 1 < α ≤ 2; danger, α > 2. The aforementioned 2674 groups of safety data were used as independent variables, and the recorded danger coefficient was used as the dependent variable. Additionally, whether different types of similar dangers occurred according to the SVMs above was an independent variable. The number "1" indicated that the corresponding danger had occurred, and "0" indicated that the corresponding danger did not occur, as shown in Table 6. Thus, the number of independent variables was increased from 8 to 11. The SVM was trained for danger coefficient prediction. A total of 80% and 20% of the samples were used for model training and testing, respectively. The predicted results for the safety coefficient in the test are presented in Figure 16. Here, the horizontal axis indicates the actual value, and the vertical axis indicates the predicted value. The points on the red diagonal line correspond to the predicted and actual values. The point in the shaded part corresponds to the correct prediction result of the danger level. For 535 groups of predicted data, the accuracy rate was 96.2%, and the R 2 reached >0.89, indicating that the prediction effect of the model was good.

Effects of Danger Alarm and Position with Scene and Handling Suggestions
The trained SVM model was used to evaluate the real-time building operation status. The danger type and danger level of each room were automatically determined. Then, the assessment information was combined with the BIM model to display the location of the danger in three dimensions. This allowed the safety management staff to intuitively understand the scene of the dangerous location. The danger can be handled quickly and accurately because safety management staff understand the surroundings of the danger owing to the 3D indoor layout. Additionally, an

Effects of Danger Alarm and Position with Scene and Handling Suggestions
The trained SVM model was used to evaluate the real-time building operation status. The danger type and danger level of each room were automatically determined. Then, the assessment information was combined with the BIM model to display the location of the danger in three dimensions. This allowed the safety management staff to intuitively understand the scene of the dangerous location. The danger can be handled quickly and accurately because safety management staff understand the surroundings of the danger owing to the 3D indoor layout. Additionally, an alarm device in the room issued an alarm, together with an alarm on the website. The alarm device was connected to the system via LoRa technology to realise simultaneous alarms in the virtual digital world and the physical real world, as shown in Figure 17. The trained SVM model was used to evaluate the real-time building operation status. The danger type and danger level of each room were automatically determined. Then, the assessment information was combined with the BIM model to display the location of the danger in three dimensions. This allowed the safety management staff to intuitively understand the scene of the dangerous location. The danger can be handled quickly and accurately because safety management staff understand the surroundings of the danger owing to the 3D indoor layout. Additionally, an alarm device in the room issued an alarm, together with an alarm on the website. The alarm device was connected to the system via LoRa technology to realise simultaneous alarms in the virtual digital world and the physical real world, as shown in Figure 17.

Discussion and Conclusions
A framework for an ISMS based on the DT method is proposed. The framework uses BIM, the IoT, and the Internet to construct a DTM for building indoor safety. BIM provides building information related to safety, information hubs, and 3D geometric models. The IoT sensors collect real-time indoor operation information and monitor the operation of indoor safety status, realising state mapping from the real physical world to the virtual digital world. An SVM performs an automatic classification and level assessment of indoor danger through the mining of safety data. The Internet provides a platform for data storage and user interaction. The method was applied to a room in a building of the bobsleigh and sled stadium for the 2022 Beijing Winter Olympic Games. The SVM was beneficial for the danger classification and level assessment, and the overall system achieved good experimental results.
The main contributions of this study are as follows.
(1) A set of methods for applying the concept of DT in the field of indoor safety was proposed. The feasibility of DTs for solving the problem of building safety was confirmed.

Discussion and Conclusions
A framework for an ISMS based on the DT method is proposed. The framework uses BIM, the IoT, and the Internet to construct a DTM for building indoor safety. BIM provides building information related to safety, information hubs, and 3D geometric models. The IoT sensors collect real-time indoor operation information and monitor the operation of indoor safety status, realising state mapping from the real physical world to the virtual digital world. An SVM performs an automatic classification and level assessment of indoor danger through the mining of safety data. The Internet provides a platform for data storage and user interaction. The method was applied to a room in a building of the bobsleigh and sled stadium for the 2022 Beijing Winter Olympic Games. The SVM was beneficial for the danger classification and level assessment, and the overall system achieved good experimental results.
The main contributions of this study are as follows.
(1) A set of methods for applying the concept of DT in the field of indoor safety was proposed. The feasibility of DTs for solving the problem of building safety was confirmed.
(2) The integration of building operating data and 3D indoor scenes was realised. The intuitiveness of the indoor safety management was improved.
(3) The feasibility of using AIoT to define the types and levels of indoor danger, which can improve the automation level and speed of the response to indoor danger, was proven.
(4) According to the classification and level of indoor danger, automatic auxiliary processing suggestions were realised. The scene data management mode was added, which relaxes the requirements regarding the quality of the safety management staff.
The proposed framework provides a good indoor safety management method which can improve the intelligence level of indoor safety management. In the future, the function of this framework will be expanded to make the suggestions for danger assistant treatment more targeted. Additionally, besides the dangers in this research, other dangers indoor environment can be taken into account based on this framework, such as the leakage of some harmful gases in the environment. Moreover, DTs will be applied to other aspects of building operation management to improve the intelligence level. For example, with reference to the framework in this article, DTMs of building structure and equipment can be established so as to improve the management of structural safety and equipment safety. This is also a direction that can be considered in the future.