如何使电力需求代码接近现实?

问题描述 投票:0回答:1

我已经编写了一些烹饪用具的使用代码,该代码将在 500 万人口(100 万个家庭)的早餐、午餐和晚餐时间运行。目的是绘制 24 小时内的电力需求。

这是我编写的代码:

function [monthlyEnergyMWhcook,powerConsumptionMWcook] = Cooking()
% Constants for appliances (Watts)
ovenPower = 3000; % Watts (household appliance)
grillPower = 6000; % Watts (household appliance)
kettlePower = 2200; % Watts (household appliance)
toasterPower = 850; % Watts (household appliance)
microwavePower = 800; % Watts (household appliance)

% Daily usage durations in minutes, converted to number of intervals
ovenDuration = ceil((132 / 60) * (241 / 24)); % 2 hours and 12 minutes
grillDuration = ceil((126 / 60) * (241 / 24)); % 2 hours and 6 minutes
kettleDuration = ceil((11 / 60) * (241 / 24)); % 11 minutes
toasterDuration = ceil((9 / 60) * (241 / 24)); % 9 minutes
microwaveDuration = ceil((11 / 60) * (241 / 24)); % 11 minutes

% Time vector for 24-hour period (241 time steps)
timeVec = linspace(0, 24, 241);

% Initialize power consumption array
powerConsumption = zeros(1, length(timeVec));

% Define key meal preparation start times
breakfastStart = find(timeVec >= 7, 1); % 7 AM
lunchStart = find(timeVec >= 12, 1); % 12 PM
dinnerStart = find(timeVec >= 18, 1); % 6 PM

% Number of households
households = 1000000;  % Example number of households

% Appliance usage during typical meal times
% Breakfast usage
powerConsumption(breakfastStart:breakfastStart+kettleDuration-1) = (kettlePower+toasterPower+microwavePower) * households;
% Lunch usage
powerConsumption(lunchStart:lunchStart+ovenDuration-1) = ovenPower * households;

% Dinner usage
powerConsumption(dinnerStart:dinnerStart+grillDuration-1) = grillPower * households;

% Convert power consumption to MW
powerConsumptionMWcook = powerConsumption / 1000000; % Convert Watts to kW and then to MW

% Calculate total daily energy in MWh
totalEnergyMWh = sum(powerConsumptionMWcook) * (6 / 60); % Convert MW to MWh, accounting for 6 minutes per interval

% Print the total daily energy consumption
fprintf('Total daily energy consumed by cooking: %.2f MWh\n', totalEnergyMWh);
%Plotting the 24-hour power consumption for cooking
figure;
plot(timeVec, powerConsumptionMWcook);
xlabel('Time (Hours)');
ylabel('Power Consumption (MW)');
title('24-Hour Cooking Power Consumption in MW');
grid on;
%Constants
daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];  % Days in each month

% Daily energy consumption in MWh (from previous calculation)
dailyEnergyMWh = sum(powerConsumptionMWcook) * (6 / 60); % Recalculated to ensure accuracy

% Initialize monthly energy consumption array
monthlyEnergyMWhcook = zeros(1, 12);

% Calculate monthly energy consumption
for i = 1:12
    monthlyEnergyMWhcook(i) = dailyEnergyMWh * daysInMonth(i);
end

问题:

问题是我的代码同时启动每个设备,这意味着例如将运行 12 分钟的数百万个水壶同时启动,因此它会产生不代表现实的巨大电力需求峰值。

有谁知道如何在早餐时间(例如 8 点到 9 点之间)让所有水壶完成 12 分钟的使用,但从不同的时间步骤开始?

这是从代码中得到的图

This is the graph obtained from the code

我认为该图应该看起来像高斯曲线,但不确定。

我尝试对高斯曲线进行建模,但总日记能量增加了很多。

我一直在寻找如何实现我的想法,但我还没有找到解决方案。

我将不胜感激任何形式的帮助, 亲切的问候。

matlab graph constraints matlab-figure smoothing
1个回答
0
投票

为了解决同时使用设备的问题,您可以通过在早餐、午餐和晚餐时间窗口内引入随机偏移来模拟更真实的设备启动时间分布。您可以通过以下方式修改代码来实现此目的:

实现随机偏移的步骤 定义使用时段:指定早餐、午餐和晚餐的时间时段(例如,早餐为上午 7:00–9:00)。 随机启动时间:使用随机分布(例如均匀分布或高斯分布)来确定每个设备在定义的窗口内启动的时间。 调整能源计算:确保使用的总能源与您的初始假设保持一致。

这是更新后的代码片段:

function [monthlyEnergyMWhcook, powerConsumptionMWcook] = Cooking()
% Constants for appliances (Watts)
ovenPower = 3000; % Watts
grillPower = 6000; % Watts
kettlePower = 2200; % Watts
toasterPower = 850; % Watts
microwavePower = 800; % Watts

% Time vector for 24-hour period (241 time steps, 6-minute intervals)
timeVec = linspace(0, 24, 241);
numIntervals = length(timeVec);

% Number of households
households = 1000000;

% Initialize power consumption array
powerConsumption = zeros(1, numIntervals);

% Define meal preparation windows in hours
breakfastStart = 7;
breakfastEnd = 9;
lunchStart = 12;
lunchEnd = 14;
dinnerStart = 18;
dinnerEnd = 20;

% Function to distribute appliance usage within a window
function consumption = distributeUsage(power, durationMinutes, startHour, endHour, households)
    durationIntervals = ceil((durationMinutes / 60) * (numIntervals / 24));
    windowStart = find(timeVec >= startHour, 1);
    windowEnd = find(timeVec >= endHour, 1);
    windowLength = windowEnd - windowStart;

    % Generate random start times for each household
    randomOffsets = randi([0, windowLength - durationIntervals], households, 1);
    consumption = zeros(1, numIntervals);

    for i = 1:households
        startIndex = windowStart + randomOffsets(i);
        endIndex = startIndex + durationIntervals - 1;
        consumption(startIndex:endIndex) = consumption(startIndex:endIndex) + power;
    end
end

% Distribute usage for appliances
powerConsumption = powerConsumption + distributeUsage(kettlePower + toasterPower + microwavePower, 12, breakfastStart, breakfastEnd, households);
powerConsumption = powerConsumption + distributeUsage(ovenPower, 132, lunchStart, lunchEnd, households);
powerConsumption = powerConsumption + distributeUsage(grillPower, 126, dinnerStart, dinnerEnd, households);

% Convert power consumption to MW
powerConsumptionMWcook = powerConsumption / 1e6; % Watts to MW

% Calculate total daily energy in MWh
totalEnergyMWh = sum(powerConsumptionMWcook) * (6 / 60); % MW to MWh

% Print the total daily energy consumption
fprintf('Total daily energy consumed by cooking: %.2f MWh\n', totalEnergyMWh);

变更说明 随机启动时间:distributeUsage 在指定的时间窗口内分配设备使用情况,确保设备不会同时启动。 保持能源一致性:每个设备在其整个持续时间内运行,并且总能源保持准确。 改进的现实性:这种方法可以随着时间的推移平滑电力需求,避免不切实际的峰值并创建更自然的使用曲线。 生成的功耗图应该看起来更平滑,类似于每个用餐窗口内的高斯分布。如果您发现能源差异,请调整分配逻辑以更好地反映家庭行为。

© www.soinside.com 2019 - 2024. All rights reserved.