Skip to content

Commit

Permalink
Merge pull request #295 from AlbertoCuadra/develop
Browse files Browse the repository at this point in the history
Solve: error with the previous changes done in shock polar
  • Loading branch information
AlbertoCuadra committed Mar 24, 2022
2 parents 91256f8 + 4353deb commit 0c38661
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
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

0 comments on commit 0c38661

Please sign in to comment.