Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve: error with the previous changes done in shock polar #295

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Validations/Functions/get_problems_solved.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
function value = get_problems_solved(mix, variable)
function value = get_problems_solved(varargin)
% Get problems solved based on the length of the given variable
for i=length(mix):-1:1
value(i) = length(mix{i}.(variable));

mix = varargin{1};
variable = varargin{2};
if nargin == 3
subvariable = varargin{3};
for i=length(mix):-1:1
value(i) = length(mix{i}.(variable).(subvariable));
end
else
for i=length(mix):-1:1
value(i) = length(mix{i}.(variable));
end
end
value = sum(value);
end
14 changes: 8 additions & 6 deletions Validations/Functions/plot_validation_shock_polar_SDToolbox.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
function [fig1, fig2] = plot_validation_shock_polar_SDToolbox(results_SDToolbox, config)
function [fig1, fig2] = plot_validation_shock_polar_SDToolbox(results_CT, results_SDToolbox, config)
% Plot numerical results obtained with SDToolbox, which use CANTERA as a thermochemical kernel.
% * Pressure ratio with the deflection angle [deg]
% * Wave angle [deg] with the deflection angle [deg]
nfrec = [2, 4, 7, 10];

fig1 = figure(1); ax1 = gca;
fig2 = figure(2); ax2 = gca;
set(fig1, 'position', [1921 -471 1080 1795]);
set(fig2, 'position', [1921 -471 1080 1795]);
% Set figures
fig1 = figure(1); set(fig1, 'position', [1921 -471 1080 1795]);
fig2 = figure(2); set(fig2, 'position', [1921 -471 1080 1795]);
% Shock polars from Combustion Toolbox
[ax1, ax2] = plot_shock_polar(results_CT, results_CT.PS.strR, results_CT.PS.strP);
% Shock polars from SDToolbox
nfrec = [2, 4, 7, 10]; % frec points SD Toolbox per case
for i=length(results_SDToolbox):-1:1
plot(ax1, results_SDToolbox{i}.theta(1:nfrec(i):end) * 180/pi, results_SDToolbox{i}.P2P1(1:nfrec(i):end), 'ko', 'LineWidth', config.linewidth, 'MarkerFaceColor', 'auto');
plot(ax2, results_SDToolbox{i}.theta(1:nfrec(i):end) * 180/pi, results_SDToolbox{i}.beta(1:nfrec(i):end) * 180/pi, 'ko', 'LineWidth', config.linewidth, 'MarkerFaceColor', 'auto');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
'S_Oxidizer', Oxidizer, 'S_Inert', Inert,...
'proportion_inerts_O2', proportion_inerts_O2, 'u1', u1,...
'tolN', tolN);
problems_solved = get_problems_solved(results_CT.PS.strP, 'theta_range');
problems_solved = get_problems_solved(results_CT.PS.strP, 'polar', 'theta');
% Load results SDToolbox
results_SDToolbox = load_struct(filename, 'data');
% Display validation (plot)
[fig1, fig2] = plot_validation_shock_polar_SDToolbox(results_SDToolbox, results_CT.Misc.config);
[fig1, fig2] = plot_validation_shock_polar_SDToolbox(results_CT, results_SDToolbox, results_CT.Misc.config);
% Save plots
folderpath = strcat(pwd,'\Validations\Figures\');
stack_trace = dbstack;
Expand Down