Employing Machine Learning for Enhancing Transient Stability of Power Synchronization Control during Fault Conditions in Weak Grids

—Grid-connected converters are exposed to the loss of synchronisation with the grid during severe voltage sags particularly when operating under weak grid condition which introduces voltage and frequency volatility. This paper presents employing machine learning methods besides modifying the converter control scheme to enhance the transient stability of power synchronization control (PSC). For early detection of synchronization instability of PSC to provide adequate time for taking correcting control actions, an encoder stacked classiﬁer is proposed which is trained to be robust against data corruption and added noise. Then, by integrating the proposed instability detection scheme to the synchronization loop of PSC, a phase freezing mode is introduced to avoid losing synchronism during grid faults. It is disclosed that the frozen synchronization loop, which is activated by the proposed instability detection scheme, can ensure synchronization stability of PSC. Time-domain simulations are conducted to conﬁrm the presented ﬁndings.

Abstract-Grid-connected converters are exposed to the loss of synchronisation with the grid during severe voltage sags particularly when operating under weak grid condition which introduces voltage and frequency volatility.This paper presents employing machine learning methods besides modifying the converter control scheme to enhance the transient stability of power synchronization control (PSC).For early detection of synchronization instability of PSC to provide adequate time for taking correcting control actions, an encoder stacked classifier is proposed which is trained to be robust against data corruption and added noise.Then, by integrating the proposed instability detection scheme to the synchronization loop of PSC, a phase freezing mode is introduced to avoid losing synchronism during grid faults.It is disclosed that the frozen synchronization loop, which is activated by the proposed instability detection scheme, can ensure synchronization stability of PSC.Time-domain simulations are conducted to confirm the presented findings.
Index Terms-Grid-interactive converter, machine learning, power synchronization control, representation learning, situation awareness, transient stability.

I. INTRODUCTION
T HE GROWING integration of Renewable Energy Sources (RESs) into weak grids, combined with the demand for transferring power between remote points, calls for the stable interconnection of grid-connected converters with weak grids.Weak grids introduce voltage and frequency volatility that necessitate a robust and reliable control of grid-connected converters [1].Thus, the combination of RESs with the existing synchronous machines should contribute to stabilizing the power system and enhancing the security of weak grids.Though, the behavior of power electronics used to interface RESs, the intermittency of RESs, and the multi-energy nature of these systems pose significant technical and operational difficulties [2].
The power system embodying synchronous machines takes advantage of synchronizing torque, damping, and inertia as the main support services during grid transients.In this regard, the emulation of synchronous machine dynamics by converters has become a progressing concept for power systems with high integration level of RESs [3].This has led to several voltage-stiff control schemes in which Power Synchronization Control (PSC), Virtual Synchronous Machine (VSM), and Synchronous Power Controller (SPC) are the leading ones [4].These voltage-stiff control schemes have been proposed to emulate the dynamic response of synchronous machines with stiff control on voltage and frequency to address the dynamic issues of the grid.Specifically, for achieving seamless integration of RESs into weak grids under normal operating condition, PSC represents a viable solution which allows transferring power between remote points of the grid [5].Also, PSC demonstrates technical advantages in ultra-weak-grid applications [6].However, during severe grid disturbances and transients in weak grids there are fundamental distinctions between a PSC-controlled voltage-source converter and a synchronous machine including limited current contribution in short-circuit faults and different transient response [4].In addition, the transient stability of PSC-controlled converters during severe grid disturbances in weak grids is vulnerable and substantially different from that of synchronous machines.
Synchronization stability of the recent voltage-stiff control schemes under large-signal disturbances has been extensively discussed in the literature [7]- [13].Specifically, the transient stability of grid-forming converters has been addressed by design-oriented analyses under large-signal disturbances by studying the equilibrium points and phase portraits in [7] and [8].Similarly, phase portraits have been used for PSC and critical clearing angle has been identified to facilitate the design of power system protection in [9].The nonlinear characteristics of the synchronization loop is also discussed in [10] where the averaging method is employed to present a time-domain expression during disturbances and to establish the related stability criterion.
However, neglecting the grid dynamics makes these design-oriented analyses inappropriate for studying the transient stability of converters under weak grid condition and in parallel systems [11], [12].The study in [11] demonstrates that the loss of synchronization following a grid voltage sag is essentially the result of transient interaction of the This work is licensed under a Creative Commons Attribution 4.0 License.For more information, see https://creativecommons.org/licenses/by/4.0/weak terminal voltage and the converter synchronization loop.In [12], the authors addressed the challenges of paralleled systems that influence the transient stability by considering the dynamics of islanded microgrids.The dynamic synchronization characteristics of grid-tied converters regarding the effect of grid impedance, controller parameters, and current references has been explored in [13] as well.Moreover, the authors in [14] developed models for the transient stability assessment of grid-tied converters exposed to severe grid faults.Finally, the study in [15] presents a modified PSC by adding dc component suppressing capability and a back-calculation anti-windup for the synchronization loop to address the transient stability of PSC at the time of short-circuit faults in weak grids.
Although the existing works have discussed the transient stability of grid-connected converters, established the related stability criterion, and developed the transient stability assessment methods, none of them focus on maintaining the synchronization during severe voltage sags in weak grids.Therefore, this paper focuses on the early detection of the converter instability due to the grid disturbances, which allows sufficient time for taking corrective control actions to preserve the synchronization with the grid.Considering the complex and challenging nature of time series forecasting, this paper employs machine learning to predict instability of PSC and proposes the related corrective control action during disturbances based on the PSC dynamics and modifies the synchronization loop.
Related applications of machine learning for power electronic systems have been presented in [16]- [25].For instance, long-short term memory (LSTM) technique has been applied in [17] and [18] to predict the stability of the smart grid and to specify the active power fluctuations.To address the destabilization effect of constant power loads under voltage variations, neural networks have been used in [19], and the authors in [20] developed a model for voltage stability prediction using an active learning solution as well.Similarly, machine learning has been used in protection of power electronic based systems and determining the possible outage of grid components in [21] and [22].Further, some data-driven control has been presented to improve frequency regulation and low-voltage ride through (LVRT) performance of converters in [23] and [24], and the data-driven control of DC power converters has been developed in [25].
Given the aforementioned issues with the transient stability analysis of PSC under weak grid condition, the current paper aims to propose a joint instability detection and control-scheme modification in order to prevent the loss of synchronization during severe disturbances by employing machine learning.The current paper contributes to the on-going effort of modifying the control of converters in weak grids, as follows.
• Analyze the deteriorating influence of the reactive power control loop on the transient stability of PSC and study the dynamics of PSC during severe voltage sags.• Integrate the methods of data reconstruction, dimension reduction, and representation learning to achieve the early instability detection of PSC during grid disturbances.• Propose a modified PSC scheme whereby the early instability detection is integrated to the synchronization loop which successfully maintains the stability of converter during grid disturbances.The rest of this paper is organized as follows: Section II briefly discusses the principles of PSC.Section III explains the transient stability of PSC in weak grids and introduces the deteriorating influence of reactive power controller on the transient stability of PSC.Section IV presents machine learning methods of data reconstruction, dimension reduction, and representation learning.Section V introduces the proposed instability detection structure.The proposed modified PSC scheme is presented in Section VI.Finally, Section VII summarizes and highlights the main conclusions of this paper.

II. PRINCIPLES OF PSC
The control scheme of PSC without virtual inertia emulation is presented thoroughly in [6], and [26].The active power control loop and the synchronization loop of PSC are demonstrated in Fig. 1.Synchronization with grid is accomplished by the power synchronization loop (PSL) as: where θ ref and K ip are the resulting phase angle and the integral gain of the synchronization loop, respectively.P ref is the active power reference, P g is the calculated active power by measurements at the point of common coupling (PCC), and ω 0 represents the grid frequency.θ g is the phase angle of the stiff grid voltage.The initial value of θ g is supposed to be zero, i.e., θ g = ω 0 t.Power angle δ represents the phase angle difference of the PCC voltage and the stiff grid voltage.Contribution of the converter in regulating the weak grid voltage and injecting reactive power is accomplished by regulating the internal-voltage delivered by where  of possible resonances: where, V 0 is the rated voltage, i dq is the current vector of the converter in SRF, and H(s) is a high-pass filter for active damping in which k d and ω d are the gain and bandwidth of the filter, respectively.It should be noted that a backup PLL is included in the synchronization loop for seamless initial synchronization with the grid [6].Linearized dynamic model describing the relation between the active power increment P (s) following an increment in the power angle θ (s) is given by J Pθ(s) as: The transmission zeros of the linearized model J Pθ(s) restrict the realizable bandwidth of the PSC control system.The place of the transmission zeros are depending on the operating point of the converter as explained in [6], [26].The particular situation in which the zeros reach to the origin is when δ = ±π/2; Thus, sufficient bandwidth and gain can not be achieved when the operating point of the converter is close to δ = ±π/2.

III. PSC TRANSIENT STABILITY
Practically, voltage-source converters interfacing renewable energy generations are connected to a dc-link regulated by energy storage for providing support services such as power quality improvement and virtual inertia emulation.As a result, the voltage of the dc-link is regulated during transients.As demonstrated in Fig. 2, the voltage source converter connects to the power system via an LCL filter (with equivalent inductance L LCL ), a star-delta transformer L trans , and two transmission lines L line1 and L line2 .The capacitance of the filter and the stray capacitance of the transmission lines have insignificant influence on the transient stability of the converter [9].Thus, the LCL filter and the two transmission lines are modeled by inductance for studying the transient stability of the converter.In the supposed control scheme, the converter adjusts the output reactive power to preserve the PCC voltage and support the grid voltage during voltage sags.In this case, the internal voltage of the converter is set at the maximum allowed value, determined by the reactive power control loop.Thus, the dynamic response of the PSC synchronization loop can be described by a first-order differential equation as: The equivalent impedance of the filter, transmission lines, and transformer defines the short-circuit ratio (SCR) of the grid.The SCR establishes bounds on the maximum possible transmitted active-power and the PSC transient stability margin which are mainly influenced by the weak-grid operating condition.Weak-grid operating condition imposes a higher power angle than a strong-grid operating condition.Furthermore, the gain and bandwidth of PSC are dependent on the power angle and the operating point of the converter.As the power angle increases, the gain and bandwidth of PSC reduce.Therefore, the transient stability of PSC is dependent on the dynamic response of the power angle.

A. Deteriorating Influence of Reactive Power Control Loop
Grid-connected converters support the grid to mitigate the adverse effects of voltage disturbances by injecting reactive power.Thus, the risk of cascaded failure and voltage collapse would be reduced.The reactive power control law introduced by ( 3) is intended to regulate the PCC voltage and inject reactive power within the limits established by grid codes for continuous operation.During a three-phase voltage disturbance, the internal voltage of the converter increases to regulate the PCC voltage as well as injecting reactive power which should be limited to the rated capacity of the converter.To better demonstrate the influence of the reactive power control loop on transient angle stability, the output active power of a PSC-controlled converter with deactivated reactive power control loop and fixed internal voltage can be expressed by where |v g | denotes the infi Ąnite bus voltage and L T is the equivalent inductance of the system which is defined by Given the reactive power controller in (3), the relationship expressed by (8) can be turned into To study the influence of the reactive power controller, the equivalent model in (10) can be used for describing the transient response of PSC.During a severe voltage sag, the grid voltage dip would lead to an immediate rise in the output reactive power of the converter due to the voltage difference between the converter and the grid.In accordance with the reactive power controller in (3), the converter internal voltage would be limited to a certain value less than the rated value to manage the output reactive power by the controller C Q (s).
Since the reactive power of the converter is limited to its rated value, during a severe voltage sag the converter internal voltage cannot instantly restore to the maximum value.In this case, V < 0 and P g,Q < P g , thus this decrease in the output power will lead to a rise in the acceleration of the power angle during the grid fault, which may result in transient angle instability.In this work, we refer to this as the deteriorating influence of reactive power controller on the transient stability of PSC-controlled converters.Although the converter internal voltage changes during severe voltage sags and faults, caused by the variation of the power angle, it is bound to a smaller value compared to the nominal value V 0 .

B. Transient Instability of PSC-Controlled Converters Following a Severe Voltage Sag
In this study, voltage sags with various duration and severity in the grid are considered where the converter is controlled by PSC during the voltage sags.The SCR of the grid also covers a range of strong grid, weak grid, and ultra-weak grid.Following a severe voltage sag, the system reaches a new stable equilibrium point if the power angle converges to a new value.This is contingent on the pre-disturbance operating point as well as the SCR value at pre-disturbance, during voltage sag, and post-disturbance operation.By substituting (10) into (7) and assuming various active power references and operating conditions, two different cases for stability analysis would be assumed.Firstly, a weak grid with an SCR greater than 1 is provided and the system reaches a stable equilibrium point after the disturbance (as shown in Fig. 3 (a) and (b)).Secondly, there are no stable equilibrium points or due to the transmission zeros of J Pθ(s) , which are located at δ = ±π/2, transient instability takes place (as shown in Fig. 3 (c) and (d)).Fig. 3 (a) and (c) illustrates the phase portraits of the two discussed stability cases, respectively.Fig. 3 (b) and (d) show the power angle trajectory of the converter following severe voltage sags fault for the stable and unstable cases, respectively.As shown in Fig. 3 (d), the direction of the active power changes and reverse active power flow (RAP) occurs.This analysis is in accordance with the parameters given in Table I and the following presumption.
• The converter output voltage is adjusted and limited by the reactive power controller to support the grid voltage during the voltage sags.• The converter can tolerate its contribution to the grid fault current.
• Because of the high-impedance weak grid, the power angle of the converter is large enough to limit the gain and bandwidth of J Pθ(s) .

C. Impact of Grid Dynamics
Impedance characteristics of the grid are needed to analyze the impact of grid dynamics on the transient stability of converters.Grid dynamics are defined by the system fault rating (i.e., the short circuit ratio (SCR)) and the ratio of the system reactance to the system resistance (the X/R ratio) [27].This study considers the typical SCRs and X/R ratios of weak grids for different voltage levels, as shown in Table I.
Under weak grid conditions when the active power capacity is limited by the grid voltage and impedance, the bandwidth of the synchronization loop of PSC decreases rapidly as the converter power angle approaches the critical value of π/2.In this case, the PSC-controlled converter may become unstable and lose synchronization following a large voltage sag.Based on the severity of the voltage sag, the grid characteristics, and the operating point of the converter, it is possible to detect transient instability in a timely manner by machine learning algorithms.Detailed algorithms are elaborated in the following sections based on the parameters given in Table I.

IV. REPRESENTATION LEARNING BY DEEP NEURAL NETWORKS
The accuracy of machine learning methods highly depends on the representation of the data they are provided.To enhance the performance and accuracy of the early instability detection of PSC via machine learning, this paper aims to employ machine learning tools to produce learned representations.Learned representations often result in much better performance than that can be obtained with unlearned representations.Then the learned representation would be used for the early instability detection of PSC during grid voltage sags.

A. Feature Selection
The proposed method exploits the measurements of the PCC voltage trajectory collected during a time interval including pre-fault and during-fault samples.Generating a proper dataset to train the machine-learning based classifier is the backbone of the intelligent transient stability assessment.The performance of the machine learning algorithm depends heavily on the representation of the given data.The generated dataset includes a large number of operating points, grid conditions, and disturbance types (i.e., disturbance duration and disturbance severity) as listed in Table II.Extracting pattern from the raw data based on a proper representation leads to fast and accurate classification.Operations such as searching a collection of data can proceed exponentially faster if the collection is structured and indexed intelligently.Designing the right set of features and the reasoning for selecting the PCC voltage and the way of generating the data collection is described in following.
Since the converter stability depends on the pre-fault operating point, the voltage sag severity, the duration of the voltage sag, and the characteristics of the grid (i.e., SCR and X/R ratio), the extracted points should represent these features influencing the converter stability.To illustrate the effects of these five factors on the transient stability of PSC, measurements of the PCC voltage regarding stable and unstable cases are shown in Fig. 4 (a) and (b), respectively.The trajectory of the PCC voltage (as shown in Fig. 4 (a) and (b)) represents the pre-fault operating condition, the disturbance severity, the ability of the converter in injecting reactive power to restore the PCC voltage, the strength and impedance characteristics of the grid, and the transient instability of the converter due to a voltage sag.The pre-fault voltage magnitude represents the pre-fault operating condition, which can be taken as an indication of the pre-fault active-and reactive power of the converter and the pre-fault power angle.The pre-fault power angle has an integral role in shaping the dynamics and transient stability of the converter.Furthermore, the voltage drop is directly related to the fault location and fault impedance, thus the PCC voltage just after the fault occurrence represents the disturbance severity which is the other major determinant of transient instability.The voltage trajectory prior to the fault clearance can be taken as an indication of the converter ability in restoring the PCC voltage by injecting reactive power and the converter stability as well.Also, the sampling window is selected large enough to encompass the time constant of the synchronization loop of PSC and small enough to provide early transient instability detection.Therefore, the PCC voltage trajectory comprises significant information for the machine learning classifier to accurately predict the converter transient stability status.Specifications of the generated data for training neural networks are listed in Table II.

B. Representation Learning
This section aims to employ machine learning to identify both the mapping from representation to output and to design the right set of features.In this study a representation learning algorithm known as autoencoder is applied to the original data which consists of an encoder function and a decoder function.The encoder converts the input data into a learned representation, whereas the decoder converts the learned representation back into the original representation.The autoencoder is trained to preserve the most important information and make the new representation robust to noise and corrupted data.Different types of encoders and decoders introduce various learned representations with diverse characteristics.Simple representations can be created by feedforward networks which map some set of input values to output values.Fig. 5 illustrates the denoising autoencoder which is adopted in this study.The autoencoder, shown in Fig. 5, is a neural network with one hidden layer.The autoencoder is trained to reconstruct the original representation with as little error as possible.The autoencoder network consists of an encoder h = f (v) and a decoder v = g(h).The hidden layer h describes the low-dimensional representation of the input v.The encoder and the decoder are trained by the back-propagation algorithm to minimize a cost function.
The dimension of the encoder output (i.e., learned representation) is chosen less than that of the input representation.At the beginning, following the input layer v, the training data ṽ is corrupted by Gaussian noise (i.e., producing the corrupted sample ṽ out of original sample v) which is of the same dimension as v.
A denoising encoder can both reduce the sensitivity to small stochastic data corruption, especially when some input data are missing, and decrease the dimension of the representation which is the input of the classification neural network for the converter instability detection.The learned representation is produced by the encoder at the next layer of M neurons.The layer is constructed by means of the weights w ml that map the contribution of input feature ṽl to the hidden layer.Firstly, an affine transformation is performed by where L is the number of samples in each time-series of the sampled PCC voltage and b m is the bias term.Next, a The squashing function f can be applied element-wise to vectors.The associated reconstruction cost function to be minimized regarding to the training data sample ṽ is expressed by The denoising autoencoder minimizes the cost function which is obtained by comparing the reconstructed representation v with the unelaborated representation v. Consequently, the denoising autoencoder can reverse the corruption.The training process is characterized by minimizing the cost function.Performing gradient descent for updating the network parameters with the objective of minimizing the reconstruction error is carried out by where α is the learning rate and ∇ W , ∇ b , ∇ Ŵ and ∇ b represent the partial derivatives of J(W, b, Ŵ, b) to the parameters W, b, Ŵ and b, respectively, for the gradient descent equations.Evaluating the new representation is possible by converting the learned representation to the original format with a visible layer.The hidden layers of the autoencoder extract abstract features from the original representation.The reconstructed data are given in Fig. 6 to demonstrate the ability of the trained autoencoder in reconstructing the original data from corrupted data containing added Gaussian noise.A mean squared error (MSE) cost function penalizing reconstructed data v for being dissimilar from the original data v (without added noise) is defined as: 16) Fig. 6.Original data, corrupted data, and reconstructed data of the sampled PCC voltage (a) original data for a stable synchronization case, (b) corrupted data with added Gaussian noise for a stable synchronization case, (c) reconstructed data by the trained autoencoder for a stable synchronization case, (d) original data for an unstable synchronization case, (e) corrupted data with added Gaussian noise for an unstable synchronization case, (f) reconstructed data by the trained autoencoder for an unstable synchronization case.

TABLE III LAYER SPECIFICATIONS OF AUTOENCODER, ESC, AND MLP
where N is the number of the training data-sets.Two different types of activation function have been used in the autoencoder as listed in Table III.The Sigmoid function is expressed as: and the Rectified Linear Unit (ReLU) activation function is defined as: Number of trainable parameters and type of activation function of the autoencoder layers are listed in Table III.
Remark: In order to achieve the denoising goal, training and evaluation of the autoencoder were carried out by training and test sets containing added Gaussian noise with the mean value of zero and the standard deviation of 10%.
Original data, corrupted data, and reconstructed data of the sampled PCC voltage for two different cases including stable synchronization and unstable synchronization of the converter are depicted in Fig. 6.Based on the minimum MSE criterion, the autoencoder was trained for increasing robustness to noise as well as decreasing the representation dimension.Lower-dimensional representations improve performance of classification, consume less memory and yield faster run-time.In the proposed approach the encoder is used for dimension reduction and feature learning.Thereby, the encoder is forced to prioritize which aspects of the original representation should be preserved and learns useful properties of the data.Similarly, the decoder is trained to reconstruct original representation from the packed down learned representation.Thereby, the most salient features of the training data are captured.

C. Visualization of the Learned Representation
Developing a predictive model should always begin by analyzing the data.Thus, in this section two machine learning algorithms are applied to explore and visualize the learned representation (output of the trained encoder).Principal Component Analysis (PCA) provides a way to transform large datasets into smaller, more manageable ones that are still able to preserve most of the information contained in the large ones.The goal in dimension reduction is to trade a little accuracy for simplicity in order to reduce the number of variables within a dataset.Small datasets are easier to explore and visualize.PCA results are plotted in Fig. 7 to differentiate between time series labeled as stability in synchronization versus those labeled as instability.The PCA plot illustrates how the PCC voltage time series can be reduced in dimension to detect synchronization instability of the converter.Additionally, in the t-Distributed Stochastic Neighbor Embedding (tSNE) algorithm, dimensions are eliminated using nonlinear dimension reduction while retaining the structure of the data.The tSNE algorithm allows for more efficient visualization of multi-dimensional data.Accordingly, the tSNE parameters are optimized so that observations and data points that were close together in the raw high-dimensional data space are close together in a compressed space.The whole data can be visualized using tSNE independently and in an exploratory way.Fig. 8 shows the tSNE visualizations of the learned representation for both stable and unstable synchronization.

V. CLASSIFIER ARCHITECTURE AND TRAINING
This section proposes an encoder-stacked classifier (ESC) for instability detection (as depicted in Fig. 9) and investigates the performance of the proposed neural network topology in  comparison with conventional neural networks.For implementing a conventional neural network, an MLP is selected as summarized in Table III.The MLP is a straightforward architecture of neural networks that has one input layer, two hidden layers, an output layer.The employed MLP has a feed-forward architecture where the neurons in the same are not connected to each The final accuracy achieved by the MLP was the aim of the training in this study.The data set used for training, validating, and testing both neural networks (i.e., ESC and MLP) consists of 42944 time series of the PCC voltage samples.The final layer of the transient instability detection system based on the MLP is a Softmax classifier similar to the ESC.
Pre-trained deep neural networks present more robustness against artefacts and missing data.Thus, in practice, stacking a well-trained encoder onto a neural network classifier provides a more robust performance as compared to the conventional MLP.Accordingly, here by employing a denoising encoder that is trained in the previous section, an encoder stacked classifier is proposed as shown in Fig. 9.The final layer of the proposed ESC is a Softmax classifier too.The Softmax classifier aims to determine the class of the given test sample and uses cross-entropy loss function.
The main approach used in this study is to interpret the outputs of the model as probabilities.P Sta.represents the probability of a stable operating point, whereas, P Ins.denotes the probability of the converter instability.The parameters of Softmax are optimized to produce probabilities that maximize the likelihood of the observed data.Then by setting a threshold and choosing the label with the maximum predicted probability, predictions are generated.Any output is interpreted as the probability that a given input belongs to one of the two classes stable and unstable.Then the class with the largest output value is selected as the prediction.The training time is related to the dimension of the training set and the number of neurons.A higher dimension of training set and a higher number of neurons require more time to train the neural network.

A. Training and Testing Neural Networks
Specifications of the generated data are listed in Table II.testing data is equal to 25% of the 42944 time series.Both ESC and MLP have been trained and tested using Keras, Scikitlearn, and TensorFlow libraries in Python and then imported to MATLAB/Simulink to be integrated into PSC, which is described in the following sections.Similar data including added Gaussian noise with the mean value of zero and the standard deviation of 10% have been used for the two classifiers (ESC and MLP).

B. Comparing Accuracy of ESC and MLP Classifiers
The confusion matrix of the MLP classifier is shown in Fig. 10 (a) and the confusion matrix of the ESC is depicted in Fig. 10 (b) for the test data consisting 5368 time series labeled as Stable and 5368 time series labeled as Unstable.Both the MLP classifier and the ESC fared well in prediction accuracy of the noisy data.However, because of the pre-trained denoising encoder, the ESC learned the most salient features of the input data and used these features to present more robustness against artefacts and missing data.The misclass rate of the MLP classifier is almost twice that of the ESC.In this case, the encoder is trained separately in order to reduce the dimension of the original representation and produce a learned representation which is more robust against corrupted data and can be reverted to the original representation by the decoder.The test data used for comparing the accuracy of these two instability detection methods consist of 10736 time series of the PCC voltage samples including same number of stable and unstable cases.

VI. INTEGRATING INSTABILITY DETECTION INTO PSC
A PSC-based converter, which can be represented as an ideal voltage source with a low-output impedance, works as a voltage-stiff (or grid-forming) converter to form the PCC voltage during transients.PSC as a voltage-stiff control scheme maintains its internal voltage phasor constant in short-duration transients [28].This is because of its inherent voltage source behavior and the converter currents vary almost instantly as a result of this, without the need for first detecting voltage magnitude or phase.Integration of the proposed early instability detection method into PSC, which is demonstrated in Fig. 11, prevents typical instability phenomena as loss of synchronization due to severe voltage sags.The early instability detection by ESC activates the phase freezing mode of the synchronization loop of the converter.Consequently, by freezing the power angle δ, the converter operates as a constant-frequency voltage source with variable amplitude controlled by the reactive power controller C Q (s).This type of response helps to form the PCC voltage during severe voltage sags and enables other grid-connected converters that are operating as grid-following (GFL) converters to remain connected to the PCC and support the grid during transients as well.Freezing the converter power angle δ is a straightforward and robust solution to address the loss of synchronization if it can be supposed that the converter is connected to a high-impedance weak grid that does not impose excessive overcurrent on the converter.Thus, it could be beneficial to freeze the converter power angle following the early detection of the converter instability by ESC.The process of freezing the power angle means that the active power error which is the input of the PSL, given by (1), is bypassed by nullifying the active power error following the early detection of the converter instability by ESC and during the grid fault.This successfully preserves the synchronization loop output at the pre-fault frequency.

A. Parallel Operation of a PSC-Based Converter With a Grid Following Converter
A GFL converter is typically designed based on vector control (VC) and phase-locked loops (PLLs) and represented as a current source connected to the grid in parallel with a high impedance.The GFL converter is intended primarily to deliver power to the grid, thus, the current source should be perfectly synchronized with the PCC voltage [28].The GFL converter needs a generator or another power converter to form the grid voltage in order to be able to operate during grid faults and severe voltage sags in weak grids.The parallel connection of a PSC-based converter and a VC-based converter is depicted in Fig. 12.Both converters are connected to the same grid and deliver active and reactive power in accordance with grid codes.During transients, inherently the PSC-based converter maintains its internal voltage phasor constant, and the VC-based converter maintains its current phasor constant.

B. Time-Domain Simulations
System parameters used for time-domain simulations are given in Table IV, and typical VC is adopted for the VC-based converter [29].Time-domain simulations consist of two different cases.The first is the conventional PSC, and the   second is the developed PSC (shown in Fig. 12).At t = 0.1 s a three-phase fault occurs in the grid and the grid voltage decreases to 0.4 p.u. Simulation results of parallel operation of the converters for the first case (conventional PSC) are shown in Fig. 13, including the grid three-phase voltage, PCC three-phase voltage, PCC voltage amplitude, power angle of the PSC-controlled converter, three-phase current of the PSC-controlled converter, and three-phase current of the VC-controlled converter.Due to the voltage sag, the PSC-based converter loses synchronization with the grid, which also leads to inappropriate operation of the parallel VC-based converter.In this case, the PCC voltage fluctuates and the PLL of the VC-based converter is not able to track the voltage properly, thus the output currents of both converters show unstable response.
Similarly, simulation results of parallel operation of the converters for the second case (developed PSC with phase freezing capability) are shown in Fig. 14.With timely prediction of the synchronization instability and activation of the phase freezing mode, the PSC-based converter behaves as a constant-frequency voltage source which allows regulating the PCC voltage and supporting the grid.Furthermore, the parallel VC-based converter works properly and helps the PCC voltage recovery by delivering reactive power.The sampling window and phase freezing interval are shown in Fig. 14 (c) and (d).The phase freezing mode is activated by ESC, as shown in Fig. 14 (d), and deactivated when the grid voltage is recovered.
Presented time-domain simulations demonstrate that the phase freezing mode can be beneficial to maintain the phase angle and synchronization stability.This is due to the fact that freezing the converter power angle properly slows down the PSL and improves its robustness against the grid voltage sag.In addition, the PSC-based converter's power angle δ can be frozen only during the faults that result in the converter instability.Thus, low voltage ride through can be achieved following severe voltage sags and the converter transient stability can be modified substantially.

VII. CONCLUSION
This paper has analyzed the transient stability of PSC during severe voltage sags associated with grid faults and proposed both an early instability detection and control scheme modification by employing machine learning methods.Data reconstruction, dimension reduction, and representation learning has been used to train and develop a deep neural network, i.e., stacked encoder classifier, for early detection of synchronization instability of PSC.Then, by integrating the proposed early instability detection system into the synchronization loop of PSC and introducing a phase freezing mode, the converter control scheme has been modified.The proposed modification prevents losing synchronization with the grid due to severe voltage sags under weak grid operating condition.Time-domain simulations have been provided to validate the modified control scheme.

Fig. 3 .
Fig. 3. Phase-portrait and power angle trajectory (a) phase-portrait of PSC with equilibrium points, (b) power angle trajectory when SCR is greater than one during fault, (c) phase-portrait of PSC without equilibrium points, and (d) power angle trajectory when SCR is close to 1.
squashing function f is applied to z m as the encoder activation h m = f enc (z m ) for each hidden neuron.At the output layer, the reconstructed representation is produced by adjusting the contribution of the learned representation h m to the sample feature vn via a set of weights ŵnm .The weights ŵnm and a set of biasing parameters bn formulate the affine mapping by ẑn = M m=1 ŵnm h m + bn (12) which is coupled with a decoder squashing function vn = f dec (ẑ n ) generates the reconstructed data sample v.The neural network parameters can be organized in a series of matrices W M×L , b M×1 , ŴL×M , and bL×1 .The parameter sets can be arranged in the following compact set of equations:

Fig. 7 .
Fig. 7. PCA plot of the learned representation for 10736 data samples.
Five variables have been considered in generating the raw data including pre-fault active power of the converter P ref , Voltage sag severity V sag , Voltage sag duration T sag , X/R ratio, and SCR.Resulting in 80000 combinations of various operating points and grid dynamics.The sampling window T w is equal to 40 ms containing 40 samples of the PCC voltage as shown in Fig. 4. The generated data consists of 58528 time-series labeled as Stable and 21472 time series labeled as Unstable.In order to train both neural networks with balanced distributed data (equal number of stable and unstable cases), 21472 time series have been selected randomly out of the 58528 time series labeled as Stable.Consequently, 42944 time series have been allocated for training and testing both ESC and MLP.The share of the training data is equal to 75% and the share of the

Fig. 11 .
Fig. 11.Integration of the early instability detection block into the synchronization loop of PSC.

Fig. 12 .
Fig. 12. Block diagram of the Parallel connection of converters with PSC and VC.

Fig. 13 .
Fig. 13.Time-domain simulation of parallel operation of converters with conventional PSC and VC without phase freezing capability (a) grid voltage with a 60% voltage sag, (b) PCC voltage, (c) amplitude of the PCC voltage, (d) power angle of the PSC-controlled converter, (e) three-phase current of the PSC-controlled converter, and (f) three-phase current of the VC-controlled converter.

Fig. 14 .
Fig. 14.Time-domain simulation of parallel operation of converters with developed PSC and VC with phase freezing capability for PSC (a) grid voltage with a 60% voltage sag, (b) PCC voltage, (c) amplitude of the PCC voltage, (d) power angle of the developed PSC-controlled converter, (e) three-phase current of the PSC-controlled converter with phase freezing, and (f) three-phase current of the VC-controlled converter.
Employing Machine Learning for Enhancing Transient Stability of Power Synchronization Control During Fault Conditions in Weak Grids Amir Sepehr , Graduate Student Member, IEEE, Oriol Gomis-Bellmunt , Fellow, IEEE, and Edris Pouresmaeil , Senior Member, IEEE ac is the alternating voltage controller and C Q (s) is the reactive power controller, V pcc,ref is the voltage-reference for the reactive power control loop, and |v pcc | is the measuredvoltage amplitude at the PCC.The reactive power reference is denoted by Q ref and the measured reactive power is shown by Q.The converter voltage-reference vector V

TABLE II SPECIFICATIONS
OF THE GENERATED DATA FOR TRAINING AND VALIDATION OF THE NEURAL NETWORKS