A Unified Transformer-Based Harmonic Detection Network for Distorted Power Systems
Abstract
1. Introduction
1.1. Prior Works and Motivations
1.2. Contributions
- High-fidelity offshore harmonic benchmark without synthetic augmentation: We establish a reproducible benchmark for offshore harmonic prediction in a DFIG-based OWF connected through a 36 km submarine cable. The dataset is generated by detailed EMT simulations driven by real meteorological wind-speed records (Typical Meteorological Year data for the Bozcaada region), producing operational snapshots and corresponding harmonic indices (e.g., THDV) that reflect realistic operating variations, rather than relying on Generative-AI-based synthetic expansion.
- Unified Physics-Transformer with attention-based coupling modeling: We propose a Transformer encoder tailored to heterogeneous physical features, where a lightweight feature tokenizer maps measured scalars into embeddings and multi-head self-attention learns the coupling among meteorological inputs, electrical states, and harmonic responses. Compared with LSTM/GRU-style sequential modeling, the proposed attention mechanism captures global dependencies and multivariate interactions in a single forward pass, which is particularly beneficial under resonance-dominated offshore conditions.
- Multi-task learning for global and characteristic harmonics: We formulate harmonic prediction as a multi-task regression problem and design an MTL head that jointly predicts the global power-quality metric (THDV) and characteristic harmonic components (e.g., the 5th harmonic magnitude). This unified formulation improves generalization and accuracy by sharing representations across correlated harmonic targets, and it provides richer diagnostic information than single-target prediction.
- Reproducible DFIG converter implementation and monitoring-aligned measurements: We incorporate a detailed DFIG back-to-back converter implementation (including PWM switching at 2700 Hz and the associated grid-interface elements) and define measurement points consistent with engineering practice (PCC at 60 kV and turbine terminal at 575 V). This bridges the learning pipeline with realistic PQ monitoring and makes the proposed framework directly applicable to offshore-grid measurement infrastructures.
- Comprehensive benchmarking and robustness under distorted conditions: We conduct systematic comparisons against representative ML/DL baselines (e.g., RF, LSTM, GRU). The results show that the proposed framework achieves superior prediction accuracy and maintains robustness under transient and high-distortion scenarios, where conventional models often degrade.
2. System Modeling and Data Generation
2.1. System Configuration and Modeling
2.1.1. Offshore Wind Farm Topology
- Onshore Substation: A , transformer connecting the grid to the subsea cable. The winding configuration is Wye-grounded/Delta (). According to the system specifications, the resistances and leakage inductances of the windings are modeled as p.u., while the magnetization inductance is set to p.u.
- Offshore Substation: A , transformer () stepping down voltage to the wind turbine terminals.

2.1.2. Submarine Cable and DFIG Configuration
2.2. Data Acquisition and Generation
2.2.1. Meteorological Input
2.2.2. Harmonic Analysis and Feature Extraction
3. A Unified Transformer-Based Harmonic Detection Network
3.1. Problem Formulation and Data Representation
3.2. Feature Tokenizer: Manifold Projection of Physical Quantities
3.3. Transformer Encoder: Modeling Multivariate Couplings via Self-Attention
3.4. Multi-Task Learning Head and Joint Optimization
4. Simulations and Discussions
4.1. Experimental Settings
- Inputs (): Meteorological and electrical state variables, including Wind Speed (), Active Power (P), Reactive Power (Q), and Bus Voltage Magnitude ().
- Target 1 (): Total Harmonic Distortion of Voltage, representing the global power quality index.
- Target 2 (): The magnitude of the 5th harmonic component, representing the dominant characteristic harmonic in DFIG systems.
4.2. Baseline Methods and Implementation Details
- (1)
- Random Forest [33] (named as RF): An ensemble learning method constructing a multitude of decision trees. It is selected as a strong baseline for tabular data regression due to its robustness against noise and ability to capture non-linear interactions without complex feature engineering.
- (2)
- Long Short-Term Memory Network [34] (named as LSTM): A classic Recurrent Neural Network (RNN) variant designed to overcome the vanishing gradient problem. It is included to evaluate the performance of sequential modeling in capturing the temporal dynamics of wind power fluctuations.
- (3)
- Gated Recurrent Unit [35] (named as GRU): A streamlined RNN architecture with fewer parameters than LSTM. It serves as a baseline to assess whether a simpler recurrent structure offers a better trade-off between computational efficiency and prediction accuracy in harmonic forecasting.
- (4)
- Standard Multi-Layer Perceptron (named as MLP): A feed-forward neural network without attention or recurrence mechanisms. This baseline is used to quantify the specific performance gain achieved by introducing the self-attention mechanism in our proposed Transformer architecture.
- (5)
- Gradient Boosting with Neural Networks [36] (named as GB-Net): Combines traditional gradient boosting with deep learning for enhanced predictive power and model flexibility.
- (6)
- Support Vector Machine with Deep Learning Features [37] (named as SVM-DL): Integrates deep feature learning with the traditional SVM model to improve classification accuracy for high-dimensional datasets.
- (7)
- Deep K-Nearest Neighbors [38] (named as D-KNN): A deep learning variant of KNN, leveraging neural networks for enhanced feature extraction and classification.
- (8)
- Bayesian Deep Learning [39] (named as BayesDL): A modern Bayesian approach that integrates deep learning models for improved uncertainty quantification in predictions.
- (9)
- eXtreme Gradient Boosting with Deep Neural Features [40] (named as XGBoost-DNN): An integration of XGBoost and deep neural networks for large-scale, high-dimensional feature learning and boosting.
- (10)
- LightGBM with Deep Embeddings [41] (named as LightGBM-DL): A hybrid model that enhances LightGBM’s boosting capabilities by incorporating deep learning embeddings for categorical and continuous features.
- (11)
- Categorical Boosting with Neural Optimization [42] (named as CatBoost-NO): A recent iteration of CatBoost that optimizes categorical feature handling through neural network-based fine-tuning.
4.3. Performance Analysis of Task-1: THD Prediction
4.4. Performance Analysis of Multi-Task Learning Strategy
4.4.1. Analysis of Task 1: THD Prediction
4.4.2. Analysis of Task 2: 5th Harmonic (H5) Prediction
4.5. Visualization of Harmonic Tracking Performance
- (1)
- Analysis of Global Distortion Tracking (Task 1)
- Trend Alignment: The model successfully captures the low-frequency trends driven by the variations in wind speed and active power output.
- Transient Response: More importantly, the model demonstrates rapid response capabilities to sudden fluctuations (e.g., the sharp peaks around time steps 40 and 85). This indicates that the self-attention mechanism effectively correlates instantaneous input features with output distortions without suffering from the “lagging” effect often seen in traditional recurrent neural networks. The tight overlapping of the curves confirms the model’s reliability in monitoring the overall power quality status of the offshore wind farm.
- (2)
- Analysis of Characteristic Harmonic Tracking (Task 2)
- Volatility Capture: As shown in the figure, the H5 signal (black line) exhibits significantly more high-frequency jitter and extreme volatility compared to the smoothed THD signal. Despite this difficulty, the proposed model (blue dashed line) effectively reconstructs the phase and amplitude of the dominant variations.
- Resonance Detection: Crucially, the model successfully identifies critical resonance events where the harmonic magnitude spikes (e.g., at time steps 55 and 95). Although there are minor discrepancies in the absolute peak values, which aligns with the slightly higher RMSE observed in Table 3, the model accurately flags the occurrence of these high-risk events. This capability is vital for protective relaying and active filter control, proving that the Multi-Task Learning strategy successfully extracts robust features that are relevant to specific spectral components even in a noisy environment.
4.6. Quantitative Ablation Study on Physics-Informed Components
4.7. Applicability to Real-World Scenarios and Limitations
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- GWEC. Global Wind Report 2024; Global Wind Energy Council: Brussels, Belgium, 2024. [Google Scholar]
- IRENA. World Energy Transitions Outlook 2024; International Renewable Energy Agency: Abu Dhabi, United Arab Emirates, 2024. [Google Scholar]
- Lakshmanan, P.; Sun, R.; Liang, J. Electrical collection systems for offshore wind farms: A review. CSEE J. Power Energy Syst. 2021, 7, 1078–1092. [Google Scholar] [CrossRef]
- Hou, P.; Zhu, J.; Ma, K.; Yang, G.; Hu, W.; Chen, Z. A review of offshore wind farm layout optimization and electrical system design methods. J. Mod. Power Syst. Clean Energy 2019, 7, 975–986. [Google Scholar] [CrossRef]
- Zhang, Y.; Klabunde, C.; Wolter, M. Frequency-Coupled Impedance Modeling and Resonance Analysis of DFIG-Based Offshore Wind Farm With HVDC Connection. IEEE Access 2020, 8, 147880–147894. [Google Scholar] [CrossRef]
- Tang, Z.; Yang, Y.; Blaabjerg, F. Power electronics: The enabling technology for renewable energy integration. CSEE J. Power Energy Syst. 2022, 8, 39–52. [Google Scholar]
- Ji, X.; Xu, H.; Liu, H.; Kong, X. Modeling and Stability Analysis of DFIG-Based Wind Farm Using Harmonic State Space Theory. In Proceedings of the 2025 Zhejiang Power Electronics Conference (ZPEC), Hangzhou, China, 22–24 August 2025; pp. 232–237. [Google Scholar]
- Huang, X.; Huang, H.; Pan, X.; Xu, Q.; He, B.; Zhang, Z.; Xu, Z. Harmonic Resonance Mode Analysis for Offshore Wind Power System Based on Impedance Gathering. In Proceedings of the 2024 IEEE PES 16th Asia-Pacific Power and Energy Engineering Conference (APPEEC), Nanjing, China, 25–27 October 2024; pp. 1–5. [Google Scholar]
- Std 519-2022; IEEE Standard for Harmonic Control in Electric Power Systems. IEEE Power and Energy Society: Piscataway, NJ, USA, 2022; pp. 1–31.
- IEC TR 61000-3-6:2008; Electromagnetic Compatibility (EMC)—Part 3–6: Limits—Assessment of Emission Limits for the Connection of Distorting Installations to MV, HV and EHV Power Systems. International Electrotechnical Commission: Geneva, Switzerland, 2008.
- Siqueira-de Carvalho, R.; Morales-Paredes, H.K.; Bates, C.; Ausmus, J.; Simões, M.G.; Sen, P.K. Overview of Big Data Analytics in Power Quality Analysis and Assessment. In Proceedings of the 9th Brazilian Technology Symposium (BTSym’23), Campinas, Brazil, 24–26 October 2024; pp. 3–16. [Google Scholar]
- Ullah, M.; Guan, Y.; Yu, Y.; Chaudhary, S.K.; Vasquez, J.C.; Guerrero, J.M. Dynamic Performance and Power Quality of Large-Scale Wind Power Plants: A Review on Challenges, Evolving Grid Code, and Proposed Solutions. IEEE Open J. Power Electron. 2025, 6, 1148–1173. [Google Scholar] [CrossRef]
- Bracale, A.; Caramia, P.; De Falco, P.; Domagk, M.; Meyer, J. Probabilistic Forecasting of Current Harmonic Distortions in Distribution Systems. In Proceedings of the 2023 IEEE PES Innovative Smart Grid Technologies Europe (ISGT EUROPE), Grenoble, France, 23–26 October 2023; pp. 1–5. [Google Scholar]
- Hadi, F.M.A.; Aly, H.H. Harmonics Forecasting of Renewable Energy System Using Hybrid Model Based on LSTM and ANFIS. IEEE Access 2024, 12, 50966–50985. [Google Scholar] [CrossRef]
- Li, G.Y.; Yen, H.J.; Wu, J.W.; Huang, W.Y.; Chang, G.W. A Comparative Study of Harmonic Distortion Assessment for an Offshore Wind Farm System. In Proceedings of the 2024 21st International Conference on Harmonics and Quality of Power (ICHQP), Chengdu, China, 15–18 October 2024; pp. 451–456. [Google Scholar]
- Ravi, T.; Srividya, S.; Praveena, A.; Anil, V.; Kumar K, S.; Jayaprakash, S. Review of Detection and Classification of Power Quality Disturbances Using Machine Learning and Deep Learning Methods. In Proceedings of the 2023 Innovations in Power and Advanced Computing Technologies (i-PACT), Kuala Lumpur, Malaysia, 8–10 December 2023; pp. 1–8. [Google Scholar]
- Elymany, M.M.; Enany, M.A.; Elsonbaty, N.A. Hybrid optimized-ANFIS based MPPT for hybrid microgrid using zebra optimization algorithm and artificial gorilla troops optimizer. Energy Convers. Manag. 2024, 299, 117809. [Google Scholar] [CrossRef]
- Song, D.; Yousaf, A.; Noor, J.; Cao, Y.; Dong, M.; Yang, J.; Rizk-Allah, R.M.; Elkholy, M.H.; Talaat, M. ANN-Based Model Predictive Control for Hybrid Energy Storage Systems in DC Microgrid. Prot. Control Mod. Power Syst. 2025, 10, 1–15. [Google Scholar]
- Hadi, F.M.A.; Aly, H.H.; Little, T. Harmonics Forecasting of Wind and Solar Hybrid Model Based on Deep Machine Learning. IEEE Access 2023, 11, 100438–100457. [Google Scholar] [CrossRef]
- Hadi, F.M.A.; Aly, H.H.; Little, T. Harmonics Forecasting of Wind and Solar Hybrid Model Driven by DFIG and PMSG Using ANN and ANFIS. IEEE Access 2023, 11, 55413–55424. [Google Scholar] [CrossRef]
- Coya, Z.; Khoodaruth, A.; Ramenah, H.; Oree, V.; Murdan, A.P.; Bessafi, M. Deep Learning Models in Photovoltaic Power Forecasting: A Review. In Proceedings of the 2024 1st International Conference on Smart Energy Systems and Artificial Intelligence (SESAI), Balaclava, Mauritius, 3–6 June 2024; pp. 1–9. [Google Scholar]
- Sezgin, E.; Salor, Ö. Enhanced Frequency and Harmonic Estimation for Electric Arc Furnace Measurements: A Least Squares Approach to Mitigate Spectral Leakage. IEEE Trans. Ind. Appl. 2025, 1–11. [Google Scholar] [CrossRef]
- Wang, Y.; Ma, H.; Xiao, X.; Wang, Y.; Zhang, Y.; Wang, H. Harmonic State Estimation for Distribution Networks Based on Multi-Measurement Data. IEEE Trans. Power Deliv. 2023, 38, 2311–2325. [Google Scholar] [CrossRef]
- Huang, H.; Lin, L.; Xu, Q.; He, B.; Zhang, Z.; Ye, Q. Offshore Wind Power System Resonance Stability: Modelling, Analysis, and Methods Comparison. In Proceedings of the 2025 10th Asia Conference on Power and Electrical Engineering (ACPEE), Beijing, China, 15–19 April 2025; pp. 1464–1472. [Google Scholar]
- Karadeniz, A. Advancing harmonic prediction for offshore wind farms using synthetic data and machine learning. Comput. Electr. Eng. 2025, 127, 110613. [Google Scholar] [CrossRef]
- Yang, S.; Xiao, W.; Zhang, M.; Guo, S.; Zhao, J.; Shen, F. Image Data Augmentation for Deep Learning: A Survey. arXiv 2023, arXiv:2204.08610. [Google Scholar] [CrossRef]
- Bengio, Y.; Simard, P.; Frasconi, P. Learning long-term dependencies with gradient descent is difficult. IEEE Trans. Neural Netw. 1994, 5, 157–166. [Google Scholar] [CrossRef]
- Lim, B.; Zohren, S. Time-series forecasting with deep learning: A survey. Philos. Trans. R. Soc. A Math. Phys. Eng. Sci. 2021, 379, 20200209. [Google Scholar] [CrossRef]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, L.; Polosukhin, I. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, Long Beach, CA, USA, 4–9 December 2017; pp. 6000–6010. [Google Scholar]
- Luo, X.; Zhang, D.; Zhu, X. Deep learning based forecasting of photovoltaic power generation by incorporating domain knowledge. Energy 2021, 225, 120240. [Google Scholar] [CrossRef]
- Wu, H.; Xu, J.; Wang, J.; Long, M. Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting. In Advances in Neural Information Processing Systems; Beygelzimer, A., Dauphin, Y., Liang, P., Vaughan, J.W., Eds.; Curran Associates Inc.: Red Hook, NY, USA, 2021. [Google Scholar]
- Karadeniz, A. Harmonic forecasting in offshore wind systems utilizing DFIG on Bozcaada Island: A hybrid machine learning and deep learning approach. Eng. Res. Express 2025, 7, 025280. [Google Scholar] [CrossRef]
- Breiman, L. Random Forests. Mach. Learn. 2001, 45, 5–32. [Google Scholar] [CrossRef]
- Hochreiter, S.; Schmidhuber, J. Long Short-Term Memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef]
- Dey, R.; Salem, F.M. Gate-variants of Gated Recurrent Unit (GRU) neural networks. In Proceedings of the 2017 IEEE 60th International Midwest Symposium on Circuits and Systems (MWSCAS), Boston, MA, USA, 6–9 August 2017; pp. 1597–1600. [Google Scholar]
- Badirli, S.; Liu, X.; Xing, Z.; Bhowmik, A.; Doan, K.; Keerthi, S.S. Gradient Boosting Neural Networks: GrowNet. arXiv 2020, arXiv:2002.07971. [Google Scholar] [CrossRef]
- Zareapoor, M.; Shamsolmoali, P.; Kumar Jain, D.; Wang, H.; Yang, J. Kernelized support vector machine with deep learning: An efficient approach for extreme multiclass dataset. Pattern Recognit. Lett. 2018, 115, 4–13. [Google Scholar] [CrossRef]
- Liao, T.; Lei, Z.; Zhu, T.; Zeng, S.; Li, Y.; Yuan, C. Deep Metric Learning for K Nearest Neighbor Classification. IEEE Trans. Knowl. Data Eng. 2023, 35, 264–275. [Google Scholar]
- Gal, Y.; Ghahramani, Z. Dropout as a Bayesian approximation: Representing model uncertainty in deep learning. In Proceedings of the 33rd International Conference on International Conference on Machine Learning—Volume 48, New York, NY, USA, 20–22 June 2016; Volume 10, pp. 1050–1059. [Google Scholar]
- Liu, Y.; Luo, H.; Zhao, B.; Zhao, X.; Han, Z. Short-Term Power Load Forecasting Based on Clustering and XGBoost Method. In Proceedings of the 2018 IEEE 9th International Conference on Software Engineering and Service Science (ICSESS), Beijing, China, 23–25 November 2018; pp. 536–539. [Google Scholar]
- Liu, R. Research on LightGBM Algorithm for Subway Gate Fault Detection. In Proceedings of the 2024 International Conference on Control, Electronic Engineering and Machine Learning (CEEML), Guangzhou, China, 22–24 November 2024; pp. 116–120. [Google Scholar]
- Hao, C.; Chu, J.; Han, T.; Hu, Q. Partial Discharge Recognition of Medium Voltage Switchgear Based on CatBoost Model. In Proceedings of the 2024 IEEE 5th International Conference on Dielectrics (ICD), Toulouse, France, 30 June–4 July 2024; pp. 1–4. [Google Scholar]










| Parameter | Value | Parameter | Value |
|---|---|---|---|
| Main Grid | Offshore Substation (Transformer) | ||
| Grid Voltage Source | 230 kV | Power Rating | 10 MVA |
| Short-circuit Capacity | 2500 MVA | Voltage Ratio | 60/0.575 kV |
| Ratio | 3 | Winding Configuration | |
| Onshore Substation (Transformer) | Wind Turbines | ||
| Power Rating | 50 MVA | Total Capacity | 9 MW |
| Voltage Ratio | 230/60 kV | Aggregated Units | MW |
| Winding Configuration | Resistance (R) | 33.6 m/km | |
| Resistance & Leakage | p.u. | Inductance (L) | 0.41 mH/km |
| Magnetization Ind. | 0.08 p.u. | Capacitance (C) | 0.24 F/km |
| Parameter | Value | Parameter | Value |
|---|---|---|---|
| Rated Power | Nominal DC voltage | ||
| Rated Speed | Line filter capacitor () | F | |
| Nominal Voltage | Grid-side conv. voltage | ||
| Nominal Frequency | DC bus capacitor | F | |
| Nominal DC bus | Coupling inductor | ||
| Stator/Rotor | Shaft spring constant | ||
| Stator/Rotor R | Inertia constant H | ||
| Switching Freq. | Shaft base speed |
| Model | Task 1: THD Prediction | Task 2: 5th Harmonic (H5) | Overall | ||
|---|---|---|---|---|---|
| RMSE ↓ | R2 ↑ | RMSE ↓ | R2 ↑ | Avg RMSE ↓ | |
| Physics-Transformer | 0.0369 | 0.5706 | 0.0412 | 0.3534 | 0.0400 |
| Random Forest | 0.0381 | 0.5416 | 0.0439 | 0.2881 | 0.0410 |
| LightGBM | 0.0387 | 0.5286 | 0.0460 | 0.2200 | 0.0423 |
| XGBoost | 0.0387 | 0.5280 | 0.0444 | 0.2725 | 0.0416 |
| CatBoost | 0.0398 | 0.5013 | 0.0423 | 0.3396 | 0.0410 |
| Decision Tree | 0.0418 | 0.4489 | 0.0440 | 0.2857 | 0.0429 |
| KNN | 0.0422 | 0.4398 | 0.0434 | 0.3035 | 0.0428 |
| MLP (Standard) | 0.0458 | 0.3393 | 0.0445 | 0.2709 | 0.0451 |
| GRU (Simplified RNN) | 0.0475 | 0.2898 | 0.0452 | 0.2452 | 0.0464 |
| Bayesian Ridge | 0.0476 | 0.2864 | 0.0457 | 0.2293 | 0.0466 |
| LSTM (Sequential) | 0.0482 | 0.2674 | 0.0463 | 0.2108 | 0.0472 |
| SVR (SVM) | 0.0487 | 0.2517 | 0.0463 | 0.2083 | 0.0475 |
| Metric | Baseline (Pure Data-Driven) | Proposed | Improvement |
|---|---|---|---|
| RMSE | 0.0393 | 0.0377 | 4.13% |
| MAE | 0.0318 | 0.0300 | 5.67% |
| Score | 0.5132 | 0.5614 | 9.39% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Zhou, X.; Chen, Q.; Zhang, L.; Wang, Q.; Zhou, N.; Peng, J.; Zhao, Y. A Unified Transformer-Based Harmonic Detection Network for Distorted Power Systems. Energies 2026, 19, 650. https://doi.org/10.3390/en19030650
Zhou X, Chen Q, Zhang L, Wang Q, Zhou N, Peng J, Zhao Y. A Unified Transformer-Based Harmonic Detection Network for Distorted Power Systems. Energies. 2026; 19(3):650. https://doi.org/10.3390/en19030650
Chicago/Turabian StyleZhou, Xin, Qiaoling Chen, Li Zhang, Qianggang Wang, Niancheng Zhou, Junzhen Peng, and Yongshuai Zhao. 2026. "A Unified Transformer-Based Harmonic Detection Network for Distorted Power Systems" Energies 19, no. 3: 650. https://doi.org/10.3390/en19030650
APA StyleZhou, X., Chen, Q., Zhang, L., Wang, Q., Zhou, N., Peng, J., & Zhao, Y. (2026). A Unified Transformer-Based Harmonic Detection Network for Distorted Power Systems. Energies, 19(3), 650. https://doi.org/10.3390/en19030650
