VISUALIZATION OF P-V DIAGRAM OF AN OTTO CYCLE USING MATLAB

AIM:

      Our aim is to write a code in matlab to visualize the P-V diagram of an Otto cycle and to provide the output of thermal efficiency of the engine

CODE FOR VISUALIZATION OF P-V DIAGRAM AND THERMAL EFFICIENCY OF OTTO CYCLE

clear all
close all
clc

%input
gamma=1.4;
t3=2300;

%state variables at point1
p1=101325;
t1=500;

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

%calculating v_s and v_c
v_s=(pi/4)*bore^2*stroke
v_c=v_s/(cr-1)

%calculating v1 and v2
v1=v_s+v_c
v2=v_c
%thermodynamic relation
constant_c=p1*v1^gamma
v_compression=engine_kinematics(bore,stroke,con_rod,cr,180,0)
p_compression=constant_c./v_compression.^gamma

%state variables at point2

%p2v2^gamma=p1v1^gamma | p2=p1*cr^gamma
p2=p1*cr^gamma

%p2v2/t2=p1v1/t1 | t2=p2*v2*t1/(p1*v1)
t2=p2*v2*t1/(p1*v1)

%state variables at point 3
v3=v2
%p3v3/t3=p2v2/t2 | p3=p2*t3/t2
p3=p2*t3/t2
%thermodynamic relation
constant_c=p3*v3^gamma
v_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180)
p_expansion=constant_c./v_expansion.^gamma

%state variables at point 4
v4=v1

%p4v4^gamma=p3v3^gamma | p4=p3*(v3/v4)^gamma
p4=p3*(v3/v4)^gamma

%p4v4/t4=p3v3/t3 | t4=p4*v4*t3/(p3*v3)
t4=p4*v4*t3/(p3*v3)

%calculating thermal efficiency
thermal_efficiency=(1-(1/(cr)^(gamma-1)))*100

%plotting

figure(1)
hold on
plot(v1,p1,'*','color','r')
plot(v2,p2,'*','color','r')
plot(v3,p3,'*','color','r')
plot(v4,p4,'*','color','r')
plot([v_compression v2 v_expansion v4 v_compression],[p_compression p2 p_expansion p4 p_compression],'color','b')
xlabel('volume')
ylabel('pressure')

CODE FOR AN FUNCTION NAMED ('engine_kinematics')

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

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

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

%thermodynamic relation
theta=linspace(start_crank,end_crank,180);
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

INPUTS:

STEP 1:

      The inputs values for gamma,bore dia,stroke length,connecting rod length,compression ratio etc have been assumed to calculate the values of swept volume and clearance volume. Then the values of state variables such as pressure, volume, temperature at all the four points (1,2,3,4) are calculated using the ideal gas formulas provided in the coding.

STEP 2:

       Followed by our 1st step our next step is to plot the values using plot command to visualize the P-V diagram of an air standard cycle. To plot the line for adiabatic compression (1-2) and adiabatic expansion (3-4) process is their original path we are using a thermodynamic relation.

STEP 3:

        Hence a function named 'engine_kinematics' is inserted into our original coding by calling a function for accurate plotting of paths of processes (1-2) and (3-4). The function named 'engine_kinematics' is framed using a proper thermodynamic logic.

STEP 4:

        Now the points and the paths between the points are plotted using the plot command.

ERRORS OCCURED DURING PROGRAMMING

1.Error due to typo such as 'r' in place of 'cr' for mentioning compression ratio

error1

STEPS TAKEN TO OVERCOME THE ERROR

1.By looking at the red hint popped in the command window.

2.By recaping the instructions provided by the instructor.

OUTPUT: 

1.P-V DIAGRAM OF OTTO CYCLE

PVDIAGRAM

2.THERMAL EFFICIENCY OF OTTO CYCLE

 

OUTPUT

CONCLUSION:

Thus the code is coded in matlab and executed successfully to visualize the p-v diagram and thermal efficiency of an otto cycle.


Projects by Avinash A S

AIM:      To perform a car crash analysis using ansys workbench. PROBLEM STATEMENT: To perform a parametric study using 3 different values of thickness for the car body. Here the car body remains stationary but the wall displaces to a distance of 500 Read more

AIM:     To perform structural analysis to simulate the rolling operation on a copper workpiece of length 90mm. STRUCTURAL ANALYSIS: Structural analysis is the process of calculating and determining the effects of loads and internal forces on a struc Read more

AIM:    To perform explicit dynamics simulation of a bullet penetrating into a bucket considering three different non-linear materials for the bucket and analyse their behaviour for the same bullet velocity. CASE SETUP:1 Assign the bucket material as Copp Read more

AIM:

    To perform an explicit dynamics simulation to simulate the machining operation with using a planer and observe their behaviour at 2 different velocities.

CASE SETUP:1Read more

AIM:    To perform the tension and torsion test on the specimen considering the case setups and find out the total deformation, equivalent stress and temperature of the specimen. TENSION TEST: A tensile test, also known as a tension test, is one Read more

AIM:    To perform transient structural analysis on a worm gear assembly. TRANSIENT STRUCTURAL ANALYSIS: Transient structural analysis is the process of calculating and determining the effects of loads and internal forces that are a function of time on a Read more

AIM:     To perform a transient structural analysis on a double universal joint with a spring using three different materials and then compare the results. TRANSIENT STRUCTURAL ANALYSIS: Transient structural analysis is the process of calculating and Read more

AIM:       To perform a transient structural analysis on a piston and cam mechanism model considering different case setups and then compare the results of the case setups. TRANSIENT STRUCTURAL ANALYSIS: Transient structural analysis is the process o Read more

AIM:      To perform structural analysisto simulate a sphere pressing on plate considering the case setup and experience the plastic deformation on the plate. STRUCTURAL ANALYSIS: Structural analysis is the process of calculating and determining the Read more

AIM:    To perform an structural analysis to simulate the bending of a wire considering three different case setups and compare their results. STRUCTURAL ANALYSIS: Structural analysis is the process of calculating and determining the effects of loads and Read more


Loading...

The End