Project

PROJECT:- AIR STANDARD OTTO CYCLE

PROJECT:- AIR STANDARD OTTO CYCLE

AIM:- Write code that can solve an Otto Cycle and make plots for it.

SOFTWARE USED:- MATLAB R2020a

THEORY:-

Otto cycle is an air standard cycle, this cycle is in spark ignition internal combustion engine.

An Otto cycle consists of four processes:

  1. Two isentropic (reversible adiabatic) processes
  2. Two isochoric (constant volume) processes

P-V Diagram of Otto Cycle:-

Process 1-2: Isentropic compression

In this process, the piston moves from bottom dead center (BDC) to top dead center (TDC) position. Air undergoes reversible adiabatic (isentropic) compression. We know that compression is a process in which volume decreases and pressure increases. Hence, in this process, volume of air decreases from V1 to V2 and pressure increases from p1 to p2.

Process 2-3: Constant Volume Heat Addition:

Process 2-3 is isochoric (constant volume) heat addition process. Here, piston remains at top dead center for a moment. Heat is added at constant volume (V2 = V3) from an external heat source.

Process 3-4: Isentropic expansion

In this process, air undergoes isentropic (reversible adiabatic) expansion. The piston is pushed from top dead center (TDC) to bottom dead center (BDC) position. Here, pressure decreases for p3 to p4, volume rises from v3 to v4

Process 4-1: Constant Volume Heat Rejection

The piston rests at BDC for a moment and heat is rejected at constant volume (V4=V1). In this process, pressure falls from p4 to p1.

OBJECTIVE:- Plot the Otto cycle using MATLAB codes.

CODES WRITTEN:-

Program for otto cycle.

clear all  % all data cleared
close all  % all running work closes
clc        % command window cleared
% PROGRAM FOR OTTO CYCLE

% ENGINE GEOMETRIC PARAMETERS(assumed)
bore = 0.1;
stroke = 0.1;
con_rod = 0.15;
cr = 10                 % cr =( V1/V2)

% inputs
gamma = 1.4           % gamma = Cp/Cv
t3 = 2300             % Temprature(K)

% VARIABLES AT STATE 1
p1 = 1.01325                %pressure ( 10^5 Pa)
t1 = 400                   % Temprature(K)


%  SWEPT VOLUME AND CLEARANCE VOLUME
v_swept = (pi/4)*bore^2*stroke;
v_clearance = v_swept/(cr-1);
v1 = v_swept+v_clearance
v2 = v_clearance

% VARIABLES AT STATE 2
%p2v2^gamma=p1v1^gamma
p2 = (p1*v1/v2)^gamma
const_c = p1*v1^gamma;
v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0);
p_compression = const_c./v_compression.^gamma;
% p1v1/t1=p2v2/t2
t2 = p2*v2*t1/(p1*v1)

% VARIABLES AT STATE 3
v3=v2
%p3v3/t3=p2v2/t2
p3 = p2*t3/t2
const_c = p3*v3^gamma;
v_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180);
p_expansion = const_c./v_expansion.^gamma;

% VARIABLES AT STATE 4
v4=v1
%p3v3^gamma=p4v4^gamma
p4 = p3*v3^gamma/v4^gamma

% EFFICIENCY OF OTTO CYCLE

efficiency_of_otto_cycle = 1-1/cr^(gamma-1)

%plotting otto-cycle 
hold on
title('P-V plot of Otto cycle')
plot(v1,p1,'*','color','k')
plot(v_compression,p_compression,'color','r')
plot(v2,p2,'*','color','g')
plot([v2 v3],[p2 p3],'color','b')
plot(v3,p3,'*','color','k')
plot(v_expansion,p_expansion,'color','g')
plot(v4,p4,'*','color','r')
plot([v4 v1],[p4 p1],'color','b')
xlabel('volume (m^3)')
ylabel('pressure (x 10^5 Pa)')
legend('p1 v1','adia comp','p2 v2','const vol HA','p3 v3','adia exp','p4 v4','const vol HR')
grid on

calling function program:

% CALLING FUNCTION
function [v] = engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)

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

% Calculation of swept Volume and clearance volume
v_swept = pi/4*bore^2*stroke;  
v_c = v_swept/(cr-1);

% For calculation of  volume 
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:-

  • Write basic command for previously worked clear.
  • Write engine parameter i.e. bore, stroke, connecting rod length etc.
  • For inserting engine parameters here function call is used. The calling function and file name should be same.
  • From this function swept volume, clearance volume of engine is calculated. This function helps to create proper plot.
  • Taking constant(gamma= 1.4) and insert assumed data( p1,t1,t3 ).
  • State variables at 1 .
  • State variables at 2 ,3 and 4 by writing MATLAB Program using relation [PV^gamma = constant] and [(P/T)=constant].
  • Now, write formula for efficiency calculation.
  • Use hold on command so that the current properties and plot will retain.
  • Use title command for giving title to the plot (P-V plot of otto cycle).
  • Plot the otto cycle by plot command for individual state and also for joining the points followed by calling function.
  • For label use xlabel on x-axis and ylabel on y-axis.
  • Legend is used for showing each line and plot.
  • Then grid on for show grid in plot.

OUTPUT:-

Output of otto cycle:

Efficiency of otto cycle:

ERROR ENCOUNTERED DURING WRITING CODING:-

  1. Error was occurred while using calling function Unrecognized function or variable 'engine_kinematic'.
  2. Error faced when using legend command.

STEPS TO OVERCOME ERROR:-

  1. This is solved by renaming the variable, the calling function and function file name should be same.
  2. To overcome this, we have to write correct syntax. This error is removed by putting parentheses at right place.

CONCLUSION:-

  • In this project we learned about how to call a function.
  • We analyzed the otto cycle using MATLAB programming.
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.