Project

Study of Otto cycle by using Matlab.

Aim: To study the piston kinematics of Otto cycle in matlab.

Formulae:

A. `Vs= π/4×(bore)^2×stroke`

where, Vs = Swept volume. (in cubic centimeters or cc)

bore = Diameter of cylinder. (in cm)

stroke = Distance from TDC to BDC or vice-versa. (in cm)

Swept volume is the displacement of one cylinder. It is the volume between top dead center (TDC) and bottom dead center (BDC). The volume piston sweeps during stroke from top to bottom. To understand the kinematics of the piston we need the values of volume and pressure at different positions of piston during whole cycle. By using above relation we can easily find the value of compression ratio.

B. `Vc= Vs/((1-cr))`

Clearance volume is the volume occupied between the cylinder head and the piston top when the piston is at top dead center. By using the clearance volume we can determine the values of volume during different processes of the otto cycle. We can also determine the compression ratio by using clearance volume.

where, Vc = Clearance volume. (in cubic centimeters or cc)

cr = Compression ratio.

`cr=((Vs+Vc)/Vc)`

The compression ratio of an internal combustion engine can be defined as, ‘The ratio of maximum volume to the minimum volume in the cylinder of an internal combustion engine’. During whole cycle the pressure, volume and temperature are under continuous change. To understand each process we need to monitor each and every parameter of these. Compression ratio helps us to monitor the volume during each process.

C. `(P2V2)^γ=(P1V1)^γ`

where, P2 = Pressure corresponding to point 2 (in bar)

V2 = Volume corresponding to point 2 (in cm3)

P1 = Pressure corresponding to point 1 (in bar)

V1 = Volume corresponding to point 1 (in cm3)

γ = 1.4

By Boyle’s law:

`P ∝ (1 )/V` `

Pressure is inversely proportional to the volume.

Or

PV = k Thus, Product of Pressure and Volume equals to some constant k.

The equation states that the product of pressure and volume is a constant for a given mass of confined gas and this holds as long as temperature is constant, same for the constant entropy but we have to take the adiabatic constant (γ = 1.4) into the consideration. This application of Boyle’s law helps in determining the values of the pressure and volume at different states during the process.

D. `P1V1/T1= P2V2/T2`

where, P1 = Pressure corresponding to point 1 (in bar)

V1 = Volume corresponding to point 1 (in cm3)

T1 = Temperature corresponding to point 1 ( in Kelvin)

P2 = Pressure corresponding to point 2 (in bar)

V2 = Volume corresponding to point 2 (in cm3)

T2 = Temperature corresponding to point 2 ( in Kelvin)

Ideal gas law is the good approximation of the behavior of many gases under many conditions. Combination of empirical Boyle’s law, Charles’s law, Avogadro’s law and Gay-Lussac’s law. It states that:

`PV=nRT`

Where, P, V and T are the pressure, volume and temperature; n is the amount of substance and R is the ideal gas constant. Applying the Ideal gas law we can obtain the equation no. 4 to study the processes of otto cycle.

Objectives:

To code the program for plotting the P-V diagram of Otto cycle by using matlab. The idea is to study the Otto cycle and plot the P-V diagram for it by using matlab so that we would come to know that, How actual P-V diagram helps us to understand the different variables are plays a vital role in the study of the air standard cycle and it’s efficiency.

01. Introduction:

The engines in which the combustion of fuel takes place inside the engine are called as internal combustion engines. But the burnt air-fuel mixture does not move into the cycle again and fresh air-fuel mixture is induced at the beginning of each cycle, the internal combustion engines are said to be working in non-cyclic process.

Whether the engine works in cyclic or non-cyclic process, its analysis is very importnt to find out the amount of fuel consumed and work produced by it. To carry out the analysis of heat engines, the concept of air standard was conceived. In these cycles certain mass of air is considered to be working in the thermodynamic cycle. The addiition and rejection of heat is considered to take place with the external reservoir and ideally all the processes are reversible. The internal combustion engines are considered to be working on the principle of air standard cycles. The two most commonly used air standard cycles are otto cycle and Diesel cycle. The otto cycle corresponds to the four stroke gasoline or petrol engines also called Spark Ignition (SI) engines. The Diesel cycle corresponds to four stroke Diesel engines also called as Compression Ignition (CI) engines.

Now we will see what is otto cycle?

An otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine.

The otto cycle is a description of what happens to amass of gas as it is subjected to changes of pressure, temperature, volume, addition of heat and removal of heat. The mass of gas that is subjected to that changes is is as called system.

Otto cycle consists of following four processes:

  1. Isentropic Compression.
  2. Heat addition at constant volume.
  3. Isentropic expansion.
  4. Heat removal at constant volume.

During the process 1-2 piston does the work on the gas and during process 3-4 gases does the work on the piston; these are Isentropic compression and Isentropic expansion processes respectively. Processes 2-3 and 4-1 are isochoric processes; heat is transferred into the system from 2-3 and out of the system from 4-2 but no work is done on the system or extracted from the system during those processes. No work is done during isochoric (constant volume) process because addition or removal of work from system requires the movement of boundaries of the system, hence as the cylinder volume does not change, no shaft work is added to or removed from the system.

Figure01: PV and TS Diagrams for Otto Cycle.

Now let’s solve the following problem in matlab to obtain the efficiency of the Otto cycle.

02. Problem Statement:

An Otto cycle having air as the working fluid has the initial Pressure of 1 atm. and Temperature 300 K. Temperature of a fluid after addition of heat is 2400 K. Bore = 0.1 m, Stroke = 0.1 m, Connecting rod = 0.15 m and Compression ratio = 12.

Solution:

Following steps were followed to solve the problem in matlab:

I.

First we will code the main program to find the values of all the parameters at each point.

II.

In this step we will be plotting the all four points of PV-Diagram.

III.

Secondly we will code the function program for, how the system changes its volume during the cycle by using the given equation.

IV.

In this step we will call the function program into the main program to plot the curves of the processes by using the all four points which were already plotted in main program.

Step-I:

Writing Main program to plot the points of all the processes:

01.	% Program for otto cycle.
02.	 
03.	clear all
04.	close all
05.	clc
06.	 
07.	% input
08.	gamma = 1.4
09.	 
10.	% Temperature after combustion
11.	T3 = 2400
12.	 
13.	% Pressure and Temperature at point-01
14.	P1 = 101325
15.	T1 = 300
16.	 
17.	% Engine Geometric Parameters
18.	bore = 0.1;
19.	stroke = 0.1;
20.	conn_rod = 0.15;
21.	cr = 12;
22.	 
23.	% Calculating Swept volume and clearance volume.
24.	Vs = (3.1421/4)*bore^2*stroke;
25.	Vc = Vs/(cr-1);
26.	 
27.	% Volume at point-01
28.	% V1 = Vs + Vc
29.	V1 = Vs + Vc;
30.	V2 = Vc
31.	 
32.	% State variables at state point 2
33.	% P2V2^gamma = P1V1^gamma
34.	% V1/V2 = cr
35.	P2 = P1*(V1/V2)^gamma
36.	 
37.	% Ideal Gas Law
38.	%P1V1/T1 = P2V2/T2
39.	 
40.	T2 = P2*V2*T1/(P1*V1);
41.	 
42.	% State variables at point-03
43.	% Ideal gas law
44.	% P3V3/T3 = P2V2/T2
45.	% V3 =V2
46.	 
47.	V3 = V2;
48.	P3 = P2*T3/T2;
49.	 
50.	% State variables at point-04
51.	% V4 = V1
52.	% P4V4*^gamma = P3V3*^gamma
53.	V4 = V1;
54.	P4 = P3*(V3/V4)^gamma
55.	 
56.	% Plotting all the four points
57.	figure(1)
58.	hold on
59.	plot(V1,P1,'*','color','r');
60.	plot(V2,P2,'*','color','r');
61.	plot(V3,P3,'*','color','r');
62.	plot(V4,P4,'*','color','r');
63.	

Step-II:

Plotting all four points of given processes.

Figure02: Plot showing four points of PV-diagram.

Detailed explanation of main program:

  1. Name of Program, “Program for Otto Cycle.”
  2. Clears your workspace.
  3. Closes all the figures.
  4. Clears Command window.
  5. Inputs
  6. Isentropic constant (γ) = 1.4
  7. Giving the input value of temperature after combustion.
  8. T3 = 2400
  9. Giving the input values for Pressure and Temperature at point-01
  10. P1 = 95000
  11. T1 = 900
  12. Giving input values for kinematics of engine which will help us to calculate the different parameters of process during cycle.
  13. bore = 0.1
  14. stroke = 0.1
  15. conn_rod = 0.15
  16. compression ratio (cr) = 12
  17. Calculating the Swept volume and Clearance volume of the piston.
  18. Vs = (3.1421/4)*bore^2*stroke
  19. Vc = Vs/(cr-1)
  20. Calculating the volume at point-01 (V1)
  21. Displaying formulae: V1 = Vs + Vc
  22. V1 = Vs + Vc

[In the beginning of the cycle after suction piston remains at BDC therefore volume of the system considered must be equal to the sum of volume swept by the piston during isentropic compression (Vs) and volume when the piston is at TDC. (Vc) ]

  1. V2 = Vc

[While piston is at TDC and heat is added by combustion of air-fuel mixture, just because there no change in the position of the piston volume remains constant throughout the process of Heat addition and the volume of system when piston is at TDC is called as Clearance volume. (Vc) ]

  1. Giving inputs for state variables of point-02
  2. Application of Boyle’s Law during process of Isentropic Compression to determine pressure at point-02 (P2)
  3. Defining the formulae for Compression ratio (cr)
  4. P2 = P1*(V1/V2)^gamma
  5. Using Ideal Gas Law
  6. Application of ideal gas law for the process of isentropic compression to determine temperature at point 2 (T2)
  7. T2 = P2*V2*T1/(P1*V1) [ Formula for determining the value of T2)
  8. Defining the variables at point-03
  9. Application of Ideal gas law during process of Heat addition at constant.
  10. P3V3/T3 = P2V2/T2
  11. V3 =V2

[During Heat addition piston remains at TDC and does not move from there]

  1. V3 =V2

[Constant volume process]

  1. P3 = P2*T3/T2

[Determining the value of Pressure at point-03]

  1. Defining state variables of point-04
  2. V4 =V1

[Volume remains constant during the process of Heat removal]

  1. Application of the Boyle’s law during the process of isentropic expansion to determine

the Pressure at point-04. (P4)]

  1. V4 =V1
  2. P4 = P3*(V3/V4)^gamma

[Determining the pressure at point-04]

55.

  1. Plotting all the four points of the processses
  2. hold on

[To hold the previous results of previous commands into the plot we need as a output.]

  1. Plotting point-01

[Syntax: plot(X1,Y1,’*’,’color’,’r’)]

  1. Plotting point-02
  2. Plotting point-03
  3. Plotting point-04

Step-III:

Code the sub-program as function for, how the system changes its volume during the cycle by using the given equation.

`V=[1+frac{1}{2}(cr-1)xx(R+1-costheta)xx(R^2-sin^2theta)^frac{1}{2}]xxVc` ...equation(01)

We will use the equation (01) to plot the parametric curves during the process of isentropic compression and isentropic expansion.

01.	function [V] = xz(bore,stroke,conn_rod,cr,sc,ec)
02.	 
03.	a = stroke/2;
04.	R = conn_rod/a;
05.	 
06.	Vs = (3.1421/4)*bore^2*stroke;
07.	Vc = Vs/(cr-1);
08.	 
09.	theta = linspace(sc,ec,180);
10.	 
11.	term1 = 0.5.*(cr-1);
12.	term2 = R + 1-cosd(theta);
13.	term3 = (R.^2-sind(theta).^2).^0.5;
14.	 
15.	V = (1+ term1*(term2-term3))*Vc
16.	 
17.	end

Detailed Explanation of the function (sub-program):

  1. Starting function for the main program.

Syantax:

Function_handle [Function_output] = Function_Name (Input Credentials);

[Here we used [V] which is the output of the equation (01) as the function output for which we assign “xz” as function name and inside circular bracket we mentioned the input credentials required for the operation of the function. We can also say that function is just like template.]

  1. Defining value of a
  2. Defining value of R
  3. Defining value of Vs
  4. Defining value of Vc
  5. theta = linspace(180,0,180);

[Here we need to plot the change in volume of a system w. r. t. crank angle. Therefore by using linspace command we are defining the starting position and ending position of the crank angle during the process of which we need a plot. Here we need plot for Isentropic compression. Hence we defined 180 as starting crank angle and 0 as the ending crank angle for which command will provide the 180 values.]

  1. Defining term1

[Equation (01) has been divided into three terms: term1, term2 and term3. Therefore term1 is defined.

  1. Defining term2
  2. Defining term3
  3. V = (1+ term1*(term2-term3))*Vc

[Defining the equation (01) by using term1, term2 and term3]

  1. End of function.

Step-IV:

In this step we will call the function program into the main program to plot the curves of the processes by using the all four points which were already plotted in main program.

  1. % Program for otto cycle.
  2. clear all
  3. close all
  4. clc
  5. % input
  6. gamma = 1.4
  7. % temperature after combustion
  8. T3 = 2400
  9. % Pressure and Temperature at point-01
  10. P1 = 101325
  11. T1 = 300
  12. % Engine Geometric Parameters
  13. bore = 0.1
  14. stroke = 0.1
  15. conn_rod = 0.15
  16. cr = 12
  17. % calculating swept volume and clearance volume
  18. Vs = (3.1421/4)*bore^2*stroke
  19. Vc = Vs/(cr-1)
  20. % Volume at point-01
  21. % V1 = Vs + Vc
  22. V1 = Vs + Vc
  23. V2 = Vc
  24. % State variables at point-02
  25. % P2V2^gamma = P1V1^gamma
  26. % V1/V2 = cr
  27. P2 = P1*(cr)^gamma
  28. % Ideal gas law
  29. % P2V2/T2 = P1V1/T1
  30. T2 = T1*P2*V2/(P1*V1)
  31. % PV^gamma = Constant
  32. Constant = P1*V1^gamma
  33. V_comp = xz(bore,stroke,conn_rod,cr,180,0)
  34. P_comp = Constant./V_comp.^gamma
  35. % State variables at point-03
  36. % Ideal gas law
  37. % P3V3/T3 = P2V2/T2
  38. % V2 = V3
  39. V3 = V2
  40. P3 = P2*T3/T2
  41. % PV^gamma = Constant
  42. Constant = P3*V3^gamma
  43. V_exp = xz(bore,stroke,conn_rod,cr,0,180)
  44. P_exp = Constant./V_exp.^gamma
  45. % State variables at point-04
  46. % V4 =V1
  47. % P4V4*^gamma = P3V3*^gamma
  48. V4 = V1
  49. P4 = P3*(V3/V4)^gamma
  50. % Plotting all the four points
  51. figure(1)
  52. hold on
  53. plot([V2 V3],[P2 P3],'linewidth',1,'color','r');
  54. plot([V4 V1],[P4 P1],'linewidth',1,'color','r');
  55. plot(V1,P1,'*','color','r');
  56. plot(V_comp,P_comp);
  57. plot(V2,P2,'*','color','r');
  58. plot(V3,P3,'*','color','r');
  59. plot(V_exp,P_exp);
  60. plot(V4,P4,'*','color','r');
  61. figure(2)
  62. plot([V1 V2 V3 V4 V1],[P1 P2 P3 P4 P1])

Steps followed to call the function program into main program are as followed:

  1. Assign the meaningful variable and run the function program.
  2. Select the main program.
  3. Come in command window of a main program.
  4. Press the ‘upper arrow button’.
  5. Right click and copy the function program.
  6. Now paste the function program in the main program where it can satisfy the requirements of the main program and will give us a required output.

How does a function program works in main program?

  • For Isentropic Compression we gave following command in command window of function program:

V_comp = xz(bore,stroke,conn_rod,cr,180,0)

  • Now we will call this function program (xz) in main program just after determining the parameters of state point-02. (Line-45)
  • Now we have V_comp but we also need P_comp to plot the Isentropic compression curve.
  • Therefore we used relation:

Constant = P1*V1^gamma (Line-44)

  • Now we got the P_comp. (Line-46)
  • Now we used the plot command to plot the Isentropic compression. (Line-80)
  • Now Run the main-program and we will get the curve for Isentropic compression process.
  • In the same way we can plot the curve for Isentropic expansion process.
  • While plotting curve for Isentropic expansion process we need to assign different variables for the function as V_exp and P_exp as mentioned in Line-58 and Line-59 respectively.
  • Also we must assign the values of start crank angle and end crank angle for expansion process.
  • Plotting of curve for Isentropic Expansion is shown in Line-83.
  • Plotting of curves for Heat addition at constant volume and Heat removal at constant volume are stated in Line-77 and Line-79 respectively by using plot
  • Figure04 shows the actual PV diagram for the coded program of a given problem.

Figure03: Ideal PV-Diagram for Otto cycle.

Figure04: Actual PV-Diagram for Otto cycle.

Errors committed during programming:

  1. Error:

Name of the sub-program (function program) and name of function were different. Whereas in matlab it’s necessary that the name of function and its program must be same to get the valid output.

Figure05: Different Names of both function and its program.

Correction:

Name of function (xa) is corrected and renamed it as the “xz”, which is also a name of function program (xz).

02.Error:

The value of Constant is taken as one (1) that is why output shows the stright line and not the curve.

Figure06: Value of Constant(1) is replaced by Constant (PV^gamma) .

Correction:

For Isentropic compression:

Value of Constant is taken as P1V1^gamma to obtain the required output.

For Isentropic expansion. (Line-44)

Value of Constant is taken as P3V3^gamma to obtain the required output. (Line-57)

03.Error:

Taking imaginary values to define the problem. T3 = 1200 K and T1= 900 K.

Figure07: Plot where point-04 (as per Ideal diagram) is missing.

Values of T3 = 2400 K and T1= 300 K were taken because these values lies in the range of values in which the cycle actually operates.

For therotical values (T3 = 1200 K and T1= 900 K) the matlab will show the output plot but nature of the PV-diagram will be different than that of actual diagram.

For example: If we erase the plot command of point-01 (Line-79) as per ideal PV-diagram point-01 must be missing in the plot but here after running the program point-04 goes missing. That clearly indicates that the nature of the plot is wrong.

Correction:

Values of T3 and T1 were taken as 2400 K and 300 K respectively so that we can obtain the plot and its nature as per actual conditions.

Figure08: PV-diagram for T3 = 1200 and T1 = 900.

Conclusion:

We studied the Otto cycle used in the petrol engines and plot the PV-diagram for the same. To study how the different parameters behaves with respect to one another. Following are the points which we can conclude from the study, that for Otto cycle:

  1. The pressure after combustion (P3) must be highest of all the pressures corresponding to points 1, 2 and 4.
  2. The pressure at the beginning of the process of isentropic compression (P1) must be the lowest of all the pressures corresponding to points 2, 3 and 4.
  3. For the process of Heat addition the volume (V2 = V3) must be constant just because the piston is at one position and does not change its position during this process.
  4. For the process of Heat removal the volumes (V4 = V1) must be constant just because the piston is at one position and does not change its position during this process.
  5. Thermal efficiency of otto cycle: `eta=1-frac{1}{(r)^gamma-1`
  6. Thermal efficiency of studied otto cycle is 93.02%.

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.