Hey guys, I have a problem. Im writing a code that models engine thrust over an altitude range. It runs ok when i keep a variable constant, 'gamma', but when its varied, it dosent run. Can someone help?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clc
clear
z = 0:1:100;
[T,P,rho,del,sig,the]= atmosi_100(z);
%% constants
r_o = 6.371e7; % earth radius, m
g_o = 9.81; % gravity, m/s^2
%T/W = F_req/(m_e*9.81);
D = 100; % Drag, N, from aero
m_i = 12000; % initial wet mass, kg
P_c = 2.233e7; % ambient pressure, Pa
g = 9.81; % gravitational acceleration, m/s^2
R = 287; % gas constatnt, J/kg*K
A_e = 1.1; % exit area, m^2
% From App.B
T_c = 3400; % temp, K
gamma = 1.2:0.05:1.4;
Mol = 13.5; % molecular mass, kg/kmol
v_o = 10; % inicial velocity, m/s
time = 140; % time to seperation, s
%% Inputs
F_req = 1334466; % required thrust, N (from Performance)
%% Engine characteristics/SSME design point
% assuming combustion efficiency of 1.0
ex = 77.5;
P_c = 2.2339e+7; % chamber pressure, Pa
A_t = (ex.^-1).*A_e; % throat area, m^2
epsilon = sqrt(gamma./(((gamma+1)./2).^((gamma+1)./(gamma-1))));
m_dot = P_c.*A_t.*g.*(epsilon./sqrt(R.*g.*T_c));
% assume f and I_sp
f = 6;
I_sp = 363;
% Newton-Raphson method for finding exit mach number
b = 2.*(gamma-1)./(gamma+1);
c = ((gamma+1)./(gamma-1)).*((ex).^(b));
d = 2./(gamma-1);
Me_0 = 7.5;
original = (c .* (Me_0 .^ b)) - (Me_0 .^ 2) - d;
derivative = (b .* c .* (Me_0 .^ (b - 1))) - (2 .* Me_0);
Me_1 = Me_0 - (original ./ derivative);
while abs(original) > 10^-2
Me_0 = Me_1;
original = (c .* (Me_0 .^ b)) - (Me_0 .^ 2) - d;
derivative = (b .* c .* (Me_0 .^ (b - 1))) - (2 .* Me_0);
Me_1 = Me_0 - (original ./ derivative);
fprintf('Iteration: M_e = %.20f, error = %.20f \n', Me_1, original);
end
mf_f = 1-exp(-(sqrt(g_o*r_o))./(I_sp*v_o*((1-D)/F_req))); % fuel mass fraction
mf = mf_f *m_i; % mass of fuel, kg,
P_e = P_c.*(1+((gamma-1)./2).*(Me_1.^2)).^(gamma./(1-gamma)); % exit static pressure, Pa
P_te = P_e./(1+((gamma-1)./(Me_1.^2))).^(-gamma./(gamma-1)); % exit total pressure, Pa
% using isentropic relations
T_e = ((P_e./P_te).*T_c.^(gamma./(gamma-1))).^(1./(gamma./(gamma-1)));
v_e = Me_0.*sqrt(gamma.*R.*T_e);
F_ava = (m_dot.*v_e) + (P_e-P).*(A_t.*ex);
S = (m_dot.*f)./F_ava; % specific fuel consumption, kg/s*N
S_t = (S.*F_ava).*time;
%% engine sizing
D_e = 0.00357.*F_ava+14.48; % engine diameter, m
m_e = F_ava./(g*0.0006098.*F_ava+13.44); % engine mass, kg
L_e = 0.000030*F_ava+327.7; % engine length, m
Lstar = 1; % characteristic length, m
A_c = A_t*(8*((2*sqrt(A_t/pi))^(-0.6)) + 1.25); % average combustion chamber cx area, m^2
L_c = Lstar*(A_t/A_c); % combusiton chamber length, m
V_c = Lstar*A_t; % combustion chamber volume, m^3
d_e = sqrt((4.*ex.*A_t)/pi); % exit diameter, m
%% Plots/outputs
fprintf('m_dot = %f [kg/s] \n',m_dot)
fprintf('v_e = %f [m/s] \n',v_e)
fprintf('V_c = %f [m^3] \n,',V_c)
fprintf('A_c = %f [m^2] \n', A_c)
fprintf('m_e = %f [kg] \n',m_e)
fprintf('L_e = %f [m] \n', L_e)
fprintf('D_e = %f [m]',D_e)
fprintf('L_c = %f [m] \n', L_c)
fprintf('S_t = %f [kg]\n', S_t)
% fprintf('m_f = %f [kg]\n', m_f)
figure(1)
plot(z,F_ava)
title('Avalible thrust vs. Altitude')
xlabel('Altitude (km)')
ylabel('F_ava (N)')
figure(2)
plot(z,S)
title('Specific fuel consimption vs. Altitiude')
xlabel('Altitude (km)')
ylabel('S (kg/s*N)')
%% Trade Studies
% plot(F_ava,gamma) % vary gamma from 1.2-1.4
11 commentaires
Walter Roberson
le 17 Nov 2018
Modifié(e) : Walter Roberson
le 18 Nov 2018
the code prompts 1 for si and 2 for imperial, and prompts for aa numeric height value . Then it tries to call atmos0_100 which we do not have the code for .
Réponses (2)
Ikenna Okoye
le 18 Nov 2018
6 commentaires
Walter Roberson
le 19 Nov 2018
"Total there are three code files: the one just mentioned, the atmosphere program it calls, atmosi0_100 and the propulsion code that I first posted in my question. "
"The one just mentioned" appears to be the script starting from "prompt =".
You seem to be saying that the atmosphere program it calls is the routine named atmosi0_100, which would be consistent for that script.
The propulsion code that you first posted appears to refer to the block of code that starts with
clc
clear
z = 0:1:100;
[T,P,rho,del,sig,the]= atmosi_100(z);
which calls atmosi_100 which is a different function, a fourth function.
Considering that the code posted first starts with "clear" then it would not appear to make sense to call the script first to establish any variables, as any variables would be erase by the clear. This suggests that the script that does the prompt is to be called at some point after the propulsion code, but the relationship between them is not obvious.
Voir également
Catégories
En savoir plus sur Localization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!