Charging and discharging optimization method and equipment for household photovoltaic energy storage system

By constructing a linear programming objective function to optimize the battery charging and discharging of a residential photovoltaic energy storage system, the problem of insufficient utilization of electricity price fluctuations in existing solutions is solved, thereby minimizing the cost of purchasing electricity from the grid and improving the economic efficiency of electricity use.

CN121863643APending Publication Date: 2026-04-14NANJING GUANGXIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing energy management solutions for residential photovoltaic energy storage systems fail to maximize the use of electricity price fluctuations, resulting in lost revenue for users. Furthermore, AI prediction models are costly and difficult to adapt to actual data biases.

Method used

By acquiring historical data to construct a linear programming objective function, and combining energy conservation and battery capacity constraints, the battery charging and discharging schedule is optimized to reduce the cost of purchasing electricity from the grid.

Benefits of technology

While ensuring the electricity demand of the load, it significantly reduces the cost of purchasing electricity from the power grid, improves the economic efficiency of electricity use, and adapts to the real-time changes in photovoltaic power generation and load electricity consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121863643A_ABST
    Figure CN121863643A_ABST
Patent Text Reader

Abstract

The invention discloses a charging and discharging optimization method and device for a household photovoltaic energy storage system, and the method comprises the steps: obtaining the photovoltaic power generation amount, household load power consumption and time-of-use electricity price data of each hour in a historical preset number of days; the method comprises the following steps of: constructing a linear programming objective function for representing the total electricity purchasing cost of a user from a power grid within a future preset duration by combining time-of-use electricity price data; and solving to obtain the future battery charging amount and the future battery discharging amount corresponding to each hour in the future preset duration when the target function is minimum, and further determining a charging and discharging plan in the future preset duration. According to the method, a target function is constructed by combining historical power generation and consumption data and time-of-use electricity price, and battery charging and discharging behaviors are solved and planned in a targeted manner under constraints, so that the total cost of users for purchasing electricity from a power grid within a future preset duration is minimized, and the power consumption of the users is reduced on the premise of guaranteeing the electricity consumption demand of household loads and battery safety. And the electricity utilization economy of the household photovoltaic energy storage system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of new energy system technology, and in particular to a method and equipment for optimizing the charging and discharging of a household photovoltaic energy storage system. Background Technology

[0002] With the global energy structure shifting towards cleaner and lower-carbon energy, distributed photovoltaic (PV) power generation technology has been widely promoted. Residential PV energy storage systems, as core equipment for realizing local solar energy consumption and reducing household electricity costs, have become an important development direction in the field of new energy applications. Residential PV energy storage systems convert solar energy into electricity through photovoltaic modules. A portion of this electricity is directly supplied to the household load, while excess electricity is stored in battery packs and released during periods of insufficient PV power generation or peak electricity demand. This effectively reduces the household's dependence on grid power and aligns with the development needs of energy conservation and emission reduction, resulting in broad market application prospects.

[0003] The existing energy management solutions for residential photovoltaic energy storage systems are mainly load priority mode and AI prediction mode. The former prioritizes meeting load demand and charging with remaining power, while the latter generates a static charging and discharging plan for the whole day by predicting data through AI models.

[0004] However, the load-price model does not take into account time-of-use pricing and cannot maximize user benefits, while the AI ​​prediction model suffers from high chip computing power costs and the inability of static plans to adapt to actual data deviations, leading to revenue losses. Summary of the Invention

[0005] To address the aforementioned issues, this application provides a method and apparatus for optimizing the charging and discharging of a residential photovoltaic energy storage system.

[0006] The embodiments of this application disclose the following technical solutions:

[0007] In a first aspect, embodiments of this application provide a method for optimizing the charging and discharging of a residential photovoltaic energy storage system, the method comprising:

[0008] Obtain the photovoltaic power generation and household load electricity consumption for each hour within a preset number of historical days, and obtain time-of-use electricity price data;

[0009] A linear programming objective function is constructed using the time-of-use electricity price data; wherein, the objective function represents the total cost for users to purchase electricity from the grid within a preset time period in the future;

[0010] Under the constraints, the objective function is solved to determine the future battery charging and discharging amounts for each hour within the future preset time period, while minimizing the user's total cost of purchasing electricity from the grid. The constraints include energy conservation constraints and battery remaining capacity constraints. The energy conservation constraint requires that the photovoltaic power generation, battery discharging, net electricity purchase from the grid, household load electricity consumption, and battery charging amount satisfy an energy balance. The battery remaining capacity constraint requires that the battery remaining capacity be within a preset range at any given time.

[0011] A charging and discharging plan for a preset duration is determined based on the future battery charging amount and the future battery discharging amount.

[0012] In one possible implementation, the objective function is the sum of the electricity purchase costs from the grid by users over multiple hours within a preset time period in the future, and the electricity purchase costs from the grid by users in each hour are determined based on the amount of electricity purchased from the grid by users and the time-of-use electricity price data.

[0013] The objective function is expressed as:

[0014] ;

[0015] in, This indicates the preset future duration. For users in hour t, electricity is purchased from the grid. Let t be the time-of-use electricity price for the t-th hour.

[0016] In one possible implementation, the energy conservation constraint is expressed as:

[0017] ;

[0018] in, Let be the photovoltaic power generation in hour t. Let be the battery discharge amount in hour t. For users in hour t, electricity is purchased from the grid. For users selling electricity to the grid in hour t, Let t be the household load electricity consumption in hour t. Let t be the amount of battery charge in hour t. The difference between the amount of electricity purchased by the user from the grid in hour t and the amount of electricity sold by the user to the grid in hour t is the net amount of electricity purchased by the user from the grid in hour t, where t is a positive integer.

[0019] In one possible implementation, the battery remaining capacity constraint is expressed as:

[0020] ;

[0021] in, Let be the battery capacity at hour t. The battery capacity at hour t-1. Let be the battery discharge amount in hour t. The amount of battery charge in hour t. This refers to the battery's rated capacity.

[0022] In one possible implementation, solving the objective function under the constraints includes:

[0023] The objective function is solved using a linear programming solver library under the constraints stated therein; wherein the linear programming solver library includes algorithms for solving the objective function under the corresponding constraints.

[0024] In one possible implementation, the method further includes:

[0025] The system detects the first deviation between the actual photovoltaic power generation and the photovoltaic power generation in real time, and also detects the second deviation between the actual household load electricity consumption and the household load electricity consumption in real time.

[0026] If the first deviation is greater than or equal to a preset threshold, the photovoltaic power generation is calibrated, and the charging and discharging plan is updated based on the household load electricity consumption and the calibrated photovoltaic power generation.

[0027] Alternatively, if the second deviation is greater than or equal to the preset threshold, the household load power consumption is calibrated, and the charging and discharging plan is updated based on the photovoltaic power generation and the calibrated household load power consumption;

[0028] Alternatively, if both the first deviation and the second deviation are greater than or equal to the preset threshold, the photovoltaic power generation and the household load power consumption are calibrated, and the charging and discharging plan is updated based on the calibrated photovoltaic power generation and the calibrated household load power consumption.

[0029] In one possible implementation, calibrating the photovoltaic power generation includes:

[0030] The photovoltaic power generation is calibrated based on a first deviation; wherein the first deviation is the ratio of the actual photovoltaic power generation to the photovoltaic power generation.

[0031] The calibration of the household load power consumption includes:

[0032] The household load power consumption is calibrated based on the second deviation; wherein the second deviation is the ratio of the actual household load power consumption to the household load power consumption.

[0033] Secondly, embodiments of this application disclose a charge / discharge optimization device for a home photovoltaic energy storage system, the device comprising:

[0034] The acquisition module is used to acquire the photovoltaic power generation and household load electricity consumption for each hour within a historical preset number of days, and to acquire time-of-use electricity price data;

[0035] A construction module is used to construct an objective function for linear programming based on the time-of-use electricity price data; wherein, the objective function is used to represent the total cost for users to purchase electricity from the grid within a preset time period in the future;

[0036] The calculation module is used to solve the objective function under constraints to determine the future battery charging and discharging amounts for each hour within the future preset time period, while minimizing the user's total cost of purchasing electricity from the grid within the future preset time period. The constraints include energy conservation constraints and battery remaining capacity constraints. The energy conservation constraint requires that the photovoltaic power generation, battery discharging, net electricity purchase from the grid, household load electricity consumption, and battery charging amount satisfy an energy balance. The battery remaining capacity constraint requires that the battery remaining capacity be within a preset range at any given time.

[0037] An optimization module is used to determine a charging and discharging plan for a preset duration based on the future battery charging amount and the future battery discharging amount.

[0038] In one possible implementation, the objective function is the sum of the electricity purchase costs from the grid by users over multiple hours within a preset time period in the future, and the electricity purchase costs from the grid by users in each hour are determined based on the amount of electricity purchased from the grid by users and the time-of-use electricity price data.

[0039] The objective function is expressed as:

[0040] ;

[0041] in, This indicates the preset future duration. For users in hour t, electricity is purchased from the grid. Let t be the time-of-use electricity price for the t-th hour.

[0042] In one possible implementation, the energy conservation constraint is expressed as:

[0043] ;

[0044] in, Let be the photovoltaic power generation in hour t. Let be the battery discharge amount in hour t. For users in hour t, electricity is purchased from the grid. For users selling electricity to the grid in hour t, Let t be the household load electricity consumption in hour t. Let t be the amount of battery charge in hour t. The difference between the amount of electricity purchased by the user from the grid in hour t and the amount of electricity sold by the user to the grid in hour t is the net amount of electricity purchased by the user from the grid in hour t, where t is a positive integer.

[0045] In one possible implementation, the battery remaining capacity constraint is expressed as:

[0046] ;

[0047] in, Let be the battery capacity at hour t. The battery capacity at hour t-1. Let be the battery discharge amount in hour t. The amount of battery charge in hour t. This refers to the battery's rated capacity.

[0048] In one possible implementation, the computation module is specifically used to solve the objective function using a linear programming solver library under the constraints of the constraints; wherein the linear programming solver library includes algorithms for solving the objective function under the corresponding constraints.

[0049] In one possible implementation, the optimization module is further configured to detect in real time the first deviation between the actual photovoltaic power generation and the photovoltaic power generation, and to detect in real time the second deviation between the actual household load electricity consumption and the household load electricity consumption;

[0050] If the first deviation is greater than or equal to a preset threshold, the photovoltaic power generation is calibrated, and the charging and discharging plan is updated based on the household load electricity consumption and the calibrated photovoltaic power generation.

[0051] Alternatively, if the second deviation is greater than or equal to the preset threshold, the household load power consumption is calibrated, and the charging and discharging plan is updated based on the photovoltaic power generation and the calibrated household load power consumption;

[0052] Alternatively, if both the first deviation and the second deviation are greater than or equal to the preset threshold, the photovoltaic power generation and the household load power consumption are calibrated, and the charging and discharging plan is updated based on the calibrated photovoltaic power generation and the calibrated household load power consumption.

[0053] In one possible implementation, the optimization module is specifically used to calibrate the photovoltaic power generation based on a first deviation, wherein the first deviation is the ratio of the actual photovoltaic power generation to the photovoltaic power generation; and to calibrate the household load electricity consumption based on a second deviation, wherein the second deviation is the ratio of the actual household load electricity consumption to the household load electricity consumption.

[0054] Thirdly, embodiments of this application disclose a control device, including a processor and a memory, wherein the memory is used to store programs, instructions or code, and the processor is used to execute the programs, instructions or code in the memory to complete the charging and discharging optimization method of the home photovoltaic energy storage system as described in any of the first aspects.

[0055] Fourthly, embodiments of this application disclose a computer-readable storage medium, characterized in that it stores a computer program, which is loaded by a processor to execute the charge and discharge optimization method for a home photovoltaic energy storage system as described in any of the first aspects.

[0056] This application provides a method and device for optimizing the charging and discharging of a home photovoltaic energy storage system. The method obtains the photovoltaic power generation, household load electricity consumption, and time-of-use electricity price data for each hour within a historical preset number of days. It then constructs a linear programming objective function representing the total cost of the user to purchase electricity from the grid within a future preset period by combining the time-of-use electricity price data. Under the constraints of energy conservation and battery remaining capacity, the method solves for the future battery charging and discharging amounts corresponding to each hour within the future preset period when the objective function is minimized, thereby determining the charging and discharging plan for the future preset period.

[0057] This application embodiment constructs an objective function by combining historical hourly power generation and consumption data with time-of-use electricity prices and solves it under reasonable constraints. This enables targeted planning of battery charging and discharging behavior, ensuring that the total cost of purchasing electricity from the grid for users within a preset time period is minimized. It effectively solves the problem that existing solutions do not fully incorporate electricity price characteristics or are difficult to accurately optimize electricity costs. Under the premise of ensuring the electricity demand of household loads and battery safety, it significantly improves the electricity economy of household photovoltaic energy storage systems. Attached Figure Description

[0058] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0059] Figure 1A schematic flowchart illustrating a charging and discharging optimization method for a home photovoltaic energy storage system provided in an embodiment of this application;

[0060] Figure 2 This application also provides a schematic diagram of the structure of a charge and discharge optimization device for a home photovoltaic energy storage system. Detailed Implementation

[0061] As described earlier, current energy management solutions for residential photovoltaic (PV) energy storage systems mainly fall into two categories. The first is the load-priority mode, whose core logic is to prioritize the electricity needs of the household load. The system controls the battery pack to discharge to meet the load consumption based on the user's pre-set target load electricity consumption or the actual household load electricity consumption collected in real-time by a smart meter. Only when PV power generation exceeds the current load demand and generates surplus electricity is the excess electricity used to charge the battery pack. The second is the AI ​​prediction mode. This mode uses environmental parameters such as the next day's weather and temperature released by meteorological departments. Through PV prediction AI models and load prediction AI models deployed in the system chip, it predicts the PV power generation and household load electricity consumption for the next 24 hours, respectively, and then generates a fixed charging and discharging plan for the entire day to guide the charging and discharging operations of the battery pack.

[0062] However, both existing energy management solutions have significant technical flaws, making it difficult to balance maximizing household user benefits with system practicality. The load-priority mode focuses solely on meeting household load demands, neglecting the time-of-use pricing characteristics of the grid. It cannot prioritize releasing battery-stored electricity for grid connection during peak electricity price periods, nor can it prioritize purchasing electricity from the grid for storage during off-peak periods. This prevents household users from fully utilizing price fluctuations to optimize benefits and achieve the goal of minimizing electricity expenses. The AI ​​prediction mode suffers from several drawbacks. First, the operation of both the photovoltaic prediction AI model and the load prediction AI model relies on high-performance chips to provide sufficient computing power, significantly increasing the system's hardware costs. Second, the charge / discharge plan generated based on prediction data is static. When there are deviations between the actual photovoltaic power generation, household load power, and the predicted values, the static plan cannot dynamically adjust to adapt to actual operating conditions, easily leading to situations where electricity is purchased from the grid at high prices or batteries are discharged ineffectively, severely impacting the system's actual performance.

[0063] To address this technical problem, this application provides a method and device for optimizing the charging and discharging of a home photovoltaic energy storage system. The method acquires the photovoltaic power generation, household load electricity consumption, and time-of-use electricity price data for each hour within a historical preset number of days. It then constructs a linear programming objective function representing the total cost of electricity purchased from the grid by the user within a future preset period, based on the time-of-use electricity price data. Under the constraints of energy conservation and battery remaining capacity, the method solves for the future battery charging and discharging amounts corresponding to each hour within the future preset period when the objective function is minimized, thereby determining the charging and discharging plan for the future preset period.

[0064] This application embodiment constructs an objective function by combining historical hourly power generation and consumption data with time-of-use electricity prices and solves it under reasonable constraints. This enables targeted planning of battery charging and discharging behavior, ensuring that the total cost of purchasing electricity from the grid for users within a preset time period is minimized. It effectively solves the problem that existing solutions do not fully incorporate electricity price characteristics or are difficult to accurately optimize electricity costs. Under the premise of ensuring the electricity demand of household loads and battery safety, it significantly improves the electricity economy of household photovoltaic energy storage systems.

[0065] The method provided in this application is applicable to home photovoltaic energy storage systems equipped with photovoltaic modules, energy storage battery packs, smart meters, and embedded controllers, and is widely used in ordinary residential homes, villas, and other home scenarios. After the above hardware devices are deployed in the home, the smart meter collects historical electricity consumption data in real time and synchronizes time-of-use electricity price information. The photovoltaic modules convert solar energy into electrical energy and record historical power generation. The embedded controller, based on the historical hourly photovoltaic power generation, household load electricity consumption, and time-of-use electricity price data collected by the hardware, performs the construction and solution of a linear programming objective function. Through the calculated optimal charge and discharge plan, it controls the energy storage battery pack to charge reasonably during off-peak hours and discharge preferentially during peak hours, while strictly adhering to the energy conservation law and battery capacity limitations to ensure stable collaborative operation of the hardware devices. Whether it is an urban residence with fluctuating sunlight conditions or a rural villa with diverse electricity needs, this method can achieve precise optimization of electricity costs through the collaborative cooperation of existing home photovoltaic energy storage hardware, without the need for additional high hardware investment, and has extremely strong practical application adaptability.

[0066] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.

[0067] See Figure 1 , Figure 1This is a flowchart illustrating a charging and discharging optimization method for a home photovoltaic energy storage system provided in this application embodiment. The execution subject of this method can be a server, desktop computer, or other electronic device capable of computation. The following description uses a controller as the execution subject, and the method includes:

[0068] S101: The controller obtains the photovoltaic power generation and household load electricity consumption for each hour within a historical preset number of days, and obtains time-of-use electricity price data.

[0069] Historical preset days refer to the number of consecutive days in the past used to calculate average data. Hourly photovoltaic power generation refers to the sum of the actual electrical energy generated by photovoltaic modules in each hour of each 24-hour period within the historical preset days; the unit of photovoltaic power generation is kilowatt-hours (kWh). Hourly household load electricity consumption refers to the sum of the actual electrical energy consumed by various household electrical appliances in each hour of each 24-hour period within the historical preset days; the unit of household load electricity consumption is kilowatt-hours (kWh).

[0070] Time-of-use (TOU) pricing data refers to differentiated electricity prices based on different time periods within a 24-hour day. Prices are higher during peak hours than during off-peak hours. TOU pricing data is typically set by the power grid company. The unit for TOU pricing data is yuan per kilowatt-hour.

[0071] In this embodiment, the controller establishes a communication connection with the photovoltaic data acquisition module and smart meter in the home photovoltaic energy storage system to obtain basic data within a preset number of historical days. For photovoltaic power generation, the photovoltaic data acquisition module records the hourly power generation of the photovoltaic modules every hour of the day, and the controller reads the hourly power generation data from the photovoltaic data acquisition module for the preset number of historical days. For household electricity consumption, the smart meter monitors the household's hourly electricity consumption in real time, and the controller extracts the hourly electricity consumption data from the photovoltaic data acquisition module from the smart meter via power line carrier or wireless communication, ensuring the real-time performance and accuracy of the data acquisition.

[0072] As an example, the photovoltaic power generation of a certain day over 24 hours can be expressed as pv=[0,0,0,0,0,0.2,0.2,0.2,0.3,0.5,0.6,0.6,0.6,0.6,0.6,0.5,0.2,0.2,0,0,0,0,0,0].

[0073] As an example, the household electricity consumption on a historical day for 24 hours can be represented as load=[0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.2,1,0.1,0.1,0.1,1,1,0.7,0.1,0.6,0.4,1,0,0.2,0.2,0.3].

[0074] Simultaneously, the controller accesses the power grid company's electricity price information release channels to obtain the corresponding 24-hour time-of-use (TOU) electricity price data. This TOU data corresponds one-to-one with the hourly power generation and consumption data; for example, the photovoltaic power generation and household power consumption at 8:00 AM correspond to the TOU electricity price at 8:00 AM, providing highly relevant foundational data support for constructing the subsequent objective function. After data collection, the controller can perform preliminary verification of the photovoltaic power generation, household power consumption, and TOU electricity price data, eliminating outliers to ensure the reliability of subsequent calculations.

[0075] This application's embodiment integrates three core data types—historical hourly photovoltaic power generation, household electricity consumption, and time-of-use pricing—through a controller. It eliminates the need for complex prediction models, relying solely on actual historical data for calculations, thus reducing the computational demands on the controller and avoiding the uncertainties associated with predictive data. The data acquisition process utilizes existing hardware within the household photovoltaic energy storage system, eliminating the need for substantial additional hardware investment and demonstrating excellent economic efficiency. Furthermore, the collected hourly data and time-of-use pricing are precisely matched in the time dimension, providing a solid data foundation for constructing the objective function and solving for the optimal charging and discharging plan, ensuring the targeted and effective nature of subsequent optimization calculations.

[0076] S102: The controller combines time-of-use electricity price data to construct the objective function of linear programming.

[0077] The objective function represents the total cost for users to purchase electricity from the grid within a future preset time period. The total cost is related to the grid's electricity purchase behavior in each hour within the future preset time period. The objective function aims to minimize the total cost for users to purchase electricity from the grid within the future preset time period, such that the sum of the products of the grid-purchased electricity volume and the corresponding hourly time-of-use electricity price is minimized for each hour within the future preset time period.

[0078] Based on the hourly time-of-use electricity price data obtained in step S101, the controller constructs a linear programming objective function in conjunction with the core objective of "minimizing the total cost of electricity purchase". First, the calculation logic of the objective function is clarified: within the preset time period in the future, the electricity purchased by the user from the grid each hour is multiplied by the corresponding hourly time-of-use electricity price, and the sum of the products of all hours is the total cost of electricity purchase. The optimization direction of the objective function is to minimize this sum.

[0079] In one possible implementation, the objective function is the sum of the electricity purchase costs from the grid by users over multiple hours within a preset time period in the future, and the electricity purchase costs from the grid by users in each hour are determined based on the amount of electricity purchased from the grid by users and the time-of-use electricity price data.

[0080] The objective function can be expressed as:

[0081] ;

[0082] in, Indicates the preset duration in the future. For users in hour t, electricity is purchased from the grid. Let t be the time-of-use electricity price for the t-th hour.

[0083] The linear expression structure meets the requirements for solving linear programming problems, can be directly recognized and processed by the controller's calculation module, without the need for additional format conversion or complex calculations, and is compatible with the hardware computing power level of home photovoltaic energy storage systems.

[0084] For example, if the preset duration is 12 hours from 8 AM to 8 PM, the objective function can be expressed as: Total electricity purchase cost = (Electricity purchased at 8 AM × Electricity price at 8 AM) + (Electricity purchased at 9 AM × Electricity price at 9 AM) + ... + (Electricity purchased at 8 PM × Electricity price at 8 PM). The controller can use its built-in mathematical calculation module to transform this logic into a standardized linear expression, ensuring that the expression meets the mathematical requirements of linear programming. During the construction process, the hourly electricity purchase amount and the time-of-use electricity price correspond one-to-one in the objective function, without the need to introduce any other irrelevant variables, thus ensuring the simplicity and specificity of the function structure.

[0085] This application's embodiments clarify the core optimization direction of minimizing future total electricity purchase costs by constructing a linear objective function directly related to time-of-use pricing, avoiding the revenue loss problem caused by existing solutions not fully incorporating electricity price characteristics. The objective function adopts a linear structure, eliminating the need for complex model training or nonlinear calculations, reducing the computational burden on the controller, and adapting to the computing power level of the core control unit of a residential photovoltaic energy storage system. Simultaneously, when constructing the objective function, the use of precisely matched basic data along the time dimension ensures a high degree of alignment between the optimization objective and actual electricity consumption scenarios, providing a clear and reliable optimization guide for subsequently solving the optimal charging and discharging plan under constraints, thus guaranteeing the economic viability of the final charging and discharging plan.

[0086] S103: Under the constraints of the constraints, the controller solves the objective function to determine the future battery charging amount and future battery discharging amount corresponding to each hour within the future preset time period, while minimizing the total cost for the user to purchase electricity from the grid within the future preset time period.

[0087] The constraints are rules that restrict the solution process of the objective function, ensuring the rationality and feasibility of the solution. The constraints include energy conservation constraints and battery remaining capacity constraints. The energy conservation constraint ensures that photovoltaic power generation, battery discharge, net electricity purchased from the grid by the user, household load electricity consumption, and battery charging meet energy balance. The battery remaining capacity constraint ensures that the battery remaining capacity is within a preset range at any given time.

[0088] The energy conservation constraint can be expressed as:

[0089] ;

[0090] in, Let be the photovoltaic power generation in hour t. Let be the battery discharge amount in hour t. For users in hour t, electricity is purchased from the grid. For users selling electricity to the grid in hour t, Let t be the household load electricity consumption in hour t. Let t be the amount of battery charge in hour t. The difference between the amount of electricity purchased by the user from the grid in hour t and the amount of electricity sold by the user to the grid in hour t is the net amount of electricity purchased by the user from the grid in hour t, where t is a positive integer.

[0091] The battery remaining capacity constraint can be expressed as:

[0092] ;

[0093] in, Let be the battery capacity at hour t. The battery capacity at hour t-1. Let be the battery discharge amount in hour t. The amount of battery charge in hour t. This refers to the battery's rated capacity.

[0094] The controller combines the historical data obtained in step S101 to ensure that the energy conservation constraint expression holds true in the calculation of each hour. For the battery remaining capacity constraint, the controller limits the battery remaining capacity ∈ [0,1] for any hour.

[0095] Subsequently, the controller invokes the built-in linear programming solver module, inputting the objective function and the aforementioned constraints. Guided by minimizing total electricity purchase costs, the linear programming solver calculates the battery charging and discharging amounts for each hour within a preset timeframe, while satisfying both types of constraints. For example, when the hourly rate is high in a given hour, the solver module prioritizes battery discharging to meet household electricity demand, reducing the user's need to purchase electricity from the grid; conversely, when the rate is low, it increases battery charging to reserve energy for subsequent periods of higher rates.

[0096] In solving the objective function, to balance computational efficiency and result accuracy, in this embodiment, the controller can use a linear programming solver library to solve the objective function under constraints. The linear programming solver library includes algorithms for solving the objective function under corresponding constraints.

[0097] This application embodiment utilizes a linear programming solver library to solve the objective function. The linear programming solver library is used to quickly calculate the optimal variable result for a linear objective function under corresponding linear constraints.

[0098] Specifically, the controller converts the linear relationships corresponding to the objective function, energy conservation constraints, and battery remaining capacity limits into a standardized data format supported by the linear programming solver library, and then inputs this data into the library. The linear programming solver library, based on its built-in algorithm, automatically iterates through combinations of variables that meet the constraints. For example, when the hourly electricity price is at its peak, it prioritizes increasing battery discharge to replace grid power purchases, while simultaneously verifying whether this operation will cause the battery's remaining capacity to fall below 0; when the electricity price is at its lowest, the algorithm will attempt to increase battery charging while ensuring that the battery's remaining capacity does not exceed 1.

[0099] The entire solution process is automatically iterated and verified by the algorithm in the linear programming solver library, requiring no manual intervention. If the values ​​of a certain set of variables do not meet the constraints, the algorithm will adjust the range of variable values ​​in real time until a result is obtained that simultaneously satisfies the minimum total electricity purchase cost and all constraints. Finally, it outputs the battery charging and discharging amounts for each hour within a preset future time period.

[0100] The linear programming solver library features efficient and accurate algorithms. It can complete multi-variable optimization calculations in a short time, meeting the real-time requirements of home photovoltaic energy storage systems. It also avoids the error and stability risks associated with writing custom calculation logic. Furthermore, the pre-integrated design of the solver library eliminates the need for additional hardware costs, balancing practicality and economy.

[0101] S104: The controller determines a charging and discharging plan for a preset duration based on the future battery charging amount and the future battery discharging amount.

[0102] After determining the future battery charge and discharge amounts, the controller converts these values ​​into executable operation commands. For example, if the future battery charge amount for a certain hour is 0.5 kWh, the controller generates a corresponding control command to instruct the photovoltaic modules or grid to charge the battery pack by 0.5 kWh in that hour; if the future battery discharge amount is 0.8 kWh, it generates a corresponding control command to instruct the battery pack to discharge 0.8 kWh to household loads in that hour.

[0103] The controller then organizes these instructions into a future preset charging and discharging plan in chronological order and synchronizes it to the battery pack's control unit. If the preset duration is 24 hours, the plan will specify the charging and discharging operations for each hour from 0:00 to 24:00 that day; if it is 4 hours, it will correspond to the instructions for the next 4 hours. At the same time, the controller will synchronize key data from the plan (such as the discharge amount during periods of high electricity prices) to the home energy management terminal so that users can view the current optimization strategy.

[0104] This application's embodiments determine a pre-set charging and discharging plan based on future battery charging and discharging amounts, transforming the abstract solution results into a specific charging and discharging operation plan, allowing the home photovoltaic energy storage system to operate directly according to the optimized strategy. The hourly granularity of the charging and discharging plan matches the time dimension of time-of-use pricing and accurately adapts to the hourly electricity consumption fluctuations of the household load.

[0105] In practical applications, photovoltaic power generation may be affected by weather changes, and household electricity consumption may fluctuate due to sudden electricity consumption behavior. In order to cope with such real-time changes, this application embodiment also provides a dynamic adjustment implementation method.

[0106] Specifically, the controller detects the first deviation between the actual photovoltaic power generation and the actual photovoltaic power generation in real time, and detects the second deviation between the actual household load electricity consumption and the household load electricity consumption in real time.

[0107] If the first deviation is greater than or equal to the preset threshold, the controller calibrates the photovoltaic power generation and updates the charging and discharging plan based on the household load electricity consumption and the calibrated photovoltaic power generation.

[0108] If the second deviation is greater than or equal to the preset threshold, the controller calibrates the household load power consumption and updates the charging and discharging plan based on the photovoltaic power generation and the calibrated household load power consumption.

[0109] If both the first deviation and the second deviation are greater than or equal to the preset threshold, the controller calibrates the photovoltaic power generation and household load power consumption, and updates the charging and discharging plan based on the calibrated photovoltaic power generation and calibrated household load power consumption.

[0110] During the execution of the charge / discharge plan, the controller acquires the actual photovoltaic power generation in real time through the photovoltaic data acquisition module and collects the actual household load electricity consumption in real time through the smart meter, simultaneously calculating the first and second deviations. For example, if the photovoltaic power generation at 10:00 AM in historical data is 0.5 kWh, and the actual detected photovoltaic power generation at that time is 0.6 kWh, then the first deviation is 1.2; if the historical household load electricity consumption is 0.3 kWh, and the actual electricity consumption is 0.36 kWh, then the second deviation is 1.2.

[0111] When the first deviation is greater than or equal to a preset threshold, the controller calibrates the photovoltaic power generation based on the first deviation. When the second deviation is greater than or equal to the preset threshold, the controller calibrates the household load power consumption based on the second deviation. After calibration, the controller re-executes steps S102-S104 based on the calibrated photovoltaic power generation and the calibrated original household load power consumption to generate an updated charging and discharging plan.

[0112] This application's embodiments address the problem that purely historical data-driven plans are ill-suited to unforeseen circumstances by real-time monitoring of deviations, dynamic data calibration, and updated charging and discharging plans. This makes the charging and discharging strategy more flexible and adaptable. Whether it's fluctuations in power generation due to sudden changes in sunlight or load changes caused by sudden household electricity consumption, the system can respond promptly through rapid calibration and plan updates. This avoids ineffective discharges or high-priced electricity purchases due to data deviations, further achieving the core objective of minimizing total electricity costs and improving the reliability of the solution in complex real-world scenarios.

[0113] In the above-mentioned dynamic adjustment implementation method, the core of data calibration is to establish a correlation between actual data and historical data through deviation, so as to ensure that the calibrated data can accurately reflect the current working conditions.

[0114] Specifically, the controller calibrates the photovoltaic power generation based on the first deviation. The first deviation is the ratio of the actual photovoltaic power generation to the historical photovoltaic power generation, a core parameter used to quantify the degree of deviation between the actual and historical photovoltaic power generation. For example, if the actual photovoltaic power generation is 0.6 kWh and the historical photovoltaic power generation is 0.5 kWh, the first deviation is 1.2. The controller then calibrates the household electricity consumption based on the second deviation. The second deviation is also the ratio of the actual household electricity consumption to the historical household electricity consumption, a core parameter used to quantify the degree of deviation between the actual and historical household electricity consumption. For example, if the actual household electricity consumption is 0.36 kWh and the historical household electricity consumption is 0.3 kWh, the second deviation is 1.2.

[0115] It should be noted that when confirming the first or second deviation, it is necessary to determine it based on the actual data and historical data of the same period. For example, the first deviation can be confirmed based on the actual photovoltaic power generation at 10:00 AM on October 25 and the photovoltaic power generation at 10:00 AM on October 24, but it cannot be confirmed based on the actual photovoltaic power generation at 10:00 AM on October 25 and the photovoltaic power generation at 9:00 AM on October 24.

[0116] After determining the first and second deviations, the controller calibrates the photovoltaic power generation and household load power consumption.

[0117] For example, if the actual photovoltaic power generation at 10:00 AM is 0.6 kWh, and the first deviation is 1.2, then the photovoltaic power generation is calibrated to adjust to 0.6 kWh. The controller reconstructs and solves the objective function, increasing battery charging during this period to avoid wasting excess photovoltaic energy. Similarly, if the actual household electricity consumption at 10:00 AM is 0.36 kWh, and the second deviation is 1.2, then the household electricity consumption is calibrated to adjust to 0.36 kWh. The controller reconstructs and solves the objective function, increasing battery discharge during the corresponding period to reduce the need for expensive grid electricity purchases.

[0118] Based on the above method embodiments, this application also provides a charge and discharge optimization device for a home photovoltaic energy storage system, such as... Figure 2 As shown, the device includes:

[0119] The acquisition module 201 is used to acquire the photovoltaic power generation and household load electricity consumption for each hour within a historical preset number of days, and to acquire time-of-use electricity price data;

[0120] The construction module 202 is used to construct an objective function for linear programming based on the time-of-use electricity price data; wherein the objective function is used to represent the total cost for users to purchase electricity from the grid within a preset time period in the future;

[0121] The calculation module 203 is used to solve the objective function under constraints to determine the future battery charging amount and future battery discharging amount corresponding to each hour within the future preset time period, while minimizing the total cost of the user purchasing electricity from the grid within the future preset time period. The constraints include energy conservation constraints and battery remaining capacity constraints. The energy conservation constraint requires that the photovoltaic power generation, battery discharging amount, net electricity purchased by the user from the grid, household load electricity consumption, and battery charging amount satisfy energy balance. The battery remaining capacity constraint requires that the battery remaining capacity be within a preset range at any given time.

[0122] The optimization module 204 is used to determine a charging and discharging plan for a future preset duration based on the future battery charging amount and the future battery discharging amount.

[0123] In one possible implementation, the objective function is the sum of the electricity purchase costs from the grid by users over multiple hours within a future preset time period, and the electricity purchase costs from the grid by users in each hour are determined based on the amount of electricity purchased from the grid by users and the time-of-use electricity price data.

[0124] The objective function is expressed as:

[0125] ;

[0126] in, This indicates the preset future duration. For users in hour t, electricity is purchased from the grid. Let t be the time-of-use electricity price for the t-th hour.

[0127] In one possible implementation, the energy conservation constraint is expressed as:

[0128] ;

[0129] in, Let be the photovoltaic power generation in hour t. Let be the battery discharge amount in hour t. For users in hour t, electricity is purchased from the grid. For users selling electricity to the grid in hour t, Let t be the household load electricity consumption in hour t. Let t be the amount of battery charge in hour t. The difference between the amount of electricity purchased by the user from the grid in hour t and the amount of electricity sold by the user to the grid in hour t is the net amount of electricity purchased by the user from the grid in hour t, where t is a positive integer.

[0130] In one possible implementation, the battery remaining capacity constraint is expressed as:

[0131] ;

[0132] in, Let be the battery capacity at hour t. The battery capacity at hour t-1. Let be the battery discharge amount in hour t. The amount of battery charge in hour t. This refers to the battery's rated capacity.

[0133] In one possible implementation, the calculation module 203 is specifically used to solve the objective function using a linear programming solver library under the constraints of the constraints; wherein the linear programming solver library includes algorithms for solving the objective function under the corresponding constraints.

[0134] In one possible implementation, the optimization module 204 is further configured to detect in real time the first deviation between the actual photovoltaic power generation and the photovoltaic power generation, and to detect in real time the second deviation between the actual household load electricity consumption and the household load electricity consumption.

[0135] If the first deviation is greater than or equal to a preset threshold, the photovoltaic power generation is calibrated, and the charging and discharging plan is updated based on the household load electricity consumption and the calibrated photovoltaic power generation.

[0136] Alternatively, if the second deviation is greater than or equal to the preset threshold, the household load power consumption is calibrated, and the charging and discharging plan is updated based on the photovoltaic power generation and the calibrated household load power consumption;

[0137] Alternatively, if both the first deviation and the second deviation are greater than or equal to the preset threshold, the photovoltaic power generation and the household load power consumption are calibrated, and the charging and discharging plan is updated based on the calibrated photovoltaic power generation and the calibrated household load power consumption.

[0138] In one possible implementation, the optimization module 204 is specifically used to calibrate the photovoltaic power generation based on a first deviation, wherein the first deviation is the ratio of the actual photovoltaic power generation to the photovoltaic power generation; and to calibrate the household load electricity consumption based on a second deviation, wherein the second deviation is the ratio of the actual household load electricity consumption to the household load electricity consumption.

[0139] This application also provides a control device. The control device may include a memory and a processor. The processor is used to execute the charge and discharge optimization method for the home photovoltaic energy storage system described in any of the above embodiments. The memory may be random access memory (RAM), flash memory, read-only memory (ROM), non-volatile read-only memory (EPROM), registers, hard disk, removable disk, etc.

[0140] The memory can store computer instructions. When these instructions are executed by the processor, the processor can use them to implement charging and discharging optimization methods for a home photovoltaic energy storage system. The memory can also store data.

[0141] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape) or a semiconductor medium (e.g., solid-state disk (SSD)).

[0142] This application also provides a readable storage medium for storing the methods provided in the above embodiments. For example, RAM, flash memory, ROM, EPROM, registers, hard disk, removable disk, or any other form of storage medium in the art.

[0143] In the embodiments of this application, the terms "first" and "second" (if they exist) are used only as name identifiers and do not represent the order of first and second.

[0144] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. Regarding the methods disclosed in the embodiments, since they correspond to the product embodiments disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the description of the product embodiments.

[0145] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for optimizing the charging and discharging of a household photovoltaic energy storage system, characterized in that, The method includes: Obtain the photovoltaic power generation and household load electricity consumption for each hour within a preset number of historical days, and obtain time-of-use electricity price data; A linear programming objective function is constructed using the time-of-use electricity price data; wherein, the objective function represents the total cost for users to purchase electricity from the grid within a preset time period in the future; Under the constraints, the objective function is solved to determine the future battery charging and discharging amounts for each hour within the future preset time period, while minimizing the user's total cost of purchasing electricity from the grid. The constraints include energy conservation constraints and battery remaining capacity constraints. The energy conservation constraint requires that the photovoltaic power generation, battery discharging, net electricity purchase from the grid, household load electricity consumption, and battery charging amount satisfy an energy balance. The battery remaining capacity constraint requires that the battery remaining capacity be within a preset range at any given time. A charging and discharging plan for a preset duration is determined based on the future battery charging amount and the future battery discharging amount.

2. The method according to claim 1, characterized in that, The objective function is the sum of the electricity purchase costs from the grid by users over multiple hours within a preset time period in the future. The electricity purchase costs from the grid by users in each hour are determined based on the amount of electricity purchased from the grid by users and the time-of-use electricity price data. The objective function is expressed as: ; in, This indicates the preset future duration. For users in hour t, electricity is purchased from the grid. Let t be the time-of-use electricity price for the t-th hour.

3. The method according to claim 1, characterized in that, The energy conservation constraint is expressed as follows: ; in, Let be the photovoltaic power generation in hour t. Let be the battery discharge amount in hour t. For users in hour t, electricity is purchased from the grid. For users selling electricity to the grid in hour t, Let t be the household load electricity consumption in hour t. Let t be the amount of battery charge in hour t. The difference between the amount of electricity purchased by the user from the grid in hour t and the amount of electricity sold by the user to the grid in hour t is the net amount of electricity purchased by the user from the grid in hour t, where t is a positive integer.

4. The method according to claim 1, characterized in that, The remaining battery capacity constraint is expressed as follows: ; in, Let be the battery capacity at hour t. The battery capacity at hour t-1. Let be the battery discharge amount in hour t. The amount of battery charge in hour t. This refers to the battery's rated capacity.

5. The method according to claim 1, characterized in that, Solving the objective function under the constraints includes: The objective function is solved using a linear programming solver library under the constraints stated therein; wherein the linear programming solver library includes algorithms for solving the objective function under the corresponding constraints.

6. The method according to claim 1, characterized in that, The method further includes: The system detects the first deviation between the actual photovoltaic power generation and the photovoltaic power generation in real time, and also detects the second deviation between the actual household load electricity consumption and the household load electricity consumption in real time. If the first deviation is greater than or equal to a preset threshold, the photovoltaic power generation is calibrated, and the charging and discharging plan is updated based on the household load electricity consumption and the calibrated photovoltaic power generation. Alternatively, if the second deviation is greater than or equal to the preset threshold, the household load power consumption is calibrated, and the charging and discharging plan is updated based on the photovoltaic power generation and the calibrated household load power consumption; Alternatively, if both the first deviation and the second deviation are greater than or equal to the preset threshold, the photovoltaic power generation and the household load power consumption are calibrated, and the charging and discharging plan is updated based on the calibrated photovoltaic power generation and the calibrated household load power consumption.

7. The method according to claim 6, characterized in that, The calibration of the photovoltaic power generation includes: The photovoltaic power generation is calibrated based on a first deviation; wherein the first deviation is the ratio of the actual photovoltaic power generation to the photovoltaic power generation. The calibration of the household load power consumption includes: The household load power consumption is calibrated based on the second deviation; wherein the second deviation is the ratio of the actual household load power consumption to the household load power consumption.

8. A charge / discharge optimization device for a household photovoltaic energy storage system, characterized in that, The device includes: The acquisition module is used to acquire the photovoltaic power generation and household load electricity consumption for each hour within a historical preset number of days, and to acquire time-of-use electricity price data; A construction module is used to construct an objective function for linear programming based on the time-of-use electricity price data; wherein, the objective function is used to represent the total cost for users to purchase electricity from the grid within a preset time period in the future; The calculation module is used to solve the objective function under constraints to determine the future battery charging and discharging amounts for each hour within the future preset time period, while minimizing the user's total cost of purchasing electricity from the grid within the future preset time period. The constraints include energy conservation constraints and battery remaining capacity constraints. The energy conservation constraint requires that the photovoltaic power generation, battery discharging, net electricity purchase from the grid, household load electricity consumption, and battery charging amount satisfy energy balance. The battery remaining capacity constraint requires that the battery remaining capacity be within a preset range at any given time. An optimization module is used to determine a charging and discharging plan for a preset duration based on the future battery charging amount and the future battery discharging amount.

9. A control device, characterized in that, It includes a processor and a memory, the memory being used to store programs, instructions, or code, and the processor being used to execute the programs, instructions, or code in the memory to complete the charging and discharging optimization method for a home photovoltaic energy storage system as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The system contains a computer program that is loaded by a processor to execute the charge and discharge optimization method for a home photovoltaic energy storage system as described in any one of claims 1-7.