Project

MATLAB PROGRAM FOR AIR STANDARD CYCLE CALCULATING THERMAL EFFICIENCY AND PLOTTING THE PV DIAGRAM. 12th February 2020

OVERVIEW :-

To inscribe a MATLAB program for plotting the volume–pressure loop (PV Diagram) & finding the thermal efficiency of the mechanism with respect to Otto cycle.

GOALS

  1. To plot PV Diagram , getting the right path curve after plotting the state points and determining it by correctly connecting the thermodynamic relationship with respect to compression and expansion process to the state points to get the right path curve.
  2. Applying the piston kinematics , determine how to change in volume occurs from top dead centre (TDC) to bottom dead centre (BDC) to get thermal efficiency.

SPECIFICATIONS

Piston Kinematics deals with reciprocating IC engines, in which the piston has the linear movement inside the cylinder & the crank mechanism transforms the linear motion of the piston into rotational motion of the crankshaft , in this kind of movement, the piston’s velocity goes through zero at the top dead center (TDC) and bottom dead center (BDC) positions.Here as using OTTO cycle we see the changes in the volume with respect to the crankshaft as explained to complete the goals and determine the process.

An Otto cycle is an engine cycle which is used on four-stroke petrol engines which ideally do combustion and rejection of heat both and take place at constant volume and the operation involving four strokes of the piston: induction, compression, ignition, and exhaust.

In general the thermal efficiency of any heat engine is defined as the ratio of work it does, W, to the heat input at the high temperature, QH.

The thermal efficiency, ηth, represents the fraction of heat, QH, that is converted to work. Since energy is conserved according to the first law of thermodynamics and energy cannot be converted to work completely, the heat input, QH, must equal the work done, W, plus the heat that must be dissipated as waste heat QC into the environment. Therefore we can rewrite the formula for thermal efficiency as:

The heat absorbed occurs during combustion of fuel-air mixture, when the spark occurs, roughly at constant volume. Since during an isochoric process there is no work done by or on the system, the first law of thermodynamics dictates ∆U = ∆Q. Therefore the heat added and rejected are given by:

Qadd = mcv (T3 – T2)

Qout = mcv (T4 – T1)

Substituting these expressions for the heat added and rejected in the expression for thermal efficiency.

As we simplify the above expression using the fact that the processes 1 → 2 and from 3 → 4 are adiabatic and for an adiabatic process the following p,V,T formula is valid:

It can be derived that:

Here the ratio V1/V2 is known as compression ratio, (CR). When we rewrite the expression for thermal efficiency using the compression ratio, the Otto cycle thermal efficiency is a function of compression ratio and κ = cp/cv.

It’s specified that the thermal efficiency is with respect to the efficiency of the otto cycle, and also need to be described the input of the state points to get path curve so in program coding we will use all the four processes in the ideal otto cycle.

As elaborated while instruction to make a program , use the formula to find out the volume of the cylinder at respective crank positions so we get the related answers.

As this equation help us to find thermal efficiency ,

Now getting to the point of the program we require input that are described as following.

Consideration in the valves of otto cycle :

Initial temperature (t1) :- 500 K

Initial pressure (p1) :- 180497 kPa

gamma=k=1.4 (heat capacity at constant pressure & constant volume (cp/cv))

bore = 10; (diameter of bore)

stroke = 15; (diameter of stroke)

con_rod = 50; (diameter of connecting rod)

cr=7; (compression ratio)

PROGRAM STRIDES :-

In this matlab coding we will stride down two programs , one by one and get the outputs.

⤵️ Firstally writing the matlab code for getting plots of PV Diagram of Otto Cycle and using the data to find thermal efficiency and also the volume with respect to the crankshaft.

% Program to plot PV Diagram of Otto Cycle 

clear all
close all
clc

%inputs according to the specifications

bore = 10; %diameter of bore
stroke = 15; %diameter of stroke
con_rod = 50; %diameter of connnecting rod
k=1.4; %heat capacity at constant pressure & constant volume (cp/cv)
cr=7; %compression ratio

%calculating swept and clearance volume of v1 & v2

v_swept = (pi/4)*bore^2*stroke;

t1=500; %inital temperture or exhaust temperture on intake stroke
p1=180497;%inital pressure

v_clearance=v_swept/(cr-1);

%As we known total volume (V1)is equal to clearance volume (v_clearance) and swept
%volume (v_swept)& clearnance volume is equal to v2.

v1=v_clearance+v_swept;
v2=v_clearance;

t3=700;%exhaust gas temperture at end process of the cycle

%formula to find valves of p2,p3,p4,t2,v3,v4 using gas law
p2=p1*cr^k;
t2=p2*v2*t1/(p1*v1);
v3=v2;
p3=p2*t3/t2;
v4=v1;
p4=p3*(v3/v4)^k;

%plotting and joining the points
figure(1);
hold on;    
plot(v1,p1,'*','color','b');
plot(v2,p2,'*','color','b');
plot(v3,p3,'*','color','b');
plot(v4,p4,'*','color','b');

plot([v1 v2 v3 v4],[p1 p2 p3 p4]);

OUTPUT :-

As I got the plot , it requires to be corrected as we see that they are being joined by straight line and it shows the wrong path, so I will create a function and taking the use of what all parameters I have and also use up the volume iota function for getting the output as thermal efficiency.

⤵️ Using the first program now i will create the function & we find out thermal efficiency and volume wrt crankshaft and using the volume iota function :-

  • Creating a function to get thermal efficiency & recalling the valves form input.
%Calculating the volume iota function by putting the input valves.

%by making the use of function [P] and saving it in pistonkinematics.
function[P]=piston_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)

%relation
a=stroke/2; %radius of crank pin (single slider mechanism)
R=con_rod/a; %ratio of connecting rod & crank pin radius

v_swept = (pi/4)*bore^2*stroke;
v_clearance=v_swept/(cr-1);

%getting all the valves of crankshaft angle in theta and increment it by linspace.
theta=linspace(start_crank,end_crank,45);

%the volume iota function is expressed in three parts and puted into the
%function P

tag1=0.5*(cr-1);
tag2=(R+1-cosd(theta));
tag3=(R^2-sind(theta).^2).^0.5;

P=(1+tag1*(tag2-tag3)).*v_clearance;
end
  • Observing the thermal efficiency
%observing the thermal efficiency and plotting the points on PV Chart. 

clear all
close all
clc

%inputs according to the specifications

bore = 10; %diameter of bore
stroke = 15; %diameter of stroke
con_rod = 50; %diameter of connnecting rod
k=1.4; %heat capacity at constant pressure & constant volume (cp/cv)
cr=7; %compression ratio
t1=500; %inital temperture or exhaust temperture on intake stroke
p1=180497;%inital pressure
t3=700;%exhaust gas temperture at end process of the cycle

%calculation of v1 , v2 in swept and clearance volume

v_swept = (pi/4)*bore^2*stroke;
v_clearance=v_swept/(cr-1);

%As we known total volume (V1)is equal to clearance volume (v_clearance) and swept
%volume (v_swept)& clearnance volume is equal to v2.

v1=v_clearance+v_swept;
v2=v_clearance;


%Calculating the volume iota function using engine kinematics
%formula & finding valves of p2,p3,p4,t2,v3,v4 used in gas law 
p2=p1*cr^k;
t2=p2*v2*t1/(p1*v1);

%Calculating the pressure compression in isentropic compression process. 
constant_c2= p1*v1^k;
vol_compression=piston_kinematics(bore,stroke,con_rod,cr,180,0);
pre_compression= constant_c2./vol_compression.^k;

v3=v2;
p3=p2*t3/t2;

%Calculating the pressure expansion in isentropic compression process.
constant_c4=p3*v3^k
vol_expansion=piston_kinematics(bore,stroke,con_rod,cr,0,180);
pre_expansion=constant_c4./vol_expansion.^k
v4=v1;
p4=p3*(v3/v4)^k;

%plotting and joining the points

figure(1);
hold on;

plot([v1 v2 v3 v4],[p1,p2,p3,p4],'*','color','b');

plot(vol_compression,pre_compression);

plot([v2 v3],[p2 p3]);

plot(vol_expansion,pre_expansion);

plot([v4 v1],[p4 p1]);

title('PV Chart');
legend('state-points','expansion','heat admission in constant volume','compression','heat rejection in constant volume'); 
xlabel('vol.(V)');
ylabel('pre.(P)');

%thermal efficiency

E=1/(cr^(k-1));

thermal_eff=(1-E).*100;

OUTPUT EXPLANATION :-

Here using the function and getting the process flow to be with respect to the four processes and use the formula and before plotting both of the array , I derived out the pressure of the other remaining parameters and also got the thermal efficiency.

ERROR FACED :-

Error faced while running the function when the calculating parameters were not provided and then coded out so the function works out towards output.

OBSERVATION :-

I observed that the thermal efficiency attained is 54.08%.

CONCLUSION :-

Please note the ideal cycles are very different from the actual cycles and as elaborated earlier . And actual cycles do get on with various factors to be counted and also parameters varies.

It's also concluded that efficiency is also most important for getting to know about the performance.

Hence I conclude that goals are completed.

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.