Project #2:- solve an otto cycle and make plots for it.
Question
Write code that can solve an otto cycle and make plots for it.
Here are the requirements
- Your code should create a PV diagram
- You should output the thermal efficiency of the engine.
Basic of ideal otto cycle:-
Otto cycle is used for SI engine. Its consist of four strokes and four processes. These four processes of an engine will be responsible for the four strokes. strokes are responsible for developing the power of power of engine that results in vehicle movement. The ideal otto cycle mainly consists for processes
- Iscentropic/Adiabatic compression(1-2)
- Contant volume heat addition(2-3)
- Iscentropic//Adiabatic expansion(3-4)
- Contant volume heat rejection(4-1)

fig1:- PV diagram of otto cycle
- Compression Ratio:- Its ratio of volume of piston at BDC to volume of piston at TDC
compression ration(cr)=volume of piston at BDC/volume of piston at TDC
also
compression ration=swept volume+clearance volumn/clearnace volume
cr=s_v+c_v/c_v
also,
v1=piston at BDC=s_v+c_v
v2=piston at TDC=c_v
so, Compression ratio=v1/v2
- Expansion Ratio:- its ratio of volume before expansion to volumn after expansion.
expansion ratio(er)=v3/v4
- Swept volume(v_s):- Its volume of cylinder when piston is at BDC or volume of cylinder before compresion.
- Clearance volume(v_c):- Its volume of cylinder when piston is at TDC or volume after compression.
Program 1:- Otto cycle using MATLAB(Only state points)


fig3: Error Due to use of plot command directly
Now, To correct this error we have to use thermodynamic relation during compression and expansion process.Also we have to determine how volumn is changes according to crank angle
Program 2- Code to create funtion
During this calling or saving the code of function we have to take care of that function name and file name is same.
Problem-
My function is not running due to different file and function name during this coding. j have made it same to correct this error.
Now we have to calculate volume during compression and expansion process.
so for compression process,
To find volume,
v_compression=engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)
Now during compression piston is travelling from BDC to TDC.so,
v_compression=engine_kinematics(bore,stroke,con_rod,cr,180,0)
To find pressure,
p1*v1^gamma=c_contant
p_compression=c_contant/v_compression.^gamma
For expansion process,
To find volumn,
v_expansion=engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank)
Now during expansion piston is travelling from TDC to BDC.so,
v_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180)
To find pressure,
p3*v3^gamma=c_contant
p_expansion=c_contant/v_expansion.^gamma
Thermal efficiecy can be calculated

Fig3:- pv diagram of air standard cycle
All variables value(output)

Thermal efficiency:-
