Preprint
Article

This version is not peer-reviewed.

Physics-Informed Closed-Loop Python–OpenDSS Co-Simulation for Fault Detection and Localization in Inverter-Dominated Microgrids

Submitted:

25 August 2026

Posted:

26 August 2026

You are already at the latest version

Abstract
Protection of inverter-dominated microgrids remains challenging due to limited fault currents, bidirectional power flows, and rapidly changing operating conditions. Although machine learning (ML) techniques have shown considerable promise for fault detection and localization, most existing studies rely on offline datasets that do not fully capture inverter control dynamics and evolving network interactions, often resulting in optimistic performance estimates. This paper proposes a physics-informed closed-loop Python–OpenDSS co-simulation framework that embeds ML-based diagnostic models within a bidirectional simulation environment. The framework enables systematic fault injection, synchronized measurement acquisition, automated feature extraction, and closed-loop diagnostic evaluation under both grid-connected and islanded operating modes. Its performance is evaluated using IEEE 5-, 13-, and 15-bus inverter-dominated microgrid (MG) test systems to investigate scalability and robustness under realistic operating conditions. Results reveal a measurable performance gap between offline evaluation and closed-loop validation, demonstrating that offline accuracy does not necessarily reflect deployable performance. Random Forest and CNN models maintain strong robustness as system complexity increases, whereas K-Means clustering degrades substantially. The proposed framework establishes a reproducible, physics-consistent methodology for benchmarking artificial intelligence (AI)-based protection schemes under realistic microgrid operating conditions.
Keywords: 
;  ;  ;  ;  

1. Introduction

The rapid proliferation of distributed energy resources (DERs), including photovoltaic (PV) systems, battery energy storage systems (BESS), and power electronic converters, has fundamentally reshaped the operational characteristics of modern distribution networks. Microgrids have emerged as a key architectural solution for integrating renewable energy, enhancing local resilience, and supporting both grid-connected and islanded operation. However, the dominance of inverter-interfaced DERs introduces significant challenges for conventional protection schemes. Unlike synchronous generator-based systems, inverter-dominated microgrids exhibit limited fault current contributions, bidirectional power flows, rapid control actions, and dynamically evolving topologies, reducing the effectiveness of traditional overcurrent and impedance-based protection methods originally designed for passive radial feeders [1,2]. To address these limitations, researchers have explored ML and artificial intelligence (AI) techniques for fault detection and localization. Supervised learning algorithms such as Random Forest (RF), Support Vector Machines (SVM), Decision Trees (DT), and Artificial Neural Networks (ANN) have demonstrated strong classification performance using voltage and current measurements obtained from simulated or historical datasets [1,3,8]. Deep learning approaches further enhance diagnostic capability by automatically extracting nonlinear and transient features from time-series electrical measurements without extensive manual feature engineering [3,6]. In parallel, graph-based learning methods have been proposed to exploit the inherent topological structure of power systems, improving generalization across diverse network configurations [9]. Despite these advances, most existing studies evaluate diagnostic performance using static offline datasets generated prior to model training. Under such workflows, data generation, feature extraction, model training, and performance evaluation occur independently of the physical evolution of the microgrid. Consequently, the reported classification accuracies reflect controlled conditions that do not capture the dynamic behavior of inverter-dominated systems during fault progression, converter control response, or topology reconfiguration [3,7,11]. This limitation becomes increasingly significant as distribution networks transition toward converter-dominated operation, where reduced fault current magnitudes and complex control dynamics fundamentally alter the electrical signatures traditionally used for protection [4,5].
Alternative methodologies have attempted to improve diagnostic robustness. Graph Neural Networks (GNNs) demonstrate resilience to measurement noise and unseen configurations through neighborhood aggregation mechanisms that explicitly model electrical connectivity [9]. Signal-processing-based approaches combining synchronized phasor measurements, time-frequency analysis, and Clarke transformations have also been explored for fault detection under inverter-dominated conditions [12,13]. Hybrid and ensemble learning techniques further improve classification accuracy by combining multiple learning paradigms or incorporating optimization-based feature selection and hyperparameter tuning [14,17,19,20]. While these methods enhance performance under specific scenarios, they generally remain dependent on offline datasets and evaluate ML models independently of the physical simulation environment. From a simulation perspective, OpenDSS has become a widely adopted platform for modelling distribution networks and microgrids due to its ability to represent feeders, distributed generation, inverter-interfaced resources, and protection devices with high fidelity [16]. However, in most reported studies, OpenDSS functions as a standalone solver used solely for offline data generation. The interaction between the simulator and the learning algorithm is therefore unidirectional, with limited capability for iterative feedback, continuous scenario generation, or adaptive diagnostic evaluation under dynamically evolving operating conditions [16,17].
Despite these advances, a fundamental research gap remains. Existing ML-based fault diagnosis frameworks predominantly rely on static offline datasets, while physics-based simulators are typically employed only for offline data generation. As a result, there is limited understanding of how diagnostic models behave when continuously interacting with evolving microgrid dynamics, particularly under inverter-limited fault conditions, varying operating modes, and increasing network complexity. Furthermore, systematic benchmarking of multiple learning algorithms within a unified, physics-consistent closed-loop simulation environment across different IEEE benchmark microgrids remains largely unexplored [8,11,16]. To bridge this gap, this paper proposes a physics-informed closed-loop Python–OpenDSS co-simulation framework for fault detection and localization in inverter-dominated microgrids. Unlike conventional offline workflows, the proposed framework establishes a bidirectional interaction between OpenDSS and Python, enabling programmatic fault injection, synchronized acquisition of three-phase electrical measurements, automated feature extraction, ML-based diagnosis, and iterative performance evaluation within a unified simulation loop. By embedding learning algorithms directly into the physics-based simulation environment, the proposed methodology enables evaluation of diagnostic performance under realistic operating conditions rather than relying solely on pre-generated datasets.
The framework is validated using IEEE 5-, 13-, and 15-bus inverter-dominated microgrid test systems operating under both grid-connected and islanded modes. Four representative learning algorithms, namely, Support Vector Classifier (SVC), Random Forest (RF), Convolutional Neural Network (CNN), and K-Means clustering, are evaluated under identical fault scenarios to investigate diagnostic robustness, scalability, and topology-dependent performance. Through this comparative evaluation, the framework demonstrates the measurable performance gap between conventional offline ML assessment and physics-consistent closed-loop validation, providing a more realistic benchmark for AI-based protection schemes in modern microgrids.
The key contributions of this work are summarized as follows.
  • A physics-informed closed-loop Python–OpenDSS co-simulation framework that tightly couples ML algorithms with a validated microgrid simulator for automated fault injection, synchronized measurement acquisition, and iterative diagnostic evaluation.
  • Demonstration that offline ML accuracy represents an optimistic upper bound and does not necessarily reflect deployable diagnostic performance under inverter-dominated operating conditions, thereby emphasizing the importance of physics-consistent validation.
  • Systematic benchmarking of four representative learning algorithms under identical dynamically generated fault scenarios across IEEE 5-, 13-, and 15-bus microgrids, enabling comparative assessment of robustness, scalability, and topology-dependent performance.
  • A reproducible and physics-consistent methodology for evaluating AI-based protection systems under realistic microgrid operating conditions, establishing a practical foundation for future research on adaptive, explainable, and optimization-assisted fault diagnosis in converter-dominated power systems.
The remainder of this paper is organized as follows. Section 2 presents the proposed closed-loop methodology. Section 3 describes the simulation framework and experimental setup. Section 4 presents and discusses the experimental results. Finally, Section 5 concludes the paper and outlines directions for future research.

2. Proposed Closed-Loop Diagnostic Methodology

This section presents the physics-informed closed-loop methodology used for fault detection and localization in inverter-dominated microgrids. The approach integrates machine-learning-based diagnostic models directly within a bidirectional Python–OpenDSS co-simulation environment. The framework enables automated fault synthesis, synchronized measurement acquisition, feature extraction, and learning-based inference within a unified simulation loop. All methodological components are formulated independently of any specific MG topology; system-level configurations and experimental parameters are detailed later in the case study section.

2.1. Closed-Loop Co-simulation Architecture

The proposed diagnostic workflow is built around a closed-loop interaction between Python and OpenDSS. OpenDSS serves as the physics-based simulator responsible for computing the electrical response of the microgrid under normal and faulted conditions. Python orchestrates fault injection, retrieves three-phase measurements, performs feature extraction, executes machine-learning inference, and updates model parameters based on diagnostic outcomes. Figure 1 illustrates the architecture of the closed-loop framework. Each simulation cycle consists of four sequential operations:
  • Programmatic Fault Synthesis in Opendss,
  • Streaming of Voltage and Current Measurements to Python,
  • Feature Extraction and Ml-based Diagnosis, and
  • Iterative Refinement of Model Parameters.
This loop enables continuous evaluation of diagnostic robustness under dynamically evolving operating conditions, ensuring that learning models interact directly with physics-consistent system behavior rather than static offline datasets.

2.2. Fault Scenario Synthesis and Measurement Acquisition

Fault scenarios are generated by activating OpenDSS fault elements at selected buses and line segments. Multiple fault types, including single-line-to-ground (SLG), line-to-line (LL), and three-phase (LLL) faults, are considered [5]. The fault impedance is defined in equation (1)
Z f = R f + j X f   ,
where R f represent the resistive and reactive components of the fault, respectively. Both low- and high-impedance conditions are evaluated to capture the reduced fault-current magnitudes characteristic of inverter-dominated systems. Fault initiation time and duration are kept consistent across all simulations to ensure repeatability. During each event, three-phase voltage and current measurements are collected at predefined monitoring points. These locations are selected to provide adequate observability of fault-induced disturbances without requiring full network instrumentation. All simulations use a fixed sampling frequency f s and time-domain measurements are segmented into analysis windows of duration T w . Each window forms the basis for subsequent feature extraction and dataset construction. RMS-based feature vectors are generated for supervised learning, while unlabeled vectors support unsupervised analysis.

2.3. Feature Extraction and Representation

To ensure computational efficiency and robustness under inverter-limited fault currents, time-domain root-mean-square (RMS) features are extracted from the measured signals [22,23]. For each phase current i p ( t ) , the RMS value over a window containing N = f s T w samples is computed as in equation (2).
I p , R M S = 1 N k = 1 N i p 2 ( k )
Voltage Rms Values Are Computed Analogously. Equation (3) Defines the Resulting Feature Vector
x = I a , R M S I b , R M S I c , R M S V a , R M S V b , R M S V c , R M S
This representation avoids reliance on high-frequency transient components or frequency-domain transformations, making it suitable for real-time implementation and resilient to noise and parameter uncertainty [24].

2.4. Ml-Based Fault Diagnosis

To evaluate the proposed closed-loop framework across different machine-learning paradigms, four representative algorithms were selected. Support Vector Classifier (SVC) represents margin-based supervised learning, Random Forest (RF) represents ensemble tree-based learning, Convolutional Neural Networks (CNNs) represent deep learning capable of learning complex nonlinear relationships, while K-Means provides an unsupervised baseline for comparison. These algorithms were selected because they are widely adopted in microgrid fault diagnosis literature and collectively represent the principal categories of ML techniques used for power system protection. Their inclusion enables a balanced assessment of diagnostic robustness under identical closed-loop operating conditions. Fault diagnosis is formulated as a supervised learning problem in which the objective is to map the extracted feature vector x to a fault state label y . Given a training dataset ( x i , y i ) } i = 1 M , the classifier learns a decision function, as given in equation (4)
y ^ = f x ; θ ,
where θ denotes the model parameters. Model training is performed by minimizing the empirical loss function as presented in equation (5)
θ * = arg min θ 1 M i = 1 M L y i , f x i ; θ
An initial calibration phase establishes baseline diagnostic performance. The trained models are then deployed within the closed-loop simulation environment, where they are continuously evaluated using newly generated fault data [24].

2.5. Fault Localization and Iterative Learning

Fault localization is achieved by discretizing the network into predefined zones and treating location estimation as a classification or regression task. The learning model predicts the faulted section index as defined in equation (6)
s ^ = g x ,
which corresponds to the physical location of the fault within the network. This data-driven approach avoids reliance on impedance-based or traveling-wave methods, which are sensitive to parameter variations and converter dynamics. The closed-loop framework supports iterative learning by updating model parameters after each simulation batch. Diagnostic metrics such as detection accuracy and localization error are evaluated, and hyperparameters are refined accordingly. While the methodology is general, its practical implementation requires specific microgrid configurations, fault scenarios, and learning settings, which are detailed in the subsequent case study section.

3. Simulation Framework and Experimental Setup

This section describes the simulation environment, benchmark microgrid models, fault configurations, and measurement settings used to evaluate the proposed closed-loop diagnostic framework. All simulations are performed using OpenDSS as the physics-based power system simulator, while Python orchestrates fault generation, measurement acquisition, feature extraction, and ML inference through a bidirectional COM interface. This integrated environment ensures reproducible, physics-consistent evaluation of diagnostic performance across the IEEE 5-, 13-, and 15-bus inverter-dominated microgrid test systems.

3.1. Mg Test Systems

Three benchmark inverter-dominated microgrid models: the IEEE 5-, 13-, and 15-bus systems are used to assess the scalability and topology-dependent performance of the proposed diagnostic framework. Each benchmark system incorporates distributed photovoltaic (PV) generation, battery energy storage systems (BESS), inverter-interfaced distributed energy resources (DERs), static and dynamic loads, configurable feeder impedances, and transformer models representative of modern distribution microgrids.
Although the three benchmark systems differ in network size and feeder complexity, they share a common electrical architecture and modelling philosophy to ensure consistent implementation across all case studies. Figure 2 presents the IEEE 5-bus microgrid, which serves as the reference architecture for the proposed framework. The system comprises a utility grid interface, a step-down transformer, a PV inverter connected at Bus 3, a BESS inverter connected at Bus 5, programmable fault injection between Buses 4 and 5, and CT/VT-based measurement units at Bus 5. Figure 3 illustrates the IEEE 15-bus microgrid, featuring distributed loads across fifteen buses, PV generation at Bus 6, BESS integration at Bus 8, fault injection at Bus 7, and synchronized measurement acquisition at Bus 10. Together, these benchmark systems enable evaluation of diagnostic robustness under increasing network complexity, inverter-limited fault currents, and varying operating conditions.

3.2. Fault Scenario Configuration

Fault scenarios were designed to represent realistic disturbances encountered in inverter-dominated microgrids. Three fault categories were considered: single-line-to-ground (SLG), line-to-line (LL), and three-phase (LLL) faults. Faults were programmatically injected at multiple buses and feeder sections to evaluate the influence of fault location and network topology on diagnostic performance. Fault resistance varied between 0.01 Ω and 50 Ω in accordance with equation (1), enabling evaluation under both low- and high-impedance conditions. Fault inception was fixed at 0.4 s, while fault duration varied between 100 and 200 ms to ensure consistent comparison across all benchmark systems. Table 1 summarizes the fault scenarios evaluated in this study.

3.3. Measurement Configuration and Data Generation

Voltage and current measurements were sampled at 5 kHz and segmented into 100 ms analysis windows for feature extraction. Each simulation cycle produced synchronized three-phase voltage and current waveforms, from which RMS feature vectors were derived for supervised learning, while unlabeled feature vectors were retained for unsupervised analysis. Python automatically managed scenario initialization, fault injection, measurement retrieval, and dataset generation through the OpenDSS COM interface. The resulting datasets were divided into training and testing subsets using an 80%/20% split for all benchmark systems, enabling consistent evaluation across different network configurations.

3.4. Software Environment

The proposed framework was implemented in Python 3.13.14 using Jupyter Notebook as the development environment. OpenDSS was interfaced with Python through the COM automation interface to enable bidirectional communication between the simulation engine and the ML modules. Supervised learning algorithms were implemented using the scikit-learn library, while the CNN model was developed using the TensorFlow/Keras framework. All simulations were executed on a computer running Microsoft Windows 10, equipped with an AMD Ryzen 7 7000-series processor, 32 GB RAM, and an NVIDIA GeForce RTX GPU.

3.5. Experimental Workflow

All simulations follow a unified closed-loop execution workflow that integrates Python-based learning algorithms with the OpenDSS physics-based simulator. The complete experimental workflow is summarized in Figure 4.
This workflow ensures that diagnostic performance is evaluated under physics-consistent operating conditions, enabling realistic benchmarking of machine-learning-based protection schemes.

4. Results and Discussion

This section presents a comprehensive evaluation of the proposed closed-loop diagnostic methodology. Results are organized according to the two-stage validation strategy: (i) Python-based offline evaluation to establish baseline learning performance, and (ii) closed-loop OpenDSS microgrid validation to assess robustness under physics-consistent operating conditions. The analysis covers time-domain waveform behavior, fault detection accuracy, localization performance, and comparative assessment between offline and closed-loop learning. The IEEE 5-, 13-, and 15-bus systems were selected to represent increasing levels of network complexity, thereby enabling systematic evaluation of the scalability of the proposed framework.

4.1. Time-Domain Fault Response Analysis

Time-domain voltage and current responses obtained from OpenDSS provide insight into the dynamic behavior of inverter-dominated microgrids during fault conditions. Fault events produce amplitude distortions, phase unbalance, and transient oscillations before the system returns to steady-state operation through inverter control actions. Unlike conventional synchronous-generator-based systems, inverter-interfaced DERs contribute limited fault current, reducing the prominence of fault signatures and increasing the complexity of fault detection and localization. Consequently, robust feature extraction becomes essential for distinguishing fault conditions from normal operating variations. In this study, these waveform responses form the basis for RMS feature extraction, providing compact and noise-tolerant representations for subsequent ML-based fault detection and localization.

4.2. Python-Based Offline Performance

Offline evaluation using the classData.csv dataset establishes a baseline for assessing the performance of the ML models under static operating conditions. Table 2 summarizes the classification accuracy, precision, recall, and F1-score obtained for the evaluated supervised and deep learning algorithms. PCA-assisted classifiers consistently achieved the highest performance, with Decision Tree and Random Forest attaining 100% classification accuracy, while PCA + SVC achieved 98%. The CNN model also produced near-perfect performance, indicating that the RMS feature representation effectively captures the electrical characteristics associated with different fault conditions. In contrast, KNN achieved 84% accuracy, suggesting greater sensitivity to overlapping feature distributions and local neighborhood variations within the offline dataset. Overall, the results demonstrate that RMS-based features provide strong discriminatory capability when training and testing are performed under controlled offline conditions. Although these results confirm the suitability of the selected feature representation for fault classification, the near-perfect performance achieved by several models should be interpreted as an offline performance benchmark rather than an indicator of deployment accuracy. Because the training and testing datasets were generated under controlled simulation conditions, the reported accuracy represents an optimistic upper bound. The following subsection therefore evaluates the representative models within the proposed closed-loop Python–OpenDSS framework to assess their robustness under dynamically evolving operating conditions.
Table 2. Offline Python-only fault detection performance using the classData.csv dataset.
Table 2. Offline Python-only fault detection performance using the classData.csv dataset.
Algorithm Accuracy (%) Precision Recall F1-Score Type
PCA + SVC 98 0.98–1.00 0.98–1.00 0.98–1.00 Supervised
PCA + Decision Tree 100 1.00 1.00 1.00 Supervised
PCA + Random Forest 100 1.00 1.00 1.00 Supervised
KNN (K=5) 84 0.80 0.80 0.79 Supervised
Linear SVC 97 0.90 0.96 0.93 Supervised
Gaussian NB 100 1.00 1.00 1.00 Supervised
CNN 100 1.00 1.00 1.00 Deep Learning

4.3. Closed-Loop Opendss Microgrid Performance

The trained models were deployed within the proposed closed-loop Python–OpenDSS framework to evaluate diagnostic performance under physics-consistent operating conditions. Table 3 summarizes the fault detection and localization performance across the IEEE 5-, 13-, and 15-bus benchmark microgrids. Overall, diagnostic performance decreased as network complexity increased, reflecting the greater variability of electrical responses introduced by additional buses, distributed energy resources, and inverter control interactions. Random Forest consistently achieved the highest performance across all benchmark systems, maintaining detection accuracies between 98.7% and 100% while preserving high fault localization accuracy. The strong performance of Random Forest is attributed to its ensemble learning strategy, which reduces prediction variance and improves robustness to topology-dependent feature variability. The CNN model also demonstrated consistently high performance, achieving detection accuracies above 97% across all benchmark systems. Its ability to learn hierarchical temporal representations from RMS feature sequences enabled effective generalization under varying operating conditions. In contrast, SVC exhibited a gradual reduction in performance as system complexity increased, suggesting greater sensitivity to overlapping decision boundaries in larger microgrid topologies. K-Means clustering consistently produced the lowest performance, with detection accuracies close to 50% across all benchmark systems. This behavior reflects the limited suitability of unsupervised clustering for fault diagnosis in inverter-dominated microgrids, where fault signatures exhibit significant overlap and nonlinear characteristics. The consistently high performance achieved by Random Forest and CNN demonstrates their robustness within the proposed physics-informed framework, while the observed reduction in SVC and K-Means performance highlights the importance of evaluating diagnostic algorithms under realistic closed-loop conditions rather than relying solely on offline benchmark datasets.
Figure 5. Closed-loop detection accuracy and macro F1-score of the evaluated ML algorithms across IEEE microgrids, demonstrating robustness of RF and CNN under realistic operating conditions.
Figure 5. Closed-loop detection accuracy and macro F1-score of the evaluated ML algorithms across IEEE microgrids, demonstrating robustness of RF and CNN under realistic operating conditions.
Preprints 230169 g004

4.4. Fault Localization Performance Analysis

Fault localization performance was evaluated as a section-level classification task across the IEEE 5-, 13-, and 15-bus benchmark microgrids (Table III). The results indicate that localization accuracy decreases gradually as network complexity increases, reflecting the greater electrical interaction and feature overlap introduced by additional buses and inverter-interfaced distributed energy resources. The IEEE 5-bus system achieved the highest localization accuracy due to its compact topology and clear spatial separation of fault signatures. As the network expanded to the IEEE 13-bus and IEEE 15-bus configurations, localization became progressively more challenging because increased inter-bus coupling reduced the distinctiveness of fault-induced electrical responses. Despite this increase in complexity, the Random Forest and CNN models consistently maintained high localization accuracy across all benchmark systems, demonstrating strong scalability and robustness under inverter-dominated operating conditions. These results confirm that the proposed closed-loop Python–OpenDSS framework can accurately identify faulted network sections while maintaining reliable localization performance as microgrid size and topological complexity increase.

4.5. Offline Ml Evaluation vs. Closed-Loop Microgrid Performance Comparison

Figure 6 compares the diagnostic performance obtained from offline ML evaluation with that achieved under the proposed closed-loop Python–OpenDSS framework. While several supervised models achieved near-perfect accuracy during offline evaluation, a measurable reduction in performance was observed under closed-loop operating conditions. This reduction reflects the influence of inverter-limited fault currents, dynamic operating modes, measurement uncertainty, and topology-dependent electrical interactions that are not fully represented in static offline datasets. Despite this increased complexity, the Random Forest and CNN models maintained consistently high diagnostic performance, demonstrating strong robustness to realistic microgrid operating conditions. In contrast, SVC exhibited greater sensitivity to the increased variability introduced by larger network topologies, while K-Means remained unsuitable for reliable fault diagnosis because of the nonlinear and overlapping nature of inverter-dominated fault signatures. The observed performance gap between offline and closed-loop evaluation demonstrates that high classification accuracy obtained from static datasets does not necessarily translate into equivalent performance during realistic microgrid operation. Consequently, closed-loop validation provides a more representative assessment of deployable ML-based protection systems by evaluating diagnostic algorithms within a physics-consistent simulation environment

4.6. Fault-Type Classification Analysis

Fault-type discrimination was further evaluated using confusion matrix analysis under closed-loop operating conditions. Figure 7 presents the confusion matrix obtained using the CNN classifier for representative fault categories. The strong diagonal dominance indicates that the proposed framework consistently distinguishes between single-line-to-ground (SLG), line-to-line (LL), and three-phase (LLL) faults across the evaluated benchmark microgrids.
The limited off-diagonal entries indicate that only a small number of LL and LLL faults exhibit overlapping electrical signatures under inverter-dominated operating conditions. Such behavior is expected because inverter control actions limit fault current magnitudes and reduce the separation between transient responses compared with conventional synchronous-generator-based systems. Despite these challenges, the CNN model maintains high classification accuracy by effectively learning representative fault characteristics from the extracted RMS features. Overall, the confusion matrix confirms that the proposed closed-loop Python–OpenDSS framework provides reliable fault-type discrimination under realistic microgrid operating conditions while maintaining strong robustness across different network topologies.

4.7. Discussion

The results demonstrate that high offline classification accuracy does not necessarily translate into deployable performance in inverter-dominated microgrids. Closed-loop validation revealed the effects of reduced fault currents, topology-dependent electrical interactions, and inverter control dynamics, all of which contributed to performance degradation that was not captured under static offline conditions. These findings highlight the importance of evaluating ML algorithms within physics-consistent simulation environments. Among the evaluated models, Random Forest achieved the most robust performance across all benchmark systems, while the CNN model maintained strong generalization through effective learning of fault characteristics. In contrast, K-Means consistently underperformed, indicating that unsupervised clustering is less suitable for fault diagnosis in inverter-dominated microgrids. Unlike previous studies that rely primarily on offline datasets [3,6,9], the proposed framework integrates ML inference directly with OpenDSS, enabling realistic diagnostic evaluation under dynamically evolving operating conditions. Although the study is based on IEEE benchmark microgrids, the proposed framework provides a reproducible foundation for future hardware-in-the-loop and real-world validation. Overall, the results demonstrate that physics-informed closed-loop co-simulation offers a more realistic benchmark for AI-based protection systems than conventional offline ML evaluation.

5. Conclusions and Future Work

This paper presented a physics-informed closed-loop diagnostic framework that integrates ML-based fault detection and localization within a Python–OpenDSS co-simulation environment. Unlike conventional offline learning approaches, the proposed framework evaluates diagnostic models under realistic inverter-dominated operating conditions through continuous interaction between physics-based simulation and ML inference. Evaluation on the IEEE 5-, 13-, and 15-bus benchmark microgrids demonstrated that Random Forest and CNN models maintained robust fault detection and localization performance despite increasing network complexity and inverter-limited fault signatures, whereas K-Means clustering showed poor performance under realistic operating conditions. The results further demonstrated that high offline classification accuracy does not necessarily translate into deployable performance, highlighting the importance of physics-consistent closed-loop validation for AI-based protection systems. This methodology provides a scalable and reproducible approach for benchmarking fault diagnosis algorithms across diverse microgrid topologies. Future work will focus on hardware-in-the-loop validation, real-time implementation, adaptive measurement placement, and explainable ML techniques to further improve protection performance in inverter-dominated power systems. Overall, the proposed methodology provides a practical foundation for the development and validation of intelligent protection systems for future inverter-dominated distribution networks.

Author Contributions

Conceptualization, Z.E.N.; methodology, Z.E.N.; software, Z.E.N.; validation, Z.E.N.; formal analysis, Z.E.N.; investigation, Z.E.N.; resources, UNISA; data curation, Z.E.N.; writing—original draft preparation, Z.E.N.; writing—review and editing, Z.E.N.; visualization, Z.E.N.; supervision, Z.W.; project administration, UNISA; funding acquisition, UNISA. All authors have read and agreed to the published version of the manuscript.

Data Availability Statement

The datasets generated during this study are available from the corresponding author upon reasonable request.

Acknowledgments

This work was partly supported by the South African National Research Foundation under Grant no. AJCR230704126719.

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
CNN Convolutional Neural Network
AI Artificial Intelligence
ML Machine Learning
MG Microgrid
DERs Distributed Energy Resources
SVM Support Vector Machine
SVC Support Vector Classifier
COM Component Object Model (OpenDSS interface)
CT Current Transformer
VT Voltage Transformer
BESS Battery Energy Storage System
LL Line-to-Line Fault
LLL Three-Phase Fault
RMS Root-Mean-Square
SLG Single-Line-to-Ground Fault
PV Photovoltaic
RF Random Forest
GNN Graph Neural Network

References

  1. Srivastava; Kumar, A.; Kumar, A.; Sriharsh, S.; Parida, S.K.; Priyadarshi, H. Random Forest-based fault detection and localization in microgrid using simplified measurements. Proc. IEEE IAS Global Conf. Emerging Technologies (GlobConET), Bangalore, India, 2023; pp. 1–6. [Google Scholar]
  2. Ghosh, S.; Ranjan, R.; Sinha, A.S. Analysis and prediction of the events occurring in the scaled-down model of IEEE 5-bus system using machine learning algorithms. Int. J. Eng. Res. Technol. 2020, 9, 1–7. [Google Scholar]
  3. Long, J.; Yang, G.; Yan, L.; Liu, T. Research on online fault detection, classification and location of microgrid based on deep learning. Proc. Int. Conf. Electrical Systems and Electric Power (ICESEP), Chengdu, China, 2024; pp. 1071–1076. [Google Scholar]
  4. Rao, G.K.; Jena, P. A novel fault identification and localization scheme for bipolar DC microgrid. IEEE Trans. Ind. Informat. 2023, 19, 11752–11764. [Google Scholar] [CrossRef]
  5. Zhi, N.; Ding, Y.; Zhang, H.; Qiu, J. Research on fault detection and localization in meshed DC microgrids based on local information measurements. Proc. IEEE Int. Symp. Power Electronics for Distributed Generation Systems (PEDG), Shanghai, China, 2025; pp. 811–816. [Google Scholar]
  6. Nguyen, H.; Tran, T.; Kim, J. Deep learning-based fault diagnosis for inverter-dominated microgrids. IEEE Access 2021, 9, 123456–123468. [Google Scholar]
  7. Li, Y.; Yu, C.; Shahidehpour, M.; Yang, T.; Zeng, Z.; Chai, T. Deep reinforcement learning for smart grid operations: Algorithms, applications, and prospects. Proc. IEEE 2023, 111, 1055–1096. [Google Scholar] [CrossRef]
  8. Viana, E.R.; Sousa, A.S.; De, R.; Henrique, F.; Solic, P. A comparison framework for fault classification methods in power system distribution network. Proc. 6th Int. Conf. Smart and Sustainable Technologies (SpliTech), Split, Croatia, 2021; pp. 1–6. [Google Scholar]
  9. Kordowich, G.; Oelhaf, J.; Maier, A.; Bayer, S.; Jaeger, J. A graph neural network-based approach for power system protection. Proc. IEEE PowerTech, Milan, Italy, 2025; pp. 1–6. [Google Scholar]
  10. Li, Y.; Zhao, J.; Wang, H. Adaptive protection coordination in DER-rich distribution networks. IEEE Trans. Smart Grid 2023, 14, 2456–2468. [Google Scholar]
  11. Vivek, B.; Srinitha, G.; Hareesh Teja, B.; Mallala, B. Electrical fault detection and localization using machine learning. Proc. Int. Conf. Expert Clouds and Applications (ICOECA), Hyderabad, India, 2024; pp. 820–825. [Google Scholar]
  12. Pan, K.; et al. PMU-based fault detection in renewable-integrated distribution systems. Electr. Power Syst. Res. 2022, 204. [Google Scholar]
  13. Geetha, R.; et al. Detection and classification of faults in a power system with inverter penetration based on a real-time machine learning application. Proc. 4th Int. Conf. Smart Technologies, Communication and Robotics (STCR), India, 2025; pp. 1–6. [Google Scholar]
  14. Pansari, D.; Yadav, A. Adaptive fault diagnosis in renewable integrated microgrids using hybrid machine learning approach. Electr. Power Syst. Res. 2026, 251, 112297. [Google Scholar] [CrossRef]
  15. Bohara, B.; Krishnamoorthy, H.S. Prognostic health monitoring of DC microgrid with fault detection and localization using machine learning techniques. Proc. IEEE ECCE, Nashville, TN, USA, 2023; pp. 1555–1562. [Google Scholar]
  16. Girgis, A.; Islam, M.R.; Marwali, M.N. Recent developments in OpenDSS-based distribution system simulation and analysis. Electr. Power Syst. Res. 2022, 213. [Google Scholar]
  17. Radmanesh, H.; Hadadi, A. A hybrid machine learning and IED-based fault detection scheme for microgrids. Results Eng. 2025, 26, 105369. [Google Scholar] [CrossRef]
  18. Brahma, S.; Girgis, A.A. Data-driven protection of distribution systems with high DER penetration. IEEE Trans. Smart Grid 2021, 12, 3456–3467. [Google Scholar] [CrossRef]
  19. Karthick, R.; Saravanan, R.; Arulkumar, P. Fault detection and fault location in a grid-connected microgrid using optimized deep learning neural network. Optim. Control Appl. Methods 2025, 46, 896–911. [Google Scholar] [CrossRef]
  20. Tiwari, S.P.; KR, R. A protection scheme based on machine learning-based algorithm for fault detection in microgrid considering line-to-ground faults and weather scenarios in the Asian region. Electr. Eng. 2025, 107, 10965–10980. [Google Scholar] [CrossRef]
  21. Pradhan, R.; et al. Intelligent fault detection in AC microgrid using ensemble learning technique and data-driven clustering. Proc. IEEE ICPC2T, 2025; pp. 861–866. [Google Scholar]
  22. Bukhari, S.B.A.; et al. Deep learning-driven fault detection and classification in microgrids using temporal convolutional network. Comput. Electr. Eng. 2026, 129, 110777. [Google Scholar] [CrossRef]
  23. Ravesh, N.R.; Ramezani, N.; Ahmadi, I.; Nouri, H. A hybrid artificial neural network and wavelet packet transform approach for fault location in hybrid transmission lines. Electr. Power Syst. Res. 2022, 204, 107721. [Google Scholar] [CrossRef]
  24. Ioan, A.; Munteanu, C. The localization of electrical faults in powerlines using machine learning methods. Proc. ACEMP & OPTIM, 2025; pp. 1–6. [Google Scholar]
  25. Dutt, E.A. Machine learning approaches for fault detection in renewable microgrids. E3S Web Conf. 2024, 511, 01030. [Google Scholar] [CrossRef]
Figure 1. Closed-loop architecture of the proposed Python–OpenDSS diagnostic framework, illustrating fault synthesis, measurement acquisition, feature extraction, and iterative ML-based inference.
Figure 1. Closed-loop architecture of the proposed Python–OpenDSS diagnostic framework, illustrating fault synthesis, measurement acquisition, feature extraction, and iterative ML-based inference.
Preprints 230169 g001
Figure 3. IEEE 15-bus inverter-dominated microgrid used as the reference test system, including PV and BESS inverters, programmable fault injection, and CT/VT measurement points.
Figure 3. IEEE 15-bus inverter-dominated microgrid used as the reference test system, including PV and BESS inverters, programmable fault injection, and CT/VT measurement points.
Preprints 230169 g002
Figure 4. Closed-loop experimental workflow integrating Python-based machine-learning inference with the OpenDSS physics-based simulation engine across four execution layers.
Figure 4. Closed-loop experimental workflow integrating Python-based machine-learning inference with the OpenDSS physics-based simulation engine across four execution layers.
Preprints 230169 g003
Figure 6. Comparison of offline and closed-loop fault detection accuracy.
Figure 6. Comparison of offline and closed-loop fault detection accuracy.
Preprints 230169 g005
Figure 7. CNN confusion matrix for fault-type classification under closed-loop operating conditions.
Figure 7. CNN confusion matrix for fault-type classification under closed-loop operating conditions.
Preprints 230169 g006
Table 1. Fault scenario parameters used across IEEE microgrid test systems.
Table 1. Fault scenario parameters used across IEEE microgrid test systems.
Fault-Type Fault Resistance (Ω) Fault Location Duration (ms)
SLG 0.01–50 Multiple buses/lines 100–200
LL 0.01–50 Multiple buses/lines 100–200
LLL 0.01–50 Multiple buses/lines 100–200
Table 3. Closed-loop OpenDSS fault detection and localization performance across IEEE microgrids.
Table 3. Closed-loop OpenDSS fault detection and localization performance across IEEE microgrids.
System Algorithm Accuracy (%) F1-Macro Fault Location Accuracy (%) Remarks
IEEE-5
SVC 99.7 0.997 98.5 High separability in compact topology
RF 100 1.000 99.2 Stable
CNN 100 1.000 99.8 Strong temporal generalization
KMeans 50.1 0.39 45.0 Unreliable clustering
IEEE-13
SVC 96.8 0.95 94.3 Topology-induced degradation
RF 99.1 0.99 98.4 Robustness
CNN 97.5 0.96 97.1 Benefits from temporal features
KMeans 54.3 0.42 47.8 Insufficient feature separation
IEEE-15
SVC 95.2 0.93 92.6 Sensitive to inter-bus coupling
RF 98.7 0.98 97.3 Higher accuracy
CNN 98.2 0.97 96.9 Handles inverter dynamics
KMeans 52.7 0.40 44.5 Not suitable for large systems
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.