Project

Program to solve otto cycle & calculating thermal efficiency & plot the graph

  • Function Code :
function[V] = piston_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)

a=stroke/2;
R=con_rod/a;

v_s=pi/4*bore^2*stroke;
v_c=v_s/cr-1;

theta=linspace(start_crank,end_crank,100)

term1=0.5*(cr-1);
term2=R+1-cosd(theta)
term3=(R^2-sind(theta).^2).^0.5

V=(1+term1*(term2-term3)).*v_c



end

Code Explanation:

I made a function that take input & assign value to output array. I have created a array for different theta values.

Combuction volume calculation done.

  • Code to creat P-V diagram & Thermal efficiency:
clear all
close all
clc

%Input
gamma=1.4;
T3=2300;
%State variables
P1=101325;
T1=500;

%Engine geometric parameter

bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=12;

% Calculating the swept volume and clearence volume
v_s=(pi/4)*bore^2*stroke;
v_c=v_s/(cr-1);

v1=v_s+v_c;
v2=v_c;

%state variable at state point 2
%P2v2^gamma=P1v1^gamma
%P2=P1*(v1/v2)^gamma =P1*cr^gamma
P2=P1*cr^gamma;

% P1v1/T1=P2v2/T2 |  T2=P2*v2*T1/(P1*v1)
T2=P2*v2*T1/(P1*v1);
constant_C=P1*v1^gamma;
V_compression=piston_kinematics(bore,stroke,con_rod,cr,180,0);
P_compression=constant_C./V_compression.^gamma;

%State variable at point 3
v3=v2;

%P3v3/T3=P2v2/T2 |  P3=P2*T3/T2
 P3 = P2*T3/T2;

constant_C=P3*v3^gamma;
V_expansion=piston_kinematics(bore,stroke,con_rod,cr,0,180);
P_expansion=constant_C./V_expansion.^gamma;

% State variable at state point 4
v4=v1;

%P3v3^gamma=P4v4  | P4=P3(v3/v4)^gamma
P4=P3*(v3/v4)^gamma;

%thermal_efficiency
thermal_efficiency=(1-(1/cr^(gamma-1)))*100;

figure(1)
hold on
plot(v1,P1,'*','color','r')
plot(V_compression,P_compression)
plot(v2,P2,'*','color','r')
plot(v3,P3,'*','color','r')
plot(V_expansion,P_expansion)
plot(v4,P4,'*','color','r')
xlabel('Volume')
ylabel('Pressure')
legend('isentropic compression','constant volume heat addition','isentropic expansion','constant volume heat rejection')

Code Explanation:

  1. Input values are given for gamma & T3 (temprature at pt 3).
  2. State Variables are defined. also engine geometry defined.
  3. calcuated swept volume & clearence volume.
  4. calculated pressure & volume at pt2.calculated V_compression by calling the function & P_compression
  5. calculated pressure & volume at pt3.
  6. calculated V_expansion & P_expansion.
  7. calculated pressure & volume at pt4.
  8. calculated thermal effiiency.
  9. Plot command used to plot PV diagram.

Result:

Output:

Thermal eficiency:

thermal_efficiency =

62.9893

Plot P-V diagram:

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.