Fault Detection and Diagnosis of a Photovoltaic System Based on Deep Learning Using the Combination of a Convolutional Neural Network (CNN) and Bidirectional Gated Recurrent Unit (Bi-GRU)

: The meticulous monitoring and diagnosis of faults in photovoltaic (PV) systems enhances their reliability and facilitates a smooth transition to sustainable energy. This paper introduces a novel application of deep learning for fault detection and diagnosis in PV systems, employing a three-step approach. Firstly, a robust PV model is developed and ﬁ ne-tuned using a heuristic optimization approach. Secondly, a comprehensive database is constructed, incorporating PV model data alongside monitored module temperature and solar irradiance for both healthy and faulty operation conditions. Lastly, fault classi ﬁ cation utilizes features extracted from a combination consisting of a Convolutional Neural Network (CNN) and Bidirectional Gated Recurrent Unit (Bi-GRU). The amalgamation of parallel and sequential processing enables the neural network to leverage the strengths of both convolutional and recurrent layers concurrently, facilitating e ﬀ ective fault detection and diagnosis. The results a ﬃ rm the proposed technique’s e ﬃ cacy in detecting and classifying various PV fault types, such as open circuits, short circuits, and partial shading. Furthermore, this work underscores the signi ﬁ cance of dividing fault detection and diagnosis into two distinct steps rather than employing deep learning neural networks to determine fault types directly.


Motivation
The global energy landscape is undergoing a significant transformation, placing a growing emphasis on renewable energy sources (RESs) to mitigate carbon emissions and address climate change.The World Energy Transitions Outlook 2023 by IRENA underscores the pressing need for bold, transformative measures to expedite the global energy transition.By 2030, the installed capacity of renewable power must expand nearly fourfold to propel the world toward this transition [1].Within the field of RESs, solar photovoltaic (PV) energy plays a pivotal role in shaping a more sustainable future.As of early 2022, the global installed PV capacity surpassed the Terawatts threshold, constituting two thirds of the projected increase in global renewable capacity for 2023 [2].Moreover, PV remains the most cost-effective option for new electricity generation in numerous countries, with anticipated reductions in generation costs by 2024 [3].
PV systems are susceptible to various types of faults, from temporary to permanent failures, and these faults can potentially have significant impacts on system performance and safety.Thus, the early detection of defects and their diagnoses are crucial for ensuring the long-term reliability and sustainable operation of the entire PV system.In the literature, diverse fault detection and diagnosis methods have been proposed, each varying in speed, complexity, sensor requirements, and the ability to identify types of faults.

Literature Review
In recent years, in contrast to standard model-based fault detection procedures [4][5][6], which involve simulating the PV installation's performance and comparing the simulated output power with the monitored one, machine learning (ML) and deep learning (DL) techniques have gained popularity and are considered promising solutions for fault detection and diagnosis in PV systems.Numerous studies have evaluated the effectiveness of ML and DL approaches in fault detection and diagnosis in PV systems.For instance, Belaout et al. developed a multiclass adaptive Neurofuzzy technique for fault detection and diagnosis in PV systems [7].This algorithm can detect partial shading conditions, increased series resistance, faulty bypass diodes, and PV module short circuit faults.However, this technique cannot detect short circuits or defective strings under varying weather conditions.Madeti and Singh introduced an algorithm based on k-nearest neighbors (KNN) for real-time fault detection in PV systems, demonstrating its capability to detect and classify open-circuit faults, line-to-line faults, and partial shading faults [8].However, it is worth noting that the method, while computationally efficient, is not flawless in terms of accuracy.Chen et al. proposed an intelligent fault detection approach based on I-V characteristics, utilizing an emerging kernel-based extreme learning machine.This method exhibits high accuracy in detecting and classifying faults in PV arrays [9].Bendary et al. proposed two adaptive neuro-fuzzy inference system (ANFIS)-based controllers to address cleaning, tracking, and faulty issues in PV systems [10].This method relies on associating actual measured values of current and voltage with trained historical values for these parameters, accounting for ambient changes in conditions, including irradiation and temperature.Syafaruddin et al. suggested a simple and fast method based on several artificial neural networks (ANNs) capable of independently identifying the short-circuit location of PV modules in one string [11].Garoudja et al. introduced a fault detection and diagnosis approach based on a Probabilistic Neural Network (PNN), which was tested using noisy and noiseless data [12].Similarly, Vieira et al. proposed a fault detection method combining PNN with a Multilayer Perceptron algorithm.The process does not necessitate extensive datasets from pre-existing systems and primarily focuses on detecting short-circuited modules and disconnected strings [13].While the results derived from the use of these machine learning approaches are promising, they also exhibit drawbacks, particularly with respect to extensive databases leading to overfitting.Furthermore, machine learning methods present limitations in representing features of complex high-dimensional data [14].
Deep learning (DL) has emerged as the next generation of machine learning, gaining considerable attention for its prowess in pattern recognition, data mining, and knowledge discovery.Its notable advantage lies in its capacity to learn high-level abstract features from substantial datasets, which is particularly beneficial for classification problems [15].Liu et al. introduced a fault diagnosis method for a PV array utilizing stacked auto-encoder (SAE) and clustering.This approach mines inherent I-V characteristics, enabling automatic feature extraction and fault diagnosis [16].Similarly, based on output I-V characteristic curves and input ambient condition data, a novel deep residual network (Res-Net) based on an intelligent fault detection and diagnosis approach was proposed by Chen et al. [17].Gao and Wai presented a fault identification method for PV arrays, employing a model that combines a Convolutional Neural Network (CNN) and residual gated recurrent unit (ResGRU) to observe differences in I-V curves under various fault conditions, achieving a classification accuracy of 98.61% [18].Eldeghad et al. proposed a deep learning technique optimized via a particle swarm optimization (PSO) heuristic combination algorithm for fault diagnosis in PV systems.This algorithm exhibited good results in fault detection and is promising for enhancing system efficiency, reliability, and safety [19].Appiah et al. leveraged long short-term memory (LSTM) to extract fault features, subsequently inputting them into the softmax regression classifier for fault detection and diagnosis [20].Integrating DL with Infrared Thermography (IRT) for fault diagnosis in PV systems is another alternative, as presented in [21].This study's results show that the IRT-DL approach outperforms other IRT-ML methods in accuracy and classification.However, the utilization of IRT for fault detection in PV systems is confronted by enduring challenges.These challenges encompass constraints associated with surface defects, vulnerability to dynamic system conditions, heightened equipment expenses, and limitations in detecting specific fault types.

Contribution
This paper aims to contribute to advancing fault detection and diagnosis methods for PV systems, focusing on improving reliability, efficiency, and safety.This novel approach integrates a Convolutional Neural Network (CNN) and Bidirectional Gated Recurrent Unit (Bi-GRU) within a deep learning framework.This unique combination of parallel and sequential processing empowers the neural network to harness the strengths of both convolutional and recurrent layers simultaneously, facilitating effective fault detection and diagnosis.Unlike previous methods (existing in the literature and described above), which rely on I-V curves, the proposed approach utilizes dynamic PV system outputs at maximum power points (MPPs), which are more accessible to obtain for most PV systems, overcoming the challenges associated with accurate I-V curve measurements.The methodology uses an accurate PV model to create reliable databases representing PV system operation in healthy and faulty states.One year of monitored data from an actual PV installation in Czechia was used to calibrate the Sandia Array Performance Model (SAPM) PV model and validate the proposed fault detection and diagnosis procedure.
The remainder of this paper is organized as follows: Section 2 describes the chosen case study and the approach employed for PV modeling, followed by an in-depth explanation of the proposed fault detection methodology and the metrics utilized for its assessment.Section 3 presents the results acquired from PV modeling and the evaluation of the suggested fault detection procedure.Section 4 delivers a comparative analysis, contrasting the proposed method with existing approaches.The conclusions that can be derived from this work are summarized in Section 5.

Experimental Setup
The PV system used in this study comprises frameless Glass-Glass Cadmium Telluride (CdTe) thin-film PV panels installed on an experimental house in Buštěhrad, Czechia.The PV panels were seamlessly integrated into the east and west sides of the pitched roof, replacing the standard tiles (Figure 1).The total size of the PV system is equal to 3.84 kW.It is connected to four APsystems YC1000-3 three-phase microinverters.Each side of the roof contains 24 panels connected to two microinverters, and each microinverter has four channels connecting one string composed of three PV modules.The PV system's outputs, namely current (Impp), voltage (Vmpp), and power (Pmpp) at the maximum power point, have been monitored for every channel in a five-minute timestep since October 2018.There are two Si-RS485TC-2T-MB irradiance sensors (for both east and west) with external temperature sensors glued to the back side of PV modules used for monitoring the solar irradiance (G) and module temperature (Tm) in a one-minute resolution.The proposed fault detection and diagnosis procedure was validated using one year of measured data from the east side of the roof.Tables 1 and 2 summarize the characteristics of the selected PV generator and the PV panel data, respectively.

PV Modeling and Database Creation
Developing a high-quality database that precisely outlines the operation of a PV system is essential for effective fault detection and diagnosis.Therefore, it is imperative to have a dependable simulation model that accurately depicts the system's behavior in both standard and faulty conditions.The Sandia Array Performance Model (SAPM), an empirical model from Sandia National Laboratories [22], was chosen in this work for its simplicity and reliability in precisely characterizing and simulating PV array performance.The model demonstrated notable accuracy during extensive validation across modules of diverse technologies, as emphasized in [23].Estimations of the PV array outputs-current (Impp), voltage (Vmpp), and power (Pmpp) at the maximum power point (MPP)-are directly facilitated through the following equations: where Imp (A) and Vmp (V) represent the PV module current and voltage under Standard Test Conditions (STCs).The coefficients C0 and C1, dimensionless and empirically determined, relate Imp to the effective irradiance.The normalized temperature coefficient for Imp is denoted as αImp (°C −1 ), while C2 (dimensionless) and C3 (V −1 ) are empirical coefficients linking Vmp to the effective irradiance (Ee).Additionally, Nsc is the number of cells in a PV module, δ(Tm) represents the thermal voltage per cell at temperature Tm, q denotes the elementary charge (1.60218 × 10 −19 coulomb), n is the ideality factor, k is the Boltzmann's constant (1.38066 × 10 −23 J/K), and βVmp (V/°C) stands for the temperature coefficient for module Vmp at STC.The SAPM encompasses various coefficients and parameters (C0, C1, C2, C3, n, αImp, and βVmp) that are unknown, as the PV module's manufacturer does not typically provide them.These parameters are commonly derived through testing and actual measurements of PV modules/arrays under static and dynamic conditions.The parameter extraction technique employed in this work aligns with the approach detailed in [23], as it involves using the artificial bee colony (ABC) optimization algorithm.This algorithm assesses the model parameters for PV arrays operating in real-world conditions, utilizing daily profiles of solar irradiance and module temperature and monitored DC output current and voltage profiles.The optimization process aims to minimize the objective function, defined as the root mean square error (RMSE) in Equation ( 6), where θ = f (C0, C1, C2, C3, n, αImp, and βVmp), N denotes the length of measured data, and Vi and Ii represent the measured voltage and current at data point i, respectively.
The finalized PV system model forms the foundation for constructing databases that comprehensively capture the system's performance under outdoor conditions.This model is instrumental in generating datasets encompassing optimal operation and intentionally simulated defects, utilizing yearly solar irradiance and module temperature profiles.The simulated scenarios, reflecting common issues in grid-connected PV systems, are outlined below and depicted in Figure 2 The resulting databases encapsulate three crucial attributes-irradiance, temperature, and the output power at the maximum power point (MPP)-extracted from each simulated operational scenario.

Fault Detection and Diagnosis Procedure
The primary objective of this study was to establish a robust and reliable fault detection and diagnosis procedure for PV systems through combining Convolutional Neural Network (CNN) and Bidirectional Gated Recurrent Unit (Bi-GRU) deep learning techniques.This subsection starts with a general description of CNNs and Bi-GRUs.Then, the proposed hybrid model-based fault detection is detailed.Finally, it provides the evaluation metrics used to assess the performance of the proposed technique.

Convolutional Neural Network (CNN)
CNNs are a supervised and specific class of deep learning (DL) algorithms [24].They differ from classical neural networks by using convolution in layers instead of matrix multiplication.A CNN is composed of two parts: the feature extractor part and the classifier part.The first part contains input layers, convolutional layers (CLs), and pooling layers (PLs), stacked layer by layer in the network as feature extractors.The input data matrix is passed through a progression of filters, creating new features called feature maps.Then, the convolution maps are flattened and concatenated into a CNN code feature vector.This CNN code at the output of the convolutional part is then associated with the input of a second part made of fully connected layers (multilayer perceptron).The classifier part is dedicated to classification and comprises fully connected (FC) layers and an output layer.The FC layers receive the features obtained by the last pooling layer as the input.The output is the last layer with one neuron per category [25].The utilization of Conv1D layers in our model reflects the leveraging of CNNs for feature extraction, tailored explicitly to datasets showcasing spatial structures.CNNs excel in unraveling spatial relationships and subtle networks inherent in data, as mirrored by the Conv1D layers in our model.This capability is pivotal in comprehensively understanding fault evolution and manifestation within the PV system, aligning seamlessly with the model's architectural implementation.The general architecture of a CNN is depicted in Figure 3.

Gated Recurrent Unit (GRU)
The GRU stands out as a special Recurrent Neural Network (RNN) variant originally proposed by Cho et al. [26].Tackling the issue of gradient vanishing inherent in traditional RNNs, GRU combines the memory function of long short-term memory (LSTM) while exhibiting faster execution due to a reduced parameter count in the training process [27].The GRU unit incorporates two gates-the reset gate and the update gate (as illustrated in Figure 4)-to regulate information transmission.The update gate determines how much the prior hidden layer state (ht -1) is preserved in the current hidden layer state (ht).It processes information from ht -1 and the input of the present moment (xt) using an activation function, with a smaller activation result indicating greater information retention.The expression for the update gate is given as: The reset gate decides how much information from the earlier moment is written into the candidate's memory state (h t).Similar to the update gate, the reset gate processes ht -1 and xt using an activation function, where a more significant activation result implies more information is written to h t.The reset gate is defined as: GRU combines the reset gate (rt) with ht − 1 and xt to form a candidate memory state (h t) through the following expression: The current hidden layer state (ht) is then obtained by combining the prior hidden layer state (ht -1) with the candidate memory state (h t) using the following expression: In the provided equations, xt represents the input of the current moment; ht -1 and ht represent the hidden layer state of the prior and present moment, respectively; h t represents the candidate memory state; rt and zt represent the reset and update gate, respectively; Wzx, Wrx, and Wh x pertain to the weight matrix concerning xt for the update gate, the reset gate, and the candidate memory state, respectively; Wzh, Wrh, and Wh h pertain to the weight matrix concerning ht -1 for the update gate, the reset gate, and the candidate memory state, respectively; and bz, br, and bh denote the corresponding biases.

Bidirectional Gated Recurrent Unit (Bi-GRU)
The Bi-GRU unit, derived from a bidirectional RNN [28], comprises two layers of GRUs with distinct information transmission directions, as illustrated in Figure 5.In the Bi-GRU configuration, a reverse layer is incorporated into the single-layer GRU network to optimally leverage input information.This architecture employs two hidden layers to capture both past and future information.The current state is influenced not only by historical data but also by future information, acknowledging that neglecting one-way communication may impact the prediction performance of the GRU model.Both hidden layers are connected to the same output layer, and the output of the current state () is expressed as follows: where ℎ » and ℎ « denote the output of the forward GRU layer and the backward GRU layer, respectively.In fault detection within PV systems, identifying issues such as open circuits, short circuits, and shading faults is crucial for ensuring system reliability.While traditional unidirectional cyclic neural networks focus solely on past-to-future dependencies, bidirectional GRU (Bi-GRU) networks excel in capturing bidirectional dependencies by processing information from both historical and anticipated future conditions.By orchestrating two GRU networks moving in opposite directions-decoding past to present and future to present-Bi-GRUs provide a comprehensive understanding of a system's temporal dynamics, significantly enhancing fault detection capabilities.This approach goes beyond mere historical data by incorporating insights into potential future conditions, which is especially useful in scenarios like anticipating shading faults.The ability of Bi-GRUs to comprehend evolving patterns and dependencies aids in discerning subtle fault patterns influenced by future conditions that might otherwise go undetected.A detailed representation of the architectures of the models developed for fault detection and diagnosis is given in Figure 7.

Fault Detection and Diagnosis Procedure
To assess the performance of the proposed hybrid model, various metrics were employed, including Categorical Accuracy, Precision, Pecall, and F1-Score, as outlined in Equations ( 12)- (15).These metrics involve True Positives (TPs), True Negatives (TNs), False Positives (FPs), and False Negatives (FNs) [33].Categorical Accuracy represents the ratio of correct predictions to the total number of predictions, calculated as follows: Precision signifies the ratio of correctly classified positive samples to the total number of classified positive samples, denoted as: Recall reflects the ratio of positive samples correctly classified as positive to the total number of positive samples, expressed as: Recall is more critical than Precision in threat detection, as false negatives can lead to severe consequences.However, there is an increasing desire to improve the efficiency of detector systems by reducing the rate of false positives.The F1-score is used when Precision and Recall are equally important and is defined as the harmonic mean of Precision and Recall: For enhanced interpretability in multiclass classification, we incorporated averaging methods.Both macro and weighted averages for Precision, Recall, and F1-score were computed.Macro-average (Macro avg) involves an unweighted mean, potentially penalizing the model for poor performance in minority classes.In contrast, weighted average (weighted avg) accounts for the number of true instances in each class, addressing class imbalance and favoring the majority class.
Ultimately, the model was compiled using the Adam optimizer and categorical crossentropy loss as defined by Equation ( 16).During the training process, strategies such as early stopping, model checkpointing, and learning rate reduction callbacks were employed to optimize model performance.Following training, the model underwent evaluation on the test set, computing its accuracy based on the generated classification report and confusion matrix.

Results
This section presents the results derived from our PV modeling approach and the prepared databases, illustrating the operation of the PV system under diverse weather conditions and various fault scenarios.Subsequently, the efficacy of the proposed innovative fault detection and diagnosis procedure, which integrates both CNNs and Bi-GRU networks, is assessed considering different performance metrics.

PV Model Validation and Constructed Database
The PV model, relying on the empirical SAPM, was used to emulate the actual behavior of the PV installation considered in this study.Daily monitored profiles including PV output power at the MPP (Pmpp), on-plane solar irradiance (G), and module temperature (Tm) were employed to extract the unknown parameters of the model.The extracted parameters are given in Table 3, and the model's validation across multiple days is depicted in Figure 8.The results indicate a good agreement between the measured and simulated hourly values of the PV system's output power.The calculated total Root Mean Square Error (RMSE) value considering clear sky, semi-cloudy, and overcast days equals 2.69%.These findings underscore the effectiveness of the parameter identification process and the resilience of the SAPM.The PV system model was subsequently utilized to generate databases that comprehensively depict the system's performance under real outdoor conditions.These databases encompass datasets representing instances of optimal operation and intentionally simulated defects, using yearly monitored solar irradiance (G) and module temperature (Tm) profiles.A section of the simulated PV output, considering various faults as described in Section 2.2, is visually presented in Figure 9. Shading faults are randomly generated throughout the year.Figure 9 illustrates the impact of different faults on the PV output, emphasizing the consideration of temporary defects associated with shadings.

Evaluation of the Proposed Fault Detection Procedure
In the data generation phase, the recorded data undergo systematic annotation with relevant class labels.Specifically, 52,385 raw data samples were used for detection, while 43,624 were reserved for diagnosis.The initial focus of the preprocessing pipeline was on data quality and reliability.The removal of rows with missing values was executed to achieve this, effectively filtering out undesirable data.Following this, identifying duplicate rows enables the detection and potential elimination of redundant information.To fortify the dataset's robustness, our attention was then directed towards handling outliers in numerical columns.The Interquartile Range (IQR) method calculates lower and upper bounds for each numerical column, and values falling outside these bounds are replaced with the corresponding boundary values.This contributes to a more accurate representation of the data distribution and reduces the impact of extreme values on subsequent analyses [34].
Post-preprocessing, 23,774 data samples were assigned for detection, and 19,788 data samples were allocated for diagnosis.The next steps involved separating the dataset into features (X) and target labels (y).Features (X) were derived from columns associated with solar irradiance (G), module temperature (Tm), and PV array output power (Pmpp), while labels corresponded to the 'System_State' column.Subsequently, the Features set underwent standardization using the StandardScaler from scikit-learn.This crucial step fosters convergence and enhances performance in deep learning models by ensuring consistent feature scaling.The length of sequential data (num_time_steps) and the number of columns (features) present in the scaled dataset were then defined.This was achieved through iterations that create sequences and corresponding labels based on the specified time steps.Sequences were generated by considering a data window with a length of num_time_steps.The loop appends these sequences and their respective labels to separate arrays (for the detection dataset, we obtained 23,575 sequences, leaving 19,589 sequences for the diagnosis dataset).The dataset was split into three sets-training, validation, and test-using the train_test_split function from scikit-learn.The training set comprised 70% of the data, while the remaining 30% was evenly divided between the validation (15%) and test (15%) groups.The specifics of constructing the detection and diagnosis datasets are outlined in Table 4.
Finally, an input layer was defined for the model and configured to accommodate the specified number of time steps and columns (features) present in the sequences (Tm, G, Pmpp, resulting in three features per time step).Additional details include the following:  The fine-tuning of the deep learning model's parameters was accomplished using the grid search optimization method [31].This meticulous tuning process systematically tests various combinations of internal hyperparameters to identify the optimal configuration that maximizes performance for our fault detection and diagnosis models.The conclusive hyperparameters for fault diagnosis and detection models are detailed in Tables 5 and 6.The findings based on the proposed deep learning (DL) architecture, which integrates CNN and Bi-GRU layers for the fault detection phase, are presented in Table 7 and visualized in Figures 10 and 11.The evaluation of the classification report and loss value underscores the exceptional performance of the binary classification model in effectively discerning faulty and healthy systems, as detailed in Table 7.For Class 0, representing the Faulty System, the model showcases outstanding precision, accurately identifying 100% of instances predicted as faulty and minimizing false positives.The recall value of 1.00 is equally noteworthy, capturing all instances of faulty systems while minimizing false negatives.The F1-score, standing at 1.00, signifies a well-balanced and effective performance.Turning to Class 1, the healthy system, the model accurately identifies nearly all instances predicted as healthy (precision value of 0.99) and captures 98% of actual instances of healthy systems (recall value of 0.98), striking an effective balance.The corresponding F1score of 0.99 further reinforces the model's effectiveness in classification.In the overall evaluation, the model achieves an impressive accuracy of 99.45%, emphasizing its ability to make accurate predictions across both classes, as illustrated in Figure 3.The macroaverage and weighted average values of 0.99 further affirm the solid overall performance.
The results indicate that the model has effectively learned underlying patterns during training, reflected in its high precision and recall for both faulty and healthy systems.The low loss value of 0.0080, depicted in Figure 11, underscores the model's robust capability in accurate PV system fault classification.The reported recall value of 0.98 for "Class 1", representing the healthy system, signifies the precise identification of 98% of actual instances, with the remaining 2% being false negatives.In the context of fault detection in PV systems, misclassifying a small proportion of healthy system instances is considered less critical than the opposite scenario.While a few cases of healthy systems may be misclassified, the overall model performance remains satisfactory for PV system fault detection, mitigating safety concerns associated with misclassifying faults as healthy instances.The outcomes of the proposed hybrid model for the diagnosis phase are presented in Table 8 and visually represented in Figures 12 and 13.Notably, the classification results showcase exceptional performance, marked by an impeccable overall accuracy of 100%.The comprehensive classification report in Table 8 highlights key metrics in the evaluation process.Precision, denoting the ratio of correctly predicted positive observations to the total predicted positives, maintains a flawless score of 1.00 across all fault classes, underscoring the model's precision in fault-type prediction.Similarly, recall, indicating the ratio of correctly predicted positive observations to all observations in the actual class, also achieves a perfect score 1.00 for each fault type, affirming the model's efficacy in capturing all instances of each fault type.The F1-score, a weighted average of precision and recall, uniformly registers a perfect score of 1.00 for all classes, indicating a harmonious balance between precision and recall.Figure 13 depicts the achieved meager loss value of 0.0001, approaching zero, underscoring the model's high accuracy in predictions and its adeptness in learning intricate patterns and features essential for accurate classification.Consequently, the model showcases exceptional capabilities in fault classification, yielding perfect precision, recall, and F1-score for each fault type.

Discussions
To highlight the effectiveness of our hybrid deep learning model architecture, which combines a CNN with a Bi-GRU for fault detection and diagnosis, we conducted a comparative analysis with various alternative approaches, including CNN, CNN-LSTM, and CNN-BiLSTM models, all following the same architecture as our models.Additionally, we followed the same steps as in our study to ensure a fair and comprehensive comparison.We fine-tuned the internal hyperparameters for each algorithm using the grid search approach.
The obtained results listed in Table 9 reveal that during the detection phase, the CNN-LSTM achieved a precision score of 98.59%, and CNN-BiLSTM demonstrated the highest overall accuracy of 98.76%.In comparison, the CNN alone showed the lowest precision of 96.22%.In contrast, our deployed CNN-Bi-GRU model outperformed all, achieving an exceptional accuracy of 99.46%.Shifting to the diagnosis phase, CNN displayed notable progress and achieved an accuracy of 97.40%, while CNN-LSTM and CNN-BiLSTM reached 100% accuracy.The CNN-Bi-GRU model, also achieving 100% accuracy, surpassed the CNN method, emphasizing the hybrid model's superior diagnostic capabilities.These results affirm the strength and effectiveness of the CNN-Bi-GRU hybrid model, showcasing its superiority in fault detection and diagnosis over individual models.
The proposed model demonstrates superior accuracy, recall, F1-score, and precision, with lower loss in both the detection and diagnosis phases.This enhanced performance can be attributed to the integrated feature extraction method, harnessing the strengths of both CNNs and Bi-GRUs.Furthermore, the efficacy of the softmax function in classification, similar to artificial neural networks (ANNs), which are recognized for their effectiveness in fault detection or classification in PV systems, further enhances our model's remarkable outcomes.
To delve deeper into the suboptimal accuracy observed in the single CNN-based architecture, we identified that the model struggles in detecting temporal faults.The model encountered difficulties distinguishing between the healthy and the fault states induced by shading, as illustrated in Figure 14 (left side).Nevertheless, upon excluding shading faults from the training data and focusing solely on permanent faults, the single architecture exhibited improved performance, attaining 100% accuracy in the detection phase, as evident in the normalized confusion matrix depicted in the right part of Figure 14.
Finally, the analyses suggest that adopting a two-phase model structure proves more advantageous when dealing with temporary faults such as shading faults.This differentiation is crucial since discerning between these fault types and the PV system's healthy state poses a considerable challenge.The complexities associated with identifying shading faults or similar issues demand a more nuanced approach, and a two-phase model enables a more accurate representation of the system's behavior in such scenarios.In contrast, a single-phase model might be sufficient for permanent faults like open or short circuits.These faults are generally easier to distinguish from the healthy state, and a more straightforward model structure may yield satisfactory performance.Therefore, the model structure selection should align with the nature and complexity of the prevalent faults in the PV system, ensuring an optimal balance between accuracy and computational efficiency.

Conclusions
Photovoltaic (PV) systems are prone to various faults, ranging from temporary to permanent failures, each potentially exerting a substantial impact on performance and safety.The timely identification of these faults and their diagnosis are imperative for ensuring the enduring reliability and sustainable operation of the entire PV system.This study introduces an innovative application of deep learning (DL) techniques tailored explicitly for fault detection and diagnosis within PV systems.
The proposed DL architecture integrates Convolutional Neural Network (CNN) and Bidirectional Gated Recurrent Unit (Bi-GRU) layers to enhance fault identification and diagnosis in PV systems.Incorporating Conv1D layers at the outset facilitates robust feature extraction, harnessing their capacity to discern intricate patterns within the data.Subsequently, the Bi-GRU layers operate sequentially, capitalizing on their bidirectional processing capabilities to comprehend the temporal dependencies and subtleties inherent in PV system-monitored data.
The combination of parallel CNN and sequential Bi-GRU processing empowers the neural network model to proficiently detect and classify various fault types, including open circuits (inverter disconnection), short circuits, and partial shading.This novel approach optimizes fault identification by exploiting the complementary strengths of convolutional and recurrent layers, enabling the model to interpret spatial and temporal information simultaneously, thereby ensuring accurate fault detection and diagnosis.
Two key pillars underpin this combined hybrid model approach.The first pillar harnesses the precision of a simulation model, specifically the Sandia Array Performance Model (SAPM), finely tuned through metaheuristic optimization algorithms to replicate actual PV system behavior.The accuracy of this model was validated against measured data from a real PV installation, yielding a Root Mean Square Error (RMSE) value lower than 3%.The second pillar involves the construction of reliable databases that meticulously represent normal and abnormal PV system operations.
Finally, in a comparative analysis featuring established methods such as CNN, CNN-LSTM, and CNN-BiLSTM, our hybrid model showcased exceptional accuracy rates exceeding 99% for both the fault detection and diagnosis phases.This performance superiority underscores the significance of aligning model structure selection with the nature and complexity of prevalent faults in PV systems to ensure an optimal balance between accuracy and computational efficiency.
In summary, the presented fault detection approach demonstrated promising results within the context of the studied PV installation.Our future analyses will aim to encompass PV plants with different specifications, particularly those allowing for the testing and evaluation of the approach on various faults-including PV module degradation, dust accumulation, line-to-line faults, etc. Further, our future work will focus on implementing the proposed approach in autonomous hardware such as Raspberry Pi, with the aim of assessing its performance in real-time operations.This step is crucial in gaining valuable insights into the practical application and efficiency of the developed fault detection methodology.

Citation:
Photovoltaic System Based on Deep Learning Using the Combination of a Convolutional Neural Network (CNN) and Bidirectional Gated Recurrent Unit (Bi-GRU).

Figure 1 .
Figure 1.PV system used to validate the proposed fault detection procedure.
:  Healthy system: This scenario represents the normal operation of the PV system without any anomalies. Three short-circuited modules: This case involves disconnecting one channel of the microinverter. Six short-circuited modules: In this situation, two channels from one microinverter are disconnected. Nine short-circuited modules: This scenario entails having three channels of one microinverter disconnected. Open-circuit faults: A situation where one microinverter of the PV system becomes non-functional. Shading faults: This scenario replicates the effects of partial shading experienced by PV systems due to factors such as cloud movement or the presence of nearby objects during specific times.It includes different shading on various days and hours throughout the year.

Figure 2 .
Figure 2. A simple representation of the layout of the PV system, along with the faults considered in this study.

Figure 3 .
Figure 3. General architecture of a Convolutional Neural Network.

Figure 6 .
Figure 6.The general structure of the adopted hybrid model integrating CNN and Bi-GRU.The concluding stage of the proposed fault detection strategy involves implementing two deep learning models.The first model identifies anomalies within the PV system, while the second model diagnoses the detected faults.Both deep learning models were developed using Python with Tensorflow-Keras and scikit-learn libraries [29-32].The architecture encompasses the following layers:  Input Layer: A 3D input layer with a shape of (num_time_steps, Variables) was defined. Convolutional Layers: Conv1D layers were utilized for feature extraction, with pooling and dropout being applied subsequently. Bidirectional GRU Layers: Two sets of Bi-GRU layers process the features extracted from Conv1D.The first set returns sequences, and the second set returns only the final output of each sequence.Layer normalization and dropout were applied to both GRU layers for regularization. Fully Connected Layers: Dense layers with dropout, kernel_regularizer_l2, ker-nel_regularizer_l1, and skip connections were implemented. Output Layer: A dense output layer with softmax activation for binary classification in the detection model and multiclass type in the diagnosis model.

Figure 7 .
Figure 7. Models designed for fault detection (left) and fault diagnosis (right).

Figure 8 .
Figure 8.Comparison between measured and simulated PV output power using SAPM.

Figure 9 .
Figure 9. Representative data of the DC output from the PV system operating under various faults.
 num_time_steps: Each sample has a sequence length of num_time_steps, and for the fault detection and diagnosis model, the sequence length per sample is 200 time steps. columns (features): Each time step contains three features (Tm, G, Pmpp).

Figure 10 .
Figure 10.Normalized confusion matrix of the CNN-Bi-GRU fault detection model.

Figure 11 .
Figure 11.Accuracy and loss evolution of the CNN-Bi-GRU fault detection model.

Figure 12 .
Figure 12.Normalized confusion matrix of the CNN-Bi-GRU fault diagnosis model.

Figure 13 .
Figure 13.Accuracy and loss evolution of the CNN-Bi-GRU fault diagnosis model.

Figure 14 .
Figure 14.A single CNN-based architecture model was employed for detecting all types of faults (left side) and specifically for detecting permanent faults (right side).

Table 1 .
Summary of the characteristics of the selected PV generator.

Table 2 .
PV module electrical data.

Table 4 .
The specifics of constructing the detection and diagnosis dataset.

Table 5 .
Hyperparameter tuning for the fault detection model.

Table 6 .
Hyperparameter tuning for the fault diagnosis model.

Table 7 .
Generated classification report for the fault detection model.

Table 8 .
Generated classification report for the fault diagnosis model.

Table 9 .
Comparative analysis of the proposed technique with various alternative approaches.