Project

Air standard Cycle, obtaining the graph using the matlab

clear all
close all
clc

%inputs
gamma= 1.4
t3=2300

%state variables at state 1
p1 = 101325
t1 = 500

%Engine geometric parameters
bore= 0.1;
stroke=0.1;
con_rod= 0.15;
cr=12;

%calculataing the swept and clearance volume
v_swept= (pi/4)*bore^2*stroke;
v_clearance= v_swept/(cr-1);

v1=v_swept + v_clearance
v2=v_clearance

% state variable in state point 2
% p2v2^gamma=p1v1^gamma
% p2= p1*(v1/v2)^gamma=p1*cr^gamma
p2=p1*cr^gamma;

%using ideal gas eqn of p1v1/t1=p2v2/t2
t2= (p2*v2*t1)/(p1*v1)

%constant_c is a point and to find each value from state 1 to 2 we can use the condition of P*V^gamma=constant as per the requirement.

constant_c=p1*v1^gamma;

%calling a function that evaluates the volume of with respect to the piston kinematics by taking the inputs of bore, stroke, connectinf rod length, compression ratio, start and end angle of the crank.

V_compression=engine_kinematics(bore,stroke,con_rod,cr,180,360);
%V_expansion is an array so dot operator is used to acces each element in the array
P_compression=constant_c./V_compression.^gamma


% state variable at state point 3
v3=v2

% using ideal gas law again
p3=p2*t3/t2

%constant_c is a point and to find each value from state 3 to 4 we can use the condition of P*V^gamma=constant as per the requirement.

constant_c=p3*v3^gamma;

%calling a function that evaluates the volume of with respect to the piston kinematics by taking the inputs of bore, stroke, connectinf rod length, compression ratio, start and end angle of the crank.

V_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180);
%V_expansion is an array so dot operator is used to acces each element in the array
P_expansion=constant_c./V_expansion.^gamma

%state variable at state point 4
v4=v1
%from state 3-4, p3*v3^gamma=p4*v4^gamma
p4= p3*(v3/v4)^gamma

%Ploting the points of the states and joining them using the function
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([v2 v3],[p2 p3],'color','r')
plot(V_expansion, P_expansion)
plot(v4,p4,'*','color','r')
plot([v4 v1],[p4 p1],'color','r')
xlabel('volume')
ylabel('pressure')
legend('P-V graph for the otto cycle engine')

%thermal efficiency if the otto cycle engine to be calculated
thermal_eff=1-(1/cr^(gamma-1))

%figure(2)
%plot([v1 v2 v3 v4 v1],[p1 p2 p3 p4 p1],'color','b')

%end of the main program


%function for the engine_kinematics

function [V]= engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)

a=stroke/2
% crankpin radius
R=con_rod/a 
%ratio of connecting rod length to the crankpin radius.

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

The code consists of the function as well with the main program with the explanantion with the comments for the steps.

Initially the variables as input are mentioned in the code, later the variables at each stage are found using the mathematical equations. The graph was obtained as a function of the volume variation with respect to the piston kinematics in order get the correct PV graph for the proposed otto cycle engine with the perfect area and efficiency.

Output graph for the code written above.

Outputs obtained

Thermal Efficiency = 0.6299 i.e. equal to about 63%.

Errors faced

-variable errors i.e. using which aren't defined.

-wrong syntax for the linspace

Steps to overcome

-changing the variables as per the required definition.

-using the right syntax for linspace i.e. (start of interval,end of interval, number of terms in the interval)

Error showing in the command window (Screenshots)

Screen shot showing the obtained plot and also the efficiency of the engine.

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.