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
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2025-12-16
- 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 to output the corrected prediction results.
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 CN120822705B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to a photovoltaic power generation prediction method and device based on physical constraints and an LSTM network, and belongs to the technical field of new energy power generation prediction and optimal operation of a power distribution network. BACKGROUND
[0002] With the transformation of global energy structure to clean energy, the proportion of photovoltaic power generation in the power system continues to rise. As of 2024, the installed capacity of photovoltaic power in China has broken through 600 GW. Source-grid-load-storage integration, as the core technical path of the new power system, can significantly improve the flexibility and new energy consumption capacity of the system by coordinating the four elements of power supply, power grid, load and energy storage. However, photovoltaic power generation is significantly affected by meteorological factors and has strong intermittency and volatility. High-precision power prediction is a key prerequisite for the coordinated operation of source-grid-load-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, there is a lack of comprehensive consideration of the synergistic effect of source-grid-load-storage, resulting in insufficient prediction accuracy and affecting system scheduling effect; third, the multi-dimensionality and redundancy of meteorological data increase the complexity of model training, reducing prediction efficiency and real-time performance.
[0004] In recent years, deep learning technology has been widely applied in the field of power prediction. LSTM neural networks can effectively process time series data and capture long-term dependencies, and are widely used in new energy power prediction. However, existing LSTM-based methods still have deficiencies in input feature selection, meteorological factor influence analysis and physical rationality guarantee, such as the occurrence of negative power, night power generation and other prediction results that do not conform to physical laws, making it difficult to meet the demand for high-precision prediction. SUMMARY
[0005] To solve the above problems, the application provides a photovoltaic power generation prediction method and device based on physical constraints and an LSTM network, which can improve the prediction accuracy, efficiency and physical rationality of photovoltaic power generation.
[0006] The technical scheme adopted by the application to solve the technical problems is:
[0007] In a first aspect, the application provides a photovoltaic power generation prediction method based on physical constraints and an LSTM network, which includes the following steps:
[0008] Step S1, collect photovoltaic power generation data and meteorological data, and after filling in missing values, normalizing and time aligning, calculate the effective data by sliding window statistical feature calculation, dynamic threshold construction and multivariate joint determination;
[0009] Step S2, based on the effective data, the time-varying Spearman rank correlation analysis is used to calculate the dynamic correlation coefficient of the meteorological characteristics and the photovoltaic power, the strong correlation characteristics and the medium correlation characteristics verified by physics are retained, the weak correlation characteristics are removed, and a key characteristic set is formed;
[0010] Step S3, taking the key characteristics as input, a LSTM network fusing physical constraints is constructed, 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 an initial prediction result is outputted;
[0011] Step S4, based on the initial prediction result and the actual power, a real-time error is calculated, network parameters are dynamically adjusted according to the error size, and a corrected final prediction result is outputted, wherein the real-time error includes a mean absolute error and a mean square error, and the network parameters include a learning rate, a physical constraint weight and a batch size.
[0012] As a possible implementation manner of the embodiment, the step S1 includes the following steps:
[0013] Step S11, collecting photovoltaic power generation data and meteorological data, wherein the photovoltaic power generation data includes inverter output power, running state and time stamp, and the meteorological data includes 22-dimensional characteristics such as solar irradiance (GTI / DHI), temperature, humidity, soil temperature and wind speed;
[0014] Step S12, performing missing value filling, Z-score normalization and time alignment processing on the collected photovoltaic power generation data and meteorological data, to ensure the accuracy and consistency of the data;
[0015] Step S13, based on the processed data, effective data is screened out through statistical characteristic calculation, dynamic threshold construction and multivariate joint determination.
[0016] As a possible implementation manner of the embodiment, the step S12 includes:
[0017] Performing missing value filling processing on the collected photovoltaic power generation data and meteorological data to complete the missing items in the data;
[0018] Performing Z-score normalization processing on the collected photovoltaic power generation data and meteorological data, and converting each characteristic value into a result of (characteristic value-characteristic mean value) / characteristic standard deviation;
[0019] Performing time alignment processing on the collected photovoltaic power generation data and meteorological data, matching the photovoltaic power generation data with the meteorological data based on the time stamp, and ensuring that the data at the same time corresponds.
[0020] As a possible implementation manner of the embodiment, the step S13 includes:
[0021] Step S131, set the sliding window length as W (such as 10 minutes), calculate the mean, standard deviation, variation range and fluctuation statistics of the meteorological parameters and photovoltaic power in the window respectively;
[0022] Step S132, construct dynamic threshold, the dynamic threshold for meteorological parameter variation range is the fluctuation mean plus the product of the sensitivity coefficient k (generally 2 or 3) and the fluctuation standard deviation; the dynamic threshold for 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;
[0023] Step S133, perform joint anomaly judgment; if the meteorological parameter variation range is greater than its dynamic threshold and the power residual is greater than its dynamic threshold, it is judged as environmental anomaly; if the meteorological parameter is normal but the power residual is abnormal, it is judged as equipment or data fault anomaly; if the meteorological parameter is abnormal but the power is normal, it is judged as sensor error or short-time interference; output valid data after removing abnormal data.
[0024] As a possible implementation manner of the embodiment, in step S131, the mean, standard deviation, variation range and fluctuation statistics of the meteorological parameters and photovoltaic power in the window are calculated respectively, including:
[0025] The mean of the meteorological parameter at time t: the sum of all data in the window divided by the window length W;
[0026] The standard deviation of the meteorological parameter at time t: the square sum of the difference between each data in the window and the mean divided by the window length W, and then square root;
[0027] The variation range of the meteorological parameter: the absolute value of the difference between the current time data and the previous time data;
[0028] Based on all variation ranges in the window, the fluctuation mean (the sum of all variation ranges divided by the window length minus 1) and the fluctuation standard deviation (the square sum of the difference between each variation range and the fluctuation mean divided by the window length minus 1, and then square root) are calculated;
[0029] The statistical characteristics of photovoltaic power: including power mean (the sum of power in the window divided by the window length W), power standard deviation (the square sum of the difference between each power value in the window and the power mean divided by the window length W, and then square root), and the correlation coefficient of power and meteorological parameter (the sum of the product of the difference between power and meteorological parameter and the mean, divided by the product of the square root of the square sum of the power difference and the square root of the square sum of the meteorological parameter difference).
[0030] As a possible implementation manner of the embodiment, the step S2 includes the following steps:
[0031] Step S21, based on the effective data (including pre-processed photovoltaic power generation data and meteorological data), the time-varying Spearman rank correlation analysis is used to calculate the dynamic correlation coefficient (time-varying Spearman rank correlation coefficient) of the meteorological characteristics and the photovoltaic power;
[0032] Step S22, based on the calculated dynamic correlation coefficient, the feature classification screening is performed according to the following standards: the strong correlation features are retained, that is, the features with the absolute value of the correlation coefficient greater than 0.5; among them, only one of the solar radiation type features (such as shortwave radiation, direct radiation, etc.) is retained to avoid collinearity; the moderate correlation features are verified and retained, that is, the features with the absolute value of the correlation coefficient between 0.3 and 0.5 are retained after the physical rationality verification (such as the consistent influence logic with the photovoltaic power); and the weak correlation features are removed, that is, the features with the absolute value of the correlation coefficient less than 0.1 are removed.
[0033] Step S23, the feature set is dynamically updated, the correlation coefficient is recalculated every 15 minutes, and when the absolute value of the change amount of the correlation coefficient is greater than 0.2, the classification and screening process of step 2 is re-executed to update the feature set, and the final key feature set is output.
[0034] As a possible implementation manner of the embodiment, the time-varying Spearman rank correlation analysis is used to calculate the dynamic correlation coefficient of the meteorological characteristics and the photovoltaic power, which includes:
[0035] The sliding window is initialized, the window width is set to 24 (corresponding to a 24-hour period), and the time decay factor is 0.05;
[0036] The photovoltaic power and meteorological data at each time t are sorted by size and assigned a rank, and the difference value of the corresponding rank is calculated (rank difference);
[0037] The weight function is calculated, and the adaptive time-varying weight function :
[0038] ,
[0039] where σ = w / 3, is the window width, is the window center time, the adaptive time-varying weight function is a normal distribution function, the mean value of which is the window center time, and the standard deviation is one-third of the window width, so as to highlight the weight of recent data;
[0040] The dynamic correlation coefficient is solved, and the correlation coefficient The calculation formula is:
[0041] ,
[0042] where, is the time decay factor.
[0043] As a possible implementation manner of the embodiment, the step S3 comprises the following steps:
[0044] In step S31, the screened key features are spatio-temporally aligned to construct time series data with an input dimension of (24, 5); wherein 24 is a time step (corresponding to a 24-hour sliding window), and 5 is a feature dimension (such as shortwave radiation, direct radiation, 2-meter temperature, 2-meter relative humidity, and daytime identifier); the key features include shortwave radiation, direct radiation, temperature, humidity, and daytime identifier.
[0045] In step S32, an LSTM network architecture is designed to construct a deep network containing a double-LSTM layer; the LSTM network includes a double-LSTM layer, the first layer contains 256 units, and the second layer contains 128 units; the input dimension is (24, 5) (24-hour time step, 5 key features); a Dropout layer (dropout rate 20%) and a LayerNormalization layer (data is standardized and then adjusted through learnable parameters) are connected in sequence.
[0046] In step S33, a physical constraint term is added to the network loss function, and the total loss function = data loss + physical constraint weight x physical constraint loss; wherein the data loss adopts huber loss; the 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, the source term (increasing with the increase of solar radiation) based on solar radiation, temperature, and humidity, and the power attenuation term (related to component aging);
[0047] In step S34, an RMSprop optimizer (initial learning rate 0.0005) is adopted, the batch size is set to 32, the training round number is set to 500, the network is trained based on the input key feature data until convergence, and an initial prediction result is output.
[0048] As a possible implementation manner of the embodiment, the step S4 comprises the following steps:
[0049] In 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 absolute values of (actual power-initial predicted power) in the window ÷ number of data in the window (30), and mean square error (MSE) = sum of squares of (actual power-initial predicted power) in the window ÷ number of data in the window (30);
[0050] In step S42, the MAE is compared with a preset threshold value; if the MAE > 5%, it is determined that the prediction accuracy is low; if the MAE < 2%, it is determined that the prediction accuracy is high.
[0051] Step S43, adjusting the network parameters according to the determination result, when MAE>5%, learning rate*0.9 (reducing the parameter update amplitude), and at the same time, the physical constraint weight*1.2 (enhancing the physical rationality constraint); when MAE<2%, learning rate*1.1 (accelerating the convergence speed), and at the same time, the batch size is adjusted to 2 times of the current value (the maximum is not more than 256);
[0052] Step S44, re-predicting the network after adjusting the parameters, and outputting the corrected result; repeating steps 41 to 44 every 30 minutes to form a closed loop optimization, so that the MAE is finally stabilized within 3.2%, and the root mean square error is stabilized within 4.5%.
[0053] In a second aspect, the embodiment of the present application provides a photovoltaic power generation prediction device based on physical constraints and an LSTM network, comprising:
[0054] A data processing module is configured to collect photovoltaic power generation data and meteorological data, fill in missing values, normalize and time-align, and then filter out effective data through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint determination;
[0055] A feature screening module is configured to calculate dynamic correlation coefficients of meteorological features and photovoltaic power based on the effective data by using time-varying Spearman rank correlation analysis, retain strong correlation features and moderately correlated features verified by physics, and eliminate weak correlation features to form a key feature set;
[0056] A prediction model module is configured to take the key features as input, construct an LSTM network integrating physical constraints, and output an initial prediction result, wherein the loss function of the network comprises a data loss term and a physical constraint loss term based on the relationship between solar radiation and power.
[0057] An adaptive correction module is configured to calculate real-time errors based on the initial prediction result and the actual power, dynamically adjust network parameters according to the error size, and output a final prediction result after correction, wherein the real-time errors include mean absolute error and mean square error, and the network parameters include learning rate, physical constraint weight and batch size.
[0058] The technical scheme of the embodiment of the present application has the following beneficial effects:
[0059] The present application 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; the time-varying Spearman rank correlation analysis is used to dynamically screen key features (retaining strong correlation features and moderately correlated features verified by physics, and eliminating weak correlation features), so that the model input is more reasonable and the prediction accuracy is improved. Strong correlation features such as short-wave radiation, direct radiation, etc. with a strong correlation of |>0.5 are removed, and weak correlation features are removed, so that the feature dimension is reduced from 22 to 4, and the redundant information interference is reduced; the physical constraint LSTM network introduces the partial differential equation constraint of the relationship between solar radiation and power (eliminates the physical unreasonable such as night power generation >0), and forms a closed loop optimization through adaptive error correction (based on MAE dynamic adjustment of learning rate, physical constraint weight and other parameters); the present application realizes high-precision prediction through a three-level optimization mechanism, significantly improves the prediction accuracy of photovoltaic power generation, and greatly reduces the prediction error of photovoltaic power generation.
[0060] The present application removes weakly correlated features in the feature screening link, reduces the dimension by 77%, and greatly reduces the calculation amount of model training and reasoning; the LSTM network adopts a double-layer structure (256+128 units) with Dropout and Layer Normalization regularization to avoid overfitting while ensuring accuracy, and the training speed is improved by 2.3 times, meeting the real-time prediction demand (such as high-frequency response scenarios of source network load storage collaborative scheduling). The present application improves the calculation efficiency through feature dimension reduction and lightweight design, and significantly enhances the calculation real-time performance.
[0061] The present application adds solar radiation partial differential equation constraint in the LSTM loss function, forcing the model to follow the physical laws such as "photovoltaic power is positively correlated with solar radiation, and power is 0 at night"; combined with the night mask mechanism (forcing the predicted power to be 0 when the daytime identifier is 0), more than 99% of the logical errors such as negative power and night power generation can be eliminated, ensuring that the prediction result is consistent with the actual physical scene. The present application solves the "physical unreasonable" problem of traditional models by injecting physical constraints, not only the prediction result is highly physically reasonable, but also the logical contradictions are eliminated.
[0062] The prediction result of the present application can accurately reflect the intermittency and volatility of photovoltaic power generation, helping the power grid to plan power sources, loads, energy storage and other elements (such as adjusting the energy storage charging and discharging strategy in advance, optimizing load matching); ultimately realizing a 22% increase in new energy consumption rate, helping the efficient operation of the source network load storage integrated system, meeting the development needs of new power systems.
[0063] The present application designs a multi-level meteorological correlation screening mechanism to reduce redundant data interference; constructs a physical information enhanced LSTM model to introduce solar radiation equation constraint; develops an adaptive error correction algorithm to realize dynamic parameter optimization; the present application realizes photovoltaic power generation prediction through innovative multi-level feature screening mechanism, adaptive network structure and collaborative optimization algorithm, not only solves the deficiencies of existing technologies in prediction accuracy, calculation efficiency and system coordination, but also improves the prediction accuracy, efficiency and physical rationality of photovoltaic power generation, which is used for high-precision power generation prediction in the source network load storage collaborative scenario, effectively supporting the optimization scheduling and new energy consumption of the power system. BRIEF DESCRIPTION OF DRAWINGS
[0064] Figure 1 is a flow chart of a photovoltaic power generation prediction method based on physical constraints and LSTM network according to an exemplary embodiment;
[0065] Figure 2 is a structural schematic diagram of a photovoltaic power generation prediction device based on physical constraints and LSTM network according to an exemplary embodiment;
[0066] Figure 3 is a structural schematic diagram of correlation analysis of weather factors and power data according to an exemplary embodiment. DETAILED DESCRIPTION
[0067] In order to more clearly illustrate the technical features of the scheme of the present application, the present application will be described in detail below with reference to specific embodiments and accompanying drawings.
[0068] As shown in Figure 1 , the photovoltaic power generation prediction method based on physical constraints and LSTM network provided by the embodiment of the present application comprises the following steps:
[0069] Step S1, collect photovoltaic power generation data and meteorological data, after filling in missing values, normalizing and time aligning, calculate the features through sliding window statistics, construct dynamic threshold and filter out effective data through multivariate joint determination;
[0070] Step S2, based on the effective data, calculate the dynamic correlation coefficient of meteorological features and photovoltaic power by time-varying Spearman rank correlation analysis, retain strong correlation features and moderately correlated features verified by physics, eliminate weakly correlated features, and form a key feature set;
[0071] Step S3, take the key features as input, build an LSTM network that integrates physical constraints, 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 output an initial prediction result;
[0072] Step S4, calculate real-time error based on the initial prediction result and the actual power, dynamically adjust the network parameters according to the error size, output the corrected final prediction result, the real-time error includes mean absolute error and mean square error, and the network parameters include learning rate, physical constraint weight and batch size.
[0073] The application adopts dynamic weight + physical verification double mechanism to carry out time-varying feature screening, embeds a network structure through a solar radiation equation to carry out fusion of physical information and LSTM, and carries out three-level self-adaptation through an error-driven parameter dynamic adjustment system, not only realizes photovoltaic power generation prediction, solves the deficiencies of the prior art in prediction accuracy, calculation efficiency and system coordination, but also improves the prediction accuracy, efficiency and physical rationality of photovoltaic power generation, and effectively supports the optimization scheduling and new energy consumption of the power system.
[0074] As a possible implementation manner of the embodiment, the step S1 comprises the following steps:
[0075] Step S11, collect photovoltaic power generation data and meteorological data, wherein the photovoltaic power generation data comprises inverter output power, running state and time stamp, and the meteorological data comprises 22-dimensional features such as solar irradiance (GTI / DHI), temperature, humidity, soil temperature and wind speed;
[0076] Step S12, perform missing value filling, Z-score normalization and time alignment processing on the collected photovoltaic power generation data and meteorological data, to ensure the accuracy and consistency of the data;
[0077] Step S13, based on the processed data, filter out effective data through statistical feature calculation, dynamic threshold construction and multivariate joint determination.
[0078] As a possible implementation manner of the embodiment, the step S12 comprises:
[0079] Perform missing value filling processing on the collected photovoltaic power generation data and meteorological data to complete the missing items in the data;
[0080] Perform Z-score normalization processing on the collected photovoltaic power generation data and meteorological data, and convert each feature value into the result of (feature value-feature mean value) / feature standard deviation;
[0081] Perform time alignment processing on the collected photovoltaic power generation data and meteorological data, match the photovoltaic power generation data and the meteorological data based on the time stamp, and ensure that the data at the same time corresponds.
[0082] As a possible implementation manner of the embodiment, the step S13 comprises:
[0083] Step S131, set the sliding window length as W (such as 10 minutes), calculate the mean value, standard deviation, change amplitude and fluctuation statistics in the window for the meteorological parameters and photovoltaic power respectively;
[0084] Step S132, constructing dynamic thresholds, the dynamic threshold for the meteorological parameter change amplitude is the fluctuation mean value plus the product of the sensitivity coefficient k (usually 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 value of the residual sequence plus the product of the residual sensitivity coefficient and the residual standard deviation;
[0085] Step S133, performing joint abnormality judgment; if the meteorological parameter change amplitude is greater than its dynamic threshold and the power residual is greater than its dynamic threshold, it is judged as environmental abnormality; if the meteorological parameter is normal but the power residual is abnormal, it is judged as equipment or data fault abnormality; if the meteorological parameter is abnormal but the power is normal, it is judged as sensor error or short-time interference; the valid data is output after removing the abnormal data.
[0086] As a possible implementation manner of the embodiment, in step S131, the mean value, the standard deviation, the change amplitude and the fluctuation statistics of the meteorological parameter and the photovoltaic power in the window are calculated respectively, including:
[0087] The mean value of the meteorological parameter at time t: the sum of all data in the window divided by the window length W;
[0088] The standard deviation of the meteorological parameter at time t: the square sum of the difference between each data in the window and the mean value divided by the window length W, and then taking the square root;
[0089] The change amplitude of the meteorological parameter: the absolute value of the difference between the current time data and the previous time data;
[0090] Based on all the change amplitudes in the window, the fluctuation mean value (the sum of all the change amplitudes divided by the window length minus 1) and the fluctuation standard deviation (the square sum of the difference between each change amplitude and the fluctuation mean value divided by the window length minus 1, and then taking the square root) are calculated;
[0091] The statistical characteristics of the photovoltaic power: including the power mean value (the sum of the power in the window divided by the window length W), the power standard deviation (the square sum of the difference between each power value in the window and the power mean value divided by the window length W, and then taking the square root), and the correlation coefficient of the power and the meteorological parameter (the sum of the product of the difference between the power and the meteorological parameter and the mean value, divided by the product of the square root of the square sum of the power difference and the square root of the square sum of the meteorological parameter difference).
[0092] As a possible implementation manner of the embodiment, the step S2 includes the following steps:
[0093] Step S21, based on the valid data (including the preprocessed photovoltaic power generation data and the meteorological data), the time-varying Spearman rank correlation analysis is used to calculate the dynamic correlation coefficient (time-varying Spearman rank correlation coefficient) of the meteorological characteristics and the photovoltaic power;
[0094] Step S22, based on the calculated dynamic correlation coefficient, the features are classified and screened according to the following standards: strong correlation features are retained, that is, the features with an absolute value of the correlation coefficient greater than 0.5; among them, only one of the solar radiation features (such as shortwave radiation, direct radiation, etc.) is retained to avoid collinearity; medium correlation features are verified and retained, that is, the features with an absolute value of the correlation coefficient between 0.3 and 0.5 are retained after physical rationality verification (such as consistent with the influence logic of photovoltaic power); weak correlation features are removed, that is, the features with an absolute value of the correlation coefficient less than 0.1 are removed.
[0095] Step S23, the feature set is dynamically updated, and the correlation coefficient is recalculated every 15 minutes. When the absolute value of the change amount of the correlation coefficient is greater than 0.2, the classification and screening process of step 2 is re-executed to update the feature set, and the final key feature set is output.
[0096] As a possible implementation manner of the embodiment, the dynamic correlation coefficient of the meteorological features and the photovoltaic power is calculated by using the time-varying Spearman rank correlation analysis, which includes:
[0097] The sliding window is initialized, the window width is set to 24 (corresponding to a 24-hour period), and the time decay factor is 0.05;
[0098] The photovoltaic power and meteorological data at each time t are sorted by size and assigned a rank, and the difference value of the corresponding rank is calculated (rank difference);
[0099] The weight function is calculated, and the adaptive time-varying weight function
[0100] ,
[0101] where σ = w / 3, is the window width, is the window center time, and the adaptive time-varying weight function is a normal distribution function, the mean value of which is the window center time, and the standard deviation is one-third of the window width, so as to highlight the weight of recent data;
[0102] The dynamic correlation coefficient is solved, and the correlation coefficient The calculation formula is:
[0103] ,
[0104] wherein, is the time decay factor.
[0105] As a possible implementation manner of the embodiment, the step S3 includes the following steps:
[0106] Step S31, the selected key features are spatio-temporally aligned to construct time series data with an input dimension of (24, 5); wherein 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 identifier); the key features include shortwave radiation, direct radiation, temperature, humidity, and daytime identifier;
[0107] Step S32, an LSTM network architecture is designed to construct a deep network containing a double-LSTM layer; the LSTM network includes a double-LSTM layer, the first layer contains 256 units, and the second layer contains 128 units; the input dimension is (24, 5) (24-hour time step, 5 key features); a Dropout layer (dropout rate 20%) and a LayerNormalization layer (data is standardized and then adjusted through learnable parameters) are connected in sequence;
[0108] Step S33, a physical constraint term is added to the network loss function, and the total loss function = data loss + physical constraint loss weight x physical constraint loss; wherein the data loss adopts huber loss; the 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, the source term (increasing with increasing solar radiation) based on solar radiation, temperature, and humidity, and the power attenuation term (related to component aging);
[0109] Step S34, an 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 based on the input key feature data until convergence, and the initial prediction result is output.
[0110] As a possible implementation manner of the embodiment, the step S4 includes the following steps:
[0111] 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 absolute values of (actual power-initial predicted power) in the window ÷ number of data in the window (30), mean square error (MSE) = sum of squares of (actual power-initial predicted power) in the window ÷ number of data in the window (30);
[0112] Step S42, the MAE is compared with the preset threshold value; if the MAE> 5%, it is determined that the prediction accuracy is low; if the MAE< 2%, it is determined that the prediction accuracy is high;
[0113] Step S43, adjusting the network parameters according to the determination result, when MAE>5%, learning rate x 0.9 (reducing the parameter update amplitude), and at the same time, the physical constraint weight x 1.2 (enhancing the physical rationality constraint); when MAE<2%, learning rate x 1.1 (speeding up the convergence speed), and at the same time, the batch size is adjusted to 2 times of the current value (the maximum is not more than 256);
[0114] Step S44, re-predicting the network after adjusting the parameters, and outputting the corrected result; repeating steps 41 to 44 every 30 minutes to form a closed loop optimization, finally making MAE stable within 3.2% and root mean square error stable within 4.5%.
[0115] As shown in Figure 2 The photovoltaic power generation prediction device based on physical constraints and LSTM network provided by the embodiment of the application comprises:
[0116] The data processing module is used for collecting photovoltaic power generation data and meteorological data, and screening out effective data through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint determination after missing value filling, normalization and time alignment;
[0117] The feature screening module is used for calculating the dynamic correlation coefficient of meteorological features and photovoltaic power based on the effective data by using time-varying Spearman rank correlation analysis, retaining strong correlation features and moderately correlated features verified by physics, and eliminating weak correlation features to form a key feature set;
[0118] The prediction model module is used for taking the key features as input, constructing an LSTM network fusing physical constraints, and outputting an initial prediction result, wherein the loss function of the network comprises a data loss term and a physical constraint loss term based on the relationship between solar radiation and power.
[0119] The adaptive correction module is used for calculating real-time errors based on the initial prediction result and the actual power, dynamically adjusting network parameters according to the error size, and outputting a corrected final prediction result, wherein the real-time errors comprise mean absolute error and mean square error, and the network parameters comprise learning rate, physical constraint weight and batch size.
[0120] The application solves the deficiencies of the prior art in prediction accuracy, calculation efficiency and system coordination through the innovative multi-level feature screening mechanism, adaptive network structure and collaborative optimization algorithm. The specific implementation process of the application is as follows.
[0121] I. Data acquisition and preprocessing
[0122] Multi-source data in the power distribution network is collected, including distributed photovoltaic power generation data, weather data and the like.
[0123] The collected data sources comprise:
[0124] Photovoltaic power generation data: inverter output power, operating status, timestamp;
[0125] Weather data: 22-dimensional features such as solar irradiance (GTI / DHI), temperature, humidity, soil temperature, wind speed, etc.
[0126] Data preprocessing: missing value filling, Z-score normalization, time alignment, to ensure the accuracy and consistency of the data, and provide a reliable basis for subsequent analysis and prediction.
[0127] In order to realize the intelligent anomaly detection of photovoltaic power generation power data and its related meteorological input, the invention designs a statistical feature extraction mechanism for historical data and target power, the specific steps are as follows.
[0128] 1. Multi-source meteorological parameter statistical feature calculation:
[0129] Let the observed value of meteorological parameter (such as temperature, radiation, etc.) at time t be , set the sliding window length as W (such as W=10 minutes), calculate the statistical features of the data sequence of this parameter in the window:
[0130] ,
[0131] Calculate its statistical features:
[0132] Mean:
[0133] ,
[0134] Standard deviation:
[0135] ,
[0136] Change amplitude (absolute value of adjacent time difference):
[0137] ,
[0138] Based on all Δ in the historical window, calculate the fluctuation mean and standard deviation :
[0139] .
[0140] 2. Target power value statistical feature and correlation analysis:
[0141] Let the measured photovoltaic power value be , calculate synchronously:
[0142] Power mean:
[0143] ;
[0144] Power standard deviation:
[0145] ;
[0146] Correlation coefficient between power and meteorological parameters (take temperature as an example):
[0147] ;
[0148] This correlation is used to determine whether the meteorological data and the target power are logically matched, and to assist in abnormality determination.
[0149] Dynamic threshold construction and abnormality determination: take the change amplitude For example, set the dynamic threshold according to historical statistical characteristics :
[0150] ,
[0151] Among them, the sensitivity coefficient k is adjustable (generally 2 or 3);
[0152] The current change amplitude meets the conditions:
[0153] ,
[0154] That is, it can be determined that the meteorological data at this moment is abnormal;
[0155] Similarly, for target power residual abnormality detection, first define the prediction residual:
[0156] ,
[0157] Among them, is the predicted power calculated based on the model corresponding to the input;
[0158] Calculate the mean and standard deviation of the residual historical sequence , construct the residual threshold:
[0159] ,
[0160] If , it is determined that the power is abnormal, which may indicate device or data abnormality.
[0161] 4. Joint multivariate abnormality determination principle:
[0162] Integrate single meteorological indicators, power and its residual to perform joint abnormality analysis:
[0163] If the meteorological indicators are abnormal and the power is abnormal, it is determined that the environment is abnormal;
[0164] If the weather is normal but the power is abnormal, it is determined to be an equipment or data malfunction.
[0165] If the weather is abnormal but the power is normal, sensor error or short-term interference should be considered.
[0166] II. Multi-level meteorological correlation analysis:
[0167] Time-varying Spearman rank correlation analysis was used to mine the nonlinear correlation between meteorological data factors and photovoltaic power. The formula for calculating the dynamic correlation coefficient is:
[0168] ,
[0169] in, :time The difference in grade; Adaptive time-varying weight function; Time decay factor; : Sliding window size.
[0170] The process of calculating the dynamic correlation coefficient:
[0171] 1. Sliding window initialization: Set the window width w=24 (corresponding to a 24-hour cycle), and initialize the time decay factor λ=0.05;
[0172] 2. Rank difference calculation: Sort and rank the photovoltaic power and meteorological data at each time t;
[0173] 3. Weight function calculation:
[0174] ,
[0175] Where σ=w / 3, it reflects the characteristic that recent data has a higher weight;
[0176] Real-time update mechanism: The correlation coefficient within the window is recalculated every 15 minutes, and the feature set is updated when |Δrs|>0.2. Feature selection:
[0177] Correlation analysis was performed between weather factors and power data to obtain a Spearman correlation heatmap of power generation and meteorological factors.
[0178] Using correlation analysis, the top 10 items with the highest correlation were obtained, such as... Figure 3 As shown.
[0179] The specific implementation process of feature selection:
[0180] Screening criteria:
[0181] 1. Retain | Strongly correlated features with |r|>0.5, where solar radiation class is selected (to avoid collinearity).
[0182]
[0183] 2. Auxiliary features (0.3≤|r|<0.5) that need to be physically verified.
[0184]
[0185] 3. Weakly correlated features (|rs|<0.1): direct rejection.
[0186] After screening, the feature dimension is reduced from 22 to 4, and the calculation efficiency is improved by 40%.
[0187] III. Physical information enhances LSTM network:
[0188] 1. Technical overview:
[0189] Based on historical power generation data (power) and weather data (weather), a deep learning prediction model that integrates physical laws is constructed to achieve high-precision time series prediction of photovoltaic power.
[0190] Considering the intermittency and volatility of photovoltaic power generation, the invention uses a long short-term memory (LSTM) model, which can capture long-term dependencies in time series data and effectively improve prediction accuracy.
[0191] Forget gate formula: ,
[0192] Input gate formula: ,
[0193] Candidate cell state formula: =tanh( WC [ ht 1, xt ]+ ),
[0194] Cell state update formula: t = ft ⊙ Ct 1+ it ⊙ ,
[0195] Output gate formula: ,
[0196] Hidden state output formula: ,
[0197] Symbol explanation:
[0198] : Sigmoid activation function (for gating mechanism, range [0, 1]),
[0199] : Hadamard product (element-level multiplication),
[0200] f , i , WC , o : Weight matrix (subscript corresponds to different gating units),
[0201] f , i , , o : Bias vector,
[0202] : Previous hidden state Concatenation operation of the current input ,
[0203] The present application designs a LSTM network combined with physical constraints, and adds a physical law constraint term in the loss function:
[0204] ,
[0205] Wherein, is the physical constraint loss, including the partial differential equation constraint of the relationship between solar radiation and power:
[0206] ,
[0207] is the source term based on solar radiation , temperature , humidity , is the power attenuation term. By introducing physical constraints, the LSTM network can eliminate physically unreasonable predictions such as night-time power generation > 0, significantly improving the physical rationality of the prediction.
[0208] 2. Data input and feature engineering:
[0209] 2.1 Data mapping relationship:
[0210] power: power_num (unit: kW), indicating the inverter output power,
[0211] weather: corresponding to 22-dimensional weather data, key features include: shortwave radiation (W / m²), daytime identifier, 2-meter temperature (°C), 2-meter relative humidity (%).
[0212] 2.2 Spatio-temporal alignment processing: time alignment using pandas.
[0213] 3. Network core design:
[0214] 3.1 LSTM network architecture design: build a deep network containing a double LSTM layer, the LSTM network includes a double LSTM layer, the first layer contains 256 units, the second layer contains 128 units, the input dimension is (24, 5) (24-hour time step, 5 key features), followed by a Dropout layer (dropout rate 20%) and a LayerNormalization layer (standardize data and adjust through learnable parameters).
[0215] 3.2 Key component description:
[0216] 1) Input layer design:
[0217] Input dimension: input_shape=(24, 5),
[0218] 24: time step (24-hour sliding window),
[0219] 5: feature dimension (key features after screening): shortwave radiation, direct radiation, temperature, humidity, and daytime identifier.
[0220] 2) Double LSTM layer structure:
[0221] First layer LSTM (256 units):
[0222] Gate calculation:
[0223] ,
[0224] ,
[0225] Number of parameters: 4×(256×(256+5)+256)=266240,
[0226] Second layer LSTM (128 units):
[0227] Output processing: return_sequences=False (single-step prediction),
[0228] Innovation: introduce time decay factor λ=0.05.
[0229] 3) Regularization mechanism:
[0230] Dropout layer (0.2): Randomly masks 20% of neurons during training.
[0231] LayerNormalization:
[0232] .
[0233] 4) Physical constraint injection:
[0234] To address the distribution shift in photovoltaic data caused by sudden weather changes;
[0235] Output layer design:
[0236] Single neuron output: directly predicts power_num at time t+1;
[0237] Physical constraint implementation:
[0238] night_mask = tf.where(is_day_input == 0, 0.0, 1.0),
[0239] constrained_output = output * night_mask.
[0240] IV. Adaptive Error Correction Mechanism:
[0241] Dynamic parameter tuning: Adjusting weights based on real-time prediction error (MAE / MSE) feedback.
[0242] The formula for calculating mean squared error (MSE) is:
[0243] ,
[0244] The formula for calculating the mean absolute error (MAE) is:
[0245] ,
[0246] in, This is the actual value. These are predicted values.
[0247] Dynamic parameter tuning algorithm flow:
[0248] 1. Error monitoring: Real-time calculation of MAE within a sliding window (30 minutes).
[0249] 2. Parameter adjustment strategy:
[0250] When MAE>5%, learning rate x 0.9, while the physical constraint weight x 1.2; when MAE<2%, learning rate x 1.1, while the batch size is adjusted to 2 times the current value.
[0251] Training configuration:
[0252] Dual-channel LSTM | Hidden layer 128 units | Time step 24,
[0253] Optimizer: Adam (lr=0.0005) | Batch Size=32 | Epochs=500,
[0254] Adam optimizer is adopted, the learning rate is set to 0.0005, the batch size is 32, and the number of training rounds is 500.
[0255] Compared with the prior art, the present application has the following significant advantages:
[0256] 1. The prediction accuracy is greatly improved: through multi-level correlation analysis and adaptive LSTM network, the average absolute error (MAE) of photovoltaic power prediction is ≤3.2%, the root mean square error (RMSE) is ≤4.5%, and the accuracy is improved by more than 58.9% compared with traditional methods;
[0257] 2. Efficiency optimization: feature dimension reduction by 77%, training speed improvement by 2.3 times;
[0258] 3. Physical rationality: eliminate >99% of negative power / nighttime power generation errors through equation constraints;
[0259] 4. Dispatching value: the prediction result supports source network load storage collaborative dispatching, and the new energy consumption rate is improved by 22%.
[0260] Finally, it should be noted that: the above examples are only used to illustrate the technical solutions of the present application and not to limit it, although the present application has been described in detail with reference to the above examples, those skilled in the art should understand that the specific embodiments of the present application can still be modified or replaced, without departing from the spirit and scope of the present application, any modification or equivalent replacement, which should be covered within the protection scope of the claims of the present application.
Claims
1.A photovoltaic power generation prediction method based on physical constraints and LSTM network, characterized in that, The method comprises the following steps: Step S1, collecting photovoltaic power generation data and meteorological data, after missing value filling, normalization and time alignment, effective data is screened out through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint determination; Step S2, based on the effective data, the dynamic correlation coefficient of the meteorological characteristics and the photovoltaic power is calculated by using time-varying Spearman rank correlation analysis, the strong correlation characteristics and the medium correlation characteristics verified by physics are retained, and the weak correlation characteristics are removed to form a key feature set; Step S3, taking the key features as inputs, an LSTM network integrating physical constraints is constructed, 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 an initial prediction result is output; Step S4, based on the initial prediction result and the actual power, a real-time error is calculated, network parameters are dynamically adjusted according to the error size, and a corrected final prediction result is output, wherein the real-time error includes mean absolute error and mean square error, and the network parameters include learning rate, physical constraint weight and batch size; The time-varying Spearman rank correlation analysis is used to calculate the dynamic correlation coefficient of the meteorological characteristics and the photovoltaic power, which comprises: Sliding window initialization, setting the window width to 24 and the time decay factor to 0.05; For each moment t The photovoltaic power and meteorological data are sorted by size and assigned a level, and the difference between the corresponding levels is calculated. ; computing a weight function, an adaptive time-varying weight function : , wherein , is the window width, is the window center time; Dynamic correlation coefficient solution, correlation coefficient The calculation formula is: , wherein is a time decay factor; The step S3 comprises the following steps: Step S31, the selected key features are spatiotemporally aligned to construct time series data with an input dimension of (24, 5); wherein 24 is the time step, and 5 is the feature dimension; the key features include shortwave radiation, direct radiation, temperature, humidity and daytime identifier; Step S32, LSTM network architecture design is performed to construct a deep network containing double LSTM layers, the LSTM network includes double LSTM layers, the first layer contains 256 units, the second layer contains 128 units, the input dimension is (24, 5), and a Dropout layer and a LayerNormalization layer are connected subsequently; Step S33, a physical constraint term is added to the network loss function, the total loss function = data loss + physical constraint weight x physical constraint loss; wherein the data loss adopts huber loss; the 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, the source term based on solar radiation, temperature and humidity, and the power attenuation term; Step S34, an RMSprop optimizer is used, the batch size is set to 32, the number of training rounds is set to 500, the network is trained based on the input key feature data until convergence, and an initial prediction result is output. 2.The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 1, wherein, The step S1 comprises the following steps: Step S11, collecting photovoltaic power generation data and meteorological data, wherein the photovoltaic power generation data includes inverter output power, operating state and time stamp, and the meteorological data includes 22-dimensional features such as solar irradiance, temperature, humidity, soil temperature and wind speed; Step S12, the collected photovoltaic power generation data and meteorological data are subjected to missing value filling, Z-score normalization and time alignment processing to ensure the accuracy and consistency of the data; Step S13, based on the processed data, effective data is screened out through statistical feature calculation, dynamic threshold construction and multivariate joint determination. 3.The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 2, characterized in that, The step S12 comprises: The collected photovoltaic power generation data and meteorological data are subjected to missing value filling processing to complete the missing items in the data. The collected photovoltaic power generation data and meteorological data are subjected to Z-score normalization processing to convert each characteristic value into the result of (characteristic value-characteristic mean value) / characteristic standard deviation. The collected photovoltaic power generation data and meteorological data are subjected to time alignment processing, and the photovoltaic power generation data and the meteorological data are matched based on timestamps to ensure that the data at the same time corresponds. 4.The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 2, characterized in that, The step S13 comprises: Step S131, setting the sliding window length as W, calculating the mean value, standard deviation, change amplitude and fluctuation statistics of the meteorological parameters and photovoltaic power in the window respectively; Step S132, constructing a dynamic threshold, the dynamic threshold for the change amplitude of the meteorological parameters is the fluctuation mean value plus the product of the sensitivity coefficient k and the fluctuation standard deviation, and the dynamic threshold for the photovoltaic power residual is the mean value of the residual sequence plus the product of the residual sensitivity coefficient and the residual standard deviation; Step S133, joint abnormality determination; if the change amplitude of the meteorological parameters is greater than the dynamic threshold and the power residual is greater than the dynamic threshold, it is determined as environmental abnormality; if the meteorological parameters are normal but the power is abnormal, it is determined as equipment or data fault abnormality; if the meteorological parameters are abnormal but the power is normal, it is determined as sensor error or short-time interference; and the effective data is output after removing the abnormal data. 5.The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 4, characterized in that, In step S131, calculating the mean value, standard deviation, change amplitude and fluctuation statistics of the meteorological parameters and photovoltaic power in the window respectively comprises: The mean of the meteorological parameter at the time t of the window: the sum of all data within the window divided by the window length W; Meteorological parameters at time t Standard deviation: square root of the sum of the squared differences of each data from the mean, divided by the window length W; The change amplitude of the meteorological parameters: the absolute value of the difference between the current time data and the previous time data; Based on all the change amplitudes in the window, the fluctuation mean value and the fluctuation standard deviation are calculated; The statistical features of the photovoltaic power include the power mean value, the power standard deviation, and the correlation coefficient of the power and the meteorological parameters. 6.The photovoltaic power generation prediction method based on physical constraints and LSTM network according to claim 1, wherein, The step S2 comprises the following steps: Step S21, based on the effective data, the dynamic correlation coefficient of the meteorological features and the photovoltaic power is calculated by using time-varying Spearman rank correlation analysis; Step S22, based on the calculated dynamic correlation coefficient, the features are classified and screened according to the following standards: strong correlation features are retained, i.e. the features with an absolute correlation coefficient greater than 0.5; among them, only one solar radiation feature is retained to avoid collinearity; medium correlation features are verified and retained, i.e. the features with an absolute correlation coefficient between 0.3 and 0.5 are verified and retained after physical rationality verification; and weak correlation features are removed, i.e. the features with an absolute correlation coefficient less than 0.1 are removed; Step S23, the feature set is dynamically updated, the correlation coefficient is recalculated every 15 minutes, and when the absolute value of the change amount of the correlation coefficient is greater than 0.2, the classification and screening process of step 2 is re-executed to update the feature set, and the final key feature set is output. 7.The photovoltaic power generation prediction method based on physical constraints and LSTM network according to any one of claims 1-6, 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 = the sum of the absolute values of (actual power-initial predicted power) in the window ÷ the number of data in the window, mean square error MSE = the sum of the squares of (actual power-initial predicted power) in the window ÷ the number of data in the window; Step S42, compare MAE with the preset threshold value, if MAE>5%, determine that the prediction accuracy is low; if MAE<2%, determine that the prediction accuracy is high; Step S43, adjust the network parameters according to the determination result, when MAE>5%, learning rate×0.9, at the same time, the physical constraint weight×1.2; when MAE<2%, learning rate×1.1, at the same time, the batch size is adjusted to twice the current value; Step S44, the network after adjusting the parameters is predicted again, and the corrected result is output; steps 41 to 44 are repeated every 30 minutes to form a closed loop optimization, so that MAE is finally stabilized within 3.2% and root mean square error is stabilized within 4.5%. 8.A photovoltaic power generation prediction device based on physical constraints and LSTM network, characterized in that, The photovoltaic power prediction device for performing the photovoltaic power prediction method based on physical constraints and LSTM network as claimed in claim 1 comprises: a data processing module for collecting photovoltaic power generation data and meteorological data, filling in missing values, normalizing and time aligning, and then screening out effective data through sliding window statistical feature calculation, dynamic threshold construction and multivariate joint determination; a feature selection module for calculating the dynamic correlation coefficient of meteorological features and photovoltaic power based on effective data using time-varying Spearman rank correlation analysis, retaining strongly correlated features and moderately correlated features verified by physics, and eliminating weakly correlated features to form a key feature set; a prediction model module for constructing an LSTM network that integrates physical constraints by taking the key features as input, wherein the loss function of the network includes a data loss term and a physical constraint loss term based on the relationship between solar radiation and power, and outputs an initial prediction result; an adaptive correction module for calculating real-time errors based on the initial prediction result and the actual power, dynamically adjusting network parameters according to the error size, and outputting the final prediction result after correction, wherein the real-time errors include mean absolute error and mean square error, and the network parameters include 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 prediction method and system considering physical mechanism correction
CN119740747A