I seem to currently be banging my head against a brick wall as try as I might, I can not see my error here.
I am attempting to write a for
loop in MATLAB that uses the equation below (adiabatic compression) to calculate the new pressure after one degree of crankshaft rotation in a four stroke engine cycle.
P2 = P1 * (V2 / V1) ^2
I am using the calculated volume from the crank-slider model as an input. I have tried this is Excel and it works as expected and gives the overall max output correctly.
The for
loop in question is below;
Cyl_P = ones(720,1)
for i = (2:1:length(Cyl_V))'
Cyl_P(i,:) = Cyl_P(i-1,:) .* (Cyl_V(i,:) ./ Cyl_V(i-1,:)).^1.35
end
my aim is to use the first element of the vector Cyl_P
which is equal to one, as an input to the equation above, and multiply it by the second element of Cyl_V
divided by the first, and multiply the volume terms by 1.35
. that should calculate the second element of Cyl_P
. I would then like to feed that value back in to the same equation to calculate the third element and so on.
What am I missing?
I've put the full code below
Theta = deg2rad(1:1:720)'
Stroke = 82 / 1000
R = Stroke / 2
L = 90.5 / 1000
Bore = 71.9 / 1000
d_h = (R+L) - (R.*cos(Theta)) - sqrt(L.^2 - (R.*sin(Theta)).^2)
Pist_h = d_h
figure
plot(Pist_h)
Bore_A = (pi*Bore^2)/4
Swept_V = (Pist_h .* Bore_A)
Clear_V = max(Swept_V) / 10
Total_V = max(Swept_V) + Clear_V
Cyl_V = (Swept_V + Clear_V)
figure
plot(Cyl_V)
for ii = (2:1:length(Cyl_V))'
div_V(ii,:) = (Cyl_V(ii) ./ Cyl_V(ii-1,:)).^1.35
end
Cyl_P = ones(720,1)
for i = (2:1:length(Cyl_V))'
Cyl_P(i,:) = Cyl_P(i-1,:) .* (Cyl_V(i,:) ./ Cyl_V(i-1,:)).^1.35
end
figure
plot(Cyl_P)