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

Add: compute shock_oblique for a given deflection angle or for a given wave angle #267 #268

Merged
merged 1 commit into from
Mar 22, 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
7 changes: 4 additions & 3 deletions Examples/Example_SHOCK_OBLIQUE.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
% EXAMPLE: SHOCK_OBLIQUE
%
% Compute pre-shock and post-shock state for a oblique incident shock wave
% at standard conditions, a set of 20 species considered and a initial
% shock front velocities u1 = 1500 [m/s]
% at standard conditions, a set of 20 species considered, a initial
% shock front velocities u1 = a1 * 10 [m/s], and a deflection angle
% theta = 20 [deg]
%
% Air == {'O2','N2','O','O3','N','NO','NO2','NO3','N2O','N2O3','N2O4',...
% 'N3','C','CO','CO2','Ar','H2O','H2','H','He'}
Expand All @@ -27,7 +28,7 @@
self.PD.proportion_inerts_O2 = [78.084, 0.9365, 0.0319] ./ 20.9476;
%% ADDITIONAL INPUTS (DEPENDS OF THE PROBLEM SELECTED)
overdriven = 10;
self = set_prop(self, 'u1', 3.472107491008314e+02 * overdriven, 'theta', 51.2161);
self = set_prop(self, 'u1', 3.472107491008314e+02 * overdriven, 'theta', 20);
%% SOLVE PROBLEM
self = SolveProblem(self, 'SHOCK_OBLIQUE');
%% DISPLAY RESULTS (PLOTS)
Expand Down
4 changes: 4 additions & 0 deletions Settings/self/ProblemDescription/ProblemDescription.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
self.u1.value = []; % [m/s]
self.overdriven.description = "Overdriven shock velocity";
self.overdriven.value = []; % [-]
self.theta.description = "Deflection angle - oblique shocks";
self.theta.value = [];
self.beta.description = "Wave angle - oblique shocks";
self.beta.value = [];
self.S_Fuel = [];
self.N_Fuel = [];
self.T_Fuel = [];
Expand Down
55 changes: 55 additions & 0 deletions Solver/Shocks and detonations/shock_oblique_beta.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function [str1, str2] = shock_oblique_beta(varargin)
% Solve oblique shock for a given shock wave angle

% Unpack input data
[self, str1, str2] = unpack(varargin);
% Definitions
a1 = soundspeed(str1); % [m/s]
u1 = str1.u; % [m/s]
M1 = u1 / a1; % [-]
beta = str1.beta * pi/180; % [rad]
beta_min = asin(1/M1); % [rad]
beta_max = pi/2; % [rad]
w1 = u1 * sin(beta); % [m/s]
% Check range beta
if beta < beta_min || beta > beta_max
error('\nERROR! The given wave angle beta = %.2g is not in the range of possible solutions [%.2g, %2.g]', str1.beta, beta_min * 180/pi, beta_max * 180/pi);
end

% Obtain deflection angle, pre-shock state and post-shock states for an oblique shock
if ~contains(self.PD.ProblemType, '_R')
[~, str2] = shock_incident(self, str1, w1, str2);
else
[~, ~, str2] = shock_reflected(self, str1, str2.w2, str2);
end

w2 = str2.v_shock;
theta = beta - atan(w2 / (u1 .* cos(beta)));
u2 = w2 * csc(beta - theta);

% Save results
str2.beta = beta * 180/pi; % [deg]
str2.theta = theta * 180/pi; % [deg]
str2.beta_min = beta_min * 180/pi; % [deg]
str2.beta_max = beta_max * 180/pi; % [deg]
str2.u = u2; % [m/s]
str2.w2 = w2; % [m/s]
str2.v_shock = u2; % [m/s]
end

% SUB-PASS FUNCTIONS
function [self, str1, str2] = unpack(x)
% Unpack input data
self = x{1};
str1 = x{2};
u1 = x{3};
beta = x{4};
str1.u = u1; % velocity preshock [m/s] - laboratory fixed
str1.v_shock = u1; % velocity preshock [m/s] - shock fixed
str1.beta = beta; % wave angle [deg]
if length(x) > 4
str2 = x{5};
else
str2 = [];
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [str1, str2_1, str2_2] = shock_oblique(varargin)
function [str1, str2_1, str2_2] = shock_oblique_theta(varargin)
% Solve oblique shock

% Unpack input data
Expand Down Expand Up @@ -48,7 +48,7 @@
M2 = u2 / soundspeed(str2);

if STOP > TN.tol_oblique || beta < beta_min || beta > pi/2 || theta < 0 || M2 >= M1
error('There is not solution for the given deflection angle');
error('There is not solution for the given deflection angle %.2g', str1.theta);
end

% Save results
Expand Down
22 changes: 15 additions & 7 deletions Solver/SolveProblem.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,24 @@
case {'SHOCK_OBLIQUE'}
try
u1 = self.PD.u1.value(i);
theta = self.PD.theta.value;
catch
u1 = self.PD.u1.value;
theta = self.PD.theta.value;
end
% if i==self.C.l_phi
[self.PS.strR{i}, self.PS.str2{i}, self.PS.strP{i}] = shock_oblique(self, self.PS.strR{i}, u1, theta);
% else
% [self.PS.strR{i}, self.PS.strP{i}] = shock_oblique(self, self.PS.strR{i}, u1, self.PS.strP{i+1});
% end
if ~isempty(self.PD.theta.value)
try
theta = self.PD.theta.value(i);
catch
theta = self.PD.theta.value;
end
[self.PS.strR{i}, self.PS.str2{i}, self.PS.strP{i}] = shock_oblique_theta(self, self.PS.strR{i}, u1, theta);
else
try
beta = self.PD.beta.value(i);
catch
beta = self.PD.beta.value;
end
[self.PS.strR{i}, self.PS.strP{i}] = shock_oblique_beta(self, self.PS.strR{i}, u1, beta);
end
case {'SHOCK_OBLIQUE_R'}
try
u1 = self.PD.u1.value(i);
Expand Down