forked from Energy-Storage-and-Transport/EST-model
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostprocessing.m
More file actions
113 lines (100 loc) · 3.11 KB
/
Copy pathpostprocessing.m
File metadata and controls
113 lines (100 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
% Post-processing script for the EST Simulink model. This script is invoked
% after the Simulink model is finished running (stopFcn callback function).
close all;
figure;
%% Supply and demand
subplot(2,2,1);
plot(tout/unit("day"), PSupply/unit("W"));
hold on;
plot(tout/unit("day"), PDemand/unit("W"));
xlim([0 tout(end)/unit("day")]);
grid on;
title('Supply and demand');
xlabel('Time [day]');
ylabel('Power [W]');
legend("Supply","Demand");
%% daily energy demand average
%avgSupply = mean(PSupply);
avgDemand = mean(PDemand);
%% Stored energy
subplot(2,2,2);
plot(tout/unit("day"), EStorage/unit("J"));
xlim([0 tout(end)/unit("day")]);
grid on;
title('Storage');
xlabel('Time [day]');
ylabel('Energy [J]');
%% Energy losses
subplot(2,2,3);
plot(tout/unit("day"), D/unit("W"));
xlim([0 tout(end)/unit("day")]);
grid on;
title('Losses');
xlabel('Time [day]');
ylabel('Dissipation rate [W]');
%% Load balancing
subplot(2,2,4);
plot(tout/unit("day"), PSell/unit("W"));
hold on;
plot(tout/unit("day"), PBuy/unit("W"));
xlim([0 tout(end)/unit("day")]);
grid on;
title('Load balancing');
xlabel('Time [day]');
ylabel('Power [W]');
legend("Sell","Buy");
%% Supply - Demand difference
PDiff = PSupply - PDemand;
tday = tout/unit("day");
PDiffW = PDiff/unit("W");
dt = tout(2) - tout(1); % [s]
ESurplus = sum(max(PDiff,0))*dt; % [J]
EDeficit = sum(max(-PDiff,0))*dt; % [J]
PeakSurplus = max(PDiff); % [W]
PeakDeficit = min(PDiff); % [W]
ESurplus_MWh = ESurplus / 3.6e9;
EDeficit_MWh = EDeficit / 3.6e9;
figure;
area(tday, PDiffW);
hold on;
yline(0, 'k--');
xlim([0 tday(end)]);
grid on;
title('Supply - Demand difference');
xlabel('Time [day]');
ylabel('Power difference [W]');
txt = sprintf([ ...
'Peak surplus: %.2e W\n' ...
'Peak deficit: %.2e W\n' ...
'Annual surplus: %.2f MWh\n' ...
'Annual deficit: %.2f MWh'], ...
PeakSurplus, PeakDeficit, ESurplus_MWh, EDeficit_MWh);
text(0.02*tday(end), 0.9*max(PDiffW), txt, ...
'FontSize', 10, ...
'BackgroundColor', 'white', ...
'EdgeColor', 'black', ...
'Margin', 6, ...
'VerticalAlignment', 'top');
%% Pie charts
% integrate the power signals in time
EfromSupplyTransport = trapz(tout, PfromSupplyTransport);
EtoDemandTransport = trapz(tout, PtoDemandTransport);
ESell = trapz(tout, PSell);
EBuy = trapz(tout, PBuy);
EtoInjection = trapz(tout, PtoInjection);
EfromExtraction = trapz(tout, PfromExtraction);
EStorageDissipation = trapz(tout, DStorage);
EDirect = EfromSupplyTransport - ESell - EtoInjection;
ESurplus = EtoInjection-EfromExtraction-EStorageDissipation;
figure;
tiles = tiledlayout(1,2);
ax = nexttile;
pie(ax, [EDirect, EtoInjection, ESell]/EfromSupplyTransport);
lgd = legend({"Direct to demand", "To storage", "Sold"});
lgd.Layout.Tile = "south";
title(sprintf("Received energy %3.2e [J]", EfromSupplyTransport/unit('J')));
ax = nexttile;
pie(ax, [EDirect, EfromExtraction, EBuy]/EtoDemandTransport);
lgd = legend({"Direct from supply", "From storage", "Bought"});
lgd.Layout.Tile = "south";
title(sprintf("Delivered energy %3.2e [J]", EtoDemandTransport/unit('J')));