%%Plotting functions
clc
close all


% fileName = 'Y:\Agnes\From Mitch Paulus\PowerData.mat';
% load(fileName);

% chillerNumber = 4;
% chillerString = num2str(chillerNumber);


set(gcf,'Position',[0 0 1600 1000])
for chillerNumber = 1:5
    
    figure(chillerNumber)
    set(gcf,'Position',[15 30 1200 600])
    
    if chillerNumber == 5
        chillerString = '6';
    else
        chillerString = num2str(chillerNumber);
    end
    
    subplot(2,3,1)
    scatter(Qevap(:,chillerNumber),power(:,1,5,chillerNumber))
    hold on
    scatter(Qevap(:,chillerNumber),power(:,9,5,chillerNumber))
    
    title(horzcat('Chiller ',chillerString,', Approach = 5 F, 70,000 ft^{3}/hr'))
    legend('36 F','44 F','Location','Best')
    xlabel('Load (kBTU/hr)');
    ylabel('Power (kW)');
    axis([0 80000 0 5000]);
    
    
    
    subplot(2,3,4)
    scatter(TinCond-460,power(:,1,1,chillerNumber))
    hold on
    scatter(TinCond-460,power(:,1,11,chillerNumber))
    
    legend('50,000 ft^{3}/hr','100,000 ft^{3}/hr','Location','Best')
    xlabel('Inlet Condenser Temperature (F)');
    ylabel('Power (kW)');
    title(horzcat('Chiller ',chillerString,', Approach = 5 F, T_{out,Evap} = 36 F'))
    axis([50 90 0 5000]);
    
    subplot(2,3,2)
    scatter(Qevap(:,chillerNumber),power(:,1,1,chillerNumber))
    hold on
    scatter(Qevap(:,chillerNumber),power(:,1,11,chillerNumber))
    scatter(Qevap(:,chillerNumber),power(:,1,5,chillerNumber))
    legend('50,000 ft^{3}/hr','100,000 ft^{3}/hr','70,000 ft^{3}/hr','Location','Best')
    xlabel('Load (kBTU/hr)');
    ylabel('Power (kW)');
    title(horzcat('Chiller ',chillerString,', Approach = 5 F, T_{out,Evap} = 36 F'))
    axis([0 80000 0 5000]);
    subplot(2,3,5)
    scatter(Qevap(:,chillerNumber),power(:,9,1,chillerNumber))
    hold on
    scatter(Qevap(:,chillerNumber),power(:,9,11,chillerNumber))
    scatter(Qevap(:,chillerNumber),power(:,9,5,chillerNumber))
    
    legend('50,000 ft^{3}/hr','100,000 ft^{3}/hr','70,000 ft^{3}/hr','Location','Best')
    xlabel('Load (kBTU/hr)');
    ylabel('Power (kW)');
    title(horzcat('Chiller ',chillerString,', Approach = 5 F, T_{out,Evap} = 44 F'))
    axis([0 80000 0 5000]);
    
    
    subplot(2,3,3)
    scatter(Qevap(:,chillerNumber),power(:,9,11,chillerNumber))
    hold on
    scatter(Qevap(:,chillerNumber),ActualPower(:,chillerNumber))
    
    Residuals = ActualPower(:,chillerNumber) - power(:,9,11,chillerNumber);
    scatter(Qevap(:,chillerNumber),Residuals)
    leg = legend('Simulated Power','Actual Power','Act - Sim','Location','Best');
%     legPos = get(leg,'Position')
%     axis([0 80000 0 5000]);
%     set(leg,'Position',[0.7 0.38 legPos(3:4)]);
    
    title(horzcat('Chiller ',chillerString,', Approach = 5 F, T_{out,evap}=44, 100,000 ft^{3}/hr)'))
    
    ylabel('Power (kW)');
    xlabel('Load (kBTU/hr)');
    
    subplot(2,3,6)   
    scatter(Qevap(:,chillerNumber), Residuals ./ ActualPower(:,chillerNumber) .* 100)        
    axis([0 80000 -inf 50]);
%     set(leg,'Position',[0.7 0.38 legPos(3:4)]);
    
    title(horzcat('Chiller ',chillerString,', Approach = 5 F'))
    
    ylabel('Power Savings (%)');
    xlabel('Load (kBTU/hr)');
    
    
    
end


figure(6)
scatter(dTdata(:,1),DeltaT)
hold on
scatter(dTdata(:,1),dTdata(:,5))
xlabel('Load (kBTU/hr)');
ylabel('Delta T (F)');
axis([0 200000 0 25]);
legend('Simulated','Measured')
title('Secondary Loop Data, with T_{out,evap} = 44 F')


figure(7)
scatter(PlantFlow,DeltaT)
hold on
scatter(dTdata(:,4),dTdata(:,5))
xlabel('Flow (gpm)');
ylabel('Delta T (F)');
axis([-inf inf 0 25]);
legend('Simulated','Measured')
title('Secondary Loop, Calculated Flow, with T_{out,evap} = 44 F')


figure(8)
scatter(dTdata(:,1),PlantFlow)
hold on
scatter(dTdata(:,1),dTdata(:,4))
xlabel('Load (kBTU/hr)');
ylabel('Flow (gpm)');
legend('Simulated','Measured')
title('Secondary Loop Data, with T_{out,evap} = 44 F')

figure(9)
scatter(totalChillerLoad,totalChillerSavings)
hold on
scatter(dTdata(:,1),pumpSavings)
legend('Chiller Savings','Pump Costs','Location','Best')
xlabel('Plant Load (kBTU/hr)')
ylabel('Power Savings (kW)')
title('Savings from using 44 F and 100,000 ft^{3}/hr compared to measured data.')




figure(10)
scatter(dTdata(:,1),DeltaT)
hold on
scatter(dTdata(:,1),DeltaTwithCalcTwb)
xlabel('Load (kBTU/hr)');
ylabel('Delta T (F)');
axis([0 200000 0 25]);
legend('Actual Wet Bulb','Calculated From Plant Load')
title('Secondary Loop Data, with T_{out,evap} = 44 F')

figure(11)
scatter(totalChillerLoad,totalChillerSavingsPercent)
hold on
scatter(dTdata(:,1),pumpSavingsPercent)
legend('Chiller Savings','Pump Costs','Location','Best')
xlabel('Plant Load (kBTU/hr)')
ylabel('Power Savings (%)')
title('Savings from using 44 F and 100,000 ft^{3}/hr compared to measured data.')


print -f1 'Y:\Agnes\From Mitch Paulus\June 25 2014 Meeting\Chiller1.png' -dpng
print -f2 'Y:\Agnes\From Mitch Paulus\June 25 2014 Meeting\Chiller2.png' -dpng
print -f3 'Y:\Agnes\From Mitch Paulus\June 25 2014 Meeting\Chiller3.png' -dpng
print -f4 'Y:\Agnes\From Mitch Paulus\June 25 2014 Meeting\Chiller4.png' -dpng
print -f5 'Y:\Agnes\From Mitch Paulus\June 25 2014 Meeting\Chiller5.png' -dpng