Machine Learning at the Grid Edge: Data-Driven Impedance Models for Model-Free Inverters

It is envisioned that the future electric grid will be underpinned by a vast number of smart inverters linking renewables at the grid edge. These inverters' dynamics are typically characterized as impedances, which are crucial for ensuring grid stability and resiliency. However, the physical implementation of these inverters may vary widely and may be kept confidential. Existing analytical impedance models require a complete and precise understanding of system parameters. They can hardly capture the complete electrical behavior when the inverters are performing complex functions. Online impedance measurements for many inverters across multiple operating points are impractical. To address these issues, we present the InvNet, a machine learning framework capable of characterizing inverter impedance patterns across a wide operation range, even with limited impedance data. Leveraging transfer learning, the InvNet can extrapolate from physics-based models to real-world ones and from one inverter to another with the same control framework but different control parameters with very limited data. This framework demonstrates machine learning as a powerful tool for modeling and analyzing black-box characteristics of grid-tied inverter systems that cannot be accurately described by traditional analytical methods, such as inverters under model-predictive control. Comprehensive evaluations were conducted to verify the effectiveness of the InvNet.

Abstract-It is envisioned that the future electric grid will be underpinned by a vast number of smart inverters linking renewables at the grid edge.These inverters' dynamics are typically characterized as impedances, which are crucial for ensuring grid stability and resiliency.However, the physical implementation of these inverters may vary widely and may be kept confidential.Existing analytical impedance models require a complete and precise understanding of system parameters.They can hardly capture the complete electrical behavior when the inverters are performing complex functions.Online impedance measurements for many inverters across multiple operating points are impractical.To address these issues, we present the InvNet, a machine learning framework capable of characterizing inverter impedance patterns across a wide operation range, even with limited impedance data.Leveraging transfer learning, the InvNet can extrapolate from physics-based models to real-world ones and from one inverter to another with the same control framework but different control parameters with very limited data.This framework demonstrates machine learning as a powerful tool for modeling and analyzing black-box characteristics of grid-tied inverter systems that cannot be accurately described by traditional analytical methods, such as inverters under model-predictive control.Comprehensive evaluations were conducted to verify the effectiveness of the InvNet.Index Terms-Grid edge, impedance, machine learning, modelfree inverter, transfer learning.

I. INTRODUCTION
T HE global energy system is witnessing a paradigm shift, where fossil fuels are being replaced by renewable energy resources in electricity production.Power electronics converters at the grid edge are playing more important roles than ever before [1], [2].These inverters at the grid edge are ubiquitously needed to integrate renewable energy resources, battery storage systems, loads, and more, into the future power grid.The grid-tied inverters' dynamics are digitally programmed with sophisticated control algorithms, and they tend to interact with one another or with other power system components, bringing unprecedented challenges to grid stability and security [3].
Modeling of grid-tied inverters are of paramount significance for understanding their dynamic behaviors and stability analyses as well.In general, existing analytical models for grid-tied inverters can be classified into two categories: 1) State-space models, inspired by the small-signal stability analysis method for conventional large-scale power systems [4], [5], are established through combining state variables from controllers and converters [6], [7], [8], [9], [10], [11].State-space model-based stability analysis is usually conducted through eigenvalues obtained from the state matrix, which has been extensively adopted to assess the harmonic stability [12], evaluate the stability of voltage-source converter-based high-voltage direct current transmission systems [8], [9] and analyze the stability of a wind turbine system [13], etc.However, the state-space model works as a white-box model that necessities the understanding of full-scale information of inverter systems, e.g., the hardware and control parameters, which is not easy to get access to [5].Moreover, it requires large complex matrices to describe highorder dynamics of large-scale systems [14], and is also very hard to be intuitively visualized and interpreted by engineering practitioners [15].Therefore, evaluating the stability of grid-tied inverter system through state-space model-based approaches is not quite practical in real-world applications [16].2) Frequency domain impedance (or equivalently admittance) models, derived either in the αβ domain [17], [18], sequence domain [19], [20], [21], or dq domain [4] (which are equivalent variants in different forms [21]), are essentially dynamic representations of grid-tied inverters in the frequency domain [4], [5], [22].Compared with state-space models, small-signal impedance models can represent terminal dynamics of grid-tied inverter systems with simplified computational process.It is a more practical way 0885-8993 © 2024 IEEE.Personal use is permitted, but republication/redistribution requires IEEE permission.
Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
of modeling grid-tied inverters considering the convenience of capturing inverter terminal impedances through external measurements [23].It has been widely used in the modeling and stability evaluations of three-phase inverter systems [24], [25], such as grid-tied inverters [17], [18], [24], [25], three-phase ac distributed systems with constant power loads [22], [26], and paralleled inverter systems [5], [24], [27].These impedance characterizations are of paramount significance in checking the stability of a grid-tied inverter system at the interfacing point, using the generalized Nyquist stability criterion (GNC) [5], [17], [24], [25].Therefore, this article mainly focuses on the frequency domain impedance characterizations of grid-tied inverters using machine learning methods.These impedances are essential for inverter-grid system stability analysis through the use of GNC methods [5].However, the operating conditions of these inverters may change across a wide range, leading to various impedance patterns requiring precise modeling for system-level analyses.Physics-based small-signal models derived from circuit analyzes can only characterize inverter impedances when all physical parameters for simplified operating conditions are known and when inverters are controlled by classic control strategies [17], [25].These traditional analytical models usually require a comprehensive understanding of both control and system parameters, such as parameters of circuit components, bandwidths and intrinsic structures of the phase-locked loop (PLL), and architectures of the control system, such that the impedance model can be analytically derived [25].
However, the physical parameters of grid-tied inverters usually change with particular hardware and/or software implementations and operating conditions.Different power-stage designs and control structures may lead to physical parameter deviations, limiting the efficacy of physics-based analytical models when significant nonidealities and/or nonmodellable nonlinearities exist.Examples of nonidealities and nonlinearities that cannot be captured by analytical models include variable frequency switching, control deadtime, quantization error, sampling error, variable digital delay, control framework with nonlinear natures, and system parameter discrepancies, etc.Therefore, impedance modeling of grid-tied inverters via analytical models is prone to be unreliable and inaccurate [17], especially when system parameters are unknown, or sometimes kept confidential by power converter manufacturers due to security and intellectual property considerations.In a future power grid with a large number of inverters at the edge, it is impractical to assume that the physical parameters of inverters are known to system operators, let alone analytical models or control strategies.Even though the analytical impedance model exists and the complete system information is known, to date, precise impedance modeling is still being impeded by difficulties in modeling nonideal-switching impacts on inverter impedances, such as the deadtime impacts [18].For many existing and emerging inverter implementations adopting advanced controllers, such as the model-predictive control (MPC) [28], there are no analytical models to describe the impedance behaviors, thus far, due to their intrinsically sophisticated functions and nonlinear behaviors.
In addition, the inverter impedance can change significantly depending on the operating conditions of the power grid.
Measuring or simulating the impedances of clusters of inverters online is possible [25], but expensive and impractical.The data acquisition on thousands of inverters across a wide range of operating points (OPs, including voltage-V , frequency-f , real power-P , reactive power-Q) via deterministic signal processing methods, such as experiments or electromagnetic transient (EMT) simulations, requires massive human efforts and computational resources.Multitime-scale EMT simulation cannot precisely capture the system dynamics at hundred-kilohertz range when simulation step is not small enough.Frequently measuring inverter impedances online may create stability and security concerns to the grid.Real-world impedance measurement needs to sweep all investigated frequency points (FPs) and injects perturbations twice for each FP, then sweep all investigated OPs.Moreover, the collected voltage and current data need to undergo the fast Fourier transform (FFT) to obtain the impedance data.Even though the pseudorandom binary sequence (PRBS) signal method [29], containing multiple frequency components can be used to expedite the frequency sweep process to some extent, the process of experimental measurements can still be very tedious when considering multiple OPs.Future power converters may operate at higher frequencies with sophisticated switching actions (hard or soft switching) based on silicon carbide [30] or gallium nitride power devices [31], making impedance measurements even more challenging.
Data-driven methods, which are model-agnostic from circuit parameters and control structures, become an effective alternative in addressing the abovementioned challenges.Prior work includes feedforward neural networks (FNNs) for modeling the inverter impedances [32] and physics-informed FNNs for reducing the data demand [33].However, these studies oversimplify the inverter system by characterizing the inverter impedances through considering the OP dependence along a single variable.Our prior work [34] considers a wide range of OP variables, but no experimental verification was provided.All aforementioned studies did not consider the scenario when inverters are controlled by frameworks where no analytical impedance models are available (such as modeling inverters under MPC).
Leveraging the recent advances in artificial intelligence and machine learning [35], [36], [37], [38], [39], we present InvNet, a simple but effective model-free machine learning framework that is capable of characterizing inverter impedance patterns across a wide operation range 1) without a thorough or precise understanding of the physical system, or 2) if only a small amount of measurement data is available.The key principle of this approach is shown in Fig. 1.The main contributions of this article include the following.a) the analytical model exists, but system parameters are unknown, leading to inaccurate models; b) the analytical model does not exist or is not mature; c) there is no sufficient data available for modeling a particular inverter.The rest of this article is organized as follows.Section II elaborates on the proposed approach in detail.Section III gives comprehensive performance evaluations of the proposed InvNet framework.Finally, Section IV concludes this article.

II. MACHINE LEARNING FRAMEWORK FOR INVERTER IMPEDANCE CHARACTERIZATION
Grid-tied inverters can be implemented as different topologies ranging from two-level inverters to multilevel inverters [40] (shown in Fig. 1), adopting very different control strategies (e.g., grid-forming or grid-following [41], current-source or voltagesource behaviors [42], etc.), and performing different functions (e.g., black start, low-voltage ride-through, reactive support, etc.).Various types of inverters with different implementations at different OPs usually reveal different output impedance patterns.We use a classic two-level grid-following inverter as a baseline example.The methodologies and modeling results presented in this work are applicable to other inverter topologies and control implementations as well.There are six major factors that may influence inverter impedance patterns, i.e., controller parameters, converter dynamic behaviors, circuit parameters, sampling process, grid conditions, and PLL implementation (Components #1 through #6 in Fig. 1), where PLL is used for grid-inverter phase synchronizations.The inverter admittance, typically embodied by a four-element (Y dd , Y dq , Y qd , and Y qq ) matrix at various FPs across multiple OPs, are represented by complex values with the real and imaginary parts (Y out = G + jB in Fig. 2(a), where G and B represent the conductance and susceptance, respectively).
As demonstrated in Fig. 2, the InvNet is an end-to-end framework comprising automatic data acquisition, scalable model training, and comprehensive model validation (see Fig. 2).It is modular, scalable, and flexible for modeling a large number of smart inverters at the grid edge with sophisticated control structures.In this work, the data used for NN training was obtained from 1) analytical models, 2) EMT simulations, and 3) experimental measurements.FFT was utilized to transform the voltage and current to frequency-dependent impedances [complex values in Fig. 2(a)].The surrogate model was obtained through training a small-scale FNN with OP information (V , f , P , Q) as its inputs and admittances as outputs [see Fig. 2(b)].State-of-the-art NN hyperparameter tuning tools and optimizers, such as Optuna [43] and Adam [44], were used to optimize the NN structure and parameters [see Fig. 2(c)].As demonstrated in [45], the design of NN structure and parameters can also be conducted based on latent features of the inverter impedances.We also explored the strength of transfer learning [37], [38], [39], [46], [47], [48], [49], [50] with the InvNet.Leveraging transfer learning, the size of the data needed to obtain a high-performance NN model could be greatly reduced by leveraging data created from existing simplified/incomplete analytical models, or data obtained from measuring similar inverters but with different parameters [see Fig. 2(d)].With the InvNet, one can take a few quick snapshots of the impedances of a new inverter at a few OPs and rapidly predict the behaviors of this new inverter across a wide operation range.

A. Analytical Impedance Models
There are many different ways of implementing grid-tied inverters.Different hardware and software implementations lead to different complexities that are hard to be captured by analytical models.Grid-tied inverters are typically controlled as current sources by controllers with a PLL [5], also known as grid-following inverters [1] (see Fig. 1).
Small-signal linearized models for grid-tied inverters operating at specific equilibrium points are well-studied [25].The time delay matrix G d of the digital control system only considers the current delay because of the grid-following framework, as shown in Fig. 3, is given by Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.where T s is the sampling period.The transfer function matrix G id between the duty-ratio and inductor current vector is where ω is the fundamental angular frequency of the system and L and R are the inductance and resistance in Fig. 2(a).The decoupled current controller matrix I c can be expressed as where k p and k i are the proportional-integral (PI) parameters, respectively, of the current controller.Defining {I d , I q } as the inductor currents and {V d , V q } as system voltages in the system d and q axes, respectively, defining {D d , D q } as the duty cycles Fig. 3. Small-signal impedance model of grid-tied inverters with current control loop and PLL.The control parameters are assumed to be unknown and may vary from inverter to inverter and from manufacturer to manufacturer.
in the system d and q axes at the steady-state OP yield and where k p_pll and k i_pll are the PI parameters of the PLL.To model the dynamic impact of the PLL, the small-signal perturbation path matrix G pll_i from the system voltage to the current in the controller dq frame and the small-signal perturbation path matrix G pll_d from the system voltage to the duty cycle in the controller dq frame are, respectively, given by The open-loop output admittance without the PLL is derived by forcing the perturbations of the duty ratio and dc voltage to zero [25], thus The output admittance of the grid-tied inverter system is Y out can be typically represented by a 2 × 2 matrix with four complex elements Y dd represents the current response in the d channel when d channel voltage is perturbed; Y qq represents the q channel current response when q channel voltage is perturbed.Y dq and Y qd represent the dq coupling admittance.Therefore, the output admittance of a grid-tied inverter at a particular OP in the dq frame can be expressed as a function of the perturbation frequency f, inverter output voltage V, active power P, and reactive power Q [18], [45].This analytical model requires precise knowledge of circuits and control parameters of inverters, which may not be accurate, or may even be kept confidential in practical scenarios.

B. Database Construction
Fig. 2(a) illustrates the admittance acquisition process.In this work, the admittances were collected through iteratively sweeping the selected OPs and selected perturbation FPs.The inverter admittance at arbitrary OP is modeled as a four-element conductance matrix G and a four-element susceptance matrix We used three types of data for performance evaluations, i.e., the AnaData generated by analytical models, the Sim-Data generated by EMT simulations, and the ExData collected through real-world experiments.To facilitate the data acquisition process, we established an automatic EMT simulation model via the platform of PLECS Blockset integrated with MATLAB Simulink, to rapidly generate admittance data.We called the "AC sweep" block in PLECS from a MATLAB script to inject perturbations and collect the frequency responses throughout the range of selected OPs.Then, the admittance data, modeled as conductances and susceptances for each OP, are saved as a .csvfile after each iteration.Through repeatedly sweeping the OPs and perturbation frequencies throughout the selected range, output admittances of inverters can be either calculated by analytical equations or by EMT simulations.
To exemplify the databases that were used in this work, the EMT simulation-generated SimData was visualized in Fig. 4 as an example of the database, where there are 40 OPs and 20 FPs in each OP, which therefore, constitutes a database with 800 (20 × 40) data points in total (The AnaData is with the same size in this work).It took approximately 40 h to complete all iterations on a personal computer (PC) with Intel 11th Gen i7-11700 processor.The same PC was used throughout this work.The ExData, by using the method of admittance measurements presented in [29], was collected through experiments conducted in the testing platform demonstrated in Fig. 2(a), the entire process of which took us more than one week to construct a database comprising 817 data points for the ExData.

C. Hyperparameter Optimization
In this work, the optimization of NN hyperparameters was conducted via the Optuna framework1 embedded in the Ten-sorFlow platform. 2The optimization process was conducted Fig. 4. SimData (used for performance evaluations in Section III) visualized in 3-D view.The conductance and susceptance are illustrated against both the active-power-P and frequency when the reactive-power is zero and both the reactive-power and frequency when the active-power is zero, respectively.As shown, The output voltages 0.9, 1.0, and 1.1 (nominal value) have trivial impacts on the admittance, the admittance in Y qq changes significantly along the active-power axis while the admittance in Y dq varies significantly with the reactive-power, which imply that the admittance of grid-tied inverters is more susceptible to active and reactive power than to the output voltage. in a two-step manner [as depicted in Fig. 2(c)].First, the NN structure, namely, the layer and neuron numbers and the Adam optimizer [44] parameters, i.e., decay epoch (specifying the epoch number that each decay of the learning rate takes), batch size, decay rate, and initial learning rate were all put into trials.We implemented 100 trials in total which took approximately 16 h to complete.Then, we fixed the NN structure by using the optimized layer and neuron numbers and only conducted the optimization of the Adam optimizer parameters for another 100 trials, which also took roughly 16 h.Finally, we used the NN structure from the first step and Adam parameters from the second step as the final hyperparameters.The evaluations presented in Section III implied that the obtained hyperparameters did not lead to overfitting and achieve optimal performances.

D. NN Training
We developed FNNs to model the admittances of a grid-tied inverter in this work.Fig. 2(b) illustrates a typical FNN structure with one input layer, N hidden layers, and one output layer.The FNN has four input neurons, i.e., I 1 -I 4 , representing f, V, P, and Q, and eight output neurons, i.e., O 1 -O 8 , representing the conductance (G), and the susceptance (B) of the output admittance, i.e., G dd , B dd , G dq , B dq , G qd , B qd , G qq , and B qq .As shown in Fig. 2(b), the ith hidden layer has k i neurons, and the neuron values are subject to the following equation: where σ is the activation function, e.g., the sigmoid activation function that frames the neuron values into probability values between 0 and 1, and H (i) , w (i) , and b (i) are the matrices of neuron values, weights, and biases in the ith hidden layer, which are given by The neuron values of the first hidden layer are where where The next step is to train the NN.As shown in Fig. 2(b), we split the acquired database into training (70%), validation (15%), and test sets (15%), respectively.The test set was reserved for final evaluations, while the training and validation sets were Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
randomly shuffled before each training process, such that every item had the same chance to be used for training.Then, a back-propagation algorithm with the mean squared error (MSE) loss function between the FNN prediction and the admittance data was used to train the FNN.Finally, the test sets were used to verify the performance of the FNN with multiple different types of figure-of-merits (e.g., MSE, mean average error, 95th percentile error, etc.).

E. Transfer Learning
Transfer learning is a machine learning technique that involves leveraging knowledge gained from one task to improve the performance of another related task.In traditional machine learning, models are usually trained from scratch for each new task or problem.Transfer learning, however, takes a different approach.Instead of starting from scratch, a pretrained model that has been trained on a large and diverse dataset for a related task is used as a starting point.This pretrained model has already learned useful features, representations, and patterns from the original task, which can be beneficial for the new task.It has been widely successful in various domains, including natural language processing, computer vision, audio analysis, human activity recognition, and more [37], [38], [39], [46], [47], [48], [49], [50].
It usually involves the following two main steps: 1) Pretraining: In this step, a model is trained on a large dataset and a specific task, often referred to as the source task.This training helps the model learn general features and patterns that are useful for various related tasks.Common pretrained models include language models trained on a large corpus of text, image models trained on a large dataset of images, and more [38], [48]; 2) Fine-tuning: After pretraining, the model is fine-tuned on the target task, which is the specific problem we want to solve.During fine-tuning, the model's parameters are adjusted using a smaller dataset specific to the target task.The knowledge gained during pretraining helps the model adapt and learn task-specific nuances more quickly and with less data.
Transfer learning offers several advantages, as follows.1) Faster training: Since the model starts with knowledge from a related task, it often requires fewer iterations or epochs to achieve good performance on the target task.2) Less data dependency: Transfer learning can mitigate the need for an extremely large dataset for the target task, as the model can generalize from the knowledge it gained during pretraining.3) Better generalization: The learned features from the pretrained model are often more robust and generalizable, leading to improved performance on the target task.4) Reduced computational resources: Training a model from scratch can be computationally intensive, while transfer learning can significantly reduce the required resources [37], [38], [39], [48], [49], [50].As demonstrated in Fig. 2(d), we showcased the strength of transfer learning in two commonly useful scenarios: 1) Model extrapolation from analytical data-based model to real-world data-based model: Supposing that we have a pretrained model that is trained on a large amount of AnaData from a particular type of Inverter A whose parameters and control structures are all available (note the AnaData cannot capture deadtime effect and other nonlinear or nonideal information), then, we can retrain the model based on a small amount of real-world data from this same Inverter A or another Inverter B (with different parameters but the same control framework) that is controlled as a black-box, i.e., its parameters are all unavailable.In this way, we can get a model with high accuracy for both Inverter A and B, since the pretrained model are fine-tuned by real-world data.2) Model extrapolation from one inverter to another with the same control framework but different control parameters: Supposing that we have a pretrained model that is trained on a large-scale database from Inverter A (i.e., a large amount of confidential impedance data available from the manufacturer), then, we can use a small-scale database from Inverter B to retrain the pretrained model to get Inverter B's impedance model with high accuracy (It is worth noting that in this work, Inverter A and B share the same control framework, there are a number of literatures investigating how transferable the features in NNs are [51], [52].It was found that even features transferred from distant tasks were better than random weights trained from scratch [52].The possibilities of extrapolations between inverters with a variety of control frameworks and features will be studied in our future work.).

III. MODEL PERFORMANCE EVALUATION
We evaluate the performance of the InvNet framework in the following three scenarios.
1) When an analytical model exists, but system parameters are unknown or kept confidential.2) When an analytical model does not exist or is not mature.
3) Lack of sufficient data for particular inverters.We collected data from analytical calculations, EMT simulations, and experimental measurements.Each type of data was randomly partitioned into a training set (70% of the total dataset), a validation set (15% of the total dataset), and a test set (15% of the total dataset).In each training process, we monitored the model's performance on the validation set during training while the test set was preserved and referred to once the training was complete to evaluate the model performance.The final models were thoroughly evaluated on the test set that was never used during the training process.
We exemplified four different grid-tied inverters, each with parameters listed in Table I.Two datasets collected through analytical calculations and automatic EMT simulations (using the simulation platform of PLECS integrated with MATLAB Simulink), i.e., the AnaData and the SimData, respectively, were applied to train the FNN, resulting in two NNs, i.e., the AnaNN and the SimNN, respectively.The two datasets were constructed in the same way.The operation ranges of the inverters were normalized to the following ranges in per unit: V ∈ [0.9, 1.1], P ∈ [−1, 1], and Q ∈ [−1, 1].We selected 20 frequency steps evenly distributed in the logarithmic scale in the range of f ∈ [1,200] and the steps of V , P , and Q were selected as {0.1, 0.5, 0.5}.OPs leading to overmodulation (modulation index greater  4 as an example of the database.Both the AnaData and SimData were split into three portions, i.e., 70% for training, 15% for validation, and 15% for testing.The same 15% test set of the SimData was used for evaluations of both the AnaNN and SimNN.It is noteworthy that theoretically, the frequency range of interests can be up to the Nyquist frequency, which is half the switching frequency.However, as it has been comprehensively investigated in [3] and [53], the current control, dc-link voltage control, terminal voltage control, and PLL cause sideband oscillations around two times the fundamental frequency, i.e., around 100 Hz in this work.The high-frequency range instabilities are usually caused by digital control delays, which are not usually considered as the major factors [54].Therefore, in this work, frequency range from 1 to 200 Hz is investigated, covering most of the low-frequency sideband oscillation ranges. To mimic a real-world scenario when dealing with a wide range of different inverters with unknown information, we applied deadtime to the switching events in the EMT simulation.The deadtime effect is usually not captured by commonly used analytical methods.We also assigned the same synchronous reference frame PLL architecture to both analytical models and EMT simulations, but with different PLL bandwidths or PI controller coefficients, based on the assumption that analytical models may use incorrect system parameters (The SimData was directly captured from EMT simulations without the necessity of recognizing system parameters).Similar methods can be used to study the impact of other system parameters.
An experimental rig [see Fig. 2(b)] was constructed to collect real-world impedance data.In practical scenarios, the data acquisition is conducted in a real power grid, which is a feasible approach that has been widely applied in the measurement of inverter impedances [29], there are also medium-voltage perturbation injection devices used for system-level impedance collections [55], [56].In this article, to deliver a proof-of-concept, we used a grid simulator to mimic the power grid in our lab, the inverters were connected to the grid simulator, which are considered to be at the edge of the grid.As shown in Fig. 2(b), a power amplifier to the right with an attached inductive impedance Z g worked as a grid simulator and a power source V g1 to the left mimicked the renewable energy sources.The inverter under test had the same parameters as Inverter 1 in Table I.There were two devices ("Microgrid Tech Bench" from Imperix) with a back-to-back converter structure in each one of them, where one of the converters worked as a rectifier absorbing power from energy sources and the other as an inverter injecting power to the grid.To emulate the grid, all converters were connected through an inductive impedance Z g to a power amplifier ("DM 45 000/APS" from Spitzenberger & Spies), which worked as a grid simulator to mimic the power grid.The power source V g1 to the left of Fig. 2(b) emulated the renewable energy sources and was also connected through interfacing inductors to the devices, where Device 2 was connected through a transformer to achieve galvanic isolation between Devices 1 and 2. The inverter in Device 1 was the one under test (had the same parameters as Inverter 1 in Table I) for admittance measurements while the inverter in Device 2 served as a perturbation source injecting perturbations for admittance measurements.To comparatively expedite the admittance data collection process, the PRBS method was applied here [29].In addition, to facilitate the FFT analysis for the experimentally measured voltage and current data, 19 FPs were also selected as ones, tens, and hundreds in the range of f ∈ [1,200], i.e., {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 60, 70, 80, 90, 100, 200}.To diversify the database, the step of V was selected as 0.1, while the steps of P and Q were selected by choosing the steps of active and reactive currents I d and I q as {0.4,0.4}, where OPs resulting in overmodulation and overcurrent conditions were also excluded.In this way, the final experimental database was composed of 43 OPs, which constructed a database with 817 (19 × 43) {f, V, P, Q} data points in total and was referred to as the ExData.This ExData was also randomly partitioned into a 70% training set, a 15% validation set, and a 15% test set.

A. Analytical Model Exists but Model Parameters Are Unknown
We first showcased the effectiveness of the InvNet in capturing the admittance features brought about by the deadtime effect, through the exemplification of Inverter 2. As aforementioned, existing analytical models cannot achieve sufficient accuracy for not capturing the deadtime effect, thus, the AnaData did not contain deadtime information.However, since the EMT simulation was able to implement the deadtime in each power switch of the inverter, the deadtime information was included in the SimData but could not be captured by the analytical model.As depicted in Fig. 5(a), the SimNN curve differed slightly from the AnaNN curve in Y dd and Y qq , while revealing obvious deviations from the AnaNN curve in Y dq and Y qd , for both conductance and susceptance curves, which implied the inaccuracy of the analytical model.The test set, stochastically extracted from the SimData, was in line with the SimNN curve, while inconsistent with the AnaNN curve, especially in Y dq and Y qq , for both conductance and susceptance.The absolute errors were calculated by subtracting the predictions of NNs from the Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.test set and classified into conductance and susceptance absolute errors, respectively.By normalizing the absolute errors into the range of [−1, 1] through the use of "MinMaxScaler," we constructed the probability density histograms together with a normal distribution fit for each one of them.As shown in the left two graphs of Fig. 5(b), the probability densities of the normalized absolute errors of the SimNN were more concentrated around zero than those of the AnaNN for both the conductance and susceptance, which indicated that admittances predicted by the SimNN were more accurate than the ones predicted by the AnaNN.Furthermore, we also visualized the probability density histograms of the absolute errors with their normal distribution fit in the right two graphs of Fig. 5(b).The probability densities of the real absolute errors of the SimNN were in sharp contrast to the ones of the AnaNN, the former ones were concentrated around zero while the latter ones were more widespread, which confirmed the superiority of the SimNN over the AnaNN.
To further demonstrate the advantages of the InvNet in dealing with classified or uncertain information, we conducted experiments using Inverter 1 as the source of the AnaData and Inverter 2 as the source of the SimData, assuming that the analytical model had no prior knowledge of the actual inverter Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
parameters.Likewise, as depicted in Fig. 5(c), it exposed noticeable discrepancies with the AnaNN in Y dq , Y qd , and Y qq , whereas it only differed slightly from the AnaNN in Y dd .The normalized probability densities of the absolute errors were depicted in the left two graphs of Fig. 5(d), where the histograms of the SimNN were more like the normal distributions.The actual probability densities of the absolute errors were given in the right two graphs of Fig. 5(d), where the probability densities of the absolute errors of the SimNN were also in stark contrast to the ones of the AnaNN, the former ones were mostly located near zero while the later ones span across a wide range, which were almost close to zero.
The underlying logics of this demonstration design are threefold: 1) the SimData contains information that cannot be captured by analytical models, the SimNN trained on the SimData are superior to analytical models; 2) to ensure fairness, comparisons between analytical models and the SimNN are switched to comparisons between the AnaNN (the NN trained on the AnaData) and the SimNN; 3) test set preserved from SimData in advance but not used in NN training aligns well with predictions of the SimNN, i.e., the NN trained on the SimData.For the studies in Fig. 5, the FNN consisted of three hidden layers that had 683 parameters in total: layer #1, 4 neurons; layer #2, #3, and #4, 15 neurons; layer #5, 8 neurons.Using smallerscale NNs can enhance the computational efficiency, techniques, such as network pruning [59] can be adopted to further reduce the model size.We trained the model in MATLAB using the optimizer of Bayesian regularization back-propagation, which updates the weight and bias values according to Levenberg-Marquardt optimization.It minimizes a combination of squared errors and weights, and then determines the correct combination so as to produce a network that generalizes well.We trained each model for 3000 epochs, which took approximately 8 min for each training process on the same PC (Intel 11th Gen i7-11700 processor).

B. Analytical Model Does Not Exist or Is Not Mature
Traditionally, grid-tied inverters were mostly controlled by linear-controllers, which can be analytically modeled straightforwardly.In recent years, applications of more advanced nonlinear controllers have become a future trend, among them, MPC is a promising alternative to control power electronic converters, which has been heavily explored over the past few years [57], [58].Due to its distinctive advantages, such as fast dynamic response, straightforward implementation, compatibility with nonlinear constraints of converters, and the capability to simultaneously tackle multiple control objectives, MPC is much more powerful to address emerging challenges that modern power converters are facing than traditional control methods are.However, to date, there are no mature solutions for the modeling of MPC-controlled grid-tied inverters, due to the inherent nonliearities of MPC.The MPC uses the discrete model of the system to minimize the cost function such that the optimal switching action is selected for the next control iteration [on the left of Fig. 6(a)].The optimization process is a highly nonlinear one that can hardly be modeled through traditional small-signal modeling approaches [on the right of Fig. 6(a)].Most existing MPC frameworks do not have a constant switching frequency behavior.Their stability cannot be solely described by frequency-domain impedance analysis.In this work, we adopted the multivector model-predictive-control (MV-MPC) [28], a subset of MPC control strategy, which has a constant switching frequency behavior that can be described by frequency-domain impedance analysis.
Fig. 6 illustrates the implementation process of the MV-MPC.The physical model of the inverter system in the αβ-frame is where u = [u α u β ] T and i = [i α i β ] T , which are converter voltage and current vectors in the αβ-frame, respectively.
The discrete-time model can be obtained by applying Euler forward approximation To determine the optimal voltage vector in terms of the current tracking performance at the time instant k, the following prediction model can be established: Here, u * (k) represents the reference voltage vector that forces the actual current to ideally track the reference current i * (k + 1).
The calculated reference vector is rapidly located in the 120 • oblique frame (transformed from the αβ-frame) and three adjacent voltage vectors are selected over one control (sampling) iteration, which replaces the computationally inefficient calculation or lookup table approaches to simple integer arithmetic.Current tracking is prioritized through duty cycle optimization of the selected adjacent vectors.Finally, the optimal switching sequence is generated through an external modulator that follows the symmetric pulse pattern of seven segments [see Fig. 6(b)].Replacing the PI current controller [see Fig. 2(a)] with a nonlinear MV-MPC made the entire grid-tied inverter system "model-free." We developed an automatic EMT simulation platform in PLECS to collect the admittance data (SimData) for an inverter with the same PLL bandwidth as Inverter 2, but controlled by MV-MPC.Here, we selected 19 FPs as ones, tens, and hundreds in the range of f ∈ [1,200], which were {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 60, 70, 80, 90, 100, 200}.A randomly selected test set was reserved from the SimData using a 15% split and used for model evaluations.As shown in Fig. 7(a), at an arbitrary OP, the test set data points all aligned with the SimNN curve, which proved the InvNet's power of reconstructing admittance models at the whole OP range.We also constructed the probability density histograms together with a normal distribution fit for each one of them.The probability densities of the absolute errors Fig. 6.Control diagrams of MV-MPC [28].(a) Principle of MPC.The selection process for optimal switching actions is highly nonlinear that can hardly be modeled through traditional small-signal approaches.(b) Control diagram of the multivector MPC.The current tracking is realized through the use of MPC while also retaining the fixed switching frequency characteristics in traditional PI-controller-based space-vector pulsewidth-modulation strategies.Due to inherent nonlinearities of the MPC, the impedance models are unavailable to date.The data-driven methods can be used to establish multi-OP impedance models for grid-tied inverters controlled by such kind of controllers.For studies in Fig. 7, the FNN structure also had three hidden layers with 15 neurons in each layer.We also trained the model in MATLAB using Bayesian regularization optimizer for 1000 epochs, which took roughly less than 3 min.

C. Insufficient Data for Modeling a Particular Inverter
To gain a comprehensive understanding of inverter impedances across a wide range of OPs, it is usually necessary to train the NN using a relatively large amount of data.We leveraged transfer learning [see Fig. 2(d)] to reduce the database volume and empower the InvNet framework with the ability of cross-inverter extrapolation [see Fig. 8(a)] when there is no sufficient data for a particular inverter.
The first demonstration includes extrapolating from an FNN trained on data from analytical models, which may not accurately capture impedance information due to insufficient parameter knowledge from the inverter system, to an FNN capable of understanding impedance knowledge from real-world experiments.The FNN was first pretrained on a large amount of data generated from analytical models and then fine-tuned by a small amount of data collected from real-world experiments.
We pretrained the model on the AnaData generated from analytical models for Inverter 2, 3, and 4 (see Table I) for 500 epochs.With data readily generated from analytical models, we were able to construct a large database as the AnaData.Similarly to Fig. 5, 20 FPs were also evenly selected in the logarithmic scale in the range of f ∈ [1,200] but with the steps of V , P , and Q selected as {0.1, 0.1, 0.1}.Excluding overmodulation and overcurrent conditions, it resulted in 1084 OPs and 21 680 (20 × 1084, 1084 OPs, 20 FPs) data points in total.We then retrained (fine-tuned) the model on the ExData (from Inverter 1) using 5, 10, 30, 50, 100, 150, 200, 300, 400, and 550 data points for also 500 epochs.To achieve a fair comparison, we also trained the model from scratch on ExData using the same number of data points as well.We repeatedly trained each model ten times with a different random seed each time and recorded the absolute errors and MSEs for both conductance and susceptance simultaneously at the end of each training cycle for further analyses.In this regard, the total training count was: 3 (source inverter count)×1 (target Inverter count)×10 (repeating times)×10 (number of used data points) = 300, which took approximately 30 h to complete on the same PC (Intel 11th Gen i7-11700 processor).
As seen from the left two figures in Fig. 8(b), the transfer learned models' MSE dropped significantly even when trained with only 30 data points (note each data point is a set of time sequences at an OP), for both conductances and susceptances.The MSE of the transfer learned models approached zero after only 100 data points.The transfer-learned models considerably outperformed the models trained from scratch.From the MSE perspective, the models trained from scratch could only reach a performance comparable to the transfer-learned models at approximately 200 data points for the conductance and 550 data points for the susceptance.Training from scratch led to significantly higher MSE when using fewer than 50 data points.We also evaluated the probability densities of the absolute errors [the right two figures in Fig. 8(b)].Similar to the studies in Fig. 5, the probability density histograms together with a normal distribution fit for each histogram (when using 30 data points) were also shown.The probability densities of absolute errors of the transfer learned models were more concentrated around zero than those of the model trained from scratch, which indicated that admittances predicted by transfer learned models were more accurate than the ones predicted by the models trained from scratch.
In addition to the aforementioned model extrapolation from the analytical data-based model to the experimental data-based model, we also performed cross-inverter extrapolations (inverters with the same control framework but different control parameters), i.e., from all other three inverters to one inverter in Table I using transfer learning (for instance, from Inverter 2, 3, and 4 to Inverter 1).This time, to conduct a proof-of-concept for cross-extrapolations and facilitate the data acquisition process, we used analytical models to generate databases assuming that all analytical models were well-aware of all system parameters.The performance evaluations were conducted in the same way as studies demonstrated in Fig. 8 (with each training process repeated ten times).We first pretrained the model on the Ana-Data generated from analytical models of source inverters (from Inverters 1, 2, 3, and 4) with 21 680 (20 × 1084, 1084 OPs, 20 FPs) data points in total for 500 epochs.We then fine-tuned the model on the other AnaData from target inverters (also from Inverters 1, 2, 3, and 4) using 5, 10, 30, 50, 100, 150, 200, 300, 400, and 550 data points for 500 epochs.Also, we trained the model from scratch on the AnaData from target inverters using the same numbers of data points for 500 epochs as well.We also repeated each training for ten times.Therefore, the total training count was: 4 (source inverter count)×4 (target Inverter count)×10 (repeating times)×10 (number of data points)=1600, which took approximately 160 h to complete all the training.
All transfer-learned models outperformed the models trained from scratch, and the transfer learning depended on considerably less data than the training from scratch did to achieve the Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.Fig. 9. Performance evaluations for cross-inverter extrapolations using transfer learning (inverters with the same control framework but different control parameters).(a) Conductance evaluations: The MSE curves were visualized by adding standard deviations as margins of the mean MSE value for the ten-time training.The transfer-learned models outperformed the models learned from scratch even when only a few data points were used.The probability densities of the absolute errors also confirmed the superiority of the transfer learning (when using 30 data points).(b) Susceptance evaluations: The MSE curves were visualized in similar ways to the conductance evaluations.The transfer-learned models also outperformed the models learned from scratch.The probability densities of the absolute errors also consolidated the superiority of the transfer learning (when using 30 data points).same level of performance in terms of MSE (see Fig. 9).The transfer-learned models even revealed promising extrapolation results when only 10 data points were used for fine-tuning.The transfer learning from Inverter 1, 2, and 3 to Inverter 4 performed exceptionally well, with close to zero MSE at only 5 data points.Subsequent to 30 data points, the MSEs of all transfer learned models began to approach zero, which were remarkably lower than those of the models trained from scratch.Furthermore, the probability densities constructed in the same way as Fig. 8 (when using 30 data points) all reflect the transfer learning's superior performance over training from scratch and its extremely mild reliance on database size.In Figs. 8 and 9, we trained the models in the TensorFlow platform using the Adam optimizer, the adopted FNN comprised 5482 parameters in total (three hidden layers): layer #1, 4 neurons; layer #2, 43 neurons, layer #3, 56 neurons, layer #4, 43 neurons, and layer #5, 8 neurons.The learning rate decreased as epochs increased, the initial learning rate was 0.0159, decay epochs were 49, decay rate was 0.498, and batch size was 16.These hyperparameters have been optimized through Optuna following the two-step process presented in Section II.
Transfer learning mitigates the NN's dependency on large databases and empowers the NN with cross-extrapolation capability through the use of very small-scale databases from realworld simulations or measurements.This is extremely valuable for rapidly evaluating the stability of a future power grid with a large number of inverters with opaque black-box behaviors at the grid edge.It was shown that with the pretrained models retrained on only a few admittance data points, transfer-learned models captured the necessary information for reconstructing accurate admittance models of the grid-tied inverters, outperforming the models trained from scratch.We expect that this approach could greatly reduce the database required to achieve excellent modeling accuracy, especially when considering the unrealistic and expensive data acquisition process for simulations and realworld experiments, and could also save computational resources for cross-inverter model extrapolations using very small-scale databases.

IV. CONCLUSION
Using analytical models for the impedance modeling of gridtied inverters can be unreliable, inaccurate, and not scalable, particularly when system parameters are unknown or kept confidential for cybersecurity or intellectual property protection purposes.Moreover, a number of practical issues hinder the application of analytical models.
1) The deadtime effects cannot be effectively modeled, making analytical models inaccurate in capturing the fullspectrum characteristics of the inverter impedances.
2) The inverter system parameters are often unknown, which makes the application of analytical models impractical.3) No mature analytical models are available for modern inverter control strategies, such as the MPC.4) High-quality real-world impedance data acquisition is always expensive and impractical, especially when dealing with multiple OP circumstances or a large number of geographically distributed inverters.Measuring or simulating impedances of clusters of inverters in the real world for stability evaluations is even more impractical.To address such issues, we proposed a machine learning framework, the InvNet, for grid-tied inverter impedance modeling, which not only solves the hardship in multiple-OP impedance modeling but also addresses the problem of large database requirements for high-performance NN constructions.We showcased that the InvNet can replace the physics-based impedance model in system-level stability analyses for grid-tied inverters and can also promptly predict the output impedances based on the operating conditions of inverters.This approach is parameter-agnostic and completely data-driven and, thus, does not rely on precise understandings of the inverter hardware or software implementations.In addition, leveraging transfer learning, the InvNet is able to extrapolate from analytical data-based models to real-world data-based models using a small-scale real-world database and is also able to cross-extrapolate among various inverters with the same control framework but different control parameters using small-scale databases.
In summary, we present an end-to-end machine-learning framework for data-driven impedance modeling of model-free inverters across wide ranges of OPs, with limited access to experimental measurement data.The machine learning framework spans from data acquisitions (including analytical calculations, EMT simulations, and experimental measurements), model designs, model training, to model evaluations.Researchers can train the models on small-scale databases thanks to the use of transfer learning, and promptly establish the desired impedance models at specific OPs.Various test scenarios across a wide range of operating conditions confirmed that this proposed framework reduced the need for large-scale databases and improved both the accuracy and efficiency of impedance modelings for black-box grid-tied inverters.The generated models can be further used for system-level stability studies for grid-tied inverters.We expect that the proposed framework can further advance system-level studies for grid-tied inverter systems and pave the way toward more data-driven models.Toward this end, more research efforts are expected.
1) Further investigations on the transferability between inverters with various control or circuit frameworks (gridfollowing, grid-forming, two-level, three-level, and multilevel topologies, etc.).2) Further explorations of other commonly used machine learning models and their performance comparisons and evaluations [recurrent NN or long short-term memory network, etc.]. 3) Further expanding the InvNet's applicability to the impedance modeling of large-scale renewable generation farms, predicting the node impedance matrix of a renewable power grid based on node OPs, and the aggregated impedance modeling of renewable generation farms, enabling system-level stability analyzes in the mediumvoltage scale.

Fig. 1 .
Fig. 1.Key principles of the InvNet framework.Left: modeling inverter impedances as NNs for stability analyses of distribution networks comprising a variety of inverters.Right: the system diagram of typical grid-tied inverters with PLL-based current control, where nonidealities and nonlinearities in the physical and control systems (such as sampling errors, parameter discrepancies, and deadtime) make precise impedance modeling highly challenging.

Fig. 2 .
Fig. 2. Overview of the InvNet framework and methodologies.(a) Data acquisition.Top: the implementation process of the admittance collection, which models the admittance as a function of the perturbation frequency f, inverter output voltage V, active power P, and reactive power Q and sweeps the FPs and OPs across a wide range.Bottom: an example of an experimental platform for impedance data acquisition.(b) Model training.Training an FNN in the TensorFlow platform with data collected through either analytical models, EMT simulation models in MALTAB+PLECS framework, or real-world experiments, where the OPs serve as inputs and admittances as outputs.(c) Hyperparameter tuning.Hyperparameter tuning process for the InvNet using the Optuna framework.(d) Transfer learning framework.The InvNet used models pretrained by large-scale databases to extrapolate to real-world models based on small-scale databases (left) and pretrained inverter models to extrapolate to other inverter models through transfer learning (right).

Fig. 5 .
Fig. 5. Performance evaluation under unknown parameter circumstances.(a) Prediction results of the AnaNN and the SimNN compared to the test set at the same example OP (the No. 23 OP in both the AnaData and the SimData, where V , P , and Q were {1.1, −1, 0.5}).The SimNN managed to capture the deadtime effect while the AnaNN did not.Thus, the SimNN achieved better accuracy than the AnaNN.(b) Probability density histograms together with a normal distribution fit for each one of them.Left two: probability densities of the normalized absolute errors.Right two: probability densities of the actual absolute errors.(c) Prediction results of the AnaNN and the SimNN compared to the test set at the same example OP (the No. 23 OP in both the AnaData and the SimData, where V , P , and Q were {1.1, −1, 0.5}).The SimNN successfully captured the comprehensive information of the real system, while The AnaNN, which lacked awareness of system parameters, failed to establish an accurate admittance model.Therefore, the SimNN achieved better accuracy than the AnaNN.(d) Probability density histograms together with a normal distribution fit for each one of them.Left two: probability densities of the normalized absolute errors.Right two: probability densities of the actual absolute errors.

Fig. 7 .
Fig. 7. Performance evaluation under no analytical model circumstances.(a) SimNN was trained on the SimData collected from the multivector MPC-controlled inverter with the same PLL bandwidth as Inverter 2. Prediction results of the SimNN were compared with the test set at the same example OP (the No. 23 OP in the SimData, where V , P , and Q were {1.1, −1, 0.5}).(b) Probability density histograms together with a normal distribution fit for each one of them.Left two: probability densities of the absolute errors.Right two: probability densities of the relative errors.
followed a normal distribution and were primarily concentrated around an extremely narrow band around zero [left two graphs of Fig. 7(b)], which confirmed the accuracy of the SimNN's predictions.Moreover, the probability density histograms of the relative errors were also largely concentrated around a narrow band around zero [right two graphs of Fig. 7(b)].

Fig. 8 .
Fig. 8. Transfer learning performance evaluations for the extrapolations from analytical data-based model to experimental data-based model.The MSE curves of the transfer learned models were lower than the models learned from scratch even when training on only a few data points (the MSE curves were visualized by adding standard deviations as margins of the mean MSE value for the ten training cycles) and the probability densities of the absolute errors of the transfer learning were more concentrated than those of the models learned from scratch (when using 30 data points), indicating the superior performance of transfer learning.

TABLE I PARAMETERS
OF FOUR INVERTER IMPLEMENTATIONS than 1) and overcurrent (inductor current greater than 110% of the rated current) conditions were excluded from all datasets.Therefore, the final dataset had 800 (20 × 40) {f, V, P, Q} data points in total.Each data point comprised an admittance matrix [Y dd , Y dq ; Y qd , Y qq ].The EMT simulation-generated SimData was visualized in Fig.