A scoping review of In-the-loop paradigms in the energy sector focusing on software-in-the-loop

Software-in-the-Loop (SIL) testing is an approach used for verification and validation in the energy sector. However, there is no comprehensive overview of the application, potential, and challenges of SIL within this sector. Therefore, this paper conducts a thorough scoping review of the existing literature within the scope of SIL and related in-the-loop approaches in the energy sector. A total of 88 full-text articles from four significant databases ACM, IEEE Xplore, Scopus, and Web of Science are analyzed and categorized to map the purpose, methods, architecture, interoperability and protocols, technologies, challenges, and limitations. The results present a grand perspective of in-the-loop across several domains followed by an analysis of SIL in the energy sector. The application domains carry characteristics from complex systems, systems-of-systems, cyber-physical systems, critical systems, real-time systems, and sociotechnical systems. The energy sector and the automotive industry are amongst the most applied domains. Within energy-and electricity systems, hardware-based in-the-loop paradigms are mostly applied for testing low-level signaling, and SIL is used for control strategy testing, optimization, dispatching, and experimentation. The examined SIL architectures have distributed, real-time, and closed-loop properties, and are constrained by specialized simulation power hardware. Future research should address how to systematically develop SIL testing environments with guiding principles to support application development for the future digitalized energy system.


Introduction
The energy systems are undertaking a digital transformation to combat the climate crisis, provide accessible and affordable energy, and minimize dependency (https:// eur-lex.europa.eu/ legal-conte nt/ EN/ ALL/? uri= CELEX: 52022 DC0552).Many challenges arise when extending the applications of the energy system with smart capabilities e.g., smart grid, demand-response (DR), and distributed energy resources (DER) (Dekeyrel and Fessler 2023).The digital transformation exposes the energy system to challenges similar to complex systems (Hanel et al. 2018a), system-of-systems (Sommerville 2016), cyber-physical systems (Lee 2008(Lee , 2010;;Derler et al. 2012), critical systems, and sociotechnical systems.Interoperability is highlighted as one of the key challenges to developing applications that utilize information across the entire energy system (Gopstein et al. 2020;Papaioannou, et al. 2018;Directorate-General for Energy 2018).Furthermore, an interconnected, decentralized, resilient, and self-adaptable energy system is characterized by complex dynamics and emergent behavior.The complex and emergent behavior is not only hard to model, but stakeholders will have difficulty in verifying and validating system scenarios with traditional methods.
Verification & validation (V&V) processes can be performed for every integration level in the development lifecycle to ensure integrity and to enable early feedback.The resulting feedback can be used to validate and modify the product in a timely and cost-efficient manner.V&V takes up more than 50% of the total development costs in critical systems (https:// softw are-engin eering-book.com/ web/ criti cal-syste ms/).Critical systems exist in many sectors e.g., energy, automotive, medical, aviation, military, etc. where failures may result in tremendous costs including loss of infrastructure capability, injuries, death, and economic or environmental damages.Therefore, critical systems need to be reliable, and the integrity must be thoroughly verified and validated at all levels (system, hardware, and software) before operation.
V&V can be achieved through various approaches e.g., model-based design (MBD), in-the-loop testing, formal methods, model checking, property-based testing, cosimulation, multi-agent simulation, (virtual) prototyping, static code analysis, and debugging.MBD is an engineering method applied in critical control systems where V&V activities are prioritized.The development steps involve (i) modeling the plant or process to be controlled, (ii) modeling the controller, (iii) establishing interoperability between the plant and controller, (iv) simulating the symbiotic behavior, and (v) collecting metrics for V&V analysis.Sophisticated development tools like MATLAB/ Simulink and Modelica/Dymola exist to implement the plant and controller inside an integrated environment using block elements.The MBD lifecycle follows the V-model where system integrity and rapid feedback are ensured across all levels (system, hardware, and software) to reduce faults, risks, and costs before operation.
However, traditional testing methods are unsuitable for holistically verifying and validating the energy system.Therefore, there is a need to develop integrated methods and tools that can assist stakeholders to verify and validate the behavior and interoperability of the future energy sector.Efforts on this matter are documented in the European Guide to Power System Testing (Strasser and Jong 2020).SIL testing holds considerable promise as a potential solution for verification issues in the energy sector.However, there is a notable absence of a comprehensive overview of the application, potential, and challenges of SIL within this sector.
Therefore, the primary objective of this paper is to conduct a thorough scoping review of the existing literature within the scope of SIL in the energy sector.This review will provide a panoramic view of the current state of SIL application in the energy domain, including its methodological approaches, benefits, limitations, and contextual variations.Furthermore, this paper aims to identify significant gaps in the current research landscape regarding SIL in the energy sector.By scrutinizing the literature, this paper will highlight underexplored areas, thereby illuminating possible directions for future research.Through these endeavors, we anticipate this paper will serve as a valuable resource for researchers, industry professionals, and policymakers, equipping them with the insights necessary to navigate and shape the future of SIL in the energy sector.
The paper is organized as follows: section Scoping review method details the scoping review method.Section Results presents the results of the literature analysis in the dimensions of interest.Section Discussion provides a discussion of the results.Section Conclusion concludes the paper with suggestions on future research directions.

Scoping review method
The scoping review process is depicted in Fig. 1.The approach involves the formulation of multiple search strings given the scope.The search strings were transformed into database-specific syntax compatible with the selected databases.The search results were downloaded, and unique references were found across the entire set of references.The unique references were screened based on the inclusion criteria.The screened references were downloaded in full text and analyzed individually.The following subsections describe the review method in detail.

Search string formulation
Table 1 shows the identified search terms based on the scope.The domain includes terms from the energy system that impose integration challenges.The topic focuses Fig. 1 The scoping review process on architecture, communication patterns, and virtual environments because these are fundamental issues for in-the-loop testing.The methodology is MBD, including model-based software, model-based systems, and in-the-loop.
The search terms were used to construct the generic search strings in Table 2.The generic search strings were then translated into the database-specific syntax (see Table 14 appendix A).Multiple search strings were constructed to explore the extent of the literature.G1 is a narrow search string that includes domain terms and all 'inthe-loop' paradigms.G2 focus on SIL and architectures, patterns, and frameworks.G3 is a broad search string that includes all SIL literature.G4 is almost identical to G1, but G4 is domain-and methodology agnostic.

Evidence collection
Four significant and reputable databases within the engineering field were targeted for evidence collection: • Web of Science (WoS) • Scopus • The ACM Guide to Computing Literature (ACM) • The Institute of Electrical and Electronics Engineers (IEEE) Xplore.The search had no date restriction, and the database hits are shown in Table 3.The evidence was managed in the Mendeley reference manager and was organized into hierarchical subfolders corresponding to each search string and database.This enabled aggregation of the results in a parent folder where duplications were removed in a twostep process: (i) With the 'Check for Duplicates' functionality and (ii) by manual inspection of duplicate entries.This left 199 unique hits across all databases and search strings.The evidence content type included conference proceedings, journal articles, short papers, early access, and book chapters in English (see Table 15 in appendix B).
The unique hits of each search string reveal the extent of the literature.The search strings G1 and G2 provide a narrow evidence base for the scoping review.The  inclusion of search strings G3 and G4 provides a wider evidence base.Collectively, the search strings enable comprehensive analysis with a total of 199 unique references.

Inclusion criteria and evidence screening
The 199 unique references were screened for relevance based on the following inclusion criteria: Based on the title or abstract the paper must: 1. Apply one of the stated methodologies in combination with in-the-loop 2. AND 3. (Address one of the stated topics OR 4. Address one of the targeted domains OR 5. Indicate general applicability, i.e., domain agnostic) No exclusion criteria were formulated because in this case such criteria would be the inverse of the inclusion criteria.For example, one inclusion criterion is to address one of the stated topics.The inverse of this criterion is that the paper does not address one of the stated topics.
105 references were included based on the criteria by which 88 references were available for full-text download.The unavailable references were either behind a paywall or unavailable for download (see Table 16 in appendix C).
The publication trend of the literature is shown in Fig. 2. Most research was published in 2010-2019 and declined in 2020.The trend increased again in 2021.The year 2022 is not fully covered, but it is expected that the number of references is around the same or slowly declining compared to 2021.The selected references follow the publication trend and span most of the period.

Full-text examination and data extraction
The selected references were carefully and systematically examined, and the evidence was extracted into dimensions with the use of a spreadsheet.Each reference was recorded together with 13 columns corresponding to each dimension as shown in Table 4.These dimensions map to the aim of the scoping review.

Results
This section systematically presents the analysis of the selected literature.The SIL application domains are presented first to provide the breadth of SIL.Subsequently, the focus shift to energy-and electricity systems and explores the various in-the-loop paradigms in this domain.Finally, the focus narrows to SIL in energy-and electricity systems and provides a detailed analysis in each dimension; purpose, methods, SUT & plant, performance metrics, architecture, communication patterns, interoperability protocols, and technologies.

Application domains and scope of software-in-the-loop
Table 5 shows an overview of the SIL applications in the analyzed literature, including the domains and subdomains together with the frequency.A reference may span multiple domains-for example (Nguyen et al. 2019a) is located within Grids, Renewables, and Low inertia systems.The application domains carry characteristics from complex systems, systems-of-systems, cyber-physical systems, critical systems, realtime systems, and sociotechnical systems.These types of systems are notoriously difficult to test due to their inherent complexity.However, the applications require significant upfront testing because faults may lead to major losses including death, injury, and economic losses.The SIL testing paradigm focuses on verifying the emergent behavior between the controller and the virtual model.This includes verifying that the control strategy can achieve the intended functionality by manipulating the virtual model (Raghupatruni et al. 2019).The functionality can be verified by observing the response of the virtual model.Non-functional behavior e.g., performance, interoperability, real-time constraints, etc. may also be verified (Raghupatruni et al. 2019).SIL testing may vary in scope, meaning that the approach can be used to verify different aspects of the overall system (Raghupatruni et al. 2019).The SIL testing  scope is defined by the testing objectives in a given scenario and the objectives in the reviewed literature can be summarized according to the application domains: • In energy-and electricity systems, SIL has been used for control strategy testing (Nguyen et al. 2019a;Guerrero, et al. 2016;Huber et al. 2014;Rossi et al. 2019;Singh and Shubhanga 2017;Tuominen et al. 2017), optimization (Nguyen et al. 2019a, b;Tuominen et al. 2017;Frotscher, et al. 2019), dispatching/scheduling (Osadcuks and Galins 2012;Bonassi 2020), and experimentation (Kwon and Choi 1999).A detailed analysis of SIL in energy-and electricity systems are provided in later sections.• In the automotive domain, SIL has been used to test battery management systems Frotscher, et al. 2019 [135], ESP software (Kwon and Choi 1999), geographically distributed subsystems in real-time (Pieper and Obermaisser 2018a), advanced driver assistance systems (Taut et al. 2019) (Pieper and Obermaisser 2018a), electronic circuits (Lai and Lin 2021), home appliances with property-based testing of the source code (Park et al. 2020), embedded code for DC motor control (Muresan and Pitica 2012;Werner et al. 2015), and image processing (Werner et al. 2015).• In manufacturing, SIL has been used for rapid prototyping of automated manufacturing (Bonivento et al. 2011), and material flow simulation (Scholz et al. 2017;Nagy et al. 2012).For these applications, agent-based and discrete event simulations are often used.• For unmanned aerial vehicles (UAV), SIL is used to test adaptive formation controllers (Yang et al. 2019), altitude controllers using proportional integral derivative (PID) control (Silva et al. 2019), pathfinding (Bittar et al. 2014), and radio frequency communication in swarm UAV applications (Mastronarde et al. 2022).• In robot systems, SIL has been used for industrial robots (Jaensch et al. 2019), and verification of source code for a robot manipulator (Ayed et al. 2017).• In satellite applications such as microsatellites and nanosatellites, SIL has been used for attitude control and determination using PID control (Hassani and Lee 2013; Kiesbye, et al. 2019;Pereira et al. 2016), and formation flying (Park et al. 2013).• For railway systems, SIL has been used to integrate geographically distributed railway components with co-simulation (Pieper and Obermaisser 2018b) and to test the control unit for driverless railway vehicles (Vignati et al. 2021).
Generally applicable SIL methods have been suggested to solve particular challenges such as relative time synchronization (Lee et al. 2017), distributed agent simulation (Riley and Riley 2003a, b), pervasive simulation (Brambilla et al. 2014), and job scheduling in heterogenous cluster computing (Bonivento et al. 2011).

In-the-loop paradigms in energy-and electricity systems
The in-the-loop approach is concerned with MBD V&V on the emergent behavior between the plant and controller in a virtual environment at different abstraction levels.Early use of in-the-loop can be traced back to military applications (Garcia et al. 1994;Lynch et al. 1989;Organization 1988).The approach aims to objectively collect evidence to confidently ensure that the controller and System Under Test (SUT) conform to the V&V scenarios.
Common in-the-loop paradigms shown in Fig. 3 include model-in-the-loop (MIL), software-in-the-loop (SIL), processor-in-the-loop (PIL), and hardware-in-the-loop (HIL).MIL verifies the design of a controller on a virtual model, often developed and modeled in schematic block diagrams.MIL is used early in the development cycle to test the controller design.SIL verifies the controller code on virtual models.The output of the controller serves as input to simulated virtual models.These models mimic physical systems/hardware with a high degree of complexity and real-time properties.
The in-the-loop paradigm has similarities with the Process Control paradigm (Shaw 1994;Åström and Wittenmark 2011).The Process Control paradigm separates the process of interest in a virtual model from the control policy i.e., the controller.The interaction between the controller and the virtual model is that the controller receives values from the process and the controller continuously guides the process to achieve a defined objective.The collected evidence depends on the scenario and may address functional or non-functional issues.For example, a scenario may focus on the functionality to verify that the controller can control the SUT to satisfy a functional requirement.Non-functional focus on qualitative issues, for example, reliability, performance, safety, adaptability, resiliency, etc.The advantage of in-the-loop testing lies in the early fault detection which lowers the overall project costs.Furthermore, the controller software can be generated from block diagrams through code generation, reducing development effort.Advantages of SIL include early verification, fault detection, reduced hardware costs, and rapid feedback cycles.PIL verifies the controller code executed on the target hardware against a virtual model.PIL testing identifies faults when the controller code is executed on the targeted hardware platform.HIL verifies the controller output in a simulated environment involving physical equipment that is limited by real-world constraints.Higher costs are involved with HIL testing and are used late in the development process to test real-world behavior or integration issues that cannot be detected by earlier tests.HIL runs in real-time and consequently has a slow feedback cycle.
Power-hardware-in-the-loop (PHIL) is a specialization of HIL that is often used to test applications in the electricity domain (Hubschneider et al. 2018).The paradigm is applied in power systems to study and test the performance and interactions given different control strategies.PHIL uses specialized hardware which enables real-time simulation of virtual power grids and circuits.The virtual circuits are built from virtual electrical components such as amplifiers, rectifiers, photovoltaics (PV), inverters, and more.The virtual electrical circuits are deployed to a real-time power hardware simulator.The input/output of the simulator is low-voltage signals that can be amplified to imitate real-world signals.
Purposes of software-in-the-loop applications in energy-and electricity systems SIL has been used for four major purposes as summarized in Table 7: Control strategy testing/evaluation, optimization dispatching/scheduling, and experimentation.In power grids, generally, SIL has been used to evaluate a power oscillation damping (POD) controller of a synchronous condenser (Nguyen et al. 2019a).Furthermore, the authors Nguyen et al. (2019a) optimized the parameters for an IEEE standard automatic voltage regulator (AVR).In distribution grids, SIL has been used to test coordinated Volt/ Var control strategies by the same authors Guerrero, et al. (2016Guerrero, et al. ( , 2021)).The authors in Tuominen et al. (2017) applied SIL to both evaluate the functionality of a distribution automation architecture and to evaluate a power control algorithm.In microgrids, SIL has been used for both control strategy testing and optimization for microgrids.Osadcuks and Galins (2012), Bonassi (2020) studied dispatch and scheduling algorithms using SIL, while Lai and Lin (2021) used optimization to deal with oscillatory stability issues.
For renewable energy sources, the authors in Huber et al. (2014) used SIL to evaluate solar cooling control strategies in solar thermal systems.For photovoltaics, SIL has been used to test maximum power point tracker (MPPT) control (Singh and Shubhanga 2017).A more complex system consisting of district heating, combined heat and power plant, solar collectors, and thermal energy storage had its operation optimized (Frotscher et al. 2019).Furthermore, SIL was studied to test and verify control logic and its reliability governing a power plant (Rossi et al. 2019) and to experiment with distributed control structures (Kwon and Choi 1999).The distributed control structures, in this case, mean that the control algorithm was separated from the plant.

Experimental validation and reported benefits of SIL testing
The previous Sect.3.3 accounted for the overall purpose of SIL.This section reports how studies have validated or benefitted from SIL.Table 8 shows the analysis overview.The authors in Guerrero et al. (2016) focus on validating the closed-loop interoperability aspects between the control algorithm and the simulator over a TCP/IP-based network instead of using shared files.The authors in Rossi et al. (2019), Tuominen et al. (2017) reported that SIL was used to validate the control approach prior to field testing.The authors in Singh and Shubhanga (2017), Kwon and Choi (1999) reported that SIL can be useful in classrooms for teaching in control education or for demonstration purposes.The authors in Singh and Shubhanga (2017) also reported that SIL can be useful for both testing and deploying optimal control algorithms.The authors of Osadcuks and Galins (2012), Kwon and Choi (1999) reported that SIL provided design and

Experimentation
Experimentation with distributed control structures Kwon and Choi (1999) modification benefits, and furthermore enabled implementing the control algorithm in high-level programming languages as opposed to low-level programming in e.g.C/C++.The authors in Osadcuks and Galins (2012) also noted that the control system could be transferred to the field with minimal change.The authors in Guerrero et al. (2021) used SIL to (i) validate the system behavior under different system operating scenarios (functional behavior), and (ii) to analyze the real-time performance of the control algorithm (non-functional behavior).

Software-in-the-loop methods and approaches applied in energy-and electricity systems
Table 9 shows the methods and approaches used for SIL in energy-and electricity systems, and they can be divided into eight categories.The method categories are closely related to the purpose categories because each method is used to realize the application purpose.

• Simulation methods
Simulation is inherent in the SIL paradigm.A model of a plant must be simulated over time to estimate the performance and impact of control strategies.Real-time simulation is a dominant simulation approach (Nguyen et al. 2019a, b;Guerrero et al. 2016Guerrero et al. , 2021;;Singh and Shubhanga 2017;Tuominen et al. 2017;Bonassi 2020;Kwon and Choi 1999).This approach advances in sync with "wall clock" time-either because of the computational complexity or to study the system behavior under real-time constraints.Alternative approaches such as Frotscher et al. (2019) use TRNSYS which is also a timedependent simulation approach.The authors in Huber et al. (2014) use equation-based and Number of Transfer Units (NTU) simulation models in Dymola.

• Optimization methods
Optimization is a frequently used approach for minimizing/maximizing objectives such as control variables or parameters of a control strategy.Biological-inspired algorithms i.e., Artificial Immune Systems Optimization (AISO) (Guerrero et al. 2016(Guerrero et al. , 2021)), Genetic Algorithms (GAs) (Nguyen et al. 2019a, b), and Clonal Selection Algorithm

Validation and reported benefits of SIL References
Closed-loop interoperability validation Guerrero et al. (2016) Validation of control approach prior to field testing Rossi et al. (2019), Tuominen et al. (2017) Useful in classroom teaching, control education or demonstrations Singh and Shubhanga (2017), Kwon and Choi (1999) Testing and deploying optimal control algorithms Singh and Shubhanga (2017) Design and modification benefits of control algorithms (also in high-level programming languages) Osadcuks and Galins (2012), Kwon and Choi (1999) Enables model-driven architecture and software development Osadcuks and Galins (2012) Enables transferring the control system to the field with minimal change Osadcuks and Galins (2012) Analysis of system behavior under different system operating scenarios Guerrero et al. (2021) Analysis of real-time performance of the control algorithm Guerrero et al. 2021) (CLONALG) (Guerrero et al. 2021) have been studied.AISO was applied in a coordinated Volt/Var control strategy (Guerrero, et al. 2016(Guerrero, et al. , 2021)).In Nguyen et al. (2019b) a GA was used for parameter optimization for oscillatory stability issues and parameter optimization of an automatic voltage regulator (Nguyen et al. 2019a).In photovoltaic applications, Maximum Power Point Tracking (MPPT) is used to optimize the power output (Singh and Shubhanga 2017).Numerical optimization has been used to optimize the operation of a system consisting of renewable energies (Frotscher et al. 2019).
The authors in Bonassi (2020) applied the Alternating Direction Method of Multipliers (ADMM) for local microgrid optimization.

• Emulation approaches
Emulation was used as part of a simulation loop to emulate an IEEE-34 bus test feeder in two studies by the same authors (Guerrero et al. 2016(Guerrero et al. , 2021)).

• Dispatching approaches
Dispatching approaches were used to dispatch and schedule the operation of renewable energy sources in two studies (Osadcuks and Galins 2012;Bonassi 2020).Dispatching has a notion of optimization since the objective is to find optimal dispatch strategies to operate a facility.

• Real-time price approaches
Bonassi 2020) uses real-time day-ahead energy price signals as part of its SIL approach to improving the overall control strategy.

• Control methods
The control category contains methods and approaches from the perspective of the actuation.A limited number of studies conduct control.The authors of Guerrero, et al. (2016), Guerrero et al. (2021) apply Volt/VAR control for feeder automation.The specific functions are (1) feeder voltage control, (2) feeder reactive power control, and (3) substation voltage control.The authors of Nguyen et al. (2019a) apply Proportional-Integral-Derivative (PID) control for automatic voltage regulation and they optimize the three PID coefficients with a GA.The authors of Rossi et al. (2019) apply a two-level hierarchical control.The first level covers a 15-min horizon for plant configuration i.e., the control variables, and the second level governs the power plant with real-time resolution using model-predictive control (MPC).In Tuominen et al. (2017), the authors describe the architecture for three-level hierarchical control where each level operates at different time scales.The first level operates in seconds and is responsible for controlling locally connected devices e.g., voltage control or power control of a DER.The second level operates in minutes and is responsible for controlling larger sections of the distribution network.The third level operates for tens of minutes and is responsible for coordinating secondary controllers and incorporating financial aspects into the network control.

• Analysis methods
Prony's method has been used in two studies by the same author (Nguyen et al. 2019a, b) to analyze oscillation and to find frequency and damping ratios.

Systems under test, virtual models, and performance metrics of software-in-the-loop in energy-and electricity systems
Table 10 shows the SUT, the virtual model, and metrics used for SIL in energy-and electricity systems.The SUT is the system being evaluated by enacting the virtual model.The model may vary in scale and represent e.g., a distribution network, a power plant, or a PV system.The metrics are either the direct output of the virtual model or performance indicators of the SUT.For electricity systems, the most common metrics include active power, reactive power, voltage, and power output.For power grids, the performance metric is system frequency.For PV systems, the performance metrics include solar energy, cooling energy, COP factor, and P-V curves.For battery control systems, the performance metric is the State of Charge (SoC).

Software-in-the-loop technologies used in energy-and electricity systems
This section presents a detailed analysis of the implementing technologies used for SIL in energy-and electricity systems.The results are shown in Table 11 and are organized into categories.Each category is described in detail.

• Simulation technology
The most used technology is the Real-time Digital Simulator (RTDS) (Nguyen et al. 2019a, b;Guerrero, et al. 2016Guerrero, et al. , 2021) ) which is a specialized simulator for power grids.The authors of Guerrero et al. (2016Guerrero et al. ( , 2021) )  interfaces with RTDS.For example, RSCAD/Draft is used for circuit assembly and parameter entry (Nguyen et al. 2019a, b), and RSCAD/Runtime is used to control simulation scenarios performed on the RTDS hardware (Nguyen et al. 2019a;Guerrero, et al. 2016Guerrero, et al. , 2021)).HOMER has been used to provide load profiles and available resources in hybrid power systems (Osadcuks and Galins 2012).In Singh and Shubhanga (2017), the authors used an FPGA XCS100E for real-time simulation where they used a hardware description language (VERILOG) to realize a photovoltaic module.In Frotscher et al. (2019), TRNSYS has been used as simulation software to create a complex reference model (CRM) of a district heating system, including solar thermal plants and short-term thermal energy storage.

• Integrated environment software technology
Integrated environments are software that provides a substantial and integrated toolbox to develop plant models, simulations, controllers, and graphical user interfaces and to execute test scenarios.MATLAB/Simulink was used the most (Guerrero et al. 2016(Guerrero et al. , 2021;;Rossi et al. 2019;Tuominen et al. 2017;Nguyen et al. 2019b;Osadcuks and Galins 2012;Bonassi 2020).In Guerrero et al. (2016Guerrero et al. ( , 2021)), the short-term load forecast, system state estimation, and coordinated volt/var control were implemented in MATLAB.In Nguyen et al. (2019b), MATLAB was used for both optimization and control of an RTDS in a closed loop.In Rossi et al. (2019), MATLAB was used to implement an MPC controller that controlled a model developed in Siemens AMESIM.In Osadcuks and Galins (2012), MATLAB was used to design a simulation model library of hybrid power system equipment.In Bonassi (2020), MATLAB was used to implement microgrid models and optimizations.Modelica/Dymolink was used by Huber et al. (2014) to implement the model of a solar cooling system.

• Interoperability protocols
MaktrikonOPC is an implementation of Open Platform Communication (OPC) which was used for data collection (Nguyen et al. 2019a, b).In Guerrero et al. (2016), the authors used a plugin for the RSCAD platform, to establish communication between RTDS and MATLAB.Interoperability has also been established through sockets (TCP/IP).These instances are elaborated on in the architecture and communication pattern section.

• Programming languages/frameworks
The use of programming languages was sparse and for different purposes.Python has been used for load-and production forecasts (Tuominen et al. 2017).C# and.NET have been used to implement the controller and user interface (UI) for the dispatch of resources.C has been used to implement an adapter between a controller and Modelica (Huber et al. 2014).The number of references that use conventional programming languages to implement the controller is unexpected when considering the purpose of SIL.Namely, to test or verify control software written in a conventional language against a virtual plant.It should be noted that MATLAB can generate code based on the controller models.The analyzed studies do not report the use of this feature.

• Metering hardware technology
A single study uses smart meters for power measurements including load and reactive power (Tuominen et al. 2017).

Software-in-the-loop architectures and communication patterns used in energyand electricity systems
Various SIL architectures have been applied in energy-and electricity systems.Architecture refers to a system consisting of a set of structures, the relations among them, and the corresponding properties of both.This section first describes the structures and relations and then describes the architectural properties.

Structures and relations
The structure and relations are analyzed in this section.Generally, the controller is separated from the virtual model and interconnected through networking.Guerrero et al. (2016Guerrero et al. ( , 2021) ) use a structure as depicted in Fig. 4. The physical devices consist of a developer machine that hosts the controller and SCADA system and a realtime digital simulator that hosts the virtual model of a distribution grid.The subsystems are interconnected by TCP/IP for data collection and control.Nguyen et al. (2019a, b) use a structure as depicted in Fig. 5.This architecture contains three physical devices.The developer machine hosts the controller in MATLAB.The real-time digital simulator hosts the virtual model of a distribution grid.The middleware server hosts an OPC broker for flexible interoperability.Data from the virtual model are collected by the OPC.The controller is connected to the OPC to get the data from the Fig. 4 SCADA architecture used in Guerrero et al. (2016Guerrero et al. ( , 2021) ) virtual model.The connection between the controller and the virtual model is used for control.Huber et al. 2014) uses a structure as depicted in Fig. 6.The controller is connected via TCP/IP to the Modelica simulation environment which contains the virtual model of a solar thermal system.This architecture uses peer-to-peer communication and resembles the Process Control paradigm closely.Kwon and Choi (1999) uses a master-slave architecture as depicted in Fig. 7 where a coordinator controls a distributed SIL of multiple controllers and simulators.Each controller controls separate simulators.The elements are connected through UDP/IP to improve performance.This architecture has similarities with co-simulation which is a distributed simulation of subsystems.Tuominen et al. (2017) uses a hybrid architecture as depicted in Fig. 8 of SIL and HIL where physical smart meters and automatic voltage controllers/regulators are part of the loop.The substation automation unit is a form of supervisor that exists on two levels: Primary and secondary depending on the control level.The depicted architecture is a simplification of the two levels that encapsulates the abstract idea.The virtual models of low-and medium-voltage networks run on the real-time digital simulator.MATLAB is used both as a controller and a measurement collector.The smart meter is connected Furthermore Rossi et al. (2019) uses an architecture in which the virtual power plant model is developed and executed in the Siemens AMESIM environment, and the controller is developed in MATLAB.The deployment configuration is not further specified.Osadcuks and Galins (2012) uses MATLAB to model the virtual model, its sensors, and actuators.The controller is running in a separate program written in C#.NET.The Fig. 7 The master-slave architecture is used in Kwon and Choi (1999) Fig. 8 The hybrid architecture used in Tuominen et al. (2017) simulation runs in discrete time steps in contrast to real-time.This boosts the simulation speed on average 150:1.Singh and Shubhanga (2017) uses a Field-Programmable Gate Array (FPGA) board to conduct real-time simulation and evaluation of an MPPT algorithm for photovoltaics.Thus, the architecture includes an element of specialized hardware.The output of the simulator can be used to control DC-DC converters.The authors separate the photovoltaic module (virtual model) and the MPPT module (controller) to enable the testing of various MPPT algorithms with few modifications.Both modules are deployed in a single FPGA board and communicate via electric signaling i.e., voltage and current.
Moreover, Bonassi (2020) uses a proprietary platform e-mesh ™ to optimize the dispatching of DER in microgrids.Their simulation and control architecture is sparsely described.They use MODBUS over TCP/IP to communicate with field controllers and HTTP/REST to communicate with a SCADA system.Frotscher et al. (2019) uses TRN-SYS to simulate a virtual district heating system in discrete time.The overall architecture is a closed loop where a separate controller optimizes the district heating system.The communication between the simulator and controller is established through files that are exchanged in a shared folder.

Architectural properties
The architectural properties are presented in Table 12.Most studies have similar properties i.e., closed loop, real-time simulation, and distributed architecture.A closed loop is a common type of control loop where process variables are fed back into the control algorithm as a point of reference.The control algorithm then decides the values of the manipulated variables of the controlled process.The real-time property is evident in the cases where the virtual model and controller are executed at the same rate as "wall clock" time.Consequently, if a two-week scenario is tested in a real-time simulator, it takes two weeks to obtain the results.Each application operates at application-specific time scales.Thus, a real-time application may operate within short intervals (micro-seconds or seconds) e.g., grid-stabilization, or long intervals (e.g., minutely, hourly, daily, yearly, decades) for long-term decision-making.In  contrast, two studies (Frotscher, et al. 2019;Osadcuks and Galins 2012) use discretetime simulation to progress faster than "wall clock" time.A distributed architecture is commonly used to separate the controller and virtual model over a network.These two components may be deployed to physical nodes or executed in separate processes on the same developer machine.A single study (Tuominen et al. 2017) combines SIL and HIL to study interfacing issues before field demonstration.

Interoperability in the context, of the OSI model
The analyzed studies use a variety of protocols for realizing interoperability.The interconnected subsystems are usually the controller, virtual model, middleware, and physical devices.Table 13 lists the applied protocols.TCP/IP is a connectionoriented used for reliable socket communication (Nguyen et al. 2019a, b;Guerrero, et al. 2016Guerrero, et al. , 2021;;Tuominen et al. 2017).On the contrary Kwon and Choi (1999) uses the connectionless UDP/IP for performance reasons.These protocols operate at the transport layer of the OSI model.Similarly, Ethernet is also used, but this protocol operates at the data link layer.The DNP3 protocol is used within utilities e.g., power grids to control physical equipment over a network.Nguyen et al. (2019a, b) states its use between the real-time digital simulator and local equipment.MODBUS is a competing protocol for DNP3 and is used in two studies (Tuominen et al. 2017;Bonassi 2020).OPC is the middleware used for secure interoperability and uniform access to industrial automation equipment.Nguyen et al. (2019a, b) uses OPC as a middleware technology to interconnect the controller and real-time digital simulator.One study (Tuominen et al. 2017) uses application standards i.e., IEC 62056-5-3:2017 for electricity metering data exchange, and IEC 61850 which is a communication protocol for intelligent electronic devices.Two studies state that they transfer files over the network to exchange data (Huber et al. 2014;Frotscher et al. 2019).
Table 13 Protocols for interoperability and their mapping to the ISO model

Discussion
The digitalized energy system of the future operates with heterogenous, interconnected, and concurrent entities on a large scale.Extending the energy system capabilities with advanced applications, e.g., DR, and DER, requires that entities can interoperate to achieve a greater goal.The local control systems must be capable of responding to external events to operate optimally.It is no longer sufficient to operate in siloes.These capabilities call for advancement in V&V, ontology, and interoperability development for testing the future energy system.Hardware-based testing approaches such as PHIL require specialized equipment that is difficult to scale.Most of the analyzed literature rely on hardware-based plants for in-the-loop testing of energy-and electricity systems.Relying on hardware testbeds in a lab environment involves upfront investment for equipment, installation, and training.The use of a hardware-based real-time simulator (e.g., RTDS) for V&V constrains the lab environment to a proprietary hardware platform.
Future potential, emerging trends, technologies, and related fields SIL has the potential to reduce testing costs if the architectural properties required for testing (e.g., real-time, closed-loop, distributed computation, heterogenous models, protocol simulation, etc.) can be realized with software-based approaches on commodity hardware.A virtual lab environment for SIL testing would enable earlier V&V feedback and potentially reduce hardware costs by executing the simulation on commodity hardware.It may also be possible to speed up the simulation execution on commodity hardware beyond real-time as shown in Osadcuks and Galins (2012).
Another potential of SIL testing is experiment reproducibility and benchmarking.SIL testing enables to rerun hypothetical scenarios and configurations to analyze edge cases that may be difficult to test in the real-world.Reproducibility can also be used as an enabler for benchmarking testing.For example, many SIL applications involve optimization where the objective is to find an optimal control strategy for a particular system.If the same simulation environment can be used to test various control strategies, it is possible to make benchmarking analysis.
The emerging field of digital twins enable high-fidelity modeling of energy equipment to be used in closed-loop testing.This area of research is called twin-in-the-loop (Park et al. 2019;Dettù et al. 2023;Eyring et al. 2022) and exhibits promising prospects such as (i) improved integrability testing of renewable energy source and electric vehicles, and (ii) improved reliability and resilience testing of the energy system.An example could be in testing and comparing electric vehicle charging strategies on a simulated model of the infrastructure.Here the 'software' part of 'software-in-theloop' would constitute a component that accurately resembles software that can be deployed in the real-world.The 'in-the-loop' part would resemble a system-level digital twin simulation of the infrastructure and would provide responses of enacted control.A concrete case could be testing real control software using the Open Charge Point Protocol (OCPP) 2.0.1 as a basis of protocol and topology.The control software in this case would be deployed as a charging station management system and a digital twin would simulate the infrastructure with individual charging stations and other distribution grid entities.
Game engines commonly serve as a technology for creating digital twins (Clausen et al. 2022;Sørensen et al. 2022;Negrin et al. 2021;Eyre et al. 2018).For example, Universal Scene Description (USD) can be used to create simulation-ready assets and to create ecosystems to describe, compose, simulate, and collaborate within 3D worlds.Imagine if vendors provide simulation-ready assets that can be seamlessly integrated into a simulation to evaluate scenarios.Another game engine example is the object model used in Unreal Engine 5.It separates the actor from the behavior like the process control paradigm.A major limitation of game engines in the perspective of energy-and electricity systems is that game engine technology focus on real-time body simulation (collision, fluids, destruction, etc.) in contrast to electromagnetism, realistic wind patterns, and information flow analysis.Nevertheless, the exploration of game engine technology for in-the-loop testing of energy-and electricity systems is an open issue.
Agent-based modeling and simulation have also been proposed to model digital twins (Schimeczek et al. 2023a, b).Each agent reflects a certain entity in the energy-and electricity system, encapsulating its control logic.Furthermore, the agent-based approach facilitates the examination of higher-level economics and interactions among roles, actors, and objects in different ecosystem configurations (Ma et al. 2019;Fatras et al. 2022;Vaerbak et al. 2021).In the context of SIL, agent-based modeling can be used to model the individual plants in one simulation and then have externalizes control interacting with each agent in the model.This approach may be useful for SIL testing on a system-level scale.
Energy metaverses (Ma 2023) can enable analysis of the emerging behavior between stakeholders, infrastructure, environment, business models, regulations, and policies.The energy metaverse connects tangible and intangible assets in the energy system through digital twins.In this case, it would be interesting to assess the emergent behavior of SIL in a grand perspective.
Cooperative simulation (co-simulation) is an approach that enables global simulation of a coupled system through composition of independent simulators (Gomes et al. 2017).Each simulation may differ internally in terms of solving and model paradigm (discrete, state machine, ordinary differential equations, etc.), but they agree upon a well-defined interface to operate in concert through an orchestrator.The orchestrator is responsible for data exchange and synchronization between the models (Steinbrink et al. 2017).This approach is modular, and offers flexibility, reusability, parallel development, and protection of intellectual property (model internals are hidden).The result of the co-simulation is the effect of emergent behavior.Co-simulation and SIL could be combined to analyze real-time properties of a system under test.

Challenges of SIL
SIL testing is no silver-bullet and there are limitations and challenges towards this approach that are discussed below.
• Development process.The applied SIL development process is not systematically reported in the literature.The focus is devoted to functional-and behavioral aspects, simulation modeling, optimal control modeling, results, and structure (components, and their mutual relation).Thus, it remains a challenge to adapt SIL based on a set of guiding principles.• Real-world operation aspects.SIL is insufficient in testing the physical aspects of a system.It is challenging to accurately model all aspects of real-world operating conditions and hardware interactions.PIL, PHIL, and HIL testing must still be used for testing physical aspects that belong in that domain i.e. low-level signaling concerns, physical connections, physical component failure, processor capabilities, etc.Furthermore, critical conditions of security and safety may not be appropriate to test using SIL and it is still necessary to test in the real world.• Simulation model validity and fidelity.SIL relies on a simulation model of the environment.The experiments conducted on these models are therefore dependent on (i) the validity of the model, i.e. to which degree and under which circumstances do the simulation model represent the real-world.(ii) The fidelity of the simulation model which is the degree/accuracy to which the simulation model represents its real-world counterpart.Fidelity involves a tradeoff between accuracy and computation time.A higher accuracy demands higher computational resources.Sacrificing accuracy yields faster computation, but the simulation must still provide usable results.Determining validity and fidelity of the SIL approach is a challenge.• Interoperability aspects.The software under test and the simulation model must be interoperable which requires well-defined interfaces, protocol and data exchange formats starting already in the early stages of development.These issues are still fundamental to solve in SIL.• Real-time and concurrency aspects.Separating the control logic from the simulation model into separate components implies that these execute concurrently and possibly in real-time.This fosters challenges of synchronization, timeliness, traceability, and other properties of real-time systems.• Scaling.Scaling is not magically solved through SIL testing.However, scaled test scenarios may be easier to conduct because the controller and simulation model may be cheaper and easier to instantiate on scale.• Controller emulator acquisition.A premise for SIL testing is that the actual control software is tested.Therefore, it is implied that the software must be able to execute on a development platform.If the control software is written in Java a Java Virtual Machine (JVM) must be available.If the control software is written in C/C++ for embedded devices, then an embedded emulator must be available.• Cost/benefit analysis.It is a challenge to decide whether SIL testing is worth pursuing based on cost and potential benefits.Even estimating the costs for SIL test-ing alone is challenging.Costs are challenging because it depends on the domain, scale, and analytic metrics to provide.The benefits also vary and are therefore hard to quantify.However, in many of the domains such as the energy sector, faults cannot be tolerated during experimental endeavors on a large scale.Such experiments jeopardize the business, well-being or can cause serious harm.But experimentation is needed to evaluate innovative solutions and scenarios prior to real-world deployment.These benefits are purely functional (i.e., testing the controller against the system), but there must also be added benefits from the project management perspective e.g., rapid development, rapid feedback cycles, reduced risks, and overall costs.
Claims on this matter can only be validated through rigid project monitoring and evidence analysis.

Study validity threats
This section accounts for validity threats within this scoping review.The identified threats are enumerated and addressed below.
• Evidence collection.The evidence collection does not include grey literature in the extent of doctorial theses, patents, or standards.Furthermore, white literature such as industry reports, non-academic publications, technical blogs, software manuals, are not included.Therefore, this study does not explore literature beyond white literature.One such example of a white paper is found in Reyes (2024).• Selection bias.The literature search is subject to selection bias to the extent that the inclusion criteria may be narrow in the domain dimension of search string G1.This search string may not uncover the entire energy domain with regards to all in-theloop paradigms.However, G1 contains 46 hits and has a reasonable size for evidence for a scoping review study.This problem is not inherent when the focus is narrowed to software-in-the-loop across domains, because search string G3 is domain agnostic.• Language bias.Depending on the field (domain), scholars may use different terms for addressing in-the-loop semantics.(i) Papers may address in-the-loop in the main body text but does not entitle to address it in the title.Examples of this can be found in Čech et al. (2017) and (Steinbrink, et al. 2017).(ii) Papers may use abbreviations such as MIL, SIL, PIL and HIL directly in the title.Such examples can be found in the papers (Nibert et al. 2012).

Conclusion
The study applies a scoping review methodology to find, screen, analyze and synthesize the literature, including conference and journal papers from the significant engineering databases ACM, IEEE Xplore, Scopus, and Web of Science.A thorough literature processing is conducted including screening for relevance based on inclusion criteria.The included 88 articles were full-text analyzed and categorized to map the purpose, methods, architecture, interoperability and protocols, technologies, challenges, and limitations.
The analysis result shows that hardware-based in-the-loop paradigms are commonly applied for testing low-level signaling issues.Power-hardware-in-the-loop is most frequently used to test control applications in the energy sector.Power-hardware-inthe-loop focuses on testing the physical phenomenon at the hardware level.With the transition towards a digitalized energy system and increasingly advanced interconnected applications, hardware-based in-the-loop testing approaches fall short.Softwaredefined in-the-loop testing received increased attention over the past decade but is less frequently applied in the energy sector.
There is a gap in the literature on how to systematically develop software-based inthe-loop lab environments to verify and validate new control strategies, technologies, regulations, and policies in energy-and electricity systems.This includes functional and non-functional requirements, conceptual design, architecture, interfaces, and compliance with interoperability standards.There was found no previous work that address these issues.
Based on the scoping review, there is limited research on: • Modeling of energy-and electricity systems using software-in-the-loop approaches, game engine technology, agent-based simulation, and co-simulation.• Applying software-in-the-loop for energy-and electricity systems to test emergent behavior in an ecosystem context in applications such as EV charging, Power-to-X (PtX), demand-response, DER, and renewable energy.• Software-in-the-loop testing at scale in environments that are highly heterogeneous and geographically distributed.This includes the problem of achieving interoperability across sectors.• Using high-fidelity models, for example, digital twins for twin-in-the-loop testing.
• Reproducibility and benchmarking of SIL testing.
Therefore, the following future research directions are proposed: • Development of a conceptual software-in-the-loop testing framework with reference architectures, guiding design principles, use cases, non-functional properties in energy-and electricity systems.• Explore and apply game engine technology, digital twins, agent-based simulation, and co-simulation to construct an energy metaverse that can be used for softwarein-the-loop testing.• Identify interoperability issues and propose solutions that can be used for sector coupling in the energy ecosystem.

Table 1
Search terms in the literature search

Table 2
Generic search strings G2Title = (software-in-the-loop) AND (architect* OR pattern OR framework) G3 Title = (software-in-the-loop) G4 Title = ("software-in-the-loop") AND (architect* OR framework OR platform OR pattern OR interop* OR interconnect* OR environment OR exchange OR communicat* OR protocol OR distribut* OR synchroniz* OR emulator OR simulat*)

Table 3
Database search hits

Table 4
Dimensions extracted from the analyzed material

Table 5
Application domains of SIL

Table 7
Purposes of SIL in energy-and electricity systems

Table 8
Experimental validation and report advantages of SIL

Table 9
Methods and approaches of SIL in energy-and electricity systems

Table 10
System under test, virtual plant, and metrics use RTDS to simulate an IEEE 34-bus distribution network.The network has three phases, 23 busses, 19 distribution lines, and 19 loads.The authors in Nguyen et al. (2019b) use RTDS to simulate microgrids and renewable energy sources.The authors in Nguyen et al. (2019a) simulate the future Western Danish power system in RTDS.RSCAD is a platform (or ecosystem) thatTable 11 SIL technologies in energy-and electricity systems

Table 12
Architectural properties of SIL in energy-and electricity systems

Table 14
Database specific syntax G1 Web of Science (WoS) TI = ((electricity OR "distribution grid" OR "demand side" OR "consumption side" OR "distributed energy resources" OR DER OR solar OR photovoltaic* OR PV OR "electric vehicle" OR EV OR "heat pump") AND (architect* OR pattern OR communicat* OR connect* OR protocol* OR interop* OR interconnect* OR exchange OR synchroniz* OR distribut* OR "digital environment" OR "virtual environment" OR emulator) AND (in-the-loop OR "model-based systems" OR "model-based software" OR "modelbased design" OR MBD OR MBS*) ) G1 Scopus TITLE ((electricity OR "distribution grid" OR "demand side" OR "consumption side" OR "distributed energy resources" OR DER OR solar OR photovoltaic* OR PV OR "electric vehicle" OR EV or "heat pump") AND (architect* OR pattern* OR communicat* OR connect* OR protocol* OR interop* OR interconnect* OR exchange OR feedback* OR synchroniz* OR distribut* OR "digital environment" OR "virtual environment" OR emulator) AND (in-the-loop OR "model-based systems" OR "model-based software" OR "model-based design" OR MBD OR MBS*))

Table 15
Search results content type