MATLAB: Creating a matlab code to investigate various parameter combinations of a thermal efficiency gas turbine

energygas turbine

Having trouble creating a MATLAB code that gives me the three outcomes (back work ratio, thermal efficiency, and net work output) for all the combinations of the following parameters (a total of 432 combinations):
Tmax = [1500 2000 2500 3000];
pr = [6 12 15 18];
nc = [0.8 0.9 1.0];
nt = [0.8 0.9 1.0];
E = [0.8 0.9 1.0];
So far,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Objective:
% To determine the effects of pressure ratio, maximum/minimum temperature
% ratio, compressor efficiency, turbine efficiency, and regenarator
% effectiveness on the cycle thermal efficiency, net work output per unit
% mass, and back work ratio of a regenerator Brayton cycle. Treat the
% working fluid as air entering the compressor at 100 kPa, 300K. Use
% constant specific heats for air at an average temperature and other
% equations relating thermodynamic properties.
%
% =========================================================================
% Tmax - the maximum absolute temperature of the working fluid (air) in
% SI units
% T1 - the temperature of the working fluid as air enters the compressor
% Tavg - average temperature at which to use constant specific heats for
% air
% P - absolute pressure of the working fluid (air) in SI units
% dcp - specific heat of air at constant pressure per unit mole
% cp - specific heat of air at constant pressure per unit mass
% cv - specific heat of air at constant volume per unit mass
% R - gas constant of air
% k - specific heat ratio of air at average temperature
% M - Molar mass of air
% pr - Pressure ratio
% nc - Compressor adiabatic efficiency
% nt - Turbine adiabatic efficiency
% E - Regenarator effectiveness
% q_reg - actual heat transfer from exhaust gases to teh air in the
% regenerator
% wt_out- work output done by the turbine
% wc_in - work input done by the compressor
% wnet - net work output done by the gas turbine
% qin - the heat input
% Nth - thermal efficiency of the gas tubine
% r_bw - the ratio of the compressor work to the turbine work, called the
% back work ratio
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M = 28.97;
R = 0.287;
T1 = 300;
Tmax = [1500 2000 2500 3000];
pr = [6 12 15 18];
nc = [0.8 0.9 1.0];
nt = [0.8 0.9 1.0];
E = [0.8 0.9 1.0];
Tavg = (Tmax+300) ./ 2;
a=28.11; b=0.1967E-2; c=0.4802E-5; d=-1.966E-9;
dcp=(a+(b.*Tavg)+(c.*(Tavg.^2))+(d.*(Tavg.^3)));
cp = dcp./M;
cv = cp - R;
k = cp./cv;
T2s=T1.*(pr.^((k-1)./k));
T4s=Tmax.*((1./pr).^((k-1)./k));
for ii=1:1:3
T2(ii,1:4)=T1+((T2s-T1)./nc(ii))
T4(ii,1:4)=Tmax(1:4)-(nt(ii).*(Tmax(1:4)-T4s))
end
wc=cp(3).*(T2-T1)
wt=cp(2).*(-T4 + Tmax)
wnet = (wt - wc)
r_bw = wc./wt
q_reg = E(2)*cp.*(T4 - T2)
qin = (cp.*(Tmax(2) - T2)) - q_reg
*I seem to get only a 3*3 matrix for each output and I want is an array that displays an output for each combination of input *

Best Answer

thanks a lot it worked