% Code to plot simulation results from sscfluids_simple_cpu_cooling
%% Plot Description:
%
% The plot below shows the volumetric flow rate - pressure rise 
% characteristics of CPU fan.

% Copyright 2018 The MathWorks, Inc.

% Reuse figure if it exists, else create new figure
if ~exist('h1_sscfluids_simple_cpu_cooling', 'var') || ...
        ~isgraphics(h1_sscfluids_simple_cpu_cooling, 'figure')
    h1_sscfluids_simple_cpu_cooling = figure('Name', 'sscfluids_simple_cpu_cooling');
end
figure(h1_sscfluids_simple_cpu_cooling)
clf(h1_sscfluids_simple_cpu_cooling)

plotFanCharacteristics(omega_vec,flow_rate_TLU,dp_norm,dp_max_vec)

function plotFanCharacteristics(omega_vec,flow_rate_TLU,dp_norm,dp_max_vec)
% Fan characteristics
n = length(omega_vec);
legend_param = cell(size(omega_vec));
for i=1:n
   dp_vec = dp_max_vec(i) .* dp_norm(:);
   plot(flow_rate_TLU(i,:), dp_vec, '-o', 'LineWidth', 1)
   hold on
   % Print legend
   legend_param(i) = {['\omega = ', num2str(omega_vec(i)), ' (rpm)']};
end

% Plot fan characteristics
xlabel('Volumetric flow rate (l/min)')
ylabel('Pressure rise (Pa)')
legend(legend_param)
legend('boxoff')
title('Fan Characteristics')
grid on
hold off

end
