A single-phase inverter energy control system and method based on hybrid modulation strategy
By introducing intelligent optimization modules and hybrid modulation modules into single-phase inverters and using neural networks to dynamically adjust pulse width modulation signals, the problem of insufficient performance of traditional single-phase inverters under dynamic grid conditions is solved and the energy conversion efficiency is improved. and power quality, achieving efficient adaptation and precise control of complex power grid environments.
Patent Information
- Application Number
- CN202410711281.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-04
AI Technical Summary
Traditional single-phase inverters are difficult to maintain optimal performance under dynamically changing grid conditions. They have low energy conversion efficiency, limited harmonic suppression and efficiency optimization capabilities, and insufficient ability to monitor and respond to changes in grid status in real time.
A single-phase inverter energy control system based on a hybrid modulation strategy is adopted, using an intelligent optimization module and a hybrid modulation module to dynamically adjust the duty cycle and phase of the pulse width modulation signal through a neural network model, combined with real-time data from the inverter monitoring module , generate a target pulse width modulation signal to optimize the inverter output.
It improves energy conversion efficiency and power quality, enhances the system's adaptability to complex grid environments and energy management control accuracy, and achieves adaptive and intelligent energy management.
Smart Images

Figure CN118282233B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of inverters, and in particular to a single-phase inverter energy control system and method based on a hybrid modulation strategy. Background Art
[0002] Single-phase inverters are an important component in the field of power electronics and are widely used to convert direct current (DC) power to alternating current (AC) power, especially in solar photovoltaic systems, home and small business power supply. Traditional single-phase inverter technology relies on a fixed modulation strategy to control the inverter switch unit to generate the required AC output by adjusting the on and off time of the switching element. These systems usually include basic monitoring modules to observe the output characteristics of the inverter and some grid status data to ensure that the inverter output is basically matched with the grid demand.
[0003] However, existing technologies face multiple problems. First, fixed modulation strategies often have difficulty maintaining optimal performance under dynamically changing grid conditions and load demands, resulting in low energy conversion efficiency, especially when grid voltage fluctuates and loads change rapidly. Second, existing systems have limited capabilities in harmonic suppression and inverter efficiency optimization, which affects power quality and overall system reliability. In addition, traditional inverter systems are also insufficient in their ability to monitor and respond to changes in grid status in real time, limiting their scope of application in complex grid environments.
[0004] Therefore, there is an urgent need to develop a new single-phase inverter energy control system. Summary of the invention
[0005] The present application provides a single-phase inverter energy control system and method based on a hybrid modulation strategy to optimize the output of the inverter.
[0006] The present application provides a single-phase inverter energy control system based on a hybrid modulation strategy, comprising:
[0007] A single-phase inverter comprises a bus capacitor unit and an inverter switch unit, wherein the bus capacitor unit is used to smooth the voltage of a DC power supply and provide a stable DC voltage to the inverter switch unit; the inverter switch unit is used to convert DC power into AC power, thereby realizing power supply to an external power grid;
[0008] The inverter monitoring module is used to monitor the status data of the single-phase inverter and the status data of the external power grid; and provide the monitoring data to the hybrid modulation control module and the intelligent optimization module; wherein the status data of the single-phase inverter includes the output voltage, output current, output power, frequency of the output current, efficiency and temperature of the inverter; and the status data of the external power grid includes the power grid voltage, power grid frequency, power grid load demand and power grid harmonic level;
[0009] An intelligent optimization module, used to generate modulation parameters that meet the requirements based on the monitoring data provided by the inverter monitoring module and using a trained neural network model; output the generated modulation parameters to the hybrid modulation module; wherein the modulation parameters include a duty cycle parameter of a pulse width modulation signal and a phase parameter of a pulse width modulation signal; and the pulse width modulation signal is used to control the switching action of the inverter switch unit;
[0010] The hybrid modulation module is used to generate a target pulse width modulation signal that meets the requirements according to the modulation parameters provided by the intelligent optimization module; and apply the generated target pulse width modulation signal to the inverter switch unit to generate target alternating current.
[0011] Furthermore, the neural network model used in the intelligent optimization module includes a dynamic feature adaptation layer, a modular feature extraction layer, a time series processing layer, and a bidirectional multi-task learning layer;
[0012] The dynamic feature adaptation layer uses an adaptive weighting technology based on an attention mechanism to process the state data of the monitored single-phase inverter and the state data of the external power grid to obtain feature data after weight adjustment;
[0013] The modular feature extraction layer uses a multifunctional convolutional neural network module to process the weighted feature data provided by the dynamic feature adaptation layer to obtain a comprehensive feature representation; wherein the multifunctional convolutional neural network module has multiple parallel convolution channels, and after each convolution channel extracts a special feature, the special features of all convolution channels are merged through a merging layer to obtain a comprehensive feature representation; each convolution channel includes a convolution layer and a pooling layer; the convolution layer of each convolution channel uses a convolution kernel size, number of layers and step size that match the target extraction feature;
[0014] The time series processing layer uses a long short-term memory network and an attention mechanism to process the comprehensive feature representation provided by the modular feature extraction layer to obtain an event dependency feature representation;
[0015] The bidirectional multi-task learning layer uses a multi-output fully connected layer to implement multi-task learning and generate modulation parameters that meet the requirements.
[0016] Furthermore, the adaptive weighting technique of the attention mechanism used in the dynamic feature adaptation layer is implemented by the following steps:
[0017] Receive input monitoring data, including output voltage, output current, output power, output frequency, efficiency, temperature of the single-phase inverter, and voltage, frequency, load demand and harmonic level of the external power grid;
[0018] Through an attention generation network, an attention weight is calculated for each input in the monitoring data;
[0019] The calculated attention weights are used to perform weighted processing on the monitoring data to obtain feature data after adjusting the weights.
[0020] Furthermore, the adaptive weighting technique of the attention mechanism used in the dynamic feature adaptation layer is implemented by the following steps:
[0021] Receive input monitoring data, including output voltage, output current, output power, output frequency, efficiency, temperature of the single-phase inverter, and voltage, frequency, load demand and harmonic level of the external power grid;
[0022] The first input monitoring data is calculated according to the following formula 1: The weight of the feature :
[0023]
[0024] in, and is the adjustment coefficient; is a composite scoring function, calculated using the following formula 2:
[0025]
[0026]
[0027] in, Indicates the energy efficiency ratio of the inverter, which is calculated by the ratio of output power to input power; Indicates the grid demand satisfaction, which is calculated by the matching degree between the inverter output and the grid load demand; It represents time sensitivity and is used to evaluate how quickly a feature responds to time changes; It represents environmental adaptability and is used to evaluate the stability of the performance of characteristics under different environmental conditions; , , and is the weight coefficient; It is The contextual relevance score of a feature is calculated using the following formula 3:
[0028]
[0029] in, Indicates Features Indicates the target state of the system; Representation characteristics Relevance score to system goals; Representation characteristics Rating of impact on system performance;
[0030] Using the calculated attention weights Perform weighted processing on the monitoring data to obtain feature data after adjusting the weights.
[0031] Furthermore, the convolution channels in the multifunctional convolutional neural network module include periodic convolution channels, mutation convolution channels, stability convolution channels, noise convolution channels, efficiency convolution channels and harmonic convolution channels.
[0032] Furthermore, the convolution kernel size of the convolution layer of the periodic convolution channel is 7×7, the number of layers is 3, and the step size is 2, so as to capture patterns in long-period changes; the convolution kernel size of the convolution layer of the mutation convolution channel is 3×3, the number of layers is 2, and the step size is 1, so as to capture the details of sudden changes; the convolution kernel size of the convolution layer of the stability convolution channel is 5×5, the number of layers is 2, and the step size is 2, so as to balance the need to capture details and maintain stability characteristics; the convolution kernel size of the convolution layer of the noise convolution channel is 3×3, the number of layers is 2, and the step size is 1, so as to identify noise and irregular fluctuations; the convolution kernel size of the convolution layer of the efficiency convolution channel is 5×5, the number of layers is 3, and the step size is 2, so as to capture patterns related to inverter efficiency; the convolution kernel size of the convolution layer of the harmonic convolution channel is 5×5, the number of layers is 3, and the step size is 2, so as to identify harmonic characteristics and power quality problems.
[0033] Furthermore, the time series processing layer is specifically used for:
[0034] receiving the comprehensive feature representation from the modular feature extraction layer;
[0035] A long short-term memory network is used to perform sequence analysis on the comprehensive feature representation to generate a time-dependent feature representation;
[0036] An attention mechanism is introduced in the output layer of the LSTM network, which identifies the key time points in the sequence by calculating the importance weight of the feature representation of each time step relative to the final prediction task;
[0037] An event-dependent feature representation is generated by combining the time-dependent feature representation generated by the long short-term memory network and the weighted adjustment of the time-dependent feature representation by the attention mechanism.
[0038] Furthermore, the single-phase inverter also includes a control logic unit, which is used to receive a target pulse width modulation signal sent from the hybrid modulation module; dynamically adjust the switching frequency and duty cycle of the inverter switch unit according to the target pulse width modulation signal to optimize the energy conversion efficiency and power quality during the inversion process.
[0039] Furthermore, the inverter monitoring module uses a high-precision sensor array to capture and record the operating status data of the inverter and the status data of the external power grid in real time.
[0040] The present application provides a single-phase inverter energy control method based on a hybrid modulation strategy, comprising:
[0041] The bus capacitor unit is used to smooth the voltage of the DC power supply to provide a stable DC voltage to the inverter switch unit;
[0042] Convert direct current into alternating current through an inverter switch unit, thereby supplying power to an external power grid;
[0043] Monitor the status data of the single-phase inverter and the external power grid, where the status data of the single-phase inverter includes output voltage, output current, output power, frequency of output current, efficiency and temperature; the status data of the external power grid includes power grid voltage, power grid frequency, power grid load demand and power grid harmonic level;
[0044] According to the monitored state data of the single-phase inverter and the external power grid, the intelligent optimization module uses the trained neural network model to analyze and generate modulation parameters that meet the requirements, wherein the modulation parameters include the duty cycle parameters and phase parameters of the pulse width modulation signal;
[0045] Generate a target pulse width modulation signal that meets the requirements according to the generated modulation parameters;
[0046] The generated target pulse width modulation signal is applied to the inverter switch unit to generate target alternating current.
[0047] The beneficial effects of the present application mainly include: (1) By introducing the intelligent optimization module and the hybrid modulation module, the system can dynamically adjust the modulation parameters, such as the duty cycle and phase of the pulse width modulation (PWM) signal in real time to adapt to the changes in the grid load demand and the fluctuations in the grid voltage, thereby improving the energy conversion efficiency and power quality. (2) Through the integrated inverter monitoring module, the system can monitor the status data of the inverter and the grid in real time, and provide accurate input data for the intelligent optimization module, so that the optimization of the modulation strategy is more accurate and efficient. This not only enhances the adaptability of the system to complex grid environments, but also improves the control accuracy of the energy conversion process under different operating conditions. (3) The use of the trained neural network model to generate modulation parameters brings intelligence and adaptability to the modulation strategy of the inverter. This means that the system can self-learn and adapt to the changing grid conditions to achieve more optimized and efficient energy management. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a schematic diagram of a single-phase inverter energy control system based on a hybrid modulation strategy provided in the first embodiment of the present application.
[0049] Figure 2 This is a flow chart of a single-phase inverter energy control method based on a hybrid modulation strategy provided in the second embodiment of the present application. DETAILED DESCRIPTION
[0050] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0051] The first embodiment of the present application provides a single-phase inverter energy control system based on a hybrid modulation strategy. Figure 1 , which is a schematic diagram of the first embodiment of the present application. Figure 1 A single-phase inverter energy control system based on a hybrid modulation strategy is described in detail in the first embodiment of the present application.
[0052] The single-phase inverter energy control system includes a single-phase inverter 101 , an inverter monitoring module 102 , an intelligent optimization module 103 and a hybrid modulation module 104 .
[0053] The single-phase inverter 101 includes a bus capacitor unit and an inverter switch unit, wherein the bus capacitor unit is used to smooth the voltage of the DC power supply and provide a stable DC voltage to the inverter switch unit; the inverter switch unit is used to convert DC power into AC power, thereby realizing power supply to an external power grid.
[0054] The single-phase inverter 101 is a device for converting direct current (DC) into alternating current (AC), especially for supplying power to an external power grid. The inverter includes two key components: a bus capacitor unit and an inverter switch unit. The main function of the bus capacitor unit is to smooth the voltage from the DC power supply and ensure that a stable DC voltage is provided to the inverter switch unit. This is achieved by introducing one or more capacitors in the circuit, which can store electrical energy and buffer voltage fluctuations, thereby reducing the voltage fluctuations of the power supply.
[0055] The inverter switch unit is the core of the single-phase inverter 101, which is responsible for the actual conversion process from DC to AC. This unit is composed of a series of electronic switches, which can be modern power electronic switching devices such as insulated gate bipolar transistors (IGBTs) and metal oxide semiconductor field effect transistors (MOSFETs). The inverter switch unit generates AC at the output end by quickly turning these electronic switches on and off. The opening and closing of the switch is controlled by a pulse width modulation (PWM) signal, which determines the opening time (conduction) and closing time (off) of the switch, thereby controlling the waveform, frequency and amplitude of the output voltage.
[0056] Furthermore, the single-phase inverter also includes a control logic unit, which is used to receive a target pulse width modulation signal sent from the hybrid modulation module; dynamically adjust the switching frequency and duty cycle of the inverter switch unit according to the target pulse width modulation signal to optimize the energy conversion efficiency and power quality during the inversion process.
[0057] In the single-phase inverter energy control system, the control logic unit is part of the system core, and it plays a key role in converting the prediction results of the intelligent optimization module into actual operations. The design and function of this unit is to ensure that the inverter can dynamically adjust its working state according to the latest optimization parameters, that is, the target pulse width modulation (PWM) signal, so as to achieve the purpose of improving energy conversion efficiency and power quality.
[0058] First, the unit receives the target PWM signal from the hybrid modulation module. This signal is the optimal modulation strategy calculated by an intelligent algorithm based on the current operating status of the system and the external grid demand. It contains all the necessary parameters, such as the duty cycle and switching frequency of the PWM signal, which directly determine the working mode of the inverter switch unit.
[0059] After receiving the target PWM signal, the control logic unit starts to adjust the inverter switch unit. Specifically, it dynamically adjusts the switching frequency and duty cycle according to the parameters of the target PWM signal. The switching frequency determines the opening and closing speed of the switch element, while the duty cycle affects the proportion of time the opening and closing state lasts. These two parameters work together to determine the voltage and frequency of the inverter output.
[0060] In this way, the control logic unit can accurately control the inversion process, adjust the inverter output in real time according to the actual needs of the power grid and the operating status of the inverter, and optimize the energy conversion efficiency and power quality. This can not only reduce energy waste, but also improve the inverter's response speed and accuracy to power grid needs.
[0061] The inverter monitoring module 102 is used to monitor the status data of the single-phase inverter and the status data of the external power grid; and provide the monitoring data to the hybrid modulation control module and the intelligent optimization module; wherein the status data of the single-phase inverter includes the output voltage, output current, output power, frequency of the output current, efficiency and temperature of the inverter; and the status data of the external power grid includes the grid voltage, grid frequency, grid load demand, and grid harmonic level.
[0062] The inverter monitoring module 102 plays a vital role in the single-phase inverter energy control system. It is responsible for collecting and analyzing key operating data from the single-phase inverter 101 and its external power grid environment in real time. These data are essential to ensure that the inverter can operate efficiently and safely, and also ensure the best match between the inverter output and the power grid demand.
[0063] In the single-phase inverter energy control system, it is crucial to accurately measure and monitor the status data of the inverter and the power grid. These status data not only reflect the current working status of the system, but also provide necessary information for intelligent optimization. The following will describe the measurement methods of these status data in detail.
[0064] First, the output voltage and output current of the inverter are measured by voltage and current sensors installed at the output of the inverter. These sensors provide real-time voltage and current readings, allowing the system to monitor the instant output performance of the inverter. The output power is obtained by calculating the product of the output voltage and current and considering the power factor, which directly reflects the efficiency of the inverter in converting DC to AC.
[0065] The frequency measurement of the output current is usually achieved by analyzing the periodic changes of the current signal. This is very important to ensure that the inverter output is synchronized with the grid frequency. The efficiency calculation is based on the ratio of input power to output power, which requires measuring the DC input and AC output power of the inverter at the same time.
[0066] Temperature measurement of the inverter is usually done using temperature sensors such as thermistors or thermocouples. These sensors are placed on key components inside the inverter, such as around the inverter switch unit, to monitor the thermal conditions of the inverter during operation.
[0067] As for the status data of the external power grid, the measurement of grid voltage and grid frequency also relies on high-precision voltage and frequency sensors. These sensors are connected to the grid power supply point and can provide accurate readings of grid voltage and frequency in real time.
[0068] The measurement of grid load demand involves monitoring the total load flow on the grid, which is usually achieved through data provided by the grid operator or current sensors installed at key access points. The harmonic level of the grid is determined by performing spectral analysis of the grid voltage or current signal, which can reveal the harmonic content and its intensity in the grid.
[0069] In short, by adopting a series of high-precision sensors and advanced data processing technology, the single-phase inverter energy control system can accurately measure and monitor the key status data of the inverter and the power grid. These data not only provide a reliable basis for real-time monitoring of the system, but also provide the intelligent optimization module with detailed information required for decision-making, ensuring the efficiency and stability of system operation.
[0070] The inverter monitoring module 102 achieves the above functions by using a high-precision sensor array and advanced data acquisition technology. These sensors can continuously monitor the operating status of the inverter during the entire operation process, including its performance under different load and grid conditions. The monitored data is then sent to an integrated data processing unit, where the data is analyzed and processed to provide real-time information about the current operating status of the inverter.
[0071] In addition, the inverter monitoring module 102 is also designed with a communication interface so that the collected data can be transmitted to other modules in the system, such as the hybrid modulation control module and the intelligent optimization module. This is particularly important because these modules rely on the received real-time data to dynamically adjust the modulation strategy to optimize the performance of the inverter and ensure that its output meets the needs of the power grid. In particular, the intelligent optimization module 103 will use this data to generate modulation parameters that adjust the duty cycle and phase of the PWM signal, and further guide the hybrid modulation module 104 to generate a target pulse width modulation signal that meets the requirements of the power grid.
[0072] In summary, the inverter monitoring module 102 not only provides the necessary real-time data support for the single-phase inverter energy control system, but also ensures that the inverter can achieve efficient, stable and safe operation under various operating conditions through close cooperation with other modules in the system.
[0073] The intelligent optimization module 103 is used to generate modulation parameters that meet the requirements based on the monitoring data provided by the inverter monitoring module and using a trained neural network model; the generated modulation parameters are output to the hybrid modulation module; wherein the modulation parameters include a duty cycle parameter of a pulse width modulation signal and a phase parameter of a pulse width modulation signal; and the pulse width modulation signal is used to control the switching action of the inverter switch unit.
[0074] The intelligent optimization module 103 is the core component of the single-phase inverter energy control system. It undertakes the important task of analyzing the data provided by the inverter monitoring module 102 and generating adaptive modulation parameters accordingly. The module uses advanced neural network models to process the received data, which includes the output voltage, current, power, frequency, efficiency and temperature of the inverter, as well as the voltage, frequency, load demand and harmonic level of the external power grid. This processing capability enables the intelligent optimization module 103 to deeply understand the performance of the inverter under specific working conditions and predict how to optimize its performance by adjusting the duty cycle parameters and phase parameters of the pulse width modulation (PWM) signal.
[0075] The design of the intelligent optimization module 103 takes into account the need to process a large amount of real-time data and extract useful information from it to generate modulation parameters. Therefore, the module integrates trained neural network models, which are trained with a large amount of historical data and can identify the optimal modulation strategy under various operating conditions. By inputting real-time monitoring data, the neural network can quickly calculate the optimal PWM signal settings, such as adjusting the duty cycle to change the average value of the output voltage, or adjusting the phase of the signal to improve synchronization with the power grid.
[0076] During implementation, the intelligent optimization module 103 will dynamically generate modulation parameters based on the real-time monitored system status and grid demand, and these parameters are then output to the hybrid modulation module 104. The hybrid modulation module adjusts the PWM signal according to these parameters, accurately controls the operation of the inverter switch unit, and achieves efficient and stable energy conversion. This design of the intelligent optimization module not only improves the overall performance and adaptability of the system, but also provides a new path for the advancement of inverter technology.
[0077] Furthermore, the neural network model used in the intelligent optimization module includes a dynamic feature adaptation layer, a modular feature extraction layer, a time series processing layer, and a bidirectional multi-task learning layer;
[0078] The dynamic feature adaptation layer uses an adaptive weighting technology based on an attention mechanism to process the state data of the monitored single-phase inverter and the state data of the external power grid to obtain feature data after weight adjustment;
[0079] The modular feature extraction layer uses a multifunctional convolutional neural network module to process the weighted feature data provided by the dynamic feature adaptation layer to obtain a comprehensive feature representation; wherein the multifunctional convolutional neural network module has multiple parallel convolution channels, and after each convolution channel extracts a special feature, the special features of all convolution channels are merged through a merging layer to obtain a comprehensive feature representation; each convolution channel includes a convolution layer and a pooling layer; the convolution layer of each convolution channel uses a convolution kernel size, number of layers and step size that match the target extraction feature;
[0080] The time series processing layer uses a long short-term memory network and an attention mechanism to process the comprehensive feature representation provided by the modular feature extraction layer to obtain an event dependency feature representation;
[0081] The bidirectional multi-task learning layer uses a multi-output fully connected layer to implement multi-task learning and generate modulation parameters that meet the requirements.
[0082] The adaptive weighting technique of the attention mechanism used in the dynamic feature adaptation layer is implemented by the following steps:
[0083] Receive input monitoring data, including output voltage, output current, output power, output frequency, efficiency, temperature of the single-phase inverter, and voltage, frequency, load demand and harmonic level of the external power grid;
[0084] Through an attention generation network, an attention weight is calculated for each input in the monitoring data;
[0085] The calculated attention weights are used to perform weighted processing on the monitoring data to obtain feature data after adjusting the weights.
[0086] In the single-phase inverter energy control system, the dynamic feature adaptation layer plays a vital role. It is the first link in the intelligent optimization module and is responsible for processing and optimizing the state data collected from the single-phase inverter and the external power grid. The core of this layer is to use an adaptive weighting technology based on the attention mechanism, which can intelligently identify and weight the data features that are most critical to the inverter performance and the grid demand response.
[0087] First, the dynamic feature adaptation layer receives various status data from the inverter and the power grid, which covers key performance indicators such as the inverter's output voltage, output current, output power, and output frequency, as well as important status information such as the power grid's voltage, frequency, load demand, and harmonic level. The received data first goes through a preprocessing stage, which may include data cleaning, denoising, and standardization to ensure the quality and consistency of the data for subsequent processing.
[0088] Next, the adaptive weighting technology based on the attention mechanism comes into play. The core of this technology is to assign an "attention weight" to each data feature, which reflects the importance of the feature in the current system state. The weight is calculated based on the contribution of the data feature to the inverter performance and meeting the grid needs, as well as its sensitivity to changes under different operating conditions. In this way, the system can dynamically adjust the attention paid to different data features and prioritize those more critical information.
[0089] The specific method of calculating attention weights involves multiple steps, including scoring each feature, processing the score with a function to enhance discrimination, and finally normalizing to ensure that all weights add up to 1. This process takes into account not only the independent impact of the features, but also the interactions between features and the overall system goals.
[0090] After obtaining the weighted feature data, the dynamic feature adaptation layer will pass this data to the next stage of the system - the modular feature extraction layer. In this layer, the data will be further analyzed and processed to extract more in-depth and comprehensive information to support the final optimization decision.
[0091] Through the dynamic feature adaptation layer, the single-phase inverter energy control system can respond to environmental changes more intelligently and flexibly, improving energy efficiency and the ability to meet grid demands.
[0092] Below is a sample code showing how to implement the attention mechanism adaptive weighting technique in the dynamic feature adaptation layer.
[0093] import numpy as np
[0094] import torch
[0095] import torch.nn.functional as F
[0096] from torch import nn
[0097] class AttentionMechanism(nn.Module):
[0098] """Dynamic feature adaptation layer based on attention mechanism"""
[0099] def __init__(self, feature_dim):
[0100] """
[0101] Initialization function
[0102] :param feature_dim: feature dimension
[0103] """
[0104] super(AttentionMechanism, self).__init__()
[0105] # Define the attention generation network, here we simply use a fully connected layer
[0106] self.attention_net = nn.Linear(feature_dim, 1)
[0107] def forward(self, features):
[0108] """
[0109] Forward Propagation
[0110] :param features: feature data, dimension is (batch_size, feature_dim)
[0111] :return: Feature data after adjusting weights
[0112] """
[0113] # Calculate attention weights
[0114] attention_weights = self.attention_net(features) # Dimension: (batch_size, 1)
[0115] attention_weights = torch.softmax(attention_weights, dim=0)# Normalize the weights using softmax
[0116] # Use attention weights to weight features
[0117] weighted_features = features * attention_weights
[0118] return weighted_features
[0119] # Assume there is a batch of monitoring data with a dimension of (batch_size, feature_dim)
[0120] # Among them, feature_dim may include key performance indicators such as output voltage and output current of the inverter
[0121] batch_features = torch.rand(10, 6) # Sample data
[0122] # Initialize dynamic feature adaptation layer
[0123] attention_layer = AttentionMechanism(feature_dim=6)
[0124] # Process monitoring data through the dynamic feature adaptation layer
[0125] weighted_features = attention_layer(batch_features)
[0126] # Print weighted feature data for subsequent modular feature extraction layers
[0127] print(weighted_features)
[0128] Code Explanation:
[0129] First, a class named `AttentionMechanism` is defined. This class inherits from `nn.Module` and is used to implement the attention mechanism.
[0130] In the initialization function, an attention generation network is defined, which is simplified to a fully connected layer `self.attention_net`.
[0131] In the forward propagation function `forward`, the attention weight of each feature is first calculated through the attention generation network. Then, these weights are used to weight the input feature data to obtain the feature data after weight adjustment.
[0132] Finally, a sample monitoring data `batch_features` is created and processed through the defined dynamic feature adaptation layer. The result `weighted_features` can be used as input for subsequent processing pipelines.
[0133] `torch.rand(10, 6)` in the code generates random data to simulate the actual monitoring data received. In practical applications, feature data should come from real-time monitoring data of inverters and power grids. `torch.softmax` is used to normalize the attention weights to ensure that the sum of the weights of all features is 1, which helps to highlight the more important features.
[0134] Furthermore, the adaptive weighting technique of the attention mechanism used in the dynamic feature adaptation layer is implemented by the following steps:
[0135] Receive input monitoring data, including output voltage, output current, output power, output frequency, efficiency, temperature of the single-phase inverter, and voltage, frequency, load demand and harmonic level of the external power grid;
[0136] The first input monitoring data is calculated according to the following formula 1: The weight of the feature :
[0137]
[0138] in, and is the adjustment coefficient; It is The contextual relevance score of each feature;
[0139] The denominator in Formula 1 is a key part of the attention weight calculation, ensuring that the weights of all features add up to 1. This is done to normalize the features so that the calculated attention weights reflect the importance of each feature relative to all other features.
[0140] Composite scoring function in the denominator :This item represents each feature A composite score based on the energy efficiency ratio of the feature , grid demand satisfaction , time sensitivity and environmental adaptability Calculated by formula 2.
[0141] Contextual relevance scoring :This item represents the feature The contextual relevance score of , that is, the importance of the feature in the current context relative to the system goal.
[0142] The main function of the denominator is to perform normalization to ensure that all calculated attention weights The sum of is 1. This allows for a relative comparison of the importance of each feature, regardless of the total number of features or the absolute value of the score of a single feature. The attention weight of a reflects its relative importance among all features, which is crucial for subsequent weighted processing and decision making.
[0143] is a composite scoring function, calculated using the following formula 2:
[0144]
[0145]
[0146] in, Indicates the energy efficiency ratio of the inverter, which is calculated by the ratio of output power to input power; Indicates the grid demand satisfaction, which is calculated by the matching degree between the inverter output and the grid load demand; It represents time sensitivity and is used to evaluate how quickly a feature responds to time changes; It represents environmental adaptability and is used to evaluate the stability of the performance of characteristics under different environmental conditions; , , and is the weight coefficient, which can be directly set through expert experience;
[0147] Using the calculated attention weights Perform weighted processing on the monitoring data to obtain feature data after adjusting the weights.
[0148] In the single-phase inverter energy control system, the dynamic feature adaptation layer is a key link, responsible for converting the monitoring data collected from the inverter and the external power grid into a form that is more useful for system optimization. This layer uses an adaptive weighting technology based on the attention mechanism, which can intelligently evaluate and weight the importance of each monitoring data feature, thereby providing more accurate information for subsequent data processing and decision-making.
[0149] First, this layer receives a series of monitoring data, including the output voltage, output current, output power, output frequency, efficiency and temperature of the single-phase inverter, as well as the voltage, frequency, load demand and harmonic level of the external grid. These data are obtained from the actual inverter operation and grid status monitoring, reflecting the current operating status.
[0150] Next, for each monitoring data feature, a weight is calculated , this weight represents the relative importance of the feature in the current context. The calculation of the weight depends on two main parts: one is the composite scoring function , and the second is the contextual relevance score of the feature . Adjustment coefficient and The adjustment coefficients are used to balance the impact of these two parts, and these adjustment coefficients can be directly set through expert knowledge.
[0151] Contextual relevance score of features A measure that assesses the importance of a feature relative to the system objectives in a given operating context. This score is calculated based on the relevance of the feature to the current system operating state and objectives, as well as the potential impact of the feature on system performance. The purpose of the contextual relevance score is to identify and highlight those features that are most critical to inverter performance and grid demand satisfaction under specific operating conditions.
[0152] Contextual relevance scoring The calculation can be achieved by following the steps below:
[0153] 1. Correlation analysis between features and target states: First, analyze the correlation between each feature and the system target. This can be achieved through statistical methods, such as the Pearson correlation coefficient or the Spearman rank correlation coefficient. Features with higher correlations indicate that they are more closely related to the system target and may therefore be given a higher score.
[0154] 2. Evaluation of the impact of features on system performance: Evaluate the potential impact of each feature on system performance (such as energy efficiency, stability, load matching, etc.). This evaluation can be based on historical data analysis and determine the impact of feature changes on system performance indicators by observing the impact of feature changes on system performance indicators.
[0155] 3. Comprehensive score calculation: Combine the analysis results of the above two aspects to comprehensively calculate the context relevance score of each feature This can be achieved through a weighted average approach, where the weights reflect the relative importance of the relevance analysis and impact assessment.
[0156] Contextual relevance scoring The calculation formula can be expressed as:
[0157]
[0158] in:
[0159] - Indicates Features.
[0160] - Indicates the system target state.
[0161] - Representation characteristics Relevance score to the system goal.
[0162] - Representation characteristics A rating of the impact on system performance.
[0163] - and It is the weight coefficient of the two scoring items, which is set according to the actual application requirements.
[0164] To elaborate on the contextual relevance score The calculation formula and its components are broken down and explained in detail below, and each component and how to calculate each item are explained one by one.
[0165] Contextual relevance scoring The composition includes:
[0166] feature , represents the first A characteristic, such as the output current of a single-phase inverter or the load demand of the power grid. The determination method is to collect data in real time through sensors or system monitoring equipment, which may need to be pre-processed (such as filtering, denoising, etc.) to ensure the quality of the data.
[0167] System target status , which indicates the target state that the system is trying to achieve, such as improving energy efficiency ratio, ensuring grid load matching, etc. Its determination method is based on the preset goals of system design and operation requirements, which may involve a comprehensive evaluation of multiple indicators.
[0168] Relevance score Evaluation characteristics System goals The higher the value, the more relevant the feature is to the target state. The calculation method uses statistical methods, such as the Pearson correlation coefficient, to quantify the characteristics and goals The Pearson correlation coefficient ranges from -1 to 1, where 1 indicates a perfect positive correlation, -1 indicates a perfect negative correlation, and 0 indicates no correlation.
[0169] like For specific numerical indicators (such as energy efficiency ratio target value), it can be directly calculated and The correlation coefficient of For a more abstract state (such as stability), Convert to quantifiable indicators or use expert evaluation methods to determine and relationship.
[0170] Impact score To evaluate the characteristics The influence on system performance. The higher the value, the greater the impact of the feature on system performance.
[0171] Impact score The calculation method is as follows:
[0172] Analyze historical data and observe characteristics How changes in affect system performance indicators. For example, regression analysis is used to evaluate The impact of changes on energy efficiency ratio or grid load matching.
[0173] Influence can be a quantitative indicator based on statistical analysis or a qualitative assessment based on expert experience.
[0174] and They are the weight coefficients of the relevance score and the influence score, respectively, reflecting the relative importance of these two scoring items in the total score. They can be set according to specific application scenarios and system optimization goals, and the optimal weight can be determined through historical data analysis, or through experimental adjustments to optimize system performance.
[0175] The calculation example is as follows:
[0176] Suppose there is a feature , represents the output power of the inverter. System goal Is to improve energy efficiency.
[0177] 1. Calculation : By analyzing past data, it is found that the output power of the inverter has a high positive correlation with the energy efficiency ratio of the system, and the Pearson correlation coefficient is calculated to be 0.8.
[0178] 2. Calculation : Further analysis shows that the increase in output power is often accompanied by an increase in energy efficiency ratio. Through regression analysis, it is determined that the impact of output power on energy efficiency ratio is scored as 0.9.
[0179] 3. Determine the weight coefficient: Assuming that based on the system design requirements, given = 0.6 and = 0.4.
[0180] 4. Based on the above information and formula, we can calculate Contextual relevance score as follows:
[0181]
[0182] This rating = 0.84 indicates that the output power of the inverter has a high relevance and influence on achieving the system goal in the current context, and therefore may be given a higher attention weight in the dynamic feature adaptation process.
[0183] Composite scoring function By increasing the inverter's energy efficiency , grid demand satisfaction , time sensitivity and environmental adaptability With their respective weight coefficients , , and The importance of features is comprehensively evaluated by combining and applying nonlinear functions such as tangent function, hyperbolic sine function, and linear or logarithmic processing.
[0184] Energy efficiency ratio : Calculated as the ratio of the inverter output power to the input power. This is a direct ratio calculation that reflects the inverter's energy efficiency level.
[0185] Energy efficiency ratio It is calculated by the ratio of the inverter output power to the input power, and the formula is:
[0186]
[0187] in, Represents the output power of the inverter in watts (W); Represents the input power of the inverter, also in watts (W).
[0188] Grid demand satisfaction : Obtained by evaluating how well the inverter output matches the grid load demand. This involves evaluating the difference between the output power and the load demand.
[0189] Grid demand satisfaction It can be calculated by the following formula:
[0190]
[0191] in, is the output power of the inverter, is the current load demand of the grid.
[0192] Time Sensitivity and environmental adaptability :These two indicators evaluate the performance of features over time and under different environmental conditions. The specific calculation method may involve historical data analysis and comparison of the performance of features under different environmental conditions.
[0193] Finally, according to the calculated attention weight , all monitoring data will be weighted accordingly to generate feature data with adjusted weights, which will more effectively reflect the key information of the current system operation status.
[0194] Time Sensitivity It can be evaluated by analyzing the speed or volatility of the feature value over time. For example, time sensitivity can be quantified by calculating the standard deviation or rate of change of the feature value within a certain time window.
[0195] Suppose that at five consecutive time points, the readings of a feature value are 10, 12, 14, 13, and 15. By calculating the rate of change or standard deviation of these values, we can get the time sensitivity score of the feature in this time window.
[0196] Environmental adaptability This can be assessed by comparing how the feature value changes under different environmental conditions. This may involve comparing the performance of the same feature under different temperatures, humidity or other environmental parameters.
[0197] For example, if a feature performs significantly differently at 20°C and 30°C, an environmental adaptability score can be obtained by collecting data and calculating the average difference in the feature values under these environmental conditions.
[0198] In the single-phase inverter energy control system, the modular feature extraction layer is a key component of the intelligent optimization module, responsible for in-depth analysis and extraction of complex patterns in the feature data after the dynamic feature adaptation layer adjusts the weights. Through the multifunctional convolutional neural network module, this layer can effectively identify and extract various features, thereby obtaining a comprehensive feature representation containing rich information, providing high-quality input for subsequent time series processing and multi-task learning.
[0199] The multifunctional convolutional neural network module used in the modular feature extraction layer includes multiple parallel convolution channels, each of which is designed for a specific type of feature, such as periodic changes, sudden events, stability, noise characteristics, efficiency, and harmonics. These convolution channels are constructed through independent convolutional layers and pooling layers, where the convolutional layers are used to extract the spatial pattern of the features, while the pooling layers are used to reduce the feature dimension and enhance the robustness of the features.
[0200] The design of each convolution channel is based on the understanding of the target features, and the appropriate convolution kernel size, number of layers, and step size are selected to maximize the efficiency and effect of feature extraction. For example, the periodic feature module may use a larger convolution kernel to capture the pattern of long-term changes, while the mutation feature module may use a smaller convolution kernel to identify subtle changes.
[0201] After extracting specific types of features, the outputs of all convolutional channels are fed into a merging layer, which fuses the specialized features extracted by different channels to generate a comprehensive feature representation. This comprehensive representation not only contains comprehensive information about the inverter and grid status, but also has been intelligently weighted to highlight those features that are more important in the current context.
[0202] Furthermore, the convolution channels in the multifunctional convolutional neural network module include periodic convolution channels, mutation convolution channels, stability convolution channels, noise convolution channels, efficiency convolution channels and harmonic convolution channels.
[0203] Furthermore, the convolution kernel size of the convolution layer of the periodic convolution channel is 7×7, the number of layers is 3, and the step size is 2, so as to capture patterns in long-period changes; the convolution kernel size of the convolution layer of the mutation convolution channel is 3×3, the number of layers is 2, and the step size is 1, so as to capture the details of sudden changes; the convolution kernel size of the convolution layer of the stability convolution channel is 5×5, the number of layers is 2, and the step size is 2, so as to balance the need to capture details and maintain stability characteristics; the convolution kernel size of the convolution layer of the noise convolution channel is 3×3, the number of layers is 2, and the step size is 1, so as to identify noise and irregular fluctuations; the convolution kernel size of the convolution layer of the efficiency convolution channel is 5×5, the number of layers is 3, and the step size is 2, so as to capture patterns related to inverter efficiency; the convolution kernel size of the convolution layer of the harmonic convolution channel is 5×5, the number of layers is 3, and the step size is 2, so as to identify harmonic characteristics and power quality problems.
[0204] In the intelligent optimization module of the single-phase inverter energy control system, the multifunctional convolutional neural network module plays a vital role. It processes the weighted feature data received from the dynamic feature adaptation layer through a series of specially designed convolution channels to extract deep information about the inverter and grid status. This layer is designed to capture and analyze multi-dimensional features from the inverter and grid, including periodic changes, emergencies, stability indicators, noise levels, energy efficiency performance, and harmonic characteristics.
[0205] Convolutional channels are carefully designed to optimize for specific types of data features.
[0206] The periodic convolution channel is designed to capture the long-term variation patterns in the inverter output and grid demand. A 7×7 convolution kernel, a 3-layer convolution layer structure, and a stride of 2 are used. Larger convolution kernels can cover a wider input area, thereby capturing periodic variation patterns.
[0207] The mutation convolution channel is used to identify and capture rapid changes or anomalies caused by sudden events. A 3×3 convolution kernel, a 2-layer convolution layer structure, and a stride of 1 are used. Smaller convolution kernels and compact layer design help identify subtle mutation features.
[0208] The stability convolution channel is used to balance the need for capturing details and stability features, and evaluate the long-term stability of the inverter operation. A 5×5 convolution kernel, a 2-layer convolution layer structure, and a step size of 2 are used. This design helps to balance the capture of details and the emphasis on stability features.
[0209] The noise convolution channel is used to identify noise and irregular fluctuations in the data and improve the model's sensitivity to real signals. It uses a 3×3 convolution kernel, a 2-layer convolution layer structure, and a step size of 1. The compact design helps to identify and filter noise.
[0210] The efficiency convolution channel is used to capture patterns related to inverter efficiency and evaluate energy efficiency performance. It uses a 5×5 convolution kernel, a 3-layer convolution layer structure, and a step size of 2. The moderate convolution kernel size and number of layers help to deeply analyze the factors that affect energy efficiency.
[0211] The harmonic convolution channel is used to identify harmonic features in power grid data and evaluate power quality issues. A 5×5 convolution kernel, a 3-layer convolution layer structure, and a step size of 2 are used. This design helps to deeply detect complex patterns related to power quality.
[0212] When designing the sample code for the modular feature extraction layer, an object-oriented approach is adopted to facilitate implementation according to the design ideas. The following sample code shows how to build a multi-functional convolutional neural network module with multiple specialized convolution channels.
[0213] import torch
[0214] import torch.nn as nn
[0215] import torch.nn.functional as F
[0216] # Define the basic convolution channel class
[0217] class ConvChannel(nn.Module):
[0218] def __init__(self, in_channels, out_channels, kernel_size, num_layers, stride):
[0219] super(ConvChannel, self).__init__()
[0220] self.layers = nn.ModuleList()
[0221] for i in range(num_layers):
[0222] conv_layer = nn.Conv2d(in_channels if i == 0 else out_channels, out_channels, kernel_size, stride=stride)
[0223] self.layers.append(conv_layer)
[0224] def forward(self, x):
[0225] for layer in self.layers:
[0226] x = F.relu(layer(x))
[0227] return F.max_pool2d(x, 2)
[0228] # Define modular feature extraction layer
[0229] class ModularFeatureExtractor(nn.Module):
[0230] def __init__(self, in_channels):
[0231] super(ModularFeatureExtractor, self).__init__()
[0232] # Define different convolution channels
[0233] # Periodic convolution channel
[0234] self.periodic_channel = ConvChannel(in_channels, 16, (7, 7),3, 2)
[0235] # Mutate convolution channels
[0236] self.sudden_channel = ConvChannel(in_channels, 16, (3, 3), 2,1)
[0237] # Stable convolution channel
[0238] self.stability_channel = ConvChannel(in_channels, 16, (5, 5),2, 2)
[0239] # Noise convolution channel
[0240] self.noise_channel = ConvChannel(in_channels, 16, (3, 3), 2,1)
[0241] # Efficient convolution channels
[0242] self.efficiency_channel = ConvChannel(in_channels, 16, (5,5), 3, 2)
[0243] # Harmonic convolution channels
[0244] self.harmonic_channel = ConvChannel(in_channels, 16, (5, 5),3, 2)
[0245] def forward(self, x):
[0246] # Extract features of each channel
[0247] periodic_features = self.periodic_channel(x)
[0248] sudden_features = self.sudden_channel(x)
[0249] stability_features = self.stability_channel(x)
[0250] noise_features = self.noise_channel(x)
[0251] efficiency_features = self.efficiency_channel(x)
[0252] harmonic_features = self.harmonic_channel(x)
[0253] # Merge features
[0254] combined_features = torch.cat((periodic_features, sudden_features, stability_features, noise_features, efficiency_features, harmonic_features), dim=1)
[0255] # You can add a fully connected layer or other processing layers here to further process the merged features
[0256] return combined_features
[0257] # Example: Initialize the model and provide input
[0258] # Assume the input data dimension is: [batch_size, in_channels, height, width]
[0259] model = ModularFeatureExtractor(in_channels=3)
[0260] # This is just for example, the actual input should be set according to the actual situation
[0261] input_tensor = torch.randn((1, 3, 224, 224))
[0262] output_features = model(input_tensor)
[0263] print(output_features.shape) # Output feature dimensions
[0264] The code description is as follows:
[0265] -Base convolution channel class `ConvChannel`: used to create a single convolution channel, including consecutive convolution layers and activation functions.
[0266] - Modular feature extraction layer `ModularFeatureExtractor`**: integrates multiple `ConvChannel` instances, each of which focuses on a specific type of feature extraction. This layer finally merges the outputs of all channels into a comprehensive feature representation.
[0267] -Parallel processing and feature merging: In the modular feature extraction layer, different types of data features are processed in parallel and merged into a comprehensive feature representation through the `torch.cat` method for subsequent processing.
[0268] This sample code provides a reference implementation to help those skilled in the art understand how to implement a modular feature extraction layer in a single-phase inverter energy control system.
[0269] In the single-phase inverter energy control system, the time series processing layer plays a vital role. It is responsible for analyzing and processing the comprehensive feature representation provided by the modular feature extraction layer to capture the time dependency and dynamic changes in the data. By adopting the long short-term memory network (LSTM) and attention mechanism, this layer is able to identify and emphasize important time points and events, providing key time dimension information for the final decision making.
[0270] LSTM is a special recurrent neural network (RNN) designed to solve the gradient vanishing or gradient exploding problems encountered by traditional RNNs when processing long sequence data. It controls the inflow, retention, and outflow of information by introducing three gate structures - input gate, forget gate, and output gate - so that the network can effectively retain and utilize key information in long time series. In the time series processing layer, the LSTM network analyzes the sequence data in the comprehensive feature representation and identifies the temporal patterns and dependencies related to inverter performance and grid demand.
[0271] The attention mechanism is a technique that enables the model to automatically focus on the important parts of the input data. In the time series processing layer, it is used in conjunction with the LSTM network to emphasize the moments that are more critical to the final prediction by calculating the importance weight of each time point in the sequence. In this way, the model can not only capture the dynamic characteristics of the time series, but also adaptively adjust the focus on different time points according to the specific needs of the current task.
[0272] The time series processing layer is responsible for analyzing and processing the comprehensive feature representation, aiming to extract time-related patterns and dependencies from these features. The core of this layer is to use a combination of long short-term memory network (LSTM) and attention mechanism to accurately capture and emphasize the most critical information in the sequence data for the prediction task.
[0273] The implementation steps are as follows:
[0274] First, the time series processing layer receives comprehensive feature representations containing rich inverter and grid status information from the modular feature extraction layer. These feature representations have been processed by the previous layers and contain deep information extracted from the original monitoring data.
[0275] Subsequently, the LSTM network is used to perform sequence analysis on these comprehensive feature representations. The characteristic of LSTM is that it can process long sequence data and remember the long-term dependencies in the sequence, which makes it particularly suitable for analyzing time series data. Through LSTM processing, a feature representation containing time dependencies can be generated from the comprehensive feature representation.
[0276] Based on the LSTM network, the attention mechanism is introduced to further enhance the model's ability to identify key time points in the sequence. The attention mechanism assigns a weight to each time step in the sequence, which reflects the importance of each time point relative to the final prediction task. This process enables the model to automatically focus on the time points that have the greatest impact on the prediction results.
[0277] Finally, the time-dependent feature representation generated by LSTM is combined with the weighted features adjusted by the attention mechanism to generate the final event-dependent feature representation. This representation not only contains the dynamic characteristics of the time series, but also emphasizes the most critical information for the current task, providing high-quality input for the subsequent multi-task learning layer.
[0278] Provided below is the reference code for the time series processing layer, which aims to show how to combine LSTM and attention mechanism to process comprehensive feature representation.
[0279] import torch
[0280] import torch.nn as nn
[0281] import torch.nn.functional as F
[0282] class TimeSeriesProcessingLayer(nn.Module):
[0283] def __init__(self, input_size, hidden_size, output_size):
[0284] super(TimeSeriesProcessingLayer, self).__init__()
[0285] # Initialize LSTM module
[0286] self.lstm = nn.LSTM(input_size, hidden_size, batch_first=True)
[0287] # Parameters of the attention mechanism
[0288] self.attention_weights = nn.Parameter(torch.randn(hidden_size, 1))
[0289] # Linear layer is used to generate the final event dependency feature representation
[0290] self.linear = nn.Linear(hidden_size, output_size)
[0291] def forward(self, x):
[0292] # x is the comprehensive feature representation received from the modular feature extraction layer
[0293] lstm_out, _ = self.lstm(x)
[0294] # Calculate attention score
[0295] attention_scores = torch.matmul(lstm_out, self.attention_weights)
[0296] attention_scores = F.softmax(attention_scores, dim=1)
[0297] # Apply attention weights
[0298] weighted_lstm_out = lstm_out * attention_scores
[0299] # Pass the weighted LSTM output through the linear layer to generate the final event dependency feature representation
[0300] final_representation = self.linear(weighted_lstm_out)
[0301] return final_representation
[0302] # Assumed parameters
[0303] input_size = 100 # Dimension of comprehensive feature representation
[0304] hidden_size = 50 # LSTM hidden layer size
[0305] output_size = 10 # The dimension of the final feature representation
[0306] # Example
[0307] model = TimeSeriesProcessingLayer(input_size, hidden_size, output_size)
[0308] # Assume x is a comprehensive feature representation, dimension [batch_size, seq_length, input_size]
[0309] x = torch.randn(32, 10, input_size)
[0310] final_representation = model(x)
[0311] # Here final_representation is the final event dependency feature representation, which can be used for subsequent processing
[0312] Code Explanation:
[0313] - This example defines the `TimeSeriesProcessingLayer` class, which is an implementation of the time series processing layer based on the PyTorch framework.
[0314] - Use LSTM network to process comprehensive feature representation of input and capture temporal dependencies in the sequence.
[0315] - By introducing an attention mechanism (defined as `attention_weights`), the importance weights of each time step are calculated and applied to the output of the LSTM to emphasize important time points.
[0316] - Finally, the weighted LSTM output is transformed into the final event dependency feature representation through a linear layer.
[0317] This code shows how to combine LSTM and attention mechanism in the time series processing layer to process comprehensive feature representation.
[0318] The bidirectional multi-task learning layer is responsible for converting the complex data processed by the previous layers into specific modulation parameters. The key point of this layer is that it can not only handle multiple tasks and learn at the same time, but also enhance mutual learning and information sharing between tasks through the bidirectional information flow mechanism.
[0319] The implementation of the bidirectional multi-task learning layer is based on a multi-output fully connected network structure, which allows the system to optimize for different output tasks (such as different aspects of the modulation strategy). Each task has its own independent output node, but internally, these tasks are related to each other through hidden layers in the shared network, so that they can learn useful information about other tasks.
[0320] First, the bidirectional multi-task learning layer receives event-dependent feature representations from the time series processing layer. These features have incorporated the dynamic changes of time series data and the attention weights on key time points, providing rich contextual information for multi-task learning.
[0321] Then, a fully connected network is used to process the input features. The design of the network allows it to generate an output for each specific task, such as different parameters in the modulation strategy of the inverter. This means that the network needs to have enough output nodes corresponding to all the modulation parameters that need to be predicted.
[0322] In traditional multi-task learning, information sharing between different tasks is usually unidirectional. However, in the bidirectional multi-task learning layer, information sharing between different tasks is enhanced by implementing a bidirectional information flow mechanism in the network. This means that the output of a task can not only affect its own learning process, but also feed back into the network to affect the learning process of other tasks.
[0323] Finally, the bidirectional multi-task learning layer generates a series of modulation parameters based on the learning results of each task. These parameters will be directly used to adjust the working state of the single-phase inverter to achieve optimization of energy output and improvement of grid quality.
[0324] Through the design and implementation of a bidirectional multi-task learning layer, it is possible to respond to various operating conditions more intelligently and flexibly, achieve detailed adjustments to the inverter modulation strategy, and ultimately improve the overall performance and efficiency of the system.
[0325] Below is a sample code of a bidirectional multi-task learning layer, showing how to implement bidirectional information flow and multi-task learning in a neural network model.
[0326] import torch
[0327] import torch.nn as nn
[0328] import torch.nn.functional as F
[0329] # Assume there are two tasks: prediction of modulation strategy parameters A and B
[0330] class BiDirectionalMultiTaskLearningLayer(nn.Module):
[0331] def __init__(self):
[0332] super(BiDirectionalMultiTaskLearningLayer, self).__init__()
[0333] # Shared Layers
[0334] self.shared_layer = nn.Linear(in_features=100, out_features=50)
[0335] # Task A's dedicated layer
[0336] self.task_A_layer = nn.Linear(in_features=50, out_features=1)
[0337] # Task B's dedicated layer
[0338] self.task_B_layer = nn.Linear(in_features=50, out_features=1)
[0339] def forward(self, x):
[0340] # Shared layer processing
[0341] shared_output = F.relu(self.shared_layer(x))
[0342] # Task A processing flow
[0343] task_A_output = self.task_A_layer(shared_output)
[0344] # Task B processing flow
[0345] task_B_output = self.task_B_layer(shared_output)
[0346] # Take the output results of tasks A and B as the results of bidirectional multi-task learning
[0347] return task_A_output, task_B_output
[0348] # Assume input data
[0349] input_data = torch.rand(10, 100) # Assume there are 10 samples, each with 100 features
[0350] # Model instantiation
[0351] model = BiDirectionalMultiTaskLearningLayer()
[0352] # Forward pass
[0353] task_A_output, task_B_output = model(input_data)
[0354] # Print the output results of tasks A and B
[0355] print("Task A Output:", task_A_output)
[0356] print("Task B Output:", task_B_output)
[0357] This example shows how to build a bidirectional multi-task learning layer. This layer consists of a shared layer and a dedicated layer for each task. The shared layer is designed to capture features that are useful for all tasks, while the dedicated layer generates predictions for each specific task.
[0358] In the single-phase inverter energy control system, the training of the neural network model is a multi-stage, iterative process involving a series of steps from data collection to model deployment. This process ensures that the model can effectively learn and adapt to the dynamic changes of the inverter and the power grid to achieve optimized energy control. The following are the specific steps of model training:
[0359] Step 1: Data collection and preprocessing
[0360] First, the system needs to collect the operating parameters of the inverter and the power grid, including output voltage, current, power, frequency, efficiency, temperature, and the voltage, frequency, load demand, and harmonic level of the power grid. The collected data is pre-processed, including data cleaning, denoising, and normalization, to ensure data quality and consistency, laying a solid foundation for subsequent model training.
[0361] Step 2: Model training
[0362] Dynamic feature adaptation layer training: In this stage, the system uses adaptive weighting technology based on the attention mechanism to process and optimize monitoring data and highlight important data features.
[0363] Modular feature extraction layer training: In this stage, a multifunctional convolutional neural network module is used to conduct in-depth analysis of the feature data after weight adjustment, extract features of various complex patterns through specialized convolution channels, and generate comprehensive feature representations.
[0364] Time series processing layer training: Long short-term memory network (LSTM) is used in combination with attention mechanism to analyze comprehensive feature representation, capture the temporal dependency of data, identify key time points, and provide key information for the final modulation parameter prediction.
[0365] Bidirectional multi-task learning layer training: Finally, through the bidirectional multi-task learning layer, the system achieves simultaneous prediction of different modulation parameters, using multi-output fully connected layers and enhancing information sharing between tasks through bidirectional information flow.
[0366] Step 3: Model evaluation and testing
[0367] After training is completed, the model needs to undergo rigorous evaluation and testing, using cross-validation and various performance indicators (such as accuracy, response time, etc.) to verify the effectiveness and reliability of the model to ensure that its performance in actual applications meets system requirements.
[0368] Step 4: Model deployment and implementation
[0369] The model that has been evaluated and tested will be deployed in the single-phase inverter control system to process the monitoring data of the inverter and the power grid in real time, dynamically adjust the output of the inverter according to the results predicted by the model, optimize the energy conversion efficiency and meet the dynamic needs of the power grid.
[0370] Step 5: Continuous monitoring and iterative updates
[0371] After deployment, the system will continuously monitor the performance and actual application effects of the model, collect new operating data for iterative updates and optimization of the model, ensure that the model can adapt to environmental changes and new needs, and continue to provide efficient and accurate energy control solutions.
[0372] Through this rigorous and detailed training and implementation process, the single-phase inverter energy control system can fully utilize the powerful learning and prediction capabilities of neural networks, continuously optimize and improve the working performance of the inverter, and achieve efficient use of energy and accurate satisfaction of grid needs.
[0373] The hybrid modulation module 104 is used to generate a target pulse width modulation signal that meets the requirements according to the modulation parameters provided by the intelligent optimization module; and apply the generated target pulse width modulation signal to the inverter switch unit to generate target alternating current.
[0374] The hybrid modulation module 104 plays a core role in the single-phase inverter energy control system. It is directly responsible for generating and adjusting the pulse width modulation (PWM) signal according to the modulation parameters provided by the intelligent optimization module 103, and then accurately controlling the switching action of the inverter switch unit to generate an AC output that meets the needs of the external power grid.
[0375] The core function of the hybrid modulation module 104 is to receive the modulation parameters generated by the intelligent optimization module 103, which include the duty cycle and phase parameters of the PWM signal. The duty cycle parameter affects the average value of the inverter output voltage, while the phase parameter is related to the synchronization between the inverter output and the grid voltage. These two parameters together determine the output performance of the inverter, including power factor, harmonic distortion and energy conversion efficiency.
[0376] To achieve this function, the hybrid modulation module 104 includes a PWM signal generator, which dynamically adjusts the waveform of the PWM signal according to the input modulation parameters. The signal generator may be based on a microcontroller design, or a higher performance implementation using a dedicated digital signal processor (DSP) and a field programmable gate array (FPGA) to meet the requirements of modulation speed and accuracy in different application scenarios.
[0377] In terms of technical implementation, the hybrid modulation module 104 uses advanced control algorithms to finely adjust each pulse of the PWM signal, including the pulse width (duty cycle) and the time (phase) of occurrence. These control algorithms can ensure that the switching action of the inverter switch unit in each PWM cycle is accurate and correct, thereby generating high-quality AC output.
[0378] In addition, in order to adapt to the rapid changes in grid conditions and load demands, the hybrid modulation module 104 is designed to be able to receive and process in real time the feedback data from the inverter monitoring module 102 and the modulation parameters updated by the intelligent optimization module 103. This real-time feedback mechanism enables the system to respond quickly to changes in grid conditions and further optimize the performance of the inverter.
[0379] In general, the hybrid modulation module 104 generates and adjusts the PWM signal in real time by comprehensively utilizing the modulation parameters provided by the intelligent optimization module, and accurately controls the action of the inverter switch unit, thereby producing high-efficiency, high-quality AC power to meet the power supply needs of the external power grid.
[0380] The following is an example of an application of this embodiment. On a sunny afternoon, a home solar photovoltaic system located in the suburbs is running at full load. This system adopts the single-phase inverter energy control system based on the hybrid modulation strategy provided by this embodiment. In this application scenario, solar panels collect sunlight and convert it into direct current, which then needs to be converted into alternating current for home use or fed back to the power grid.
[0381] First, the DC power generated by the solar panel is supplied to the inverter switch unit through the bus capacitor unit. The bus capacitor unit plays a role in smoothing the voltage here, ensuring that the DC power provided to the inverter switch unit is stable. Then, the inverter switch unit takes over this task and uses internal electronic switches (such as IGBTs or MOSFETs) to convert DC power into AC power. This process is achieved by modulating the switching frequency and timing of these switches, and it is here that the "hybrid modulation strategy" plays a core role.
[0382] At the same time, the inverter monitoring module 102 continuously monitors the inverter's output voltage, current, power, frequency and other key performance indicators, and also pays attention to the voltage, frequency, load demand and harmonic level of the external power grid. All of this information is fed back to the intelligent optimization module 103 in real time.
[0383] The intelligent optimization module 103 uses an advanced neural network model to analyze these data and intelligently generates modulation parameters, including the duty cycle and phase of the pulse width modulation signal, based on the current inverter performance and grid demand. These parameters directly determine the switching action of the inverter switch unit, and further affect the quality of the AC output of the inverter.
[0384] Once the intelligent optimization module 103 determines the optimal modulation parameters, these parameters are sent to the hybrid modulation module 104. The hybrid modulation module 104 then generates a target PWM signal that meets the requirements and applies this signal to the inverter switch unit to accurately control its action to generate high-quality AC power that meets the needs of the home and the power grid.
[0385] In this way, not only the household electricity demand is met, but the excess electricity can also be fed back through the power grid, achieving efficient use of energy. Through real-time monitoring and intelligent optimization, this system can work continuously and stably under different environmental and load conditions, demonstrating a high degree of flexibility and adaptability.
[0386] In the above-mentioned embodiment, a single-phase inverter energy control system based on a hybrid modulation strategy is provided. Correspondingly, the present application also provides a single-phase inverter energy control method based on a hybrid modulation strategy. Figure 2 , which is a flow chart of an embodiment of a single-phase inverter energy control method based on a hybrid modulation strategy of the present application. Since this embodiment, i.e., the second embodiment, is basically similar to the first embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the first embodiment. The method embodiment described below is only illustrative.
[0387] A second embodiment of the present application provides a single-phase inverter energy control method based on a hybrid modulation strategy, comprising:
[0388] Step S201: using a bus capacitor unit to smooth the voltage of a DC power supply to provide a stable DC voltage to an inverter switch unit;
[0389] Step S202: converting direct current into alternating current through an inverter switch unit, thereby supplying power to an external power grid;
[0390] Step S203: monitoring the status data of the single-phase inverter and the external power grid, wherein the status data of the single-phase inverter includes output voltage, output current, output power, frequency of output current, efficiency and temperature; the status data of the external power grid includes power grid voltage, power grid frequency, power grid load demand and power grid harmonic level;
[0391] Step S204: according to the monitored state data of the single-phase inverter and the external power grid, the intelligent optimization module uses the trained neural network model to analyze and generate modulation parameters that meet the requirements, wherein the modulation parameters include duty cycle parameters and phase parameters of the pulse width modulation signal;
[0392] Step S205: generating a target pulse width modulation signal that meets the requirements according to the generated modulation parameters;
[0393] Step S206: applying the generated target pulse width modulation signal to the inverter switch unit to generate target alternating current.
[0394] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
Claims
1. A single-phase inverter energy control system based on a hybrid modulation strategy, characterized in that: include: A single-phase inverter comprises a bus capacitor unit and an inverter switch unit, wherein the bus capacitor unit is used to smooth the voltage of a DC power supply and provide a stable DC voltage to the inverter switch unit; the inverter switch unit is used to convert DC power into AC power, thereby realizing power supply to an external power grid; The inverter monitoring module is used to monitor the status data of the single-phase inverter and the status data of the external power grid; and provide the monitoring data to the hybrid modulation control module and the intelligent optimization module; wherein the status data of the single-phase inverter includes the output voltage, output current, output power, frequency of the output current, efficiency and temperature of the inverter; and the status data of the external power grid includes the power grid voltage, power grid frequency, power grid load demand and power grid harmonic level; An intelligent optimization module, used to generate modulation parameters that meet the requirements based on the monitoring data provided by the inverter monitoring module and using a trained neural network model; output the generated modulation parameters to the hybrid modulation module; wherein the modulation parameters include a duty cycle parameter of a pulse width modulation signal and a phase parameter of a pulse width modulation signal; and the pulse width modulation signal is used to control the switching action of the inverter switch unit; A hybrid modulation module, used to generate a target pulse width modulation signal that meets the requirements according to the modulation parameters provided by the intelligent optimization module; and apply the generated target pulse width modulation signal to the inverter switch unit to generate a target alternating current; The neural network model used in the intelligent optimization module includes a dynamic feature adaptation layer, a modular feature extraction layer, a time series processing layer, and a bidirectional multi-task learning layer; The dynamic feature adaptation layer uses an adaptive weighting technology based on an attention mechanism to process the state data of the monitored single-phase inverter and the state data of the external power grid to obtain feature data after weight adjustment; The modular feature extraction layer uses a multifunctional convolutional neural network module to process the weighted feature data provided by the dynamic feature adaptation layer to obtain a comprehensive feature representation; wherein the multifunctional convolutional neural network module has multiple parallel convolution channels, and after each convolution channel extracts a special feature, the special features of all convolution channels are merged through a merging layer to obtain a comprehensive feature representation; each convolution channel includes a convolution layer and a pooling layer; the convolution layer of each convolution channel uses a convolution kernel size, number of layers and step size that match the target extraction feature; The time series processing layer uses a long short-term memory network and an attention mechanism to process the comprehensive feature representation provided by the modular feature extraction layer to obtain an event dependency feature representation; The bidirectional multi-task learning layer uses a multi-output fully connected layer to implement multi-task learning and generate modulation parameters that meet the requirements; The adaptive weighting technology of the attention mechanism used in the dynamic feature adaptation layer is implemented by the following steps: Receive input monitoring data, including output voltage, output current, output power, output frequency, efficiency, temperature of the single-phase inverter, and voltage, frequency, load demand and harmonic level of the external power grid; Through an attention generation network, an attention weight is calculated for each input in the monitoring data; The calculated attention weights are used to perform weighted processing on the monitoring data to obtain feature data after adjusting the weights.
2. The single-phase inverter energy control system according to claim 1, characterized in that: The adaptive weighting technique of the attention mechanism used in the dynamic feature adaptation layer is implemented by the following steps: Receive input monitoring data, including output voltage, output current, output power, output frequency, efficiency, temperature of the single-phase inverter, and voltage, frequency, load demand and harmonic level of the external power grid; The first input monitoring data is calculated according to the following formula 1: The weight of the feature : in, and is the adjustment coefficient; Representation characteristics Energy efficiency ratio; Representation characteristics The degree of grid demand satisfaction; Representation characteristics time sensitivity; Representation characteristics Environmental adaptability; Representation characteristics Contextual relevance score of ; is a composite scoring function, calculated using the following formula 2: in, Indicates the energy efficiency ratio of the inverter, which is calculated by the ratio of output power to input power; Indicates the grid demand satisfaction, which is calculated by the matching degree between the inverter output and the grid load demand; It represents time sensitivity and is used to evaluate how quickly a feature responds to time changes; It represents environmental adaptability and is used to evaluate the stability of the performance of characteristics under different environmental conditions; , , and is the weight coefficient; It is The contextual relevance score of a feature is calculated using the following formula 3: in, Indicates Features Indicates the target state of the system; Representation characteristics Relevance score to system goals; Representation characteristics Rating of impact on system performance; Using the calculated attention weights Perform weighted processing on the monitoring data to obtain feature data after adjusting the weights.
3. The single-phase inverter energy control system according to claim 1, characterized in that: The convolution channels in the multifunctional convolutional neural network module include a periodic convolution channel, a mutation convolution channel, a stability convolution channel, a noise convolution channel, an efficiency convolution channel and a harmonic convolution channel.
4. The single-phase inverter energy control system according to claim 3, characterized in that: The convolution kernel size of the convolution layer of the periodic convolution channel is 7×7, the number of layers is 3, and the step size is 2, so as to capture patterns in long-period changes; the convolution kernel size of the convolution layer of the mutation convolution channel is 3×3, the number of layers is 2, and the step size is 1, so as to capture the details of sudden changes; the convolution kernel size of the convolution layer of the stability convolution channel is 5×5, the number of layers is 2, and the step size is 2, so as to balance the need to capture details and maintain stability characteristics; the convolution kernel size of the convolution layer of the noise convolution channel is 3×3, the number of layers is 2, and the step size is 1, so as to identify noise and irregular fluctuations; the convolution kernel size of the convolution layer of the efficiency convolution channel is 5×5, the number of layers is 3, and the step size is 2, so as to capture patterns related to inverter efficiency; the convolution kernel size of the convolution layer of the harmonic convolution channel is 5×5, the number of layers is 3, and the step size is 2, so as to identify harmonic characteristics and power quality problems.
5. The single-phase inverter energy control system according to claim 1, characterized in that: The time series processing layer is specifically used for: receiving the comprehensive feature representation from the modular feature extraction layer; A long short-term memory network is used to perform sequence analysis on the comprehensive feature representation to generate a time-dependent feature representation; An attention mechanism is introduced in the output layer of the LSTM network, which identifies the key time points in the sequence by calculating the importance weight of the feature representation of each time step relative to the final prediction task; An event-dependent feature representation is generated by combining the time-dependent feature representation generated by the long short-term memory network and the weighted adjustment of the time-dependent feature representation by the attention mechanism.
6. The single-phase inverter energy control system according to claim 1, characterized in that: The single-phase inverter also includes a control logic unit, which is used to receive a target pulse width modulation signal sent from the hybrid modulation module; dynamically adjust the switching frequency and duty cycle of the inverter switch unit according to the target pulse width modulation signal to optimize the energy conversion efficiency and power quality during the inversion process.
7. The single-phase inverter energy control system according to claim 1, characterized in that: The inverter monitoring module adopts a high-precision sensor array to capture and record the operating status data of the inverter and the status data of the external power grid in real time.
8. A single-phase inverter energy control method based on a hybrid modulation strategy, characterized in that: include: The bus capacitor unit is used to smooth the voltage of the DC power supply to provide a stable DC voltage to the inverter switch unit; Convert direct current into alternating current through an inverter switch unit, thereby supplying power to an external power grid; Monitor the status data of the single-phase inverter and the external power grid, where the status data of the single-phase inverter includes output voltage, output current, output power, frequency of output current, efficiency and temperature; the status data of the external power grid includes power grid voltage, power grid frequency, power grid load demand and power grid harmonic level; According to the monitored state data of the single-phase inverter and the external power grid, the intelligent optimization module uses the trained neural network model to analyze and generate modulation parameters that meet the requirements, wherein the modulation parameters include the duty cycle parameters and phase parameters of the pulse width modulation signal; Generate a target pulse width modulation signal that meets the requirements according to the generated modulation parameters; Applying the generated target pulse width modulation signal to the inverter switch unit to generate target alternating current; The neural network model includes a dynamic feature adaptation layer, a modular feature extraction layer, a time series processing layer, and a bidirectional multi-task learning layer; The dynamic feature adaptation layer uses an adaptive weighting technology based on an attention mechanism to process the state data of the monitored single-phase inverter and the state data of the external power grid to obtain feature data after weight adjustment; The modular feature extraction layer uses a multifunctional convolutional neural network module to process the weighted feature data provided by the dynamic feature adaptation layer to obtain a comprehensive feature representation; wherein the multifunctional convolutional neural network module has multiple parallel convolution channels, and after each convolution channel extracts a special feature, the special features of all convolution channels are merged through a merging layer to obtain a comprehensive feature representation; each convolution channel includes a convolution layer and a pooling layer; the convolution layer of each convolution channel uses a convolution kernel size, number of layers and step size that match the target extraction feature; The time series processing layer uses a long short-term memory network and an attention mechanism to process the comprehensive feature representation provided by the modular feature extraction layer to obtain an event dependency feature representation; The bidirectional multi-task learning layer uses a multi-output fully connected layer to implement multi-task learning and generate modulation parameters that meet the requirements; The adaptive weighting technique of the attention mechanism used in the dynamic feature adaptation layer is implemented by the following steps: Receive input monitoring data, including output voltage, output current, output power, output frequency, efficiency, temperature of the single-phase inverter, and voltage, frequency, load demand and harmonic level of the external power grid; Through an attention generation network, an attention weight is calculated for each input in the monitoring data; The calculated attention weights are used to perform weighted processing on the monitoring data to obtain feature data after adjusting the weights.
