Calculation of Thermal Efficiency of a engine and plotting of Otto cycle in MATLAB programming
Aim:-
To plot Otto cycle and calculate thermal efficiency of the engine by MATLAB programming.
Governing equations:-
Equation that play main role to fulfill the aim of this
project:-
(v/v_c)=1+1/2(r_c-1)[R+1-cos_theta-(R^2-sin^2_theta)^0.5]
i.e change in volume due to various processes.
where,
r_c=compression ratio
R=connecting rod length
v_c=clearance volume
Swept volume = (pi/4)*bore^2*stroke
Clearance volume = Swept volume/(r_c-1)
r_c = v_s+v_c/v_c
Objective:-
The main objective of this project is to calculate engine efficiency and plot Otto cycle (p-v) diagram using MATLAB programming.
Brief Theory:-
Otto cycle project depends on engine kinematics.
Engine kinematics:- It is the kinematics by which an IC engine converts chemical energy into Mechanical energy taht produces from fuel.
Otto cycle:- It is basically a air standard cycle (Air standard cycle give the data about the performance of IC engine). Otto cycle is purely based on isentropic compression and expansion, constant volume heat addition and rejection (Generally heat addition is called combustion process).
Isentropic process:- Both of adiabatic and reversible process together are called isentropic process in Thermodynamics. This is two types --- compression and expansion.
P-V diagram of Otto cycle:-
1-2 is isentropic compression
2-3 is constant volume heat addition
3-4 is isentropic expansion
4-1 is constant volume heat rejection
Workflow:-
1) Initial pressure, temperature is assumed.
2) Engine parameters are assumed.
3) Swept volume and clearance volume is calculated.
4)State variables calculating.
5) Thermal Efficiency is calculated.
6) Plotting of graph completed.
Brief Content of this project:-
This project has been done by MATLAB programming. The code of the program has been attached below.
%Calculation of thermal efficiency and plotting of otto cycle in MATLAB programming
clear all
close all
clc
%taking inputs
%gamma(air)=1.4
gamma=1.4;
%max. engine temparature (K)
t3=2300;
%State variables at point 1(values are assumed)
p1=101325;
t1=500;
%Engine geometric parameters
bore=0.1;
stroke=0.1;
con_rod=0.15;
r_c=10;
%Calculation swept and clearance volume
v_swept=(pi/4)*bore^2*stroke;
v_clear=v_swept/(r_c-1);
v1=v_swept+v_clear;
v2=v_clear;
%State variable at point 2
%p2*v2^gamma=p1*v1^gamma
p2=p1*(r_c^gamma);
%p1*v1/t1=p2*v2/t2 (ideal gas law)
t2=(p2*v2*t1)/(p1*v1);
c_const=p1*(v1^gamma);
v_compression=kinematics(bore,stroke,con_rod,r_c,180,0);
p_compression=c_const./(v_compression.^gamma);
%State variable at point 3
v3=v2;
%p3*v3/t3=p2*v2/t2
p3=(p2*v2*t3)/(t2*v3);
c_const=p3*(v3^gamma);
v_expansion=kinematics(bore,stroke,con_rod,r_c,0,180);
p_expansion=c_const./(v_expansion.^gamma);
%State variable at point 4
v4=v1;
%p3*v3^gamma=p4*v4^gamma
p4=p3*(v3/v4)^gamma;
%Calculation thermal efficiency
therm_eff=(1-(1/(r_c)^(gamma-1)))*100;
fprintf('Thermal efficiency of the otto cycle is : %f percent',therm_eff);
%plotting
hold on
plot(v1,p1,'*','color','r')
text(v1,p1,'point1')
plot(v_compression,p_compression,'linewidth',3)
plot(v2,p2,'*','color','r')
text(v2,p2,'point2')
plot(v3,p3,'*','color','r')
line([v2 v3],[p2 p3],'linewidth',3)
plot(v_expansion,p_expansion,'linewidth',3)
text(v3,p3,'point3')
plot(v4,p4,'*','color','r')
text(v4,p4,'point4')
line([v4 v1],[p4 p1],'linewidth',3)
Code for the function has been attached below.
%Function for engine kinematics
function [v]=kinematics(bore,stroke,con_rod,r_c,start_crank,end_crank)
%Crank pin radius
a=stroke/2;
%Crank radius
r=con_rod/a;
%calculation of swept volume and clearance volume
v_swept=(pi/4)*bore^2*stroke;
v_clearance=v_swept/(r_c-1);
%linear space vector of crank angle
theta=linspace(start_crank,end_crank,100);
term1=0.5*(r_c-1);
term2=r+1-cosd(theta);
term3=(r^2-sind(theta).^2).^0.5;
**Error correction:- function will be ended with
'end'.
Result:-
Plot of Otto cycle:-
Algorithm of the program:-
1) Inputs (gamma,t3) are taken as per requirement.
2) State variables at point 1 and engine geometric parameters values are taken.
3) For calculation of swept and clearance volume formulas are put.
4) State variables at point 2 are taken and formulas are put.
5) At code line no 40 function named kinematics is called which takes the values of bore,stroke,con_rod,r_c,180,0. The function is defined at last of the program so that the program looks fresh.
6) Similarly,state variable at point 3 and point 4 are taken into consideration .
7) Thermal Efficiency formula is put and value is printed.
8) Graph of Otto cycle is plotted in which clors, linewidth are mentioned.
Algorithm of the function:-
1) Function 'kinematics' is named.
2)The function takes values of bore,stroke,con_rod,start_crank,end_crank.
3)Crank pin and Crank radius values are put.
4) Using formulas swap volume and clearance volume are calculated.
5) Calculation of linspace vector of Crank angle is done.Here linspace command is used as it acts as an array (vector).
6)End of the function.
Conclusion:-
Through this whole project we have learnt about the Otto cycle and it's uses in engine and figures are plotted. Lastly, saying whole about Otto cycle was clearly learnt by this project and the inner was fulfilled that enables us to solve engine kinematics problems in industry level by MATLAB programming.