I am writing a code for and HCCI combustion engine and need to plot the effect of changing equivalence ratio in the range 0.3<phi<0.8. I have it set up in a loop with hold on so that it combines the points onto one graph, but my plot shows up empty?
Show older comments
for i = 1:np
theta(i) = 180+n*CR; %set crank to go from 180deg-540deg
V(i) = Vc*(1+0.5*(Rc-1)*(2+1-cosd(theta(i))-(4-sind(theta(i))^2)^0.5));
n = n+1;
end %solves for volume
P(1) = Pbdc;
T(1) = Tbdc;
gamma = 1.4;
%isentropic relation so solve for T and P using the following
set(gas,'T',T(1),'P',P(1),'X',x);
for phi = 0.3:.05:0.8
for i = 2:360/CR
t = 0;
dt = 8.33e-5;
set(gas,'T',T(i-1),'P',P(i-1));
r = Reactor(gas);
network = ReactorNet({r});
for n = 1:10
t = t+dt/10;
advance(network,t);
end
temp = temperature(r);
Pr = pressure(r);
P(i) = Pr*(V(i-1)/V(i))^gamma;
T(i) = temp*(V(i-1)/V(i))^(gamma-1);
end %Have T and P, now place them in arrays
subplot(2,1,1);
plot(phi,T);
xlabel('Equivalence Ratio (phi)');
ylabel('Temperature (K)');
hold on
subplot(2,1,2);
plot(phi,P);
xlabel('Equivalence Ratio (phi)');
ylabel('Pressure (Pa)');
hold on
end end
Accepted Answer
More Answers (0)
Categories
Find more on Thermodynamics and Heat Transfer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!