Project

Matlab script to trace out volume changes during Isentropic processes in order to plot PV diagram for Otto Cycle and to calculate its Thermal Efficiency

The program is coded to plot PV diagram for Otto Cycle using Matlab. A function is created to trace out the volume values during the compression and expansion process to maintain non-linearity of the isentropic processes, governed by the non-linear equation `PV^gamma`. The code assigned to the function calculates volume using Slider-Crank Model formula, which is shown below:



Also, the thermal efficiency of the engine is calculated for the input compression ratio using the formula shown below:

Program:

clear all
close all
clc

% Air Standard Cycle
% By Arjun Damodar

% Engine Kinematics

% Otto Cycle Simulator

% Inputs
p1=101325;
t1=500;
gamma=1.4;
t3=2300;

% Geometric Parameters
bore=0.1;
stroke=0.1;
con_rod=0.15;
cr=5;

% Volume Parametrs
v_s = (pi/4)*bore^2*stroke;     
v_c = v_s/(cr-1);

% state point 1
v1 = v_c + v_s;

% state point 2
v2 = v_c;
p2 = p1*cr^gamma; % from ideal gas relation   
t2 = p2*v2*t1/(p1*v1);

constant = p1*v1^gamma; % P*V^gamma = constant
v_comp = engine_kinematics(bore,stroke,con_rod,cr,180,0);
p_comp = constant./(v_comp.^gamma);

% state point 3
v3=v2;
p3 = (p2*t3/t2);

constant = p3*v3^gamma; % P*V^gamma = constant
v_expa = engine_kinematics(bore,stroke,con_rod,cr,0,180);
p_expa = constant./(v_expa.^gamma);

% state point 4
v4=v1;
p4=p3*((v3/v4)^gamma);

% To calculate thermal efficiency
therm_eff = 1-(1/(cr^(gamma-1)))
therm_eff_percentage = therm_eff * 100

% Plotting of PV Diagram
figure(1)
hold on
plot(v_comp,p_comp,'b')
plot([v2,v3],[p2,p3],'r')
plot(v_expa,p_expa,'g')
plot([v4,v1],[p4,p1])
xlabel('Volume')
ylabel('Pressure')

% Function to calculate volume trace during compression and expansion

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

% Geometric Parameters
a = stroke/2;
R = con_rod/a;

% Volume Parametrs
v_s = pi/4*bore^2*stroke;    %Swept Volume
v_c = v_s/(cr-1);            %Clearence Volume

	
theta = linspace(start_crank,end_crank,100);

% Slider-Crank Model formula to calculate Volume inside the cylinder
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

Explanation of the code:

  1. Input state variables p1,t1, gamma were defined along with the given engine geometry parameters.
  2. t3 is taken as 2300 as the temperature after constant volume heat addition will be higher.
  3. Swept volume and clearance volumes were calculated.
  4. State point variables were calculated using the ideal gas relation.
  5. Volume values during compression and expansion were calculated using the function and corresponding pressure values were also calculated.
  6. Function perform the slider-crank formula and traces out the volume values during isentropic processes
  7. Thermal efficiency is calculated using the given formula.
  8. PV Diagram is plotted.

Results:

Thermal Efficiency for the compression ratio 5 is: 0.4747 or 47.4%

PV Diagram

Screenshot of the Output:

Errors faced:

1. Missing Command: 'hold on' command not used. Errors didn't show up but the plot acquired was wrong.

2. Syntax Error: Used 'hold (on) instead of 'hold on'.

3. 'Print' command used to display a text.

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.