Introduction

The transition towards decarbonizing electricity is accelerating globally, driven by substantial increases in renewable energy capacity1. Renewable energy is expected to meet all additional electricity demand through 20262, with wind and solar power generation already contributing over 40% or even 60% in some countries3. Wind and solar power generation require inverter-based interfaces to connect power resources to power grids. Renewable energy sources integrated into the power grid via these interfaces are classified as inverter-based resources (IBRs). The fast and complex dynamic behavior of IBRs, characterized by reduced system inertia, rapid power-electronic transients, and diverse control interactions, complicates the modeling and transient analysis of power systems4,5. Given that dynamic models are the cornerstone of power system stability and control6, several analyses of recent power system disturbances have raised serious concerns about the accuracy of IBR dynamic modeling7,8,9, highlighting the need for improved modeling methods to support power system security and stability at higher levels of renewable energy penetration.

The transient analysis of large-scale power systems incorporating IBRs typically relies on time-domain simulations utilizing dynamic models, also known as the root mean square (RMS) model, phasor-domain model, electromechanical transient model, positive sequence model, etc. Despite vendors developing proprietary dynamic models (vendor models), significant concerns have emerged regarding confidentiality and software-specific implementations10. Therefore, in 2010, the first-generation generic dynamic models for wind turbines and photovoltaic (PV) systems were released by the Western Electricity Coordinating Council (WECC)11. Due to the inherent limitations, such as low accuracy and limited model customization capabilities, the International Electrotechnical Commission (IEC) and WECC collaborated to release the second-generation generic models in 201512. These generic models are fundamentally developed using physics-based approaches derived from simplified physical governing equations. Although continuous refinements have been made in the subsequent years13,14, inherent challenges persist. These limitations stem from several factors: (1) The precise operational mechanisms of IBRs are often obscured by proprietary concerns. Inverter characteristics are primarily dictated by control algorithms, which vendors may not fully disclose for reasons of commercial confidentiality5,10. (2) The growing diversity of control strategies employed in inverters, broadly categorized into grid-following and grid-forming paradigms, challenges the efficacy and universality of single generic models. (3) The mismatch in temporal resolution makes it infeasible to explicitly formulate the detailed physical mechanisms, thereby inherently limiting the fidelity and accuracy of the models5,15. This is because IBR dynamic models are typically simulated at the millisecond time scale, which is coarser than the microsecond time scale governing the physical processes within some IBR devices of IBRs.

Given these limitations of physics-based approaches, data-driven modeling methods have emerged as a promising alternative. The proliferation of measurement devices, such as wide-area measurement systems (WAMS)16 and supervisory control and data acquisition (SCADA)17, facilitates the development of data-driven dynamic models. By using measured data, models can be optimized or tuned to represent the dynamics of IBRs without relying on detailed physical understanding and information. Recent studies18,19,20 use measured data to cluster IBRs, and then perform parameter identification to establish dynamic models. These methods, however, may not fully overcome the inherent limitations derived from physics-based modeling methods. Neural networks, with their data-driven nature and powerful expressive capabilities, hold significant potential for addressing the challenges associated with IBR dynamic modeling. Xiao et al.21 form a neural network-based modeling framework to accurately capture the dynamics of power system components. They further propose a design for power system time-domain simulators to accommodate neural networks22. Some studies also analyze and improve the methods for incorporating neural networks into time-domain simulation23,24. In ref. 25, a data-driven dynamic model of synchronous generators is proposed. Ref. 26 utilizes the data-driven method to precisely model the profiles and dynamics of the load with IBRs. In ref. 27, a black-box dynamic model for microgrids with IBRs is proposed by using long short-term memory (LSTM). In ref. 25,27, the similarity between LSTM and differential algebraic equations (DAEs) describing power system dynamics is discussed in detail. In ref. 28, a dynamic equivalent model is developed for the hybrid renewable energy source in the form of a deep LSTM network. Ref. 29 proposes a high-precision dynamic modeling framework for PV power stations using LSTM. Despite their ability to achieve high accuracy in dynamic modeling, purely neural network-based approaches inherently lack the capacity to enforce physical laws or integrate prior knowledge, occasionally, leading to physically inconsistent or even implausible predictions30. This potential for unreliable outputs poses a significant concern, particularly in safety-critical applications like power system operation and planning31.

Consequently, a physics-informed neural network (PINN) is proposed by combining physical mechanisms with neural network models32,33,34. This approach has gained significant attention across various power system applications, as summarized in recent reviews31, and has been adapted for tasks such as creating dynamic equivalents35 and improving state estimation36. However, a primary challenge for applying PINN to IBRs is its reliance on accurate, explicit governing equations. As established previously, such equations are often unavailable due to vendor confidentiality, mismatch in temporal resolution, etc. Furthermore, the multilayer perceptron (MLP), the foundation of PINN, is not suitable for such time-series regression tasks.

In summary, the existing modeling landscape presents a clear challenge: physics-based models struggle with accuracy due to simplifications and proprietary details; purely data-driven models, while accurate, lack physical grounding and can produce implausible results; and PINN is hampered by its reliance on known governing equations.

In this work, we propose a data-driven IBR dynamic model for time-domain simulation, composed of an LSTM, a Cross layer, and a physical Inverter dynamic model (LSTMCI). The Cross layer is designed to capture the interactions, which are important and prevalent in power system dynamics15,37,38,39,40. LSTMCI uses the advantages of neural networks while ensuring that the dynamic behavior of its output is governed by a physical inverter dynamic model. This design enforces LSTMCI to be strictly constrained by physical mechanisms, providing reliable and accurate outputs. This work aims to enhance foundational transient stability studies by providing such a precise model, thereby supporting more accurate grid planning and operational security assessments.

Results

Design of LSTMCI

The structure of the LSTMCI is shown in Fig. 1. Inspired by the similarity between LSTM and the DAEs that describe IBR dynamics, we employ LSTM as the most fundamental component of the LSTMCI to provide the primary dynamic characteristics of the neural network. To enhance expressive ability, a Cross layer is added to introduce additional interactions. The Cross layer connects to an inverter dynamic model via a fully connected layer (FC), which compresses the variable dimensions to match the inputs required by the inverter model. In this study, the inverter model used is REGC_A41, a widely adopted generic inverter model of WECC, though other inverter models can also be applied. The outputs of the LSTMCI, Ip and Iq, are generated through the inverter dynamic model, whose inputs are the active and reactive current commands (Ipcmd and Iqcmd). Neural networks, including LSTM, the Cross layer, and FC, are employed to emulate components other than the inverter, such as energy conversion systems (e.g., wind turbines, PV panels, and battery systems) and various controllers. These networks process input signals, such as voltage and environmental information, to generate corresponding command signals. This structure aligns with the functional design of IBRs. Detailed formulations and algorithm descriptions are provided in “Architecture of the LSTMCI” section, while a comprehensive overview of the data generation process for model training can be found in Supplementary Note 3. The model’s compatibility and adaptability with measured data were further verified, with full details provided in Supplementary Note 11.

Fig. 1: The proposed model structure.
figure 1

In this schematic, the top panel shows the structure applied to different inverter-based resources (IBRs), including a wind farm, a photovoltaic (PV) power station, and a battery energy storage station (BESS). In this schematic, t is the time step, h and c are the hidden and cell states, x and y are the input and output variable vectors, respectively. V and θ denote the voltage magnitude and phase angle. The active and reactive currents are given by Ip = P/V and Iq = Q/V, where P and Q are the active and reactive power. Φ denotes the other factors, such as environmental information (wind speed, solar irradiance, etc.) and power commands from the control center. Neural networks (including long short-term memory (LSTM), cross-layer, and fully connected layer (FC)) are designed to represent the dynamics beyond inverters. The inverter model simulates the behavior of the inverter and determines the outputs (Ip and Iq) that represent the IBR's interface with the grid.

Test system and scenarios

To comprehensively analyze the dynamic responses of IBRs, we examine a representative real-world power system located in southeastern China as depicted in Fig. 2. This power system includes 59 buses, 70 transmission lines, 6 synchronous generators, and 3 IBRs, including a wind farm, a PV power station, and a battery energy storage station (BESS). In particular, the BESS is grid-forming, and the remaining are grid-following. While all leverage IBR technology, wind farms, PV power stations, and BESSs exhibit substantial variations in composition, topology, and control. Also, the grid-forming and grid-following IBRs differ significantly in structure, control, and dynamics: grid-following inverters in the wind farm and PV power station rely on phase-locked loops (PLLs) for synchronization, while the grid-forming BESS typically lacks PLLs and instead maintains system frequency and voltage through direct control. Therefore, this paper studies and analyzes the three IBRs as examples. Although they cannot fully encompass all of the characteristics of IBRs, they are the most important and widely representative.

Fig. 2: Schematic of the test system.
figure 2

The key defines generator types (G1–G9) and substation voltage levels (500 kV and 220 kV). Single, double, and triple lines indicate the number of parallel circuits (one, two, or three) on a transmission corridor. Low-voltage level substations are aggregated for concise illustration.

The test system is simultaneously constructed in two time-domain simulators: PSD-BPA and an in-house simulator. PSD-BPA is a commercial off-the-shelf (COTS) time-domain simulator42, where the three IBRs are modeled using their default models, which are based on the second-generation generic model. The parameters of the default model employed in this study are used in practice. The in-house simulator is designed for time-domain simulations utilizing the proposed LSTMCI. Except for the dynamics of the IBRs, the simulation results of the two simulators are consistent (illustrated in Supplementary Note 2).

To validate the differences between the default model of PSD-BPA and the LSTMCI, we subjected three representative examples, one for each of the three IBRs, to four typical disturbances. These disturbances included two low-voltage ride-through (LVRT) scenarios and two high-voltage ride-through (HVRT) scenarios, corresponding to scenarios a, b, c, and d illustrated in Figs. 35. All models maintain consistent parameters across the four scenarios. The parameters of the default models are well-suited for scenarios a and c, resulting in the lowest errors in these scenarios compared to the other two. The scenarios and methods of model validation in the examples all satisfy the relevant IEC standard43. In addition to these fault-ride-through tests, the model’s performance was further validated under a large power mismatch scenario, as detailed in Supplementary Note 7.

Fig. 3: Validation of the modeling wind farm.
figure 3

a A low-voltage ride-through (LVRT) scenario (the voltage drops to 0.39 per unit (p.u.)). b A LVRT scenario (the voltage drops to 0.83 p.u.). c A high-voltage ride-through (HVRT) scenario (the voltage rises to 1.15 p.u.). d A HVRT scenario (the voltage rises to 1.22 p.u.). The curves of V show the voltage dips for each scenario. e The mean absolute error (MAE) analysis of P and Q between the four scenarios. f The mean square error (MSE) analysis. Source data are provided as a Source Data file.

To further assess the scalability and practical relevance, we extended our validation to a significantly larger 5,075-bus test system, which is based on an actual regional power grid in China. This large-scale grid contains 496 generators and 10,718 transmission lines, and embeds the 59-bus system described above as a subsystem. Further research and analysis are presented in Supplementary Note 5.

Model validation

Example 1: wind farm

In this example, the target 400 MW wind farm consists of 112 variable-speed wind turbines with permanent magnet synchronous generators (PMSG), each rated at 3.57 MW. Each PMSG is integrated into the medium-voltage collection network through a 0.69 kV/37 kV step-up transformer. The electrical power output is then transmitted via a 35 km medium-voltage collection circuit to a 37 kV/220 kV main transformer, which serves as the point of interconnection to the power grid. The key parameters of a PMSG are listed in S3.

To verify the performance of LSTMCI, we compare two models to the measurements: (1) the default model of the COTS simulator (PSD-BPA) and (2) LSTMCI. The parameters of the default model are actual values used in practice. The outputs of LSTMCI are obtained from the in-house simulator. For a detailed exposition of the model training and integration process with the time-domain simulator, please refer to the “Implementation details” section. The measurements are sampled at the point-of-common coupling (PCC) of the wind farm with a sampling frequency of 100 Hz and processed by a low-pass filter with a cut-off frequency of 1 Hz.

Figure 3 illustrates the simulation results of the proposed model and the default model. To enhance the observability for analytical purposes, the model outputs Ip and Iq have been transformed into P and Q. The default model performs poorly in scenarios b and d, particularly in the voltage recovery curve in scenario b. This is because a single set of default model parameters cannot adequately accommodate all scenarios. Instead, the trained LSTMCI demonstrates enhanced accuracy and adaptability across all scenarios. As depicted in Fig. 3a, b, the proposed LSTMCI model effectively captures key dynamic characteristics, exemplified by the post-fault recovery of active and reactive power.

Figure 3e shows the mean absolute error (MAE) of the four scenarios. The accuracy advantage of the LSTMCI is particularly evident, achieving the lowest error level across almost all scenarios. The mean squared error (MSE) is more sensitive to outliers, providing a perspective that prioritizes the impact of these outliers. Figure 3f shows the MSE of the four scenarios. Across the four scenarios, LSTMCI outperformed the default model, decreasing the overall MAE by 56.1% (from 5.97% to 2.63%) and the MSE by a remarkable 90.9% (from 2.72% to 0.248%). The obvious reduction in MSE suggests that LSTMCI is effective at suppressing large prediction errors and mitigating the extremity of outliers. For more details on error analysis, please refer to Supplementary Note 10. We validated the model’s practical workflow through an incremental learning study, which enhanced accuracy in scenario d by fine-tuning with a limited set of measurements (see Supplementary Note 11). It should be noted that while data are normalized for the neural network training process, model outputs are de-normalized back to their original physical scale before the calculation of any performance metrics. Therefore, all reported MAE and MSE values are based on the actual per unit (p.u.) values. The definitions of the MAE and the MSE are given by the following:

$${{{{\mathcal{L}}}}}_{{{{\rm{MAE}}}}}=\frac{1}{N}{\sum }_{i=1}^{N}\left\vert {\xi }_{i}-\hat{{\xi }_{i}}\right\vert$$
(1)
$${{{{\mathcal{L}}}}}_{{{{\rm{MSE}}}}}=\frac{1}{N}{\sum }_{i=1}^{N}{\left({\xi }_{i}-\hat{{\xi }_{i}}\right)}^{2}$$
(2)

where \({{{{\mathcal{L}}}}}_{{{{\rm{MAE}}}}}\) and \({{{{\mathcal{L}}}}}_{{{{\rm{MSE}}}}}\) represent the MAE and MSE, respectively. ξi is true value at time step i, \(\hat{{\xi }_{i}}\) is model output at time step i, and N is the number of all data points.

Example 2: PV power station

In this example, the PV power station (rated at 500 MW) comprises 500 PV panels, each rated at 1.05 MW. The brief parameters of a PV panel are listed in S4. Each PV string is connected to the collection system via a 1.14 kV/37 kV step-up transformer. Here, we also compare the performance of the default model and the proposed LSTMCI with the measurements. Measurements are also sampled at the PCC of the PV power station with a sampling frequency of 100 Hz and processed by a low-pass filter with a cutoff frequency of 1 Hz. Figure 4 presents a comparative analysis of four different scenarios.

Fig. 4: Validation of modeling photovoltaic power station.
figure 4

The validation scenarios (ad) are defined in Fig. 3. e The mean absolute error (MAE) analysis of P and Q between the four scenarios. f The mean square error (MSE) analysis. Source data are provided as a Source Data file.

In scenarios a and b shown in Fig. 4a, b, the default model suffers from overshooting during the power recovery phase after the LVRT. In scenarios c, d, the default model exhibits deviations during the occurrence and recovery of the HVRT process. Figure 4e, f show the MAE and MSE of the default model and LSTMCI relative to the measurement. The default model exhibits poorer MAE and MSE in scenarios b, d. This further highlights the default model's inability to perform accurately in all scenarios, underscoring the limitations of the existing dynamic model of IBRs in terms of accuracy. Across four scenarios, LSTMCI reduced errors compared to the default model, lowering the overall MAE by 70.4% (from 4.53% to 1.34%) and the MSE by 91.1% (from 1.95% to 0.174%). The LSTMCI demonstrates a significant accuracy advantage across all scenarios, aligning more closely with the measured data.

Example 3: grid-forming BESS

The previously analyzed wind farm and PV power station operate with grid-following inverters, which depend on the grid to provide voltage and command signals for maintaining power output. During outages, these inverters disconnect rather than actively contribute to system recovery. In contrast, grid-forming inverters have garnered significant attention for their ability to enhance system stability by autonomously regulating voltage and frequency. To further investigate this capability, we validate a 100 MW/200 MWh grid-forming BESS. The BESS is at the planning stage. The measurements are from field tests and processed by a low-pass filter with a cut-off frequency of 1 Hz.

Figure 5 shows the comparison results between the LSTMCI and the default model of the PSD-BPA. As in the above examples, the parameters of the default model here are optimized and suited for scenarios a and c. The specific parameters tuned for each of the default models are detailed in Supplementary Note 6. Compared to the modeling results for the grid-following wind farm and PV power station (presented in Figs. 3 and 4), the default model exhibits insufficient accuracy in capturing reactive power dynamics during disturbance processes and performs poorly in unoptimized scenarios. These limitations are absent in the LSTMCI model. As shown in Fig. 5e, f, LSTMCI achieves significantly lower MAE and MSE across all four scenarios. Across the four scenarios, LSTMCI significantly outperformed the default model, decreasing the overall MAE by 73.8% (from 8.04% to 2.11%) and the MSE by 94.9% (from 2.83% to 0.145%). This highlights LSTMCI’s capability to accurately model grid-forming inverter and BESS dynamics.

Fig. 5: Validation of the modeling of the battery energy storage station.
figure 5

The validation scenarios (ad) are defined in Fig. 3. e The mean absolute error (MAE) analysis of P and Q between the four scenarios. f The mean square error (MSE) analysis. Source data are provided as a Source Data file.

Time-domain simulation with LSTMCI

The superior accuracy of LSTMCI demonstrated across the three examples exhibits notable deviations compared to existing generic dynamic models of IBRs in specific scenarios, thereby allowing for more accurate power system stability assessments.

To investigate these implications, a severe three-phase ground fault is applied at the largest generator of the test system, G1. This event triggers low-frequency oscillations in the rotor angle of the grid, as illustrated in Fig. 6 for simulations employing the vendor model, LSTMCI, and a default model (with consistent parameters maintained across all simulations for a fair comparison). Vendor models, widely regarded within the industry as the most accurate and detailed representations, nevertheless suffer from significant practical drawbacks: they are computationally intensive, proprietary, and tied to specific software platforms10,44. These limitations render them unsuitable for the large-scale dynamic studies required by the industry and consequently motivate efforts, such as those by WECC and IEC, to develop generic dynamic models13. Notably, Fig. 6 shows that the rotor angle response simulated with LSTMCI closely mirrors the vendor model’s results, while the response using the default model exhibits a distinctly different oscillatory pattern. The stability characteristics of these oscillations are quantified below using Prony analysis.

Fig. 6: Comparison of rotor angle curve observed at the generator G2 relative to G1.
figure 6

For location of the G1 and G2 see Fig. 2. The simulation with the vendor models is shown as a reference, where closer agreement indicates better accuracy. Source data are provided as a Source Data file.

To further characterize these oscillations, Prony analysis is conducted on the rotor angle responses to extract dominant modes45,46. The Prony analysis results of rotor angle low-frequency oscillations in generator G2 are summarized in Table 1, where the frequency, amplitude, phase, damping, and damping ratio are provided for each model. The simulations based on the vendor model and LSTMCI both reveal a dominant low-frequency mode, with closely aligned frequencies (0.799 Hz and 0.794 Hz, respectively). Critically, both the vendor model and LSTMCI simulations yield positive damping values (0.020 and 0.021) and corresponding negative damping ratios (−0.395 and −0.411), indicating an unstable response under the fault scenario. In contrast, the simulation using the default model exhibits a different oscillatory profile, characterized by a slightly higher frequency (0.887 Hz), a negative damping value (−0.005), and a corresponding positive damping ratio (0.024), suggesting a stable mode.

Table 1 Prony analysis results of rotor angle low-frequency oscillations in generator G2

These Prony analysis findings highlight the significant accuracy improvements of time-domain simulations with LSTMCI. By accurately capturing the dominant oscillatory behavior and the instability tendency predicted by the baseline vendor model, LSTMCI offers a more reliable assessment of power system stability compared to the default model, which exhibits qualitatively different and potentially erroneous stability characteristics. This highlights the importance of employing accurate IBR dynamic models, such as LSTMCI, for comprehensive power system stability studies in power systems with high IBR penetration. To further underscore this point, a detailed comparative analysis in an IBR-dominated, low-inertia system, where the impact of model accuracy is even more critical, is provided in Supplementary Note 9.

Performance comparison

This section validates the proposed LSTMCI model by comparing its extrapolation capability against the default model, and its accuracy and efficiency against other data-driven approaches (including purely neural networks and a PINN). These comparisons serve to demonstrate the superiority of our tailored architecture.

Extrapolation capability

Model evaluation distinguishes between in-distribution data, resembling the training data, and out-of-distribution data, representing novel conditions or out-of-range inputs. Model generalization capability hinges on its extrapolation capability: accurate predictions on out-of-distribution inputs, demonstrating generalization beyond training patterns47,48. To validate the extrapolation capability of the model across different scenarios, we tested a continuous LVRT scenario for a wind farm. Initially, the wind farm drops down to 0.4 p.u. 200 ms later, a zone-based protection operates, then the PCC voltage of the wind farm returns to 0.75 p.u. Another protection operates 400 ms later, which returns the voltage to normal. In this scenario, we evaluated the performance of the vendor model, the default model, and the LSTMCI. The time-domain simulation results for each model are shown in Fig. 7a. It is important to note that the training data for LSTMCI is based on single disturbances only. Thus, the blue region in Fig. 7a is within the distribution of the training set or in-distribution, and the other region is out-of-distribution. Despite operating in an untrained scenario, LSTMCI still demonstrated high accuracy. Its dynamic response of the active and reactive power is similar to the vendor model: the MAE between the LSTMCI and the vendor model is 2.04% for active power and 0.73% for reactive power. The default model here is specifically tuned for the 0.4 p.u. LVRT scenario, but it performed poorly in this complex scenario, especially in capturing the active power recovery characteristics. The MAE between the default model and vendor models is 13.61% for active power and 2.62% for reactive power. This illustrates that the default model cannot achieve high accuracy across all scenarios. It highlights that the extrapolation capability of LSTMCI is better across multiple scenarios.

Fig. 7: Results of performance comparison.
figure 7

a Continuous low-voltage ride-through (LVRT) process observed at the point-of-common coupling (PCC) of the wind farm. The training data of LSTMCI only contains a single disturbance. The blue region represents the trained data, and the other region is untrained. In the beginning, the PCC voltage of the wind farm drops to 0.4 p.u. Then, a zone-based protection is triggered, returning the voltage to 0.75 p.u. A second protection operates 400 ms later, returning the voltage to normal. b mean absolute error (MAE) and mean square error (MSE) results of neural networks for the three inverter-based resources (IBRs). The compared models include the recurrent neural network (RNN), temporal convolutional network (TCN), multilayer perceptron (MLP), and gated recurrent unit (GRU). c MAE and MSE results of similar structures for the three inverter-based resources (IBRs): the wind farm, photovoltaic (PV) power station, and battery energy storage system (BESS). The inverter dynamic model is denoted as Inv., and the cross-layer is denoted as Cro. d Efficiency of training models for the three IBRs. Source data are provided as a Source Data file.

Comparison with other neural networks

Compared to other existing neural network models, our method has distinct theoretical advantages: the outputs of our method are more reliable and explainable. The output of our method is generated by an inverter model, and its dynamic behaviors are compelled to meet the physical constraints of the inverter.

Basically, the IBR dynamic modeling is a time-series regression problem. To provide comparative benchmarks, we evaluated several established sequence models against our proposed approach, including LSTM, RNN, gated recurrent unit (GRU), temporal convolutional neural network (TCN)49, and Transformer50. Furthermore, to situate our work in the context of physics-informed methods, we also include a state-of-the-art PINN in our comparison51. The PINN is constructed using the second-generation generic model equations as its physical basis. In order to ensure a fair comparison, the data used for the training of each model, the data normalization method, etc., are kept consistent. Additionally, when feasible, we match the number of parameters of the models to that of the proposed model as closely as possible. Table 2 shows the features of the evaluated models. To reflect the practical scarcity of measured data, the neural network in this study is trained using a limited number of data samples. Details of the data generation process are provided in Supplementary Note 3.

Table 2 Model details and descriptions

MAEs of the comparison results are shown in Fig. 7b. Among the three examples, the proposed method outperforms all other models, as demonstrated by the fact that the MAEs are at the lowest levels. Among the purely data-driven networks, the MLP shows the maximum errors across the three IBRs, which confirms its unsuitability for time-series regression tasks. The PINN, by incorporating physical information, achieves a lower error than the standard MLP, confirming the benefit of physics-informed approaches. Nevertheless, the proposed LSTMCI model still demonstrates higher accuracy than the PINN across all three IBR cases. This remaining performance gap can be attributed to the two key limitations of the PINN framework in this application: its accuracy is inherently limited by the accuracy of the simplified generic model equations it relies on, and its MLP-based structure is less adept at capturing complex temporal dependencies compared to LSTMCI. Figure 7d compares the loss function descent process of LSTMCI and LSTM in the validation set. The LSTMCI reaches lower loss faster, which demonstrates better training efficiency.

To determine the optimal structure, this study tested several related alternative structures for the three IBRs validated as examples. Every related alternative structure is detailed in Table 2 and the validation results are shown in Fig. 7c. The error of the LSTM+Inv. is reduced relative to LSTM. This indicates that using the inverter model can effectively regulate the dynamic behavior of LSTM and improve its accuracy. With the Cross layer, the accuracy of LSTM+Cro. is improved relative to LSTM in all scenarios. It shows that the Cross layer adds effective interactions between the variables to LSTM and improves its expressive accuracy. Deep & Cross network (DCN) is specifically designed to provide the interactions52, but is not effective enough in this problem. DCN provides redundant structures and parameters that complicate the model, resulting in LSTM+DCN+Inv, which is even less accurate than LSTM. The accuracy of RNN+Cro.+Inv. is lower than that of LSTMCI since LSTM is improved from RNN.

Discussion

In this article, we propose a data-driven approach to establishing dynamic models for IBRs, utilizing the advantages of neural networks to overcome the inherent limitations of physics-based, purely neural network-based, and PINN-based dynamic models. The method incorporates physical characteristics by employing an embedded physical inverter model to regulate LSTMCI outputs. This addresses the physical consistency challenges faced by purely neural network-based and PINN-based models. To evaluate its effectiveness, we validated the LSTMCI using two systems: a large-scale, real-world power system containing 5075 buses, and an IBR-dominated system with 57.8% penetration. LSTMCI significantly outperformed existing IBR dynamic models across various scenarios, including complex continuous disturbance events, exhibiting both enhanced extrapolation capability and superior accuracy, with relative reductions of over 90% in MSE and up to 73.8% in MAE. These results highlight the robustness and practical applicability of LSTMCI in power system simulations where diverse conditions and unforeseen fault combinations are common. Consequently, the findings indicate that time-domain simulations incorporating LSTMCI not only enhance simulation accuracy but may also yield transient stability analysis conclusions that differ from those obtained using existing dynamic models of IBRs. Comparing other neural network approaches, LSTMCI achieves higher accuracy with a similar number of parameters due to its physical constraints. This may help alleviate concerns of power system operators about the reliability of neural network-based dynamic models. Furthermore, the proposed LSTMCI approach demonstrates the potential to capture the dynamics of a broad range of IBRs, indicating its applicability extends beyond the specific case studies examined here (e.g., wind farms, PV power stations, and BESSs). Ultimately, by providing a more reliable foundation for time-domain simulation, this methodology has the potential to enhance a range of critical engineering studies, including power system planning, security assessment, post-mortem event analysis, and so on. For further clarification, a schematic illustrating this hierarchical application framework is provided in Supplementary Note 13.

There still remain some potential limitations associated with the present LSTMCI for IBR dynamic modeling. Firstly, the training data of LSTMCI in this study is generated from the vendor models, which are widely recognized by the industry as a benchmark for accuracy. While these models are accurate, they may not fully align with measured data and may not encompass all dynamic behaviors encountered in operational environments. In practice, measured data can be utilized to train the model for further improvement in accuracy. For new installations with scarce data, transfer learning can be employed to adapt a pre-trained model from a similar IBR, significantly accelerating deployment. A further practical consideration is the long-term validity of the model, as IBR characteristics can evolve due to aging or firmware updates, which is a challenge known as concept drift. To counteract concept drift over time, models can be efficiently updated using incremental learning, an approach whose feasibility we have successfully demonstrated in this work (see Supplementary Note 11). To solve the challenge of maintaining long-term accuracy, well-established online adaptation strategies can be employed to automate this process, where performance degradation automatically triggers model fine-tuning. A detailed discussion of these strategies is provided in the Supplementary Note 11. Additionally, when initial training data are insufficient, transfer learning from pre-trained models can enhance accuracy in dynamic modeling. Furthermore, for data-scarce scenarios such as new installations, a practical strategy is to generate training data via detailed electromagnetic transient simulations using vendor models. The use of such simulated data is justified by its superior accuracy over simplified generic models and is a practice supported by recent community efforts in creating open-source datasets for this purpose53. This workflow ensures our method’s applicability even when extensive historical measurements are unavailable. Practical data quality is also a key consideration. The model’s performance is fundamentally linked to the data’s temporal resolution; the 100 Hz rate used herein is consistent with WAMS and sufficient for capturing the target dynamics. In terms of measurement accuracy, the model’s average Total Vector Error (4.81%) on test data approaches the IEEE standard for measurements (<1% Total Vector Error)54. This proximity indicates the model’s high accuracy, while also suggesting that sensitivity to measurement noise is an important characteristic for future investigation of such high-performance models. Investigating the model’s sensitivity to measurement noise, a characteristic challenge for such high-fidelity models, is therefore a key direction for future research. Furthermore, the number of parameters in the Cross layer scales cubically with the number of LSTM hidden layers. Therefore, increasing the number of hidden layers to increase the representational capacity of the model can lead to computational challenges. Based on the results of this study, an LSTMCI model with eight hidden layers is sufficient for the complexity of wind farms, PV power stations, and BESSs. Meanwhile, for IBRs of lower complexity, reducing the number of hidden layers would be beneficial in optimizing the performance and computational efficiency of the model. The independent nature of each LSTMCI instance means that the framework is naturally capable of parallel or distributed computation. This is the recommended approach to ensure computational efficiency, particularly for deployment in large-scale systems with a substantial number of IBRs. A detailed computational benchmark study has confirmed that this approach ensures the framework is both scalable and capable of faster-than-real-time performance (see Supplementary Note 8). Additionally, LSTMCI is sensitive to the initial parameters of the inverter model. This may be attributed to the training algorithm and the structure of the inverter model employed in this study, wherein specific parameters are defined by upper and lower bounds for limiting functions. These parameters are only updated when limits are triggered, leading to low update frequency, which can prevent the optimization of all inverter model parameters to their optimal values. Adjusting the optimization step size for inverter model parameters, optimizing only key parameters, or selecting alternative optimization algorithms for the inverter model could help to address this issue. Accordingly, there exists substantial potential for the enhancement of the performance of LSTMCI.

Moreover, a potential relationship exists between the parameters and computational procedures of the LSTMCI and the fundamental physical mechanisms governing IBR dynamics. It is anticipated that techniques such as visualization and sparse regression will facilitate the elucidation of these mechanisms. This investigation will constitute a key component of our future research.

Methods

Architecture of the LSTMCI

The proposed network architecture of LSTMCI is shown in Fig. 1. The model architecture reflects the physical structure of IBRs. LSTMCI uses neural networks, LSTM, Cross layer, and FC to capture and express non-inverter dynamics. Subsequently, an inverter model employs the output of the neural network to generate current for injection into the grid. This study employs an inverter model, REGC_A, and other inverter models are also available. Among the neural networks, the LSTM serves as the foundational element. The selection of LSTM over RNN is due to the fact that RNNs suffer from the vanishing gradient problem, making them ineffective at capturing the crucial long-term dependencies in power system dynamics. Compared to the similarly efficient GRU, the LSTM’s more expressive structure with separate forget and input gates allows for more flexible control over the model’s memory, which is critical for modeling the complex, path-dependent behavior of IBRs following a disturbance27,28,29. It processes the hidden state of the last time step, h(t−1), cell state of the current time step, c(t−1), and input variable of the current time step x(t), to output the middle hidden state, \({{{{\boldsymbol{h}}}}}_{(t)}^{{\prime} }\). Notably, the input vector x(t) includes voltage magnitude and phase angle, while system frequency is omitted. This is because, within the phasor-domain framework used for transient stability, frequency dynamics are implicitly captured by the time derivative of the phase angle (\(\Delta f=\frac{1}{2\pi }\frac{d\theta }{dt}\)), making it a learnable but redundant feature. The Cross layer processes \({{{{\boldsymbol{h}}}}}_{(t)}^{{\prime} }\), x(t), and the outputs of the last time step, y(t−1), to output the hidden state, h(t). FC processes h(t) to output the inputs of the REGC_A, Ipcmd and Iqcmd. In the end, REGC_A outputs Ip and Iq as the output of the LSTMCI. Supplementary Note 1 provides detailed information on the REGC_A model, including its structure, parameters, and practical availability. The LSTMCI offers a unified framework for modeling the dynamics of IBRs. The flexibility of this approach allows for the modeling of diverse IBR types by simply adjusting the inputs to LSTMCI.

A key challenge in IBR dynamic modeling is representing the numerous and significant nonlinear interactions among state variables. Fundamentally, these interactions arise from the underlying physics: for instance, quantities like active and reactive power are products of voltage and current, and the essential d/q-axis transformations central to inverter control involve nonlinear trigonometric functions of the phase angle. While a standard LSTM can capture temporal patterns, it cannot efficiently or explicitly model these crucial pairwise and higher-order feature interactions25. To address this, in this study, the cross-layer is designed to add pairwise interactions between all variables (including \({{{{\boldsymbol{h}}}}}^{{\prime} }\), x, and y) to the LSTM equations. The input of the Cross layer includes V(t), θ(t), Φ(t), Ip(t−1), and Iq(t−1). By multiplying or squaring these variables, relevant electrical power information can be incorporated. The input of the Cross layer also includes \({{{{\boldsymbol{h}}}}}^{{\prime} }\), allowing \({{{{\boldsymbol{h}}}}}^{{\prime} }\) for other inputs of the Cross layer to simulate additional pairwise interactions. The equations of the cross-layer are shown in (3) and (4). The calculation process is depicted in Fig. 8a.

$${{{\boldsymbol{{{{\mathcal{I}}}}}}}}=({M}_{h}\otimes {{{{\boldsymbol{l}}}}}^{T}){W}_{I}{{{\boldsymbol{l}}}}$$
(3)
$${{{\boldsymbol{l}}}}={[{{{{\boldsymbol{h}}}}}_{(t)}^{T},{{{{\boldsymbol{x}}}}}_{(t)}^{T},{{{{\boldsymbol{y}}}}}_{(t-1)}^{T}]}^{T}$$
(4)

where \({{{\boldsymbol{{{{\mathcal{I}}}}}}}}\) represents all the interactions, WI denotes weights, l is a column vector composed of all the variables, is the Kronecker product, Mh is an nh × nh unitary matrix, nh is the number of dimensions of h, also the number of state variables.

Fig. 8: Illustration of the cross-layer and the LSTMCI-based time-domain simulation methodology.
figure 8

a Visualization of the proposed cross-layer. b Integration process of LSTMCI into a time-domain simulator using the alternating iteration method.

Implementation details

Initialization

The parameters of the neural networks of the LSTMCI are initialized with Xavier normal55, and the parameters of the inverter model are set according to the rated values collected from vendors. The state variables of the LSTM are initialized as zeros, and the variables of the REGC_A are initialized according to the power flow results.

Data preprocessing

The comprehensive overview of the data generation process for model training can be found in Supplementary Note 3. All of the data used is low-pass filtered. For the dynamic model, the signals of the IBRs are centered around the steady-state operating point, with significant deviations occurring during faults. Therefore, we propose a mean centering adjustment based on min-max normalization to normalize the input used by the LSTM and the cross-layer of the LSTMCI. The normalization is defined by the following:

$${{{{\boldsymbol{z}}}}}^{*}=\frac{{{{\boldsymbol{z}}}}-{{{{\boldsymbol{z}}}}}_{\min }}{{{{{\boldsymbol{z}}}}}_{\max }-{{{{\boldsymbol{z}}}}}_{\min }}-\frac{1}{{N}_{i}}{\sum }_{i=1}^{{N}_{i}}\frac{{{{\boldsymbol{z}}}}-{{{{\boldsymbol{z}}}}}_{\min }}{{{{{\boldsymbol{z}}}}}_{\max }-{{{{\boldsymbol{z}}}}}_{\min }}$$
(5)

where z* is the normalized data, z is the original data points, \({{{{\boldsymbol{z}}}}}_{\min }\) and \({{{{\boldsymbol{z}}}}}_{\max }\) are the minimum and maximum values of z, Ni is the dimension of the z.

Training

In this paper, we use the MAE as the evaluation metric, which is commonly used in time-series regression and dynamic model validation43,56. The loss function employed by this study is defined as follows:

$${{{\mathcal{L}}}}={{{{\mathcal{L}}}}}_{{{{\rm{MAE}}}}}({{{\boldsymbol{\xi }}}},\hat{{{{\boldsymbol{\xi }}}}})+{\lambda }_{k}{{{{\mathcal{L}}}}}_{{{{\rm{MAE}}}}}({{{{\boldsymbol{\xi }}}}}_{k},{\hat{{{{\boldsymbol{\xi }}}}}}_{k})$$
(6)

where \({{{{\mathcal{L}}}}}_{{{{\rm{MAE}}}}}\) is the MAE function referring to (1), \(\hat{{{{\boldsymbol{\xi }}}}}\) is the output of the LSTMCI, \({\hat{{{{\boldsymbol{\xi }}}}}}_{k}\) is the output of the LSTMCI during the key time period (i.e., pre-fault, fault, and post-fault period), ξ and ξk are the corresponding true values, and λk is a parameter which controls the importance of the key time period.

We select the pre-fault period as the key time period in the loss function to ensure the model accurately establishes the initial steady-state conditions. Furthermore, to develop a more physically grounded internal state representation, the model can be trained to predict key physical quantities in addition to its primary outputs. This is achieved through a multi-task learning strategy. In addition to the primary task of predicting terminal quantities (e.g., currents Ip and Iq), the model is simultaneously trained to predict a set of auxiliary physical variables. These auxiliary targets are selected based on two criteria: their physical significance in representing the IBR’s internal dynamics and their practical availability from measurement data (e.g., DC-link voltage, PLL states). This is achieved by defining a composite loss function as shown in Eq. (6), which includes weighted loss terms for both the primary and auxiliary outputs. This process encourages the network to learn a more complete and accurate representation of the IBR’s internal dynamics if the internal state's physical quantities can be obtained.

We use the adaptive moment estimation (Adam) optimizer57 with a batch size of 4 to optimize the parameters of the models. The step size is set to 0.001, the decay rate for momentum is 0.9, and the decay rate for squared gradients is 0.999. All the parameters, including the parameters of the neural networks and the inverter model, are optimized in a synchronous manner. In this study, the neural networks and the REGC_A model are constructed and trained using PyTorch58.

Representation of different control strategies

The proposed data-driven framework accounts for various IBR control strategies, such as grid-following and grid-forming, by learning their resultant dynamic behaviors. It is important to clarify that while these control strategies correspond to physically different characteristics (i.e., controlled current sources and controlled voltage sources), the model’s structure of providing a current injection as output based on terminal voltage as an input is consistent for both. This input-output format is dictated by the standard numerical interface of large-scale time-domain simulators, which requires all component models to provide their corresponding current injections.

Therefore, the model learns to replicate the correct current injection response for any given control strategy within this simulation-compatible modeling framework. Rather than containing explicit parameters or switches for different control modes, the model learns from operational data that inherently embeds the unique dynamic characteristics produced by a specific control strategy in response to grid events. By training on a dataset from an IBR with a grid-forming scheme, for instance, the LSTMCI model learns to replicate that specific grid-forming behavior. Differentiation between control types is thus achieved by training distinct model instances on representative datasets for each strategy. This universal modeling philosophy is illustrated schematically in Supplementary Note 12.

Integration with the time-domain simulator

The proposed model is incorporated into a time-domain simulator using the alternating iteration method, a widely used technique in COTS time-domain simulation software for power systems23. Figure 8b shows the brief process of LSTMCI incorporation into a time-domain simulator. At each time step of the alternating iteration, the time-domain simulator feeds the bus voltages to the dynamic models, which in turn feed the injected currents back to the simulator. Once the alternating iteration converges, the solution proceeds to the next time step. At this point, the dynamic model saves and transfers the converged state variables for use in the next time step. Please see Supplementary Note 2 for details.