Photovoltaic power generation prediction method and device based on physical constraint and LSTM network
By adopting a photovoltaic power generation prediction method based on physical constraints and LSTM networks, the problems of nonlinear relationships and physical irrationality in photovoltaic power generation prediction are solved, achieving high-precision and real-time photovoltaic power generation prediction and supporting the optimized scheduling of integrated source-grid-load-storage systems.
Patent Information
- Application Number
- CN202511309290.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-09-15
AI Technical Summary
Existing photovoltaic power generation forecasting methods struggle to capture the complex nonlinear relationship between meteorological factors and photovoltaic power, lack the synergistic effect of multiple elements such as source, grid, load, and storage, resulting in insufficient forecast accuracy and physical inconsistencies and high redundancy, which affect the system scheduling effect.
A photovoltaic power generation prediction method based on physical constraints and LSTM network is adopted. Effective data is screened by calculating the statistical features of sliding window and constructing dynamic thresholds. Strong correlation features are retained by combining time-varying Spearman rank correlation analysis. An LSTM network integrating physical constraints is constructed, and the network parameters are optimized by adaptive error correction.
It significantly improves the accuracy and efficiency of photovoltaic power generation forecasting, reduces forecasting errors, ensures the physical rationality of forecast results, supports the coordinated operation of power generation, grid, load and storage, and improves the renewable energy consumption rate.
Smart Images

Figure CN120822705A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a photovoltaic power generation prediction method and device based on physical constraints and LSTM networks, belonging to the technical field of new energy power generation prediction and distribution network optimization operation. Background Art
[0002] As the global energy mix shifts toward clean energy, the share of photovoltaic power generation in the power system continues to rise. By 2024, my country's installed photovoltaic capacity will have exceeded 600GW. As a core technology for new power systems, integrated power generation, grid-load-storage, and energy storage significantly enhance system flexibility and renewable energy absorption capacity by coordinating the four key elements of power generation, grid, load, and energy storage. However, photovoltaic power generation is significantly affected by meteorological factors and exhibits high intermittency and volatility. High-precision power forecasting is a key prerequisite for achieving coordinated operation of power generation, grid, load, and energy storage.
[0003] Traditional photovoltaic power prediction methods have many limitations: first, a single time series model cannot capture the complex nonlinear relationship between meteorological factors and photovoltaic power; second, the lack of comprehensive consideration of the synergistic effects of multiple factors such as source, grid, load and storage leads to insufficient prediction accuracy, affecting the system scheduling effect; third, the multidimensionality and redundancy of meteorological data increase the complexity of model training and reduce prediction efficiency and real-time performance.
[0004] In recent years, deep learning technology has been widely used in power forecasting. LSTM neural networks, due to their ability to effectively process time series data and capture long-term dependencies, have been widely used for renewable energy power forecasting. However, existing LSTM-based methods still have shortcomings in input feature selection, meteorological factor impact analysis, and ensuring physical plausibility. For example, they are prone to forecasts that do not conform to physical laws, such as negative power and nighttime power generation, making them difficult to meet the demand for high-precision forecasting. Summary of the Invention
[0005] In order to solve the above problems, the present invention proposes a photovoltaic power generation prediction method and device based on physical constraints and LSTM network, which can improve the prediction accuracy, efficiency and physical rationality of photovoltaic power generation.
[0006] The technical solution adopted by the present invention to solve its technical problems is: In a first aspect, an embodiment of the present invention provides a photovoltaic power generation prediction method based on physical constraints and LSTM network, comprising the following steps: Step S1: Collect photovoltaic power generation data and meteorological data, fill in missing values, normalize and time-align, and then filter out valid data through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint judgment; Step S2: Based on the valid data, the dynamic correlation coefficient between meteorological characteristics and photovoltaic power is calculated using time-varying Spearman rank correlation analysis, and the strongly correlated features and the physically verified moderately correlated features are retained, while the weakly correlated features are eliminated to form a key feature set; Step S3: Using the key features as input, constructing an LSTM network that integrates physical constraints, wherein the loss function of the LSTM network includes a data loss term and a physical constraint loss term based on the relationship between solar radiation and power, and outputting an initial prediction result; Step S4, calculates the real-time error based on the initial prediction result and the actual power, dynamically adjusts the network parameters according to the error size, and outputs the corrected final prediction result. The real-time error includes the mean absolute error and the mean square error, and the network parameters include the learning rate, physical constraint weight, and batch size.
[0007] As a possible implementation of this embodiment, step S1 includes the following steps: Step S11, collecting photovoltaic power generation data and meteorological data, wherein the photovoltaic power generation data includes inverter output power, operating status and timestamp, and the meteorological data includes 22-dimensional features including solar irradiance (GTI / DHI), temperature, humidity, soil temperature, and wind speed; Step S12: Fill missing values, perform Z-score normalization, and perform time alignment on the collected photovoltaic power generation data and meteorological data to ensure data accuracy and consistency; Step S13: Based on the processed data, valid data is screened out through statistical feature calculation, dynamic threshold construction and multivariate joint judgment.
[0008] As a possible implementation of this embodiment, step S12 includes: Perform missing value filling processing on the collected photovoltaic power generation data and meteorological data to complete the missing items in the data; Perform Z-score normalization on the collected photovoltaic power generation data and meteorological data, and convert each eigenvalue into the result of (eigenvalue - eigenmean) / eigenstandard deviation; The collected photovoltaic power generation data and meteorological data are time-aligned, and the photovoltaic power generation data and meteorological data are matched based on the timestamp to ensure that the data at the same time correspond.
[0009] As a possible implementation of this embodiment, step S13 includes: Step S131 , setting the sliding window length to W (e.g., 10 minutes), and calculating the mean, standard deviation, variation range, and fluctuation statistics within the window for the meteorological parameters and photovoltaic power, respectively; Step S132: construct a dynamic threshold. The dynamic threshold for the meteorological parameter variation range is the product of the fluctuation mean plus the sensitivity coefficient k (generally 2 or 3) and the fluctuation standard deviation. The dynamic threshold for the photovoltaic power residual (the absolute value of the difference between the actual power and the predicted power) is the mean of the residual sequence plus the product of the residual sensitivity coefficient and the residual standard deviation. Step S133, perform a joint abnormality judgment; if the change amplitude of the meteorological parameters is greater than its dynamic threshold and the power residual is greater than its dynamic threshold, it is judged as an environmental abnormality; if the meteorological parameters are normal but the power residual is abnormal, it is judged as an equipment or data failure abnormality; if the meteorological parameters are abnormal but the power is normal, it is judged as a sensor error or short-term interference; after eliminating the abnormal data, output the valid data.
[0010] As a possible implementation of this embodiment, in step S131, calculating the mean, standard deviation, variation range, and fluctuation statistics within the window for the meteorological parameter and the photovoltaic power respectively includes: The mean value of the meteorological parameter at time t: the sum of all data in the window divided by the window length W; The standard deviation of meteorological parameters at time t: the square root of the sum of the squares of the differences between each data and the mean in the window divided by the window length W; The range of change of meteorological parameters: the absolute value of the difference between the data at the current moment and the data at the previous moment; Based on all the fluctuation amplitudes within the window, calculate the fluctuation mean (the sum of all fluctuation amplitudes divided by the window length minus 1) and the fluctuation standard deviation (the square root of the sum of the squares of the differences between each fluctuation amplitude and the fluctuation mean divided by the window length minus 1); Statistical characteristics of PV power include the mean power (the sum of the powers in the window divided by the window length W), the standard deviation of power (the square root of the sum of the squares of the differences between each power value in the window and the mean power divided by the window length W), and the correlation coefficient between power and meteorological parameters (the sum of the products of the differences between the power and meteorological parameters and their respective means, divided by the product of the square root of the sum of the squares of the power differences and the square root of the sum of the squares of the meteorological parameter differences).
[0011] As a possible implementation of this embodiment, step S2 includes the following steps: Step S21 , based on the valid data (including pre-processed photovoltaic power generation data and meteorological data), a time-varying Spearman rank correlation analysis is used to calculate the dynamic correlation coefficient (time-varying Spearman rank correlation coefficient) between meteorological characteristics and photovoltaic power; Step S22 , based on the calculated dynamic correlation coefficient, feature classification and screening are performed according to the following criteria: strongly correlated features, i.e., features with an absolute value of the correlation coefficient greater than 0.5, are retained; among these, only one solar radiation feature (such as shortwave radiation, direct radiation, etc.) is retained to avoid collinearity; moderately correlated features are verified and retained, and features with an absolute value of the correlation coefficient between 0.3 and 0.5 are retained after physical rationality verification (e.g., logical consistency with the impact of photovoltaic power); weakly correlated features, i.e., features with an absolute value of the correlation coefficient less than 0.1, are eliminated; In step S23, the feature set is dynamically updated, and the correlation coefficient is recalculated every 15 minutes. When the absolute value of the change in the correlation coefficient is greater than 0.2, the classification and screening process in step 2 is re-executed to update the feature set and output the final key feature set.
[0012] As a possible implementation of this embodiment, the calculation of the dynamic correlation coefficient between meteorological characteristics and photovoltaic power using time-varying Spearman rank correlation analysis includes: Initialize the sliding window, set the window width to 24 (corresponding to a 24-hour period), and the time decay factor to 0.05; Sort the photovoltaic power and meteorological data at each time t by size and assign them to levels, and calculate the difference between the corresponding levels (grade difference); Calculate weight function, adaptive time-varying weight function : , Where σ=w / 3, is the window width, is the center moment of the window, and the adaptive time-varying weight function is a normal distribution function with a mean of the center moment of the window and a standard deviation of one-third of the window width to highlight the weight of recent data; Dynamic correlation coefficient solution, correlation coefficient The calculation formula is: , in, is the time decay factor.
[0013] As a possible implementation of this embodiment, step S3 includes the following steps: Step S31: Perform spatiotemporal alignment on the selected key features to construct time series data with an input dimension of (24, 5); 24 is the time step (corresponding to a 24-hour sliding window), and 5 is the feature dimension (such as shortwave radiation, direct radiation, 2-meter temperature, 2-meter relative humidity, and daytime flag). The key features include shortwave radiation, direct radiation, temperature, humidity, and daytime flag. Step S32: Design an LSTM network architecture and construct a deep network with two LSTM layers. The LSTM network includes two LSTM layers, with the first layer containing 256 units and the second layer containing 128 units. The input dimension is (24, 5) (24-hour time step, 5 key features), and is subsequently connected with a Dropout layer (dropout rate 20%) and a LayerNormalization layer (which normalizes the data and adjusts it through learnable parameters). Step S33: Add a physical constraint term to the network loss function: Total loss function = Data loss + Physical constraint weight × Physical constraint loss. The data loss uses Huber loss. The physical constraint loss is constructed based on the partial differential equation for the relationship between solar radiation and power. It includes the partial derivative of power with respect to time, the gradient term of wind speed and power, a source term based on solar radiation, temperature, and humidity (the source term increases with increasing solar radiation), and a power attenuation term (related to component aging). In step S34, the RMSprop optimizer (initial learning rate 0.0005) is used, the batch size is set to 32, the number of training rounds is set to 500, the network is trained until convergence based on the input key feature data, and the initial prediction results are output.
[0014] As a possible implementation of this embodiment, step S4 includes the following steps: Step S41: Based on the initial prediction result and the actual photovoltaic power, a 30-minute sliding window is used to calculate the error: mean absolute error (MAE) = the sum of the absolute values of (actual power - initial prediction power) in the window ÷ the number of data in the window (30), mean square error (MSE) = the sum of the squares of (actual power - initial prediction power) in the window ÷ the number of data in the window (30); Step S42: compare the MAE with a preset threshold. If the MAE is greater than 5%, it is determined that the prediction accuracy is low; if the MAE is less than 2%, it is determined that the prediction accuracy is high. Step S43: Adjust the network parameters based on the judgment result. When MAE>5%, the learning rate is multiplied by 0.9 (to reduce the parameter update amplitude), and the physical constraint weight is multiplied by 1.2 (to strengthen the physical rationality constraint); when MAE<2%, the learning rate is multiplied by 1.1 (to speed up the convergence speed), and the batch size is adjusted to twice the current value (no more than 256). In step S44, the network with adjusted parameters is re-predicted and the corrected results are output; steps 41 to 44 are repeated every 30 minutes to form a closed-loop optimization, and ultimately the MAE is stabilized within 3.2% and the root mean square error is stabilized within 4.5%.
[0015] In a second aspect, an embodiment of the present invention provides a photovoltaic power generation prediction device based on physical constraints and LSTM networks, comprising: The data processing module is used to collect photovoltaic power generation data and meteorological data. After missing value filling, normalization and time alignment, valid data is screened out through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint judgment; The feature screening module is used to calculate the dynamic correlation coefficient between meteorological characteristics and photovoltaic power based on valid data using time-varying Spearman rank correlation analysis, retaining strongly correlated features and physically verified moderately correlated features, and eliminating weakly correlated features to form a key feature set; The prediction model module is used to take key features as input, build an LSTM network that integrates physical constraints, and output an initial prediction result. The adaptive correction module is used to calculate the real-time error based on the initial prediction result and the actual power, dynamically adjust the network parameters according to the error size, and output the corrected final prediction result. The real-time error includes the mean absolute error and the mean square error. The network parameters include the learning rate, physical constraint weight, and batch size.
[0016] The beneficial effects of the technical solutions of the embodiments of the present invention are as follows: The present invention adopts dynamic threshold and multivariate joint anomaly detection (based on sliding window statistical features and correlation analysis) to effectively eliminate abnormal data and provide a high-quality data basis for model input; through time-varying Spearman rank correlation analysis, key features are dynamically screened (retain | ∣>0.5, such as shortwave radiation and direct radiation, and weakly correlated features are eliminated), reducing the feature dimension from 22 to 4, reducing redundant information interference; the LSTM network integrating physical constraints introduces partial differential equation constraints on the relationship between solar radiation and power (eliminating physical irrationalities such as night-time power generation > 0), and forms a closed-loop optimization through adaptive error correction (dynamically adjusting parameters such as learning rate and physical constraint weights based on MAE); the present invention achieves high-precision prediction through a three-level optimization mechanism, significantly improving the prediction accuracy of photovoltaic power generation and greatly reducing the prediction error of photovoltaic power generation.
[0017] This method eliminates weakly correlated features during feature screening, reducing dimensionality by 77% and significantly reducing the computational effort required for model training and inference. The LSTM network employs a two-layer structure (256+128 units) with Dropout and LayerNormalization regularization, ensuring accuracy while avoiding overfitting and increasing training speed by 2.3 times, meeting real-time prediction requirements (such as high-frequency response scenarios for coordinated scheduling of power generation, grid, load, and storage). This method improves computational efficiency and significantly enhances real-time computing through feature dimensionality reduction and lightweight design.
[0018] This paper incorporates solar radiation partial differential equation constraints into the LSTM loss function, forcing the model to adhere to physical laws such as the positive correlation between photovoltaic power and solar radiation and zero power at night. Combined with a nighttime masking mechanism (forcing the predicted power to be zero when the daytime marker is 0), this eliminates over 99% of logical errors such as negative power and nighttime power generation, ensuring that the prediction results are consistent with the actual physical scenario. By injecting physical constraints, this paper addresses the "physical irrationality" of traditional models, ensuring that the prediction results are not only highly physically rational but also eliminates logical contradictions.
[0019] The prediction results of the present invention can accurately reflect the intermittency and volatility of photovoltaic power generation, helping the power grid to coordinate power supply, load, energy storage and other factors (such as adjusting energy storage charging and discharging strategies in advance and optimizing load matching); ultimately achieving a 22% increase in the new energy consumption rate, promoting the efficient operation of the integrated source, grid, load and storage system, and meeting the development needs of the new power system.
[0020] The present invention designs a multi-level meteorological correlation screening mechanism to reduce redundant data interference; constructs a physical information-enhanced LSTM model and introduces solar radiation equation constraints; develops an adaptive error correction algorithm to achieve dynamic parameter optimization; the present invention uses an innovative multi-level feature screening mechanism, adaptive network structure and collaborative optimization algorithm to not only achieve photovoltaic power generation prediction, but also solve the shortcomings of existing technologies in prediction accuracy, computing efficiency and system coordination, and improve the prediction accuracy, efficiency and physical rationality of photovoltaic power generation, and is used for high-precision power generation prediction in source-grid-load-storage collaborative scenarios, effectively supporting the optimized scheduling of power systems and the absorption of new energy. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a flow chart of a photovoltaic power generation prediction method based on physical constraints and LSTM network according to an exemplary embodiment; Figure 2 This is a schematic diagram of the structure of a photovoltaic power generation prediction device based on physical constraints and LSTM network according to an exemplary embodiment; Figure 3 The figure is a schematic diagram showing a structure of correlation between weather factors and power data according to an exemplary embodiment. DETAILED DESCRIPTION
[0022] In order to more clearly illustrate the technical features of the present invention, the present invention is described in detail below through specific implementation methods and in conjunction with the accompanying drawings.
[0023] like Figure 1 As shown, an embodiment of the present invention provides a photovoltaic power generation prediction method based on physical constraints and LSTM network, including the following steps: Step S1: Collect photovoltaic power generation data and meteorological data, fill in missing values, normalize and time-align, and then filter out valid data through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint judgment; Step S2: Based on the valid data, the dynamic correlation coefficient between meteorological characteristics and photovoltaic power is calculated using time-varying Spearman rank correlation analysis, and the strongly correlated features and the physically verified moderately correlated features are retained, while the weakly correlated features are eliminated to form a key feature set; Step S3: Using the key features as input, constructing an LSTM network that integrates physical constraints, wherein the loss function of the LSTM network includes a data loss term and a physical constraint loss term based on the relationship between solar radiation and power, and outputting an initial prediction result; Step S4, calculates the real-time error based on the initial prediction result and the actual power, dynamically adjusts the network parameters according to the error size, and outputs the corrected final prediction result. The real-time error includes the mean absolute error and the mean square error, and the network parameters include the learning rate, physical constraint weight, and batch size.
[0024] The present invention adopts a dual mechanism of dynamic weight + physical verification to screen time-varying features, embeds the solar radiation equation into the network structure to fuse physical information with LSTM, and uses an error-driven parameter dynamic adjustment system for three-level adaptation. It not only realizes photovoltaic power generation prediction, solves the shortcomings of existing technologies in prediction accuracy, computational efficiency and system coordination, but also improves the prediction accuracy, efficiency and physical rationality of photovoltaic power generation, and effectively supports the optimal scheduling of the power system and the absorption of new energy.
[0025] As a possible implementation of this embodiment, step S1 includes the following steps: Step S11, collecting photovoltaic power generation data and meteorological data, wherein the photovoltaic power generation data includes inverter output power, operating status and timestamp, and the meteorological data includes 22-dimensional features including solar irradiance (GTI / DHI), temperature, humidity, soil temperature, and wind speed; Step S12: Fill missing values, perform Z-score normalization, and perform time alignment on the collected photovoltaic power generation data and meteorological data to ensure data accuracy and consistency; Step S13: Based on the processed data, valid data is screened out through statistical feature calculation, dynamic threshold construction and multivariate joint judgment.
[0026] As a possible implementation of this embodiment, step S12 includes: Perform missing value filling processing on the collected photovoltaic power generation data and meteorological data to complete the missing items in the data; Perform Z-score normalization on the collected photovoltaic power generation data and meteorological data, and convert each eigenvalue into the result of (eigenvalue - eigenmean) / eigenstandard deviation; The collected photovoltaic power generation data and meteorological data are time-aligned, and the photovoltaic power generation data and meteorological data are matched based on the timestamp to ensure that the data at the same time correspond.
[0027] As a possible implementation of this embodiment, step S13 includes: Step S131 , setting the sliding window length to W (e.g., 10 minutes), and calculating the mean, standard deviation, variation range, and fluctuation statistics within the window for the meteorological parameters and photovoltaic power, respectively; Step S132: construct a dynamic threshold. The dynamic threshold for the meteorological parameter variation range is the product of the fluctuation mean plus the sensitivity coefficient k (generally 2 or 3) and the fluctuation standard deviation. The dynamic threshold for the photovoltaic power residual (the absolute value of the difference between the actual power and the predicted power) is the mean of the residual sequence plus the product of the residual sensitivity coefficient and the residual standard deviation. Step S133, perform a joint abnormality judgment; if the change amplitude of the meteorological parameters is greater than its dynamic threshold and the power residual is greater than its dynamic threshold, it is judged as an environmental abnormality; if the meteorological parameters are normal but the power residual is abnormal, it is judged as an equipment or data failure abnormality; if the meteorological parameters are abnormal but the power is normal, it is judged as a sensor error or short-term interference; after eliminating the abnormal data, output the valid data.
[0028] As a possible implementation of this embodiment, in step S131, calculating the mean, standard deviation, variation range, and fluctuation statistics within the window for the meteorological parameter and the photovoltaic power respectively includes: The mean value of the meteorological parameter at time t: the sum of all data in the window divided by the window length W; The standard deviation of meteorological parameters at time t: the square root of the sum of the squares of the differences between each data and the mean in the window divided by the window length W; The range of change of meteorological parameters: the absolute value of the difference between the data at the current moment and the data at the previous moment; Based on all the fluctuation amplitudes within the window, calculate the fluctuation mean (the sum of all fluctuation amplitudes divided by the window length minus 1) and the fluctuation standard deviation (the square root of the sum of the squares of the differences between each fluctuation amplitude and the fluctuation mean divided by the window length minus 1); Statistical characteristics of PV power include the mean power (the sum of the powers in the window divided by the window length W), the standard deviation of power (the square root of the sum of the squares of the differences between each power value in the window and the mean power divided by the window length W), and the correlation coefficient between power and meteorological parameters (the sum of the products of the differences between the power and meteorological parameters and their respective means, divided by the product of the square root of the sum of the squares of the power differences and the square root of the sum of the squares of the meteorological parameter differences).
[0029] As a possible implementation of this embodiment, step S2 includes the following steps: Step S21 , based on the valid data (including pre-processed photovoltaic power generation data and meteorological data), a time-varying Spearman rank correlation analysis is used to calculate the dynamic correlation coefficient (time-varying Spearman rank correlation coefficient) between meteorological characteristics and photovoltaic power; Step S22 , based on the calculated dynamic correlation coefficient, feature classification and screening are performed according to the following criteria: strongly correlated features, i.e., features with an absolute value of the correlation coefficient greater than 0.5, are retained; among these, only one solar radiation feature (such as shortwave radiation, direct radiation, etc.) is retained to avoid collinearity; moderately correlated features are verified and retained, and features with an absolute value of the correlation coefficient between 0.3 and 0.5 are retained after physical rationality verification (e.g., logical consistency with the impact of photovoltaic power); weakly correlated features, i.e., features with an absolute value of the correlation coefficient less than 0.1, are eliminated; In step S23, the feature set is dynamically updated, and the correlation coefficient is recalculated every 15 minutes. When the absolute value of the change in the correlation coefficient is greater than 0.2, the classification and screening process in step 2 is re-executed to update the feature set and output the final key feature set.
[0030] As a possible implementation of this embodiment, the calculation of the dynamic correlation coefficient between meteorological characteristics and photovoltaic power using time-varying Spearman rank correlation analysis includes: Initialize the sliding window, set the window width to 24 (corresponding to a 24-hour period), and the time decay factor to 0.05; Sort the photovoltaic power and meteorological data at each time t by size and assign them to levels, and calculate the difference between the corresponding levels (grade difference); Calculate weight function, adaptive time-varying weight function : , Where σ=w / 3, is the window width, is the center moment of the window, and the adaptive time-varying weight function is a normal distribution function with a mean of the center moment of the window and a standard deviation of one-third of the window width to highlight the weight of recent data; Dynamic correlation coefficient solution, correlation coefficient The calculation formula is: , in, is the time decay factor.
[0031] As a possible implementation of this embodiment, step S3 includes the following steps: Step S31: Perform spatiotemporal alignment on the selected key features to construct time series data with an input dimension of (24, 5); 24 is the time step (corresponding to a 24-hour sliding window), and 5 is the feature dimension (such as shortwave radiation, direct radiation, 2-meter temperature, 2-meter relative humidity, and daytime flag). The key features include shortwave radiation, direct radiation, temperature, humidity, and daytime flag. Step S32: Design an LSTM network architecture and construct a deep network with two LSTM layers. The LSTM network includes two LSTM layers, with the first layer containing 256 units and the second layer containing 128 units. The input dimension is (24, 5) (24-hour time step, 5 key features), and is subsequently connected with a Dropout layer (dropout rate 20%) and a LayerNormalization layer (which normalizes the data and adjusts it through learnable parameters). Step S33: Add a physical constraint term to the network loss function: Total loss function = Data loss + Physical constraint weight × Physical constraint loss. The data loss uses Huber loss. The physical constraint loss is constructed based on the partial differential equation for the relationship between solar radiation and power. It includes the partial derivative of power with respect to time, the gradient term of wind speed and power, a source term based on solar radiation, temperature, and humidity (the source term increases with increasing solar radiation), and a power attenuation term (related to component aging). In step S34, the RMSprop optimizer (initial learning rate 0.0005) is used, the batch size is set to 32, the number of training rounds is set to 500, the network is trained until convergence based on the input key feature data, and the initial prediction results are output.
[0032] As a possible implementation of this embodiment, step S4 includes the following steps: Step S41: Based on the initial prediction result and the actual photovoltaic power, a 30-minute sliding window is used to calculate the error: mean absolute error (MAE) = the sum of the absolute values of (actual power - initial prediction power) in the window ÷ the number of data in the window (30), mean square error (MSE) = the sum of the squares of (actual power - initial prediction power) in the window ÷ the number of data in the window (30); Step S42: compare the MAE with a preset threshold. If the MAE is greater than 5%, it is determined that the prediction accuracy is low; if the MAE is less than 2%, it is determined that the prediction accuracy is high. Step S43: Adjust the network parameters based on the judgment result. When MAE>5%, the learning rate is multiplied by 0.9 (to reduce the parameter update amplitude), and the physical constraint weight is multiplied by 1.2 (to strengthen the physical rationality constraint); when MAE<2%, the learning rate is multiplied by 1.1 (to speed up the convergence speed), and the batch size is adjusted to twice the current value (no more than 256). In step S44, the network with adjusted parameters is re-predicted and the corrected results are output; steps 41 to 44 are repeated every 30 minutes to form a closed-loop optimization, and ultimately the MAE is stabilized within 3.2% and the root mean square error is stabilized within 4.5%.
[0033] like Figure 2 As shown, an embodiment of the present invention provides a photovoltaic power generation prediction device based on physical constraints and LSTM network, including: The data processing module is used to collect photovoltaic power generation data and meteorological data. After missing value filling, normalization and time alignment, valid data is screened out through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint judgment; The feature screening module is used to calculate the dynamic correlation coefficient between meteorological characteristics and photovoltaic power based on valid data using time-varying Spearman rank correlation analysis, retaining strongly correlated features and physically verified moderately correlated features, and eliminating weakly correlated features to form a key feature set; The prediction model module is used to take key features as input, build an LSTM network that integrates physical constraints, and output an initial prediction result. The adaptive correction module is used to calculate the real-time error based on the initial prediction result and the actual power, dynamically adjust the network parameters according to the error size, and output the corrected final prediction result. The real-time error includes the mean absolute error and the mean square error. The network parameters include the learning rate, physical constraint weight, and batch size.
[0034] The present invention addresses the shortcomings of existing technologies in terms of prediction accuracy, computational efficiency, and system coordination through an innovative multi-level feature screening mechanism, an adaptive network structure, and a collaborative optimization algorithm. The specific implementation process of the present invention is as follows.
[0035] 1. Data collection and preprocessing: Collect multi-source data in the distribution network, including distributed photovoltaic power generation data, weather data, etc.
[0036] The collected data sources include: Photovoltaic power generation data: inverter output power, operating status, and timestamp; Weather data: 22-dimensional features including solar irradiance (GTI / DHI), temperature, humidity, soil temperature, and wind speed.
[0037] Data preprocessing: missing value filling, Z-score normalization, and time alignment to ensure data accuracy and consistency, providing a reliable foundation for subsequent analysis and prediction.
[0038] In order to achieve intelligent anomaly detection of photovoltaic power data and its related meteorological inputs, the present invention designs a statistical feature extraction mechanism for historical data and target power. The specific steps are as follows.
[0039] 1. Calculation of statistical characteristics of multi-source meteorological parameters: Assume that the observed values of meteorological parameters (such as temperature, radiation, etc.) at time t are , set the sliding window length to W (such as W = 10 minutes), and the data sequence of this parameter in the window: , Calculate its statistical characteristics: Mean: , Standard Deviation: , Change range (absolute value of the difference between adjacent moments): , Based on all Δ in the history window , calculate the fluctuation mean and standard deviation : .
[0040] 2. Statistical characteristics and correlation analysis of target power values: Assume that the measured photovoltaic power generation value is , synchronous calculation: Power average: ; Power standard deviation: ; Correlation coefficient between power and meteorological parameters (taking temperature as an example): ; This correlation is used to determine whether the meteorological data and the target power are logically matched, and to assist in abnormality determination.
[0041] Dynamic threshold construction and abnormality judgment: based on the amplitude of change For example, set dynamic thresholds based on historical statistical characteristics : , Among them, the sensitivity coefficient k is adjustable (usually 2 or 3); The current change range meets the conditions: , It can be determined that the meteorological data at that moment is abnormal; Similarly, for target power residual anomaly detection, the prediction residual is first defined: , in, is the predicted power calculated based on the corresponding input of the model; For the residual history series Calculate the mean and standard deviation , construct the residual threshold: , like , then the power is determined to be abnormal, which may indicate device or data abnormality.
[0042] 4. Principles for determining joint multivariate anomalies: Combine single meteorological indicators, power and their residuals to conduct joint anomaly analysis: If the meteorological indicators are abnormal and the power is abnormal, it is determined to be an abnormal environment; If the weather is normal but the power is abnormal, it is determined to be an equipment or data failure; If the weather is abnormal but the power is normal, sensor error or short-term interference must be considered.
[0043] 2. Multi-level meteorological correlation analysis: The time-varying Spearman rank correlation analysis method is used to mine the nonlinear correlation between meteorological data factors and photovoltaic power. The dynamic correlation coefficient calculation formula is: , in, :time The grade difference; : Adaptive time-varying weight function; : time decay factor; : Sliding window size.
[0044] Dynamic correlation coefficient calculation process: 1. Sliding window initialization: Set the window width w = 24 (corresponding to a 24-hour period) and the initialization time decay factor λ = 0.05; 2. Rank difference calculation: Sort and rank the photovoltaic power and meteorological data at each time t; 3. Weight function calculation: , Where σ = w / 3, reflecting the higher weight of recent data; Real-time update mechanism: recalculate the correlation coefficient within the window every 15 minutes, and trigger the feature set update when |Δrs|>0.2. Feature screening: The weather factors and power data are subjected to correlation analysis and calculation, and the Spearman correlation heat map of power generation and meteorological factors is obtained through the correlation analysis method; According to the correlation analysis method, the top 10 with the highest correlation are obtained, such as Figure 3 shown.
[0045] Specific implementation process of feature screening: Screening criteria: 1. Retention Strongly correlated features with values > 0.5, where solar radiation is selected (to avoid collinearity).
[0046]
[0047] 2. Auxiliary features (0.3≤|r|<0.5) must be physically verified.
[0048]
[0049] 3. Weakly correlated features (|rs|<0.1): directly eliminated, After screening, the feature dimension is reduced from 22 to 4, and the computing efficiency is improved by 40%.
[0050] 3. Physical Information Enhanced LSTM Network: 1. Technical Overview: Based on historical power generation data (power) and meteorological data (weather), a deep learning prediction model integrating physical laws is constructed to achieve high-precision time-series prediction of photovoltaic power.
[0051] Taking into account the intermittent and volatile nature of photovoltaic power generation, the present invention adopts a long short-term memory network (LSTM) model, which can capture long-term dependencies in time series data and effectively improve prediction accuracy.
[0052] Forget gate formula: , Input gate formula: , Candidate cell state formula: =tanh( WC [ ht 1, xt ]+ ), Cell state update formula: t = ft ⊙ Ct 1+ it ⊙ , Output gate formula: , Hidden state output formula: , Explanation of symbols: : Sigmoid activation function (used for gating mechanism, range [0,1]), ⊙: Hadamard product (element-wise multiplication), f , i , WC , o : Weight matrix (subscripts correspond to different gating units), f , i , , o : bias vector, : Hidden state at the previous moment With the current input The splicing operation, The present invention designs an LSTM network that integrates physical constraints and adds physical law constraints to the loss function: , in, is the physical constraint loss, which contains the partial differential equation constraint of the relationship between solar radiation and power: , Based on solar radiation ,temperature ,humidity The source term, is the power attenuation term. By introducing physical constraints, the LSTM network can eliminate physically unreasonable predictions such as nighttime power generation > 0, significantly improving the physical rationality of the prediction.
[0053] 2. Data input and feature engineering: 2.1 Data mapping relationship: power: power_num (unit: kW), represents the inverter output power, Weather: corresponds to 22-dimensional meteorological data. Key features include: shortwave radiation (W / m²), daytime indicator, 2-meter temperature (°C), and 2-meter relative humidity (%).
[0054] 2.2 Spatiotemporal alignment processing: Use pandas for time alignment.
[0055] 3. Network core design: 3.1 LSTM Network Architecture Design: Build a deep network with two LSTM layers. The first layer contains 256 units, the second layer contains 128 units, and the input dimension is (24, 5) (24-hour time step, 5 key features). It is subsequently connected with a Dropout layer (dropout rate 20%) and a LayerNormalization layer (data normalization and adjustment through learnable parameters).
[0056] 3.2 Key Components Description: 1) Input layer design: Input dimension: input_shape=(24,5), 24: time step (24-hour sliding window), 5: Feature dimensions (key features after screening): shortwave radiation, direct radiation, temperature, humidity and daytime identification.
[0057] 2) Dual LSTM layer structure: First layer LSTM (256 units): Gated calculation: , , Number of parameters: 4×(256×(256+5)+256)=266240, Second layer LSTM (128 units): Output processing: return_sequences=False (single-step prediction), Innovation: Introducing the time decay factor λ=0.05.
[0058] 3) Regularization mechanism: Dropout layer (0.2): randomly blocks 20% of neurons during training. LayerNormalization: .
[0059] 4) Physical constraint injection: Solve the distribution offset of photovoltaic data caused by sudden weather changes; Output layer design: Single neuron output: directly predict power_num at time t+1; Physical constraints implementation: night_mask = tf.where(is_day_input == 0, 0.0, 1.0), constrained_output = output * night_mask.
[0060] 4. Adaptive Error Correction Mechanism Dynamic parameter adjustment: weights are adjusted based on real-time prediction error (MAE / MSE) feedback: The mean square error (MSE) calculation formula is: , The mean absolute error (MAE) is calculated as: , in, is the actual value, is the predicted value.
[0061] Dynamic parameter adjustment algorithm process: 1. Error monitoring: Real-time calculation of MAE within a sliding window (30 minutes), 2. Parameter adjustment strategy: When MAE>5%, the learning rate is ×0.9, and the physical constraint weight is ×1.2; when MAE<2%, the learning rate is ×1.1, and the batch size is adjusted to twice the current value.
[0062] Training configuration: Two-channel LSTM | 128 hidden units | 24 time steps, Optimizer: Adam (lr=0.0005) | Batch Size=32 | Epochs=500, The Adam optimizer is used, the learning rate is set to 0.0005, the batch size is 32, and the number of training rounds is 500.
[0063] Compared with the prior art, the present invention has the following significant advantages: 1. Significantly improved prediction accuracy: Through multi-level correlation analysis and an adaptive LSTM network, the mean absolute error (MAE) of photovoltaic power prediction is ≤3.2%, and the root mean square error (RMSE) is ≤4.5%, which is an improvement of more than 58.9% compared to traditional methods. 2. Efficiency optimization: Feature dimensions are reduced by 77%, and training speed is increased by 2.3 times; 3. Physical plausibility: Eliminate >99% of negative power / nighttime generation errors through equation constraints; 4. Dispatching value: The prediction results support the coordinated dispatch of power generation, grid, load and storage, and the new energy consumption rate increases by 22%.
[0064] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered by the scope of protection of the claims of the present invention.
Claims
1. A photovoltaic power generation prediction method based on physical constraints and LSTM network, characterized in that: The steps include: Step S1: Collect photovoltaic power generation data and meteorological data, fill in missing values, normalize and time-align, and then filter out valid data through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint judgment; Step S2: Based on the valid data, the dynamic correlation coefficient between meteorological characteristics and photovoltaic power is calculated using time-varying Spearman rank correlation analysis, and the strongly correlated features and the physically verified moderately correlated features are retained, while the weakly correlated features are eliminated to form a key feature set; Step S3: Using the key features as input, constructing an LSTM network that integrates physical constraints, wherein the loss function of the LSTM network includes a data loss term and a physical constraint loss term based on the relationship between solar radiation and power, and outputting an initial prediction result; Step S4, calculates the real-time error based on the initial prediction result and the actual power, dynamically adjusts the network parameters according to the error size, and outputs the corrected final prediction result. The real-time error includes the mean absolute error and the mean square error, and the network parameters include the learning rate, physical constraint weight, and batch size.
2. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 1 is characterized in that: The step S1 includes the following steps: Step S11, collecting photovoltaic power generation data and meteorological data, wherein the photovoltaic power generation data includes inverter output power, operating status and timestamp, and the meteorological data includes 22-dimensional features including solar irradiance, temperature, humidity, soil temperature, and wind speed; Step S12: Fill missing values, perform Z-score normalization, and perform time alignment on the collected photovoltaic power generation data and meteorological data to ensure data accuracy and consistency; Step S13: Based on the processed data, valid data is screened out through statistical feature calculation, dynamic threshold construction and multivariate joint judgment.
3. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 2 is characterized in that: The step S12 includes: Perform missing value filling processing on the collected photovoltaic power generation data and meteorological data to complete the missing items in the data; Perform Z-score normalization on the collected photovoltaic power generation data and meteorological data, and convert each eigenvalue into the result of (eigenvalue - eigenmean) / eigenstandard deviation; The collected photovoltaic power generation data and meteorological data are time-aligned, and the photovoltaic power generation data and meteorological data are matched based on the timestamp to ensure that the data at the same time correspond.
4. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 2 is characterized in that: The step S13 includes: Step S131, setting the sliding window length to W, and calculating the mean, standard deviation, variation range, and fluctuation statistics within the window for the meteorological parameters and photovoltaic power respectively; Step S132: construct a dynamic threshold. The dynamic threshold for the meteorological parameter variation range is the product of the fluctuation mean plus the sensitivity coefficient k and the fluctuation standard deviation. The dynamic threshold for the photovoltaic power residual is the mean of the residual sequence plus the product of the residual sensitivity coefficient and the residual standard deviation. Step S133, perform a joint abnormality judgment; if the change amplitude of the meteorological parameters is greater than its dynamic threshold and the power residual is greater than its dynamic threshold, it is judged as an environmental abnormality; if the meteorological parameters are normal but the power residual is abnormal, it is judged as an equipment or data failure abnormality; if the meteorological parameters are abnormal but the power is normal, it is judged as a sensor error or short-term interference; after eliminating the abnormal data, output the valid data.
5. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 4 is characterized in that: In step S131, the mean, standard deviation, variation range and fluctuation statistics within the window are calculated for the meteorological parameters and photovoltaic power respectively, including: The mean value of the meteorological parameter at time t: the sum of all data in the window divided by the window length W; The standard deviation of meteorological parameters at time t: the square root of the sum of the squares of the differences between each data and the mean in the window divided by the window length W; The range of change of meteorological parameters: the absolute value of the difference between the data at the current moment and the data at the previous moment; Calculate the mean and standard deviation of fluctuations based on all fluctuations within the window; Statistical characteristics of photovoltaic power: including power mean, power standard deviation, and correlation coefficient between power and meteorological parameters.
6. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 1 is characterized in that: The step S2 comprises the following steps: Step S21, based on the valid data, using time-varying Spearman rank correlation analysis to calculate the dynamic correlation coefficient between meteorological characteristics and photovoltaic power; Step S22: Based on the calculated dynamic correlation coefficient, feature classification and screening are performed according to the following criteria: strongly correlated features, i.e., features with an absolute value of the correlation coefficient greater than 0.5, are retained; only one solar radiation feature is retained to avoid collinearity; moderately correlated features are verified and retained, and features with an absolute value of the correlation coefficient between 0.3 and 0.5 are retained after physical rationality verification; weakly correlated features, i.e., features with an absolute value of the correlation coefficient less than 0.1, are eliminated; In step S23, the feature set is dynamically updated, and the correlation coefficient is recalculated every 15 minutes. When the absolute value of the change in the correlation coefficient is greater than 0.2, the classification and screening process in step 2 is re-executed to update the feature set and output the final key feature set.
7. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 6 is characterized in that: The method of calculating the dynamic correlation coefficient between meteorological characteristics and photovoltaic power by using time-varying Spearman rank correlation analysis includes: Initialize the sliding window, set the window width to 24, and the time decay factor to 0.05; Sort the photovoltaic power and meteorological data at each time t by size and assign them to levels, and calculate the difference between the corresponding levels ; Calculate weight function, adaptive time-varying weight function : , Where σ=w / 3, is the window width, is the window center moment; Dynamic correlation coefficient solution, correlation coefficient The calculation formula is: , in, is the time decay factor.
8. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 1 is characterized in that: The step S3 comprises the following steps: Step S31: align the selected key features in time and space to construct time series data with an input dimension of (24, 5); where 24 is the time step and 5 is the feature dimension; the key features include shortwave radiation, direct radiation, temperature, humidity, and daytime identification; Step S32: Design an LSTM network architecture and construct a deep network with two LSTM layers. The LSTM network includes two LSTM layers, with the first layer containing 256 units and the second layer containing 128 units. The input dimension is (24, 5), and a Dropout layer and a LayerNormalization layer are subsequently connected. Step S33: Add a physical constraint term to the network loss function: total loss function = data loss + physical constraint weight × physical constraint loss; data loss uses Huber loss; physical constraint loss is constructed based on the partial differential equation of the relationship between solar radiation and power, including the partial derivative of power with respect to time, the gradient term of wind speed and power, source terms based on solar radiation, temperature, and humidity, and power attenuation terms; In step S34, the RMSprop optimizer is used, the batch size is set to 32, the number of training rounds is set to 500, the network is trained until convergence based on the input key feature data, and the initial prediction result is output.
9. The photovoltaic power generation prediction method based on physical constraints and LSTM network according to any one of claims 1 to 8, characterized in that: The step S4 comprises the following steps: Step S41: Based on the initial prediction result and the actual photovoltaic power, the error is calculated using a 30-minute sliding window: Mean Absolute Error (MAE) = sum of the absolute values of (actual power - initial prediction power) in the window / number of data in the window; Mean Square Error (MSE) = sum of the squares of (actual power - initial prediction power) in the window / number of data in the window; Step S42: compare the MAE with a preset threshold. If the MAE is greater than 5%, it is determined that the prediction accuracy is low; if the MAE is less than 2%, it is determined that the prediction accuracy is high. Step S43: Adjust the network parameters according to the judgment result. When MAE>5%, the learning rate is ×0.9, and the physical constraint weight is ×1.2; when MAE<2%, the learning rate is ×1.1, and the batch size is adjusted to twice the current value. In step S44, the network with adjusted parameters is re-predicted and the corrected results are output; steps 41 to 44 are repeated every 30 minutes to form a closed-loop optimization, and ultimately the MAE is stabilized within 3.2% and the root mean square error is stabilized within 4.5%.
10. A photovoltaic power generation prediction device based on physical constraints and LSTM network, characterized in that: include: The data processing module is used to collect photovoltaic power generation data and meteorological data. After missing value filling, normalization and time alignment, valid data is screened out through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint judgment; The feature screening module is used to calculate the dynamic correlation coefficient between meteorological characteristics and photovoltaic power based on valid data using time-varying Spearman rank correlation analysis, retaining strongly correlated features and physically verified moderately correlated features, and eliminating weakly correlated features to form a key feature set; The prediction model module is used to take key features as input, build an LSTM network that integrates physical constraints, and output an initial prediction result. The adaptive correction module is used to calculate the real-time error based on the initial prediction result and the actual power, dynamically adjust the network parameters according to the error size, and output the corrected final prediction result. The real-time error includes the mean absolute error and the mean square error. The network parameters include the learning rate, physical constraint weight, and batch size.
Citation Information
Patent Citations
LSTM network power generation multi-step prediction method based on correlation analysis
CN111832818A
Photovoltaic power generation prediction method and system based on multi-scale image convolutional neural network
CN114971007A
Photovoltaic power prediction method and system considering physical mechanism correction
CN119740747A
Distributed power supply power prediction method, system and equipment based on LSTM (Long Short Term Memory)
CN120033663A
Photovoltaic power generation power prediction method based on Bi-LSTM
CN120146096A