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

Update: improve plots polar shocks and solve some minor bugs #235

Merged
merged 5 commits into from
Mar 18, 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
9 changes: 5 additions & 4 deletions Examples/Example_SHOCK_OBLIQUE.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
% -------------------------------------------------------------------------

%% INITIALIZE
self = App('Air');
self = App('Air_ions');
%% INITIAL CONDITIONS
self = set_prop(self, 'TR', 300, 'pR', 1 * 1.01325);
self.PD.S_Oxidizer = {'O2'};
self.PD.S_Inert = {'N2', 'Ar', 'CO2'};
self.PD.proportion_inerts_O2 = [78.084, 0.9365, 0.0319] ./ 20.9476;
self.PD.S_Inert = {'N2'};
self.PD.proportion_inerts_O2 = 79/21;
%% ADDITIONAL INPUTS (DEPENDS OF THE PROBLEM SELECTED)
self = set_prop(self, 'u1', 1500);
overdriven = 2:2:14;
self = set_prop(self, 'u1', 3.477205457292110e+02 * overdriven);
%% SOLVE PROBLEM
self = SolveProblem(self, 'SHOCK_OBLIQUE');
%% DISPLAY RESULTS (PLOTS)
Expand Down
6 changes: 3 additions & 3 deletions Settings/functions/check_inputs.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
case 'SV' % * SV: Isentropic (i.e., fast adiabatic) compression/expansion to a specified v
self = check_inputs_prop(self, 'vP_vR');
self = set_prop(self, 'pP', self.PD.pR.value); % Guess
case 'SHOCK_I' % * SHOCK_I: CALCULATE PLANAR INCIDENT SHOCK WAVE
case {'SHOCK_I', 'SHOCK_R'} % * SHOCK_I and SHOCK_R: CALCULATE PLANAR SHOCK WAVE
self = check_inputs_prop(self, 'u1');
case 'SHOCK_R' % * SHOCK_R: CALCULATE PLANAR POST-REFLECTED SHOCK STATE
case 'SHOCK_OBLIQUE' % * SHOCK_OBLIQUE: CALCULATE OBLIQUE SHOCK WAVE
self = check_inputs_prop(self, 'u1');
case 'DET_OVERDRIVEN' % * DET_OVERDRIVEN: CALCULATE OVERDRIVEN DETONATION
case {'DET_OVERDRIVEN', 'DET_OVERDRIVEN_R'} % * DET_OVERDRIVEN: CALCULATE OVERDRIVEN DETONATION
self = check_inputs_prop(self, 'overdriven');
end
end
Expand Down
25 changes: 11 additions & 14 deletions Solver/Shocks and detonations/shock_oblique.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
% Definitions
a1 = soundspeed(str1);
u1 = str1.u;
M1 = u1/a1;
step = 1;
w1 = linspace(a1, u1, round((u1 - a1) / step));
N = length(w1);
Expand Down Expand Up @@ -39,38 +40,34 @@
% Save results
str1.beta = beta(end) * 180/pi; % [deg]
str1.theta = theta(end) * 180/pi; % [deg]
str1.theta_max = theta_max; % [deg]
str1.theta_sonic = theta_sonic; % [deg]
% Plot (pressure, deflection)† - shock polar
mainfigure = figure; hold on;
tiledlayout(mainfigure, 'flow');
nexttile;
ax = gca;
str1.theta_max = theta_max; % [deg]
str1.theta_sonic = theta_sonic; % [deg]
% Plot (pressure, deflection) - shock polar
figure(1); ax = gca;
set(ax, 'LineWidth', config.linewidth, 'FontSize', config.fontsize-2, 'BoxStyle', 'full')
grid(ax, 'off'); box(ax, 'off'); hold(ax, 'on'); ax.Layer = 'Top';

plot(ax, 180*theta/pi, p2,'LineWidth', config.linewidth);
plot(ax, [-flip(theta), theta] * 180/pi, [flip(p2), p2], 'k', 'LineWidth', config.linewidth);
plot(ax, theta_max, p2(ind_max), 'ko', 'LineWidth', config.linewidth, 'MarkerFaceColor', 'auto');
plot(ax, theta(ind_sonic) * 180/pi, p2(ind_sonic), 'ks', 'LineWidth', config.linewidth, 'MarkerFaceColor', 'auto');
text(ax, 0, max(p2), strcat('$\mathcal{M}_1 = ', sprintf('%.2f', M1), '$'), 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'center', 'FontSize', config.fontsize-8, 'Interpreter', 'latex')
% text(ax, theta_max, p2(ind_max), 'detachment point \rightarrow m', 'HorizontalAlignment', 'right', 'FontSize', config.fontsize-8)
% text(ax, theta_sonic * 180/pi, p2(ind_sonic), 'sonic point \rightarrow s', 'HorizontalAlignment', 'right', 'FontSize', config.fontsize-8)
xlabel(ax, 'Deflection angle $[^\circ]$', 'FontSize', config.fontsize, 'Interpreter', 'latex');
ylabel(ax, 'Pressure [bar]','FontSize', config.fontsize, 'Interpreter', 'latex');
ylim(ax, [1, max(p2)]);
% Plot (wave angle, deflection)† - shock polar
nexttile;
ax = gca;
% Plot (wave angle, deflection) - shock polar
figure(2); ax = gca;
set(ax, 'LineWidth', config.linewidth, 'FontSize', config.fontsize-2, 'BoxStyle', 'full')
grid(ax, 'off'); box(ax, 'off'); hold(ax, 'on'); ax.Layer = 'Top';

plot(ax, 180*theta/pi, beta * 180/pi,'LineWidth', config.linewidth);
plot(ax, [-flip(theta), theta] * 180/pi, [flip(beta), beta] * 180/pi, 'LineWidth', config.linewidth);
plot(ax, theta_max, beta(ind_max) * 180/pi, 'ko', 'LineWidth', config.linewidth, 'MarkerFaceColor', 'auto');
plot(ax, theta(ind_sonic) * 180/pi, beta(ind_sonic) * 180/pi, 'ks', 'LineWidth', config.linewidth, 'MarkerFaceColor', 'auto');
xlabel(ax, 'Deflection angle $[^\circ]$','FontSize', config.fontsize, 'Interpreter', 'latex');
ylabel(ax, 'Wave angle $[^\circ]$','FontSize', config.fontsize, 'Interpreter', 'latex');
% Plot velocity components
nexttile;
ax = gca;
figure(3); ax = gca;
set(ax, 'LineWidth', config.linewidth, 'FontSize', config.fontsize-2, 'BoxStyle', 'full')
grid(ax, 'off'); box(ax, 'off'); hold(ax, 'on'); ax.Layer = 'Top';

Expand Down
10 changes: 5 additions & 5 deletions Solver/SolveProblem.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
catch
u1 = self.PD.u1.value;
end
if i==self.C.l_phi
[self.PS.strR{i}, self.PS.strP{i}] = shock_oblique(self, self.PS.strR{i}, u1);
else
[self.PS.strR{i}, self.PS.strP{i}] = shock_oblique(self, self.PS.strR{i}, u1, self.PS.strP{i+1});
end
% if i==self.C.l_phi
[self.PS.strR{i}, self.PS.strP{i}] = shock_oblique(self, self.PS.strR{i}, u1);
% else
% [self.PS.strR{i}, self.PS.strP{i}] = shock_oblique(self, self.PS.strR{i}, u1, self.PS.strP{i+1});
% end
case {'DET'}
if i==self.C.l_phi
[self.PS.strR{i}, self.PS.strP{i}] = cj_detonation(self, self.PS.strR{i});
Expand Down
Loading