% Plot of results

% %% case 1
% 
% %results form optimal soultion day 1.
% load('plotres.mat')
% 
% %Plot optimal day1
% figure(1)
% plot(plotres.t,plotres.T-273, 'Linewidth',1.05)
% axis([0 24 40 100])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Temperature$,$[\circ C]$','Interpreter','latex','FontSize',14)
% title('$Water$ $temperature$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Location','NorthWest')
% 
% figure(2)
% plot(plotres.t,plotres.qhw_case,'Linewidth',1.0)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kWh]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Location','NorthWest')
% 
% figure(3)
% plot(plotres.t,plotres.JJ,'Linewidth',1.05)
% axis([0 24 0 7])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$J$,$[NOK]$','Interpreter','latex','FontSize',14)
% title('$Cost$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Location','NorthWest')
% 
% figure(4)
% plot(plotres.t,plotres.Tset-273, 'Linewidth',1.05)
% axis([0 24 40 100])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$T_{set}$,$[\circ C]$','Interpreter','latex','FontSize',14)
% title('$T_{set}$ $Profile$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Location','NorthWest')

% %% Plot case 2, Brute Force
% 
% load('plotres.mat')
% load('case1.mat')
% 
% figure(1)
% plot(plotres.t,plotres.T-273, 'Linewidth',1.05)
% hold on
% plot(case1.t,case1.T,'r', 'Linewidth',1.05)
% axis([0 24 40 100])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Temperature$,$[\circ C]$','Interpreter','latex','FontSize',14)
% title('$Water$ $temperature$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case I','Location','NorthWest')
% 
% 
% figure(2)
% plot(plotres.t,plotres.qhw_case,'Linewidth',1.0)
% hold on 
% plot(case1.t,case1.Q,'r','Linewidth',1.0)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kWh]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case I','Location','NorthWest')
% 
% figure(3)
% plot(plotres.t,plotres.JJ,'Linewidth',1.05)
% hold on 
% plot(case1.t,case1.J,'r','Linewidth',1.05)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kWh]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case I','Location','NorthWest')
% 
% %%
% 
% figure(2)
% plot(plotres.t,plotres.qhw_case,'Linewidth',1.0)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Location','NorthWest')
% 
% figure(4)
% plot(case1.t,case1.Q,'r','Linewidth',1.0)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Case I','Location','NorthWest')
% 


% %% Plot case 3, Tset=Tmax day 1.
% %results from case 3, Tset=Tmax, day 1.
% load('plotres3.mat')
% 
% 
% figure(1)
% plot(plotres.t,plotres.T-273, 'Linewidth',1.05)
% hold on
% plot(plotres3.t,plotres3.T-273,'r', 'Linewidth',1.05)
% axis([0 24 40 100])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Temperature$,$[\circ C]$','Interpreter','latex','FontSize',14)
% title('$Water$ $temperature$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case II','Location','NorthWest')
% 
% figure(2)
% plot(plotres.t,plotres.qhw_case)
% hold on
% plot(plotres3.t,plotres3.qhw_case,'r')
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kWh]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case II','Location','NorthWest')
% 
% 
% figure(3)
% plot(plotres3.t,plotres3.qhw_case,'r')
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Case II','Location','NorthWest')
% 
% figure(4)
% plot(plotres.t,plotres.qhw_case)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Location','NorthWest')
% 
% 
% figure(5)
% plot(plotres.t,plotres.JJ, 'Linewidth',1.05)
% hold on
% plot(plotres3.t,plotres3.JJ,'r', 'Linewidth',1.05)
% axis([0 24 0 7])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$J$,$[NOK]$','Interpreter','latex','FontSize',14)
% title('$Cost$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case II','Location','NorthWest')

%% plot case 4, different time intervals, day 1
%Time interval x71
load('plotres41')
%Time interval x72
load('plotres42')
%Time interval x73
load('plotres43')

figure(1)
plot(plotres.t,plotres.T-273)
hold on 
plot(plotres41.t,plotres41.T-273,'r')
hold on 
plot(plotres41.t,plotres42.T-273,'g')
hold on 
plot(plotres41.t,plotres43.T-273,'y')
axis([0 24 40 100])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$Temperature$,$[\circ C]$','Interpreter','latex','FontSize',14)
title('$Water$ $temperature$','Interpreter','latex','FontSize',14)
legend('Optimal Solution','Location','NorthWest')

figure(2)
plot(plotres.t,plotres.qhw_case)
hold on 
plot(plotres41.t,plotres41.qhw_case,'r')
hold on 
plot(plotres41.t,plotres42.qhw_case,'g')
hold on 
plot(plotres41.t,plotres43.qhw_case,'y')
axis([0 24 0 6])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$Q$,$[kWh]$','Interpreter','latex','FontSize',14)
title('$Heat$ $input$','Interpreter','latex','FontSize',14)
legend('Optimal Solution','Location','NorthWest')

figure(3)
plot(plotres.t,plotres.JJ)
hold on 
plot(plotres41.t,plotres41.JJ,'r')
hold on 
plot(plotres41.t,plotres42.JJ,'g')
hold on 
plot(plotres41.t,plotres43.JJ,'y')
axis([0 24 0 7])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$J$,$[NOK]$','Interpreter','latex','FontSize',14)
title('$Cost$','Interpreter','latex','FontSize',14)
legend('Optimal Solution','Location','NorthWest')

%% Case 5
load ('plotres')
load ('plotresdE')
load ('plotres5')
load ('plotres5dE')

%Plot optimal day1

figure(1)
plot(plotres.t,plotres.JJ,'Linewidth',1.05)
hold on 
plot(plotresdE.t,plotresdE.JJ,'r','Linewidth',1.5)
axis([0 24 0 7])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$J$,$[NOK]$','Interpreter','latex','FontSize',14)
title('$Cost$','Interpreter','latex','FontSize',14)
legend('Optimal Solution','Optimal soultion +\Delta E','Location','NorthWest')

figure(2)
plot(plotres5.t,plotres5.JJ,'Linewidth',1.05)
hold on 
plot(plotres5dE.t,plotres5dE.JJ,'r','Linewidth',1.5)
axis([0 24 0 8])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$J$,$[NOK]$','Interpreter','latex','FontSize',14)
title('$Cost$','Interpreter','latex','FontSize',14)
legend('Optimal Solution','Optimal solution +\Delta E','Location','NorthWest')


%% Plot of case 4, Pthreshold as decision variable

load ('plotres.mat')
load ('plotresPthres.mat')

figure(1)
plot(plotres.t,plotres.T-273,'Linewidth',1.05)
hold on
plot(plotresPthres.t,plotresPthres.T-273,'r','Linewidth',1.05)
hold on 
plot(case1.t,case1.T,'g', 'Linewidth',1.05)
axis([0 24 40 100])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$Temperature$,$[\circ C]$','Interpreter','latex','FontSize',14)
title('$Water$ $temperature$','Interpreter','latex','FontSize',14)
legend('Optimal Solution','Case III','Case I','Location','SouthWest')
% 
% figure(2)
% % plot(plotres.t,plotres.qhw_case)
% % hold on
% plot(plotresPthres.t,plotresPthres.qhw_case,'r')
% hold on
% plot(plotres.t,plotres.qhw_case,'g','Linewidth',1.0)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case IV','Location','NorthWest')

% figure(3)
% plot(plotres.t,plotres.JJ, 'Linewidth',1.05)
% hold on
% plot(plotresPthres.t,plotresPthres.JJ,'r', 'Linewidth',1.05)
% hold on 
% plot(case1.t,case1.J,'g','Linewidth',1.05)
% axis([0 24 0 7])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$J$,$[NOK]$','Interpreter','latex','FontSize',14)
% title('$Cost$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Case III','Case I','Location','NorthWest')

% figure(4)
% plot(plotresPthres.t,plotresPthres.qhw_case,'r')
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Case IV','Location','NorthWest')
% 
% figure(5)
% plot(plotres.t,plotres.qhw_case,'Linewidth',1.0)
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Optimal Solution','Location','NorthWest')
% 
% figure(6)
% plot(case1.t,case1.Q,'g')
% axis([0 24 0 6])
% xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
% ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
% title('$Heat$ $input$','Interpreter','latex','FontSize',14)
% legend('Case I','Location','NorthWest')
%%
figure(7)
plot(plotresPthres.t,plotresPthres.Pthres,'Linewidth',1.05)
hold on 
plot(plotres.t,plotres.p,'m','Linewidth',1.05)
axis([0 24 0.23 0.31])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$P_{threshold}$','Interpreter','latex','FontSize',14)
title('$P_{threshold}$,$  Profile$','Interpreter','latex','FontSize',14)
legend('Pthres., Case III','Electricity price, Case III','Location','SouthWest')

figure(8)
plot(plotresPthres.t,plotresPthres.Tset-273,'Linewidth',1.05)
axis([0 24 40 100])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$T_{set}$,$[\circ C]$','Interpreter','latex','FontSize',14)
title('$T_{set}$ $ Profile$','Interpreter','latex','FontSize',14)
legend('Case III','Location','SouthWest')

%% Plot of case 2 and case 4

load('plotres3.mat')
load('plotresdE.mat')


figure(1)
plot(plotresdE.t,plotresdE.T-273, 'Linewidth',1.05)
hold on
plot(plotres3.t,plotres3.T-273,'r', 'Linewidth',1.05)
axis([0 24 40 100])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$Temperature$,$[\circ C]$','Interpreter','latex','FontSize',14)
title('$Water$ $temperature$','Interpreter','latex','FontSize',14)
legend('Case IV','Case II','Location','NorthWest')

figure(2)
plot(plotresdE.t,plotresdE.JJ, 'Linewidth',1.05)
hold on
plot(plotres3.t,plotres3.JJ,'r', 'Linewidth',1.05)
axis([0 24 0 7])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$J$,$[NOK]$','Interpreter','latex','FontSize',14)
title('$Cost$','Interpreter','latex','FontSize',14)
legend('Case IV','Case II','Location','NorthWest')


%% Plot of optimal operation with dE in January

load ('plotres.mat')
load('plotresJan.mat')

figure(1)
%plot(plotres.t,plotres.T-273, 'Linewidth',1.05)
%hold on
plot(plotresJan.t,plotresJan.T-273, 'Linewidth',1.05)
axis([0 24 40 100])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$Temperature$,$[\circ C]$','Interpreter','latex','FontSize',14)
title('$Water$ $temperature$','Interpreter','latex','FontSize',14)
legend('Optimal solution','January','Location','NorthWest','FontSize',14)

figure(2)
%plot(plotres.t,plotres.qhw_case,'r')
%hold on
plot(plotresJan.t,plotresJan.qhw_case,'Linewidth',1.0)
axis([0 24 0 6])
xlabel('$Time$,$[h]$','Interpreter','latex','FontSize',14)
ylabel('$Q$,$[kW]$','Interpreter','latex','FontSize',14)
title('$Heat$ $input$','Interpreter','latex','FontSize',14)
legend('Optimal Solution','Case IV','Location','NorthWest')
