PV DIAGRAM FOR OTTO CYCLE USING MATLAB
Objective:
To write a Matlab Program to creat a PV diagram for the Otto Cycle.
Otto Cycle:
It is an air standard cycle. Because it works mostly on the source of air. This otto cycle is working on the SI engine and Diesel cycle is Working on the Diesel Engine
Process in Otto Cycle:
Process 1-2
Isentropic compression (s=c)
Pv^gamma=c and PV=mRT (Ideal gas law) is applicable. From this formula and the given output we easily find the value of Pressure, Temperature and Volume obtained at the process 1 to 2.
Process 2-3
Constant Volume Heat Addition (volume=constant)
(PV)/T = c and the value of cr is used to calculate the state points of P,T,V for 2 and 3.
Process 3-4:
Isentropic Expansion (s=c)
lly use the formula to find the points 3 and 4 for P,T,V.
Process 4-1
Constant Volume Heat Rejection.
Efficiency:
E=output/input
E for Otto cycle = 1 - (1/(compression ration^(gamma-1))).
Compression Ratio:
The ratio of volume at the begining of the compression to the volume at the end of the compression.
rc=v1/v2.
Program:
clear all
close all
clc
%otto cycle
%given data
l=0.1
d=0.1
cr=12
%Process 1-2
%1.Isentropic compression
P1=1%bar
T1=500%kelvin
%V1=vs+vc
vs=pi*0.25*d*d*l
vc=vs/(cr-1)
V1=vs+vc
%2.Constant Volume Heat addition
%process 2-3
V2=vc
%(PV)/T = constant
%P2(V2^g) =P1(V1^g)
a=P1*(V1^1.4)
P2=a/(V2^1.4)
T2=T1*(cr^(1.4-1))
%(P2V2)/(T2)=(P3V3)/(T3)
V3=V2
T3=2000%k
P3=(P2/T2)*T3
%3. Isentropic Expansion
%Process3 to 4
%P3(V3^g) =P4(V4^g)
T4=T3/(cr^(0.4))
%Constant Volume Heat Rejection
%Process 4 to 1
V4=V1
%P1V1/T1=P4V4/T4
P4=(P1/T1)*T4
%plot([V1 V2],[P1 P2],[V2 V3],[P2 P3],[V3 V4],[P3 P4],[V4 V1],[P4 P1],'linewidth',3)
%xlabel('Volume')
%ylabel('Pressure')
%title('PV Diagram of Otto cycle')
%legend('Isentropic compression','CV Heat addition','Isentropic expansion','CV Heat rejection')
%grid on
%by doing this i get isentopic curve is straight line. for that we need to generate the
%array
%for compression
Volume1=linspace(V2,V1,100)%(v2 small value, v1 large value in b/w we generate 10 values)
%PVolume^g=C this value is constant everywhere in isentropic curve
%P1V1=c
%Pvol^g=P1V1^g
Pressure1 =(P1.*(V1.^1.4))./(Volume1.^1.4)%scalar to vector(matrix to scalar elementwise)
%for Expansion
Volume2=linspace(V3,V4,100)%for 3 to 4 use v3 and v4
Pressure2=(P3.*(V3.^1.4))./(Volume2.^1.4)
plot(Volume1,Pressure1,[V2 V3],[P2 P3],Volume2,Pressure2,[V4 V1],[P4 P1],'linewidth',3)
xlabel('Volume')
ylabel('Pressure')
title('PV Diagram of Otto cycle')
legend('Isentropic compression','CV Heat addition','Isentropic expansion','CV Heat rejection')
grid on
%So creating the volume array between process 1 and 2 and process 3 and 4 by using linspace.
%creating the pressure aray by using pv^g=c (two unknown and one equation), PV^g
%value is same everywhere thats why pv^g=c in the curve, so use pv^g=p1v1^g
%for 1 and 2 and pv^g and p3v3 for 3 to 4. [v1 is single volume.(1x1)]
%Efficiency of the otto cycle
efficiency= 1-(1/(cr^(1.4-1)))
OutPut:
l =
0.1000
d =
0.1000
cr =
12
P1 =
1
T1 =
500
vs =
7.8540e-04
vc =
7.1400e-05
V1 =
8.5680e-04
V2 =
7.1400e-05
a =
5.0819e-05
P2 =
32.4230
T2 =
1.3510e+03
V3 =
7.1400e-05
T3 =
2000
P3 =
48
T4 =
740.2143
V4 =
8.5680e-04
P4 =
1.4804
Volume1 =
1.0e-03 *
Columns 1 through 9
0.0714 0.0793 0.0873 0.0952 0.1031 0.1111 0.1190 0.1269 0.1349
Columns 10 through 18
0.1428 0.1507 0.1587 0.1666 0.1745 0.1825 0.1904 0.1983 0.2063
Columns 19 through 27
0.2142 0.2221 0.2301 0.2380 0.2459 0.2539 0.2618 0.2697 0.2777
Columns 28 through 36
0.2856 0.2935 0.3015 0.3094 0.3173 0.3253 0.3332 0.3411 0.3491
Columns 37 through 45
0.3570 0.3649 0.3729 0.3808 0.3887 0.3967 0.4046 0.4125 0.4205
Columns 46 through 54
0.4284 0.4363 0.4443 0.4522 0.4601 0.4681 0.4760 0.4839 0.4919
Columns 55 through 63
0.4998 0.5077 0.5157 0.5236 0.5315 0.5395 0.5474 0.5553 0.5633
Columns 64 through 72
0.5712 0.5791 0.5871 0.5950 0.6029 0.6109 0.6188 0.6267 0.6347
Columns 73 through 81
0.6426 0.6505 0.6585 0.6664 0.6743 0.6823 0.6902 0.6981 0.7061
Columns 82 through 90
0.7140 0.7219 0.7299 0.7378 0.7457 0.7537 0.7616 0.7695 0.7775
Columns 91 through 99
0.7854 0.7933 0.8013 0.8092 0.8171 0.8251 0.8330 0.8409 0.8489
Column 100
0.8568
Pressure1 =
Columns 1 through 9
32.4230 27.9765 24.4818 21.6740 19.3764 17.4668 15.8586 14.4886 13.3096
Columns 10 through 18
12.2860 11.3904 10.6011 9.9012 9.2769 8.7171 8.2129 7.7567 7.3423
Columns 19 through 27
6.9644 6.6187 6.3014 6.0093 5.7397 5.4901 5.2586 5.0434 4.8428
Columns 28 through 36
4.6555 4.4803 4.3161 4.1620 4.0171 3.8806 3.7518 3.6303 3.5153
Columns 37 through 45
3.4064 3.3032 3.2052 3.1121 3.0236 2.9392 2.8589 2.7822 2.7090
Columns 46 through 54
2.6390 2.5721 2.5080 2.4466 2.3878 2.3313 2.2771 2.2250 2.1749
Columns 55 through 63
2.1268 2.0804 2.0357 1.9927 1.9511 1.9111 1.8724 1.8351 1.7990
Columns 64 through 72
1.7641 1.7304 1.6977 1.6661 1.6355 1.6059 1.5771 1.5492 1.5222
Columns 73 through 81
1.4959 1.4705 1.4457 1.4217 1.3983 1.3756 1.3535 1.3320 1.3111
Columns 82 through 90
1.2908 1.2710 1.2517 1.2329 1.2145 1.1967 1.1793 1.1623 1.1457
Columns 91 through 99
1.1295 1.1138 1.0984 1.0833 1.0686 1.0543 1.0402 1.0265 1.0131
Column 100
1.0000
Volume2 =
1.0e-03 *
Columns 1 through 9
0.0714 0.0793 0.0873 0.0952 0.1031 0.1111 0.1190 0.1269 0.1349
Columns 10 through 18
0.1428 0.1507 0.1587 0.1666 0.1745 0.1825 0.1904 0.1983 0.2063
Columns 19 through 27
0.2142 0.2221 0.2301 0.2380 0.2459 0.2539 0.2618 0.2697 0.2777
Columns 28 through 36
0.2856 0.2935 0.3015 0.3094 0.3173 0.3253 0.3332 0.3411 0.3491
Columns 37 through 45
0.3570 0.3649 0.3729 0.3808 0.3887 0.3967 0.4046 0.4125 0.4205
Columns 46 through 54
0.4284 0.4363 0.4443 0.4522 0.4601 0.4681 0.4760 0.4839 0.4919
Columns 55 through 63
0.4998 0.5077 0.5157 0.5236 0.5315 0.5395 0.5474 0.5553 0.5633
Columns 64 through 72
0.5712 0.5791 0.5871 0.5950 0.6029 0.6109 0.6188 0.6267 0.6347
Columns 73 through 81
0.6426 0.6505 0.6585 0.6664 0.6743 0.6823 0.6902 0.6981 0.7061
Columns 82 through 90
0.7140 0.7219 0.7299 0.7378 0.7457 0.7537 0.7616 0.7695 0.7775
Columns 91 through 99
0.7854 0.7933 0.8013 0.8092 0.8171 0.8251 0.8330 0.8409 0.8489
Column 100
0.8568
Pressure2 =
Columns 1 through 9
48.0000 41.4172 36.2436 32.0868 28.6853 25.8584 23.4776 21.4493 19.7039
Columns 10 through 18
18.1886 16.8626 15.6942 14.6580 13.7337 12.9051 12.1586 11.4832 10.8697
Columns 19 through 27
10.3103 9.7985 9.3288 8.8963 8.4972 8.1278 7.7850 7.4664 7.1694
Columns 28 through 36
6.8922 6.6328 6.3897 6.1616 5.9470 5.7449 5.5543 5.3743 5.2041
Columns 37 through 45
5.0429 4.8901 4.7451 4.6073 4.4762 4.3513 4.2324 4.1189 4.0105
Columns 46 through 54
3.9069 3.8078 3.7129 3.6221 3.5349 3.4513 3.3711 3.2940 3.2198
Columns 55 through 63
3.1485 3.0798 3.0137 2.9500 2.8885 2.8292 2.7720 2.7167 2.6633
Columns 64 through 72
2.6117 2.5617 2.5134 2.4666 2.4213 2.3774 2.3348 2.2935 2.2535
Columns 73 through 81
2.2146 2.1769 2.1403 2.1047 2.0701 2.0365 2.0038 1.9720 1.9410
Columns 82 through 90
1.9109 1.8816 1.8530 1.8252 1.7980 1.7716 1.7458 1.7207 1.6961
Columns 91 through 99
1.6722 1.6488 1.6260 1.6038 1.5820 1.5608 1.5400 1.5197 1.4998
Column 100
1.4804
efficiency =
0.6299
>>
From the above Program I mentioned the error that i faced during the coding and also shows the coding to overcome that error.
By using above Code, we get the PV diagram as,
The above diagram shows the PV diagram of the otto cycle.
Size:
Plot Explanation:
For Isentropic Process, compression take place which the volume is decreased and the pressure is increased.
For constant volume Heat addition, heat is added which shows the pressure is increased. From this logic compared with the plot we easily visualize the piston is running inside the cylinder and the process takes place.
Problem Faced During Coding:
Since we know that two points creating a line. At first we create the otto cycle with the help of the single value we get the error as,
This code leads to get PV diagram as,
we get a single point. To convert this single we need array of point between and isentropic compression and expansion.
We know isentropic process PV^gamma = c.
From v1 and v2 create the volume array and substitute this volume array by above equation and equate the equation by P1V1^gamma=c to get the pressure array for compression .
Similalry did the same method to get the curve for expansion process.
Conclusion:
PV diagram for ottocyle is created by using the Matlab program without using the kinematic equation. We can also create the PV diagram by using kinematic equation which helps to track the volume for different crank angle and for the different compression ratio.