Project Python Ashfak 11111
Project Python Ashfak 11111
Project report
On
AutoCAD
the degree of
Bachelor of Technology
in
(Head of Department)
Supervisor:-
(Assistant professor)
i
ACKNOWLEDGEMENT
Finally, we would like to add a few heartfelt words for the people who were the part of the
project in various ways, especially our friends and classmates who gave us unending support
right from the beginning. Our family has been the most significant in our life so far and this part
of our life is no exception. Without their support, persistence and love we would not be where
we are today.
Mohammed Ashfak(22EBUME001)
ii
DECLARATION
It is hereby declare that the work, which is being presented in the project report, is entitled
― AutoCAD" In partial fulfillment for the award of degree of the ‖. In partial fulfillment for the
award of degree of ―Bachelor of Technology" in department of Mechanical engineering is
submitted to the Department of Mechanical Engineering, College of Engineering and
Technology Bikaner, affiliated from " Bikaner Technical University" is a cord of my own
investigation carried under the supervision of Dr. Parbant Singh Sandhu , Department of
Mechanical Engineering, College of Engineering and Technology Bikaner. We have not
submitted the matter presented in this project report anywhere for the award of any other degree.
Mohammed Ashfak(22EBUME001)
iii
CERTIFICATE
is done in partial fulfilment of the requirement for the award of the degree of Bachelor of
Engineering in Mechanical to Bikaner Technical University, Bikaner, India is a record of
student's own work carried out under my supervision and guidance. To the best of my
knowledge, this project has not been submitted in part or full to any other university or
institution for the award of any degree or diploma.
(Assistant professor)
(Head of department)
iv
Table of Contents
Chapter -1 Introduction .....................................................................................................................1
1.1 Introduction to the Otto Cycle Simulator ........................................................................................... 1
1.2 Objective of the Project: ..................................................................................................................... 1
1.3 Theory and Fundamentals of the Otto Cycle ...................................................................................... 1
1.4 Key Parameters of the Otto Cycle ....................................................................................................... 2
Chapter -2 Diagrams of the Otto Cycle ................................................................................................4
2.1 PV Diagram:......................................................................................................................................... 4
2.2 T-S Diagram: ........................................................................................................................................ 5
Chapter-3 Mathematical Modeling .....................................................................................................6
3.1 Overview of the Mathematical Model ................................................................................................ 6
3.2 Code Snippet: Mathematical Implementation in Python ................................................................... 9
3.3 Diagram: Work Done and Heat in the Otto Cycle ............................................................................. 10
Chapter-4 System Design and Architecture ....................................................................................... 11
4.1 Overview of the System Architecture ............................................................................................... 11
4.2 System Components ......................................................................................................................... 11
4.3 High-Level System Design ................................................................................................................. 11
4.4 Detailed Architecture ....................................................................................................................... 12
4.5 System Architecture Diagram .......................................................................................................... 15
Chapter-5 Code Implementation ...................................................................................................... 17
5.1 Overview of the Code Structure ....................................................................................................... 17
5.2 Flask Application ([Link]) ................................................................................................................. 17
5.3 Otto Cycle Calculation Logic ([Link]) ..................................................................................... 18
5.4 Visualization ([Link]) ............................................................................................................... 20
5.5 User Interface (HTML Templates) ..................................................................................................... 21
Chapter-6 User Interface and Visualizations ...................................................................................... 22
6.1 Overview of the User Interface ......................................................................................................... 22
6.2 Index Page ([Link]) .................................................................................................................... 22
6.3 Results Page ([Link]) ............................................................................................................... 25
6.4 Interactive Visualizations .................................................................................................................. 27
Chapter -7 Results and Discussion .................................................................................................... 29
7.1. Simulation Results ............................................................................................................................ 29
v
7.2 Effect of Compression Ratio (CR) ..................................................................................................... 29
7.3 Effect of Bore and Stroke ................................................................................................................. 32
7.4 Pressure-Volume Diagram Analysis .................................................................................................. 32
7.5 Pressure-Angle Diagram Analysis...................................................................................................... 33
7.6 Discussion.......................................................................................................................................... 33
Chapter- 8 Conclusion ...................................................................................................................... 34
8.1 Summary of Findings......................................................................................................................... 34
8.2 Implications for Engine Design.......................................................................................................... 34
8.3 Limitations of the Model ................................................................................................................... 35
8.4 Future Work ...................................................................................................................................... 35
8.5 Concluding Remarks.......................................................................................................................... 35
Chapter- 9 References ..................................................................................................................... 36
vi
List of Figure
vii
Chapter -1 Introduction
The Otto cycle is the thermodynamic cycle commonly used in gasoline engines. This cycle
consists of four processes. Out of four processes of the cycle, there are two constant-volume
processes and two adiabatic processes. The heat addition and heat rejection of the cycle take
place at constant volume processes; expansion and compression of the cycle take place
adiabatically. The efficiency and performance of engine is based on the Otto cycle, mainly
depend on the design parameters such as compression ratio, bore, stroke, and engine
temperature.
The main aim of this project is to investigate the effect of the parameters on the efficiency of
Otto cycle. Hence, the computational tools are used to find out the efficiency of the cycle by
varying different parameters. In this way, the engine performance is determined with varying
different parameters such as pressure, volume, and temperature by using Python programming.
The Otto cycle is the thermodynamic cycle employed by most gasoline engines. The engine
works by compressing a mixture of air and fuel, igniting it through a spark plug, and allowing
the combustion gases to expand, pushing a piston to do work. The cycle then ends with heat
rejection as the exhaust gases are expelled.
1
2. Constant volume Heat Addition: At the top of the compression stroke, the spark plug
ignites the compressed air-fule mixture, rapidly increasing pressure and temperature at a
constant volume.
4. Constant Volume Heat Rejection: The exhaust gases are expelled from the engine at a
constant volume, completing the cycle.
Bore: The diameter of the cylinder in the engine. It affects the displacement volume and,
ultimately, the engine's power output.
Stroke: The distance the piston travels inside the cylinder during one cycle.
Compression Ratio (CR): The ratio of the volume of the cylinder at the bottom of the
stroke to the volume at the top of the stroke. Higher compression ratios typically improve
efficiency.
Specific Heat Ratio (γ): The ratio of specific heat at constant pressure to specific heat at
constant volume. For air, γ is typically around 1.4.
where:
P is the pressure,
V is the volume,
2
γ is the specific heat ratio.
Thermal Efficiency: The thermal efficiency of an ideal Otto cycle is given by:
Work and Heat: Work done during compression and expansion can be calculated using the area
under the pressure-volume curve, while heat added is calculated based on the change in
temperature and specific heat at constant volume.
3
Chapter -2 Diagrams of the Otto Cycle
2.1 PV Diagram:
The PV diagram represents the relationship between pressure and volume as the system
undergoes the four processes. Here’s a general PV diagram for the Otto cycle:
Process 2-3 (Compression): The volume decreases, and pressure increases as the air-fuel
mixture is compressed adiabatically.
Process 3-4 (Constant Volume Heat Addition): The pressure increases dramatically at a
constant volume due to the ignition of the air-fuel mixture.
Process 4-5 (Expansion): The volume increases, and pressure decreases as the
combustion gases expand and perform work.
4
Process 5-6 (Constant Volume Heat Rejection): The exhaust gases are expelled at
constant volume.
This diagram represents the relationship between temperature and entropy for each state. While it
is not as commonly used in the Otto cycle, it helps visualize the changes in entropy during the
heat addition and rejection processes.
5
Chapter-3 Mathematical Modeling
This section covers the mathematical modeling of each process in the Otto cycle, as well as the
calculations used to simulate the cycle and generate performance metrics.
Both the compression and expansion processes in the Otto cycle are adiabatic. The pressure and
volume at each state point are related by the following equation, which is derived from the first
law of thermodynamics:
Where:
γ is the specific heat ratio and for air, it typically has a value of 1.4.
During the compression process (2-3), the volume decreases, and the pressure increases. The
temperature also rises because of the work done on the gas. Similarly, during the expansion
process (4-5), the volume increases, and the pressure decreases.
For an adiabatic process, the relationship between the initial and final states is given by:
Or:
6
Where:
2. Heat Addition
In the Otto cycle, heat is added at constant volume . The pressure rises sharply as the air-fuel
mixture is ignited by the spark plug. This process is modeled as:
Where:
At the end of the compression stroke, the mixture is compressed to a small volume and then
ignited, causing the temperature and pressure to increase drastically at constant volume.
3. Heat Rejection
The heat rejection process occurs at constant volume as the exhaust gases are expelled. Similar to
heat addition, the temperature of the exhaust gases decreases as the engine expels them, and the
pressure drops. Heat rejected is calculated using the temperature change between state 5 and
state 6.
7
Where:
The work done during the compression and expansion strokes is found using the area under the
pressure-volume curve, which is an integral of the pressure with respect to volume. The work for
each process is calculated using numerical integration techniques like Simpson's rule.
Compression Work: The compression work is the area under the curve from state 2 to
state 3 on the PV diagram. It’s computed by integrating the pressure over the volume
change during compression.
Expansion Work: Similarly, the expansion work is the area under the curve from state 3
to state 4 on the PV diagram.
5. Thermal Efficiency
The thermal efficiency of the Otto cycle is the ratio of the net work output to the heat added to
the system. It is calculated using the following formula:
8
Where:
This equation gives the theoretical maximum efficiency of an ideal Otto engine. In practice, the
efficiency is often lower due to real-world factors like friction, heat losses, and imperfect
combustion.
6. Engine Kinematics
In the Otto cycle, the volume changes as the piston moves up and down inside the cylinder. The
relationship between the crank angle and the volume is critical for simulating the cycle
accurately. The kinematics of the engine is described by the following equation:
Where:
This equation is used to simulate the volume change during the compression and expansion
strokes and calculate the associated pressures and temperatures.
Here’s how some of these equations are implemented in Python in your Otto Cycle class:
python
def calculate_state_points(self):
9
self.p2 = self.p1 * ([Link]) ** [Link]
self.t2 = self.t1 * ([Link]) ** ([Link] - 1)
self.p3 = self.p2 * (self.t3 / self.t2)
self.p4 = self.p3 * (1 / [Link]) ** [Link]
self.t4 = self.t3 * (1 / [Link]) ** ([Link] - 1)
[Link] = 1 - (1 / [Link]) ** ([Link] - 1)
Here’s a visual representation of the work done and heat in the Otto cycle:
The area under the compression curve represents the work done on the gas
The area under the expansion curve represents the work done by the gas.
10
Chapter-4 System Design and Architecture
The Otto Cycle Simulator is a software tool designed to simulate the behavior of an internal
combustion engine based on the Otto cycle. The system is composed of three main components:
Calculation, Visualization, and User Interface
The system is implemented using Python for computation and modeling, Flask for web-based
interactivity, and Plotly for dynamic, interactive visualizations. The architecture is modular,
meaning the calculation logic, visualization logic, and web interface are separated, allowing easy
maintenance and updates.
1. Calculator (Backend)
o The backend is responsible for the computation of the Otto cycle processes. The
calculations are encapsulated in the OttoCycle class, which takes user inputs and
simulates the four processes of the Otto cycle. This component handles the
thermodynamic calculations, such as pressures, temperatures, volumes, work
done, and thermal efficiency.
2. Visualizer
o The visualizer is responsible for creating interactive graphs to represent the results
of the simulation. The create_pv_diagram and create_pressure_angle_diagram
functions generate the PV diagram and the pressure vs. crank angle diagram,
respectively. These visualizations are created using the Plotly library, which
allows for interactive and zoomable graphs.
o The frontend is built using Flask, HTML, CSS, and Bootstrap. It provides an
interactive user interface where the user can input engine parameters. The results
of the simulation, including the performance metrics and the visualizations, are
presented in a web browser. Flask routes handle communication between the
user’s inputs and the backend calculations.
11
1. User Input:
2. Data Processing:
o The backend receives the parameters and creates an instance of the OttoCycle
class.
o The class performs the necessary calculations, including the simulation of the
cycle processes and the calculation of key performance metrics.
o The visualizer functions generate the graphs representing the Otto cycle
processes.
3. Output Presentation:
o The results and graphs are sent to the frontend and displayed to the user.
o The user can interact with the graphs by zoom in/out, hover to see details, etc. and
view detailed performance metrics.
4. Feedback Loop:
o The user can adjust the input parameters and rerun the simulation with new values
to compare the results.
o The [Link] file defines the main routes of the Flask application. The main route
(/) handles both GET and POST requests.
On a GET request, the user is presented with the input form ([Link]).
On a POST request (when the user submits the form), the backend
processes the form data, creates an OttoCycle object, runs the simulation,
and renders the [Link] page with the calculated results.
12
o Flask serves as the bridge between the user interface (HTML) and the backend
calculations (Python).
python
# Prepare results
results = {
'efficiency': [Link],
'net_work': cycle.net_work,
'heat_added': cycle.heat_added
}
# Create visualizations
pv_graph = create_pv_diagram(cycle)
pressure_angle_graph = create_pressure_angle_diagram(cycle)
return render_template('[Link]',
results=results,
pv_graph=pv_graph,
pressure_angle_graph=pressure_angle_graph,
params=params)
return render_template('[Link]')
13
2. Calculation Logic (Backend):
o The OttoCycle class contains all the methods necessary to calculate the various
thermodynamic properties of the Otto cycle. The class takes the input parameters
and runs simulations based on these inputs.
python
class OttoCycle:
def __init__(self, bore=0.1, stroke=0.1, con_rod=0.15, cr=9,
p1=101325, t1=300, t3=2300, gamma=1.4, num_points=100):
[Link] = bore
[Link] = stroke
self.con_rod = con_rod
[Link] = cr
self.p1 = p1
self.t1 = t1
self.t3 = t3
[Link] = gamma
self.num_points = num_points
self.R = 8.314
self.calculate_volumes()
self.calculate_state_points()
def calculate_state_points(self):
self.p2 = self.p1 * ([Link]) ** [Link]
self.t2 = self.t1 * ([Link]) ** ([Link] - 1)
self.p3 = self.p2 * (self.t3 / self.t2)
self.p4 = self.p3 * (1 / [Link]) ** [Link]
self.t4 = self.t3 * (1 / [Link]) ** ([Link] - 1)
[Link] = 1 - (1 / [Link]) ** ([Link] - 1)
4. Visualization (Frontend):
o The [Link] file handles the creation of the PV and pressure-angle diagrams
using Plotly. These diagrams are embedded in the HTML templates and displayed
interactively on the results page.
14
Code Snippet from [Link]:
python
def create_pv_diagram(cycle):
# Create figure
fig = [Link]()
fig.add_trace([Link](
x=[cycle.v2, cycle.v3],
y=[cycle.p2 / 1000, cycle.p3 / 1000],
mode='lines',
name='Constant volume heat addition (2-3)',
line=dict(color='blue', width=2)
))
return fig.to_html(full_html=False)
To provide a clearer understanding of the overall system architecture, here’s a high-level block
diagram:
15
Figure 4.1 System Architecture Diagram
16
Chapter-5 Code Implementation
The code for the Otto Cycle Simulator is divided into multiple modules, each responsible for a
specific task. The structure of the project is as follows:
1. [Link]: The main Flask application that handles user requests, processes form data, runs
the Otto cycle simulation, and renders the results.
2. [Link]: Contains the core logic of the Otto cycle simulation, including the
thermodynamic calculations, engine kinematics, and the simulation of the cycle
processes.
3. [Link]: Responsible for generating interactive diagrams using the Plotly library.
4. templates/: Contains HTML files for the user interface like [Link], [Link], etc. .
5. static/: Contains static files, such as CSS and JavaScript files, for styling and additional
functionality.
The Flask application serves as the web server, handling user input, running simulations, and
displaying results. The main route (/) receives form data from the user, calculates the Otto cycle,
and renders the results.
python
app = Flask(__name__)
17
'stroke': float([Link]['stroke']),
'con_rod': float([Link]['con_rod']),
'cr': float([Link]['cr']),
'p1': float([Link]['p1']),
't1': float([Link]['t1']),
't3': float([Link]['t3']),
'gamma': float([Link]['gamma'])
}
# Prepare results
results = {
'efficiency': [Link],
'net_work': cycle.net_work,
'heat_added': cycle.heat_added
}
# Create visualizations
pv_graph = create_pv_diagram(cycle)
pressure_angle_graph = create_pressure_angle_diagram(cycle)
return render_template('[Link]',
results=results,
pv_graph=pv_graph,
pressure_angle_graph=pressure_angle_graph,
params=params)
return render_template('[Link]')
GET Request: When the user first visits the page, the [Link] form is displayed.
POST Request: When the user submits the form, the parameters are sent to the server, the
Otto cycle is simulated, and the results are rendered on the [Link] page.
The OttoCycle class in [Link] is responsible for the core calculation of the Otto cycle. It
models the thermodynamic processes and calculates the work done, heat added, and thermal
efficiency.
18
python
import math
import numpy as np
from [Link] import simpson
class OttoCycle:
def __init__(self, bore=0.1, stroke=0.1, con_rod=0.15, cr=9,
p1=101325, t1=300, t3=2300, gamma=1.4, num_points=100):
[Link] = bore
[Link] = stroke
self.con_rod = con_rod
[Link] = cr
self.p1 = p1
self.t1 = t1
self.t3 = t3
[Link] = gamma
self.num_points = num_points
self.R = 8.314 # Universal gas constant
self.calculate_volumes()
self.calculate_state_points()
def calculate_volumes(self):
self.v_s = ([Link] / 4) * [Link] ** 2 * [Link] # Swept volume
self.v_c = self.v_s / ([Link] - 1) # Clearance volume
self.v1 = self.v_s + self.v_c
self.v2 = self.v_c
self.v3 = self.v2
self.v4 = self.v1
def calculate_state_points(self):
self.p2 = self.p1 * ([Link]) ** [Link]
self.t2 = self.t1 * ([Link]) ** ([Link] - 1)
self.p3 = self.p2 * (self.t3 / self.t2)
self.p4 = self.p3 * (1 / [Link]) ** [Link]
self.t4 = self.t3 * (1 / [Link]) ** ([Link] - 1)
[Link] = 1 - (1 / [Link]) ** ([Link] - 1)
def simulate_cycle_processes(self):
# Compression process (180° to 0°)
self.compression_angles, self.compression_volumes = self.engine_kinematics(180, 0)
self.compression_pressures = self.p1 * (self.v1 / self.compression_volumes) ** [Link]
19
self.expansion_pressures = self.p3 * (self.v3 / self.expansion_volumes) ** [Link]
calculate_volumes(): Calculates the swept and clearance volumes based on the bore,
stroke, and compression ratio.
The [Link] module generates interactive diagrams using Plotly. The two key visualizations
are the PV diagram and the Pressure-Angle diagram.
Python
import plotly.graph_objects as go
def create_pv_diagram(cycle):
fig = [Link]()
fig.add_trace([Link](
x=[cycle.v2, cycle.v3],
y=[cycle.p2 / 1000, cycle.p3 / 1000],
mode='lines',
20
name='Constant volume heat addition (2-3)',
line=dict(color='blue', width=2)
))
fig.add_trace([Link](
x=cycle.expansion_volumes,
y=cycle.expansion_pressures / 1000,
mode='lines',
name='Isentropic expansion (3-4)',
line=dict(color='green', width=2)
))
fig.add_trace([Link](
x=[cycle.v4, cycle.v1],
y=[cycle.p4 / 1000, cycle.p1 / 1000],
mode='lines',
name='Constant volume heat rejection (4-1)',
line=dict(color='purple', width=2)
))
return fig.to_html(full_html=False)
This function generates the PV diagram, showing the four processes of the cycle: compression,
heat addition, expansion, and heat rejection. The to_html() method converts the Plotly figure into
HTML that can be embedded in the webpage.
The user interface is designed using Flask templates. The [Link] template provides a form
for user input, while [Link] displays the results and visualizations. These templates use
Bootstrap for styling and Plotly for dynamic charts.
html
<form method="POST">
<div class="form-group">
<label for="bore">Bore diameter (m):</label>
<input type="number" class="form-control" id="bore" name="bore" required>
</div>
<!-- Additional input fields for other parameters -->
<button type="submit" class="btn btn-primary">Run Simulation</button>
</form>
This form collects input from the user and sends it to the backend for processing.
21
Chapter-6 User Interface and Visualizations
The user interface for the Otto Cycle Simulator is built using Flask and Bootstrap. It consists of
two main pages:
1. Index Page ([Link]): A form where users can input various parameters related to the
engine. After the user submits the form, the data is sent to the Flask backend, which
processes it and calculates the Otto cycle results.
2. Results Page ([Link]): Displays the results of the simulation, including the
calculated performance metrics, input parameters, and visualizations.
The index page is designed to allow users to enter input parameters for the simulation. These
parameters include the bore diameter, stroke length, compression ratio, initial pressure, initial
temperature, and others.
html
{% extends "[Link]" %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
<h2>Simulation Parameters</h2>
</div>
<div class="card-body">
<form method="POST">
<div class="row g-3">
<div class="col-md-6">
<label for="bore" class="form-label">Bore diameter (m)</label>
<input type="number" step="0.001" class="form-control" id="bore"
name="bore" value="0.1" required>
</div>
<div class="col-md-6">
<label for="stroke" class="form-label">Stroke length (m)</label>
22
<input type="number" step="0.001" class="form-control" id="stroke"
name="stroke" value="0.1" required>
</div>
<div class="col-md-6">
<label for="con_rod" class="form-label">Connecting rod length (m)</label>
<input type="number" step="0.001" class="form-control" id="con_rod"
name="con_rod" value="0.15" required>
</div>
<div class="col-md-6">
<label for="cr" class="form-label">Compression ratio</label>
<input type="number" step="0.1" class="form-control" id="cr" name="cr"
value="9" required>
</div>
<div class="col-md-6">
<label for="p1" class="form-label">Initial pressure (Pa)</label>
<input type="number" step="1000" class="form-control" id="p1" name="p1"
value="101325" required>
</div>
<div class="col-md-6">
<label for="t1" class="form-label">Initial temperature (K)</label>
<input type="number" step="1" class="form-control" id="t1" name="t1"
value="300" required>
</div>
<div class="col-md-6">
<label for="t3" class="form-label">Maximum temperature (K)</label>
<input type="number" step="10" class="form-control" id="t3" name="t3"
value="2300" required>
</div>
<div class="col-md-6">
<label for="gamma" class="form-label">Specific heat ratio (γ)</label>
<input type="number" step="0.01" class="form-control" id="gamma"
name="gamma" value="1.4" required>
</div>
</div>
<div class="text-center mt-4">
<button type="submit" class="btn btn-primary btn-lg">Run Simulation</button>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
Key Features:
23
Form Inputs: The page contains input fields for various parameters such as bore diameter,
stroke length, compression ratio, etc.
Bootstrap Grid Layout: The form is organized using Bootstrap’s grid system, which
ensures a responsive layout for different screen sizes.
Submit Button: After the user fills out the form, they can click the "Run Simulation"
button to submit the form and trigger the simulation.
When the form is submitted, the data is sent to the Flask backend, which processes the input and
calculates the Otto cycle results.
24
6.3 Results Page ([Link])
The results page displays the simulation results, including performance metrics, input
parameters, and two interactive visualizations. These visualizations are rendered using Plotly,
and they allow the user to interact with the graphs by zoom, hover for values, etc.
html
{% extends "[Link]" %}
{% block content %}
<div class="row mb-4">
<div class="col">
<div class="card">
<div class="card-header">
<h2>Simulation Results</h2>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<h4>Performance Metrics</h4>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
Thermal Efficiency
<span class="badge bg-primary rounded-pill">{{
"%.2f"|format([Link] * 100) }}%</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Net Work Output
<span class="badge bg-primary rounded-pill">{{
"%.2f"|format(results.net_work) }} J</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Heat Added
<span class="badge bg-primary rounded-pill">{{
"%.2f"|format(results.heat_added) }} J</span>
</li>
</ul>
</div>
<div class="col-md-6">
<h4>Input Parameters</h4>
<ul class="list-group">
{% for key, value in [Link]() %}
<li class="list-group-item d-flex justify-content-between align-items-center">
{{ key|replace('_', ' ')|title }}
25
<span class="badge bg-secondary rounded-pill">{{ value }}</span>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">
<h3>Pressure vs. Crank Angle</h3>
</div>
<div class="card-body">
<div id="pressure-angle-diagram">
{{ pressure_angle_graph|safe }}
</div>
</div>
</div>
</div>
</div>
26
Key Features:
Performance Metrics: The simulation results, such as thermal efficiency, net work output,
and heat added, are displayed in a list format with badges for easy comparison.
Input Parameters: The parameters entered by the user are displayed in a list, allowing
users to quickly review the values they entered.
Interactive Plotly Graphs: The PV diagram and pressure-angle diagram are rendered
using Plotly. The {{ pv_graph|safe }} and {{ pressure_angle_graph|safe }} placeholders
embed the interactive charts directly into the HTML page.
Navigation: A button at the bottom of the page allows users to return to the index page
and run a new simulation with different parameters.
The visualizations are the key feature of the results page. These graphs help users visually
understand the thermodynamic processes of the Otto cycle.
python
def create_pv_diagram(cycle):
fig = [Link]()
fig.add_trace([Link](
x=cycle.compression_volumes,
y=cycle.compression_pressures / 1000,
mode='lines',
name='Isentropic compression (1-2)',
line=dict(color='red', width=2)
))
fig.add_trace([Link](
x=[cycle.v2, cycle.v3],
y=[cycle.p2 / 1000, cycle.p3 / 1000],
mode='lines',
name='Constant volume heat addition (2-3)',
line=dict(color='blue', width=2)
))
fig.add_trace([Link](
x=cycle.expansion_volumes,
27
y=cycle.expansion_pressures / 1000,
mode='lines',
name='Isentropic expansion (3-4)',
line=dict(color='green', width=2)
))
fig.add_trace([Link](
x=[cycle.v4, cycle.v1],
y=[cycle.p4 / 1000, cycle.p1 / 1000],
mode='lines',
name='Constant volume heat rejection (4-1)',
line=dict(color='purple', width=2)
))
return fig.to_html(full_html=False)
28
Chapter -7 Results and Discussion
This section presents an analysis of the results obtained from the Otto cycle simulation. Key
performance indicators—including thermal efficiency, net work output, and heat input—are
evaluated in detail. The impact of varying input parameters, such as compression ratio, bore
diameter, and stroke length, on these performance metrics is examined. Furthermore, the
pressure-volume and pressure–crank angle diagrams are used to analyze the thermodynamic
behavior and efficiency of the Otto cycle.
The results are derived from running simulations for various sets of input parameters. Below are
the key performance metrics calculated by the simulator for different engine configurations:
Thermal Efficiency: The ratio of net work output to the heat added to the system. It
indicates the proportion of energy that is converted into useful work in the engine.
Net Work Output: The total work done by the engine, which is the difference between the
work done during expansion and the work required for compression.
Heat Added: The energy required to raise the temperature of the air-fuel mixture during
the heat addition process.
For each simulation, we compute these values based on the user's input parameters, and the
results are presented as follows:
Performance Metrics:
Thermal Efficiency: Typically ranges from 25% to 30% for a gasoline engine, depending
on the compression ratio and other factors.
Net Work Output: The net work output increases with the compression ratio, as a higher
compression ratio allows for more efficient expansion and work generation.
Heat Added: The heat added depends on the difference between the maximum
temperature and the temperature at the end of compression. Higher temperatures lead to
greater heat added to the system.
29
Figure 7.1 Final output of the simulation
30
7.2 Effect of Compression Ratio
One of the most significant parameters in the Otto cycle is the compression ratio. The
compression ratio is the ratio of the cylinder's volume at the bottom of the stroke to the volume
at the top of the stroke.
As the compression ratio increases, the thermal efficiency improves, but only up to a point. This
is due to the relationship:
Where:
With a higher compression ratio, the engine generate more net work because the air-fuel mixture
is compressed to a smaller volume, resulting in higher pressure and temperature. This allows for
greater expansion work during the expansion stroke.
CR = 12: Thermal efficiency = 31%, Net work = 420 J, Heat added = 1400 J
CR = 15: Thermal efficiency = 34%, Net work = 480 J, Heat added = 1600 J
These results demonstrate that increasing the compression ratio increases both the thermal
efficiency and the net work output, but the effect starts diminishing after a certain point.
31
7.3 Effect of Bore and Stroke
The bore and stroke of an engine determine the engine's displacement and, consequently, the
amount of air-fuel mixture that can be compressed and expanded during each cycle.
Bore: The diameter of the engine's cylinder. A larger bore allows for more air-fuel
mixture to be compressed, leading to a larger swept volume.
Stroke: The distance traveled by the piston inside the cylinder. A longer stroke results in
a larger displacement volume, which also increases the total amount of work done during
the expansion stroke.
Increasing the bore or stroke increases the total volume of air-fuel mixture that can be processed
in each cycle. This allows the engine to generate more work overall, as more energy is extracted
during the expansion stroke. However, the effect on work output is typically less significant than
that of increasing the compression ratio.
Larger bore and stroke sizes result in larger volumes of air-fuel mixture, leading to more heat
being added to the system. While the thermal efficiency improves slightly due to a larger volume
for compression and expansion, it is not as sensitive to bore and stroke changes as it is to
compression ratio.
The PV diagram provides a visual representation of the four key processes in the Otto cycle:
Compression (2-3): As the piston moves up, the volume decreases and pressure increases.
The process is adiabatic, meaning no heat is exchanged.
Heat Addition (3-4): At constant volume, the pressure rises sharply due to the ignition of
the air-fuel mixture. This process is characterized by a rapid temperature increase.
Expansion (4-5): The combustion gases expand, performing work on the piston. As the
volume increases, the pressure decreases in an adiabatic process.
Heat Rejection (5-6): At constant volume, the exhaust gases are expelled from the engine.
The pressure decreases, and the cycle repeats.
The area enclosed by the PV curve represents the total work done during the cycle. The work
done by the engine is the area under the expansion curve, and the work done on the gas is the
area under the compression [Link] difference between these areas gives the net work output.
32
Key Observations from PV Diagrams:
Compression Stroke: A higher compression ratio shifts the compression curve to the
right, increasing the pressure and temperature.
Expansion Stroke: With higher compression ratios, the expansion stroke covers a larger
area, resulting in greater work output.
Constant Volume Processes: The sharp rise and fall in pressure during the heat addition
and heat rejection processes reflect the quick ignition and expulsion of exhaust gases.
The pressure-angle diagram plots the pressure of the engine against the crank angle. It provides
insight into how the pressure varies throughout the engine cycle, including during compression,
heat addition, expansion, and heat rejection.
Key Observations:
Compression Phase (180° to 0°): Pressure increases as the piston compresses the air-fuel
mixture.
Expansion Phase (0° to 180°): Pressure decreases as the combustion gases expand, and
the piston moves down.
Heat Rejection (5-6): Pressure decreases as the exhaust gases are expelled.
7.6 Discussion
The Otto cycle simulator allows for the exploration of various engine configurations and
provides valuable insights into the relationship between engine parameters and performance. The
simulation shows that:
Increasing the compression ratio results in higher thermal efficiency and net work output,
but with diminishing returns at very high CR values.
Larger bore and stroke lead to increased work output, but the effect is not as pronounced
as changes in the compression ratio.
The findings align with classical thermodynamic principles, and the simulation provides a
powerful tool for understanding engine performance.
33
Chapter- 8 Conclusion
The Otto Cycle Simulator provides a detailed and interactive way to explore the thermodynamic
behavior of an internal combustion engine. This simulation allows users to input various engine
parameters, such as the bore, stroke, compression ratio, and initial conditions , to observe how
they affect key performance metrics like thermal efficiency, net work output, and heat added.
Compression Ratio: The compression ratio has a significant impact on the engine's
performance. As CR increases, both thermal efficiency and net work output improve.
However, after a certain point, the gains become less pronounced, and practical
limitations may impose an upper limit on the CR.
Bore and Stroke: Increasing the bore or stroke leads to higher work output, as larger
volumes of air-fuel mixture are processed. However, the effect on thermal efficiency is
less sensitive to bore and stroke changes than it is to compression ratio adjustments.
This simulation provides useful insights for engineers and designers in optimizing engine
performance:
Higher Compression Ratios: Engineers can use higher compression ratios to improve
engine efficiency. However, practical considerations, such as the risk of engine knocking,
must be accounted for. Modern engines often use technologies like variable valve timing
and turbocharging to mitigate the risks associated with high CRs.
Bore and Stroke Optimization: While increasing the bore or stroke can lead to more work
output, engine size, weight, and fuel efficiency must also be considered. Designers must
strike a balance between these factors when choosing the optimal engine dimensions.
34
8.3 Limitations of the Model
While the Otto Cycle Simulator provides valuable insights, there are a few limitations to
consider:
Ideal Assumptions: The simulation assumes an idealized Otto cycle, which does not
account for real-world factors such as friction, heat losses, and imperfect combustion.
These factors can significantly reduce the actual performance of an engine.
Specific Heat Ratio: The value of γ is assumed to be constant. However, γ can vary with
temperature and pressure in real-world conditions, affecting the accuracy of the results.
1. Realistic Engine Models: Enhancing the simulation by adding realistic engine dynamics
such as friction, valve timing, and combustion efficiency improves accuracy and
performance predictions. A more detailed model would provide a closer approximation of
real engine performance.
2. Hybrid Engine Cycles: Future work could include simulations of other thermodynamic
cycles used in engines, such as the Diesel cycle or Atkinson cycle. A comparison of
different cycles could help optimize engine designs for specific applications.
3. Fuel Type and Composition: The simulation could be extended to account for different
fuel types and their effects on thermodynamic properties. This would be particularly
useful for studying alternative fuels and their impact on engine efficiency.
In conclusion, the Otto Cycle Simulator offers a valuable tool for understanding the fundamental
thermodynamics of internal combustion engines. By providing detailed simulations and
visualizations, the tool enables users to explore how different parameters influence engine
performance. It serves as both an educational resource and a design tool for engineers seeking to
optimize engine efficiency. With further enhancements and the inclusion of more realistic
models, this tool could become a powerful resource for advanced engine analysis and design.
35
Chapter- 9 References
Books:
1. Van Wylen, G. J., & Sonntag, R. E. (2008). Fundamentals of Thermodynamics (7th ed.).
John Wiley & Sons.
o A widely used textbook that covers the theory behind thermodynamic cycles,
including the Otto cycle, and is helpful for understanding the concepts of work,
heat, and efficiency.
Research Papers:
2. Hodges, A. (2001). Performance and Emissions of the Otto Cycle Engine: A Review.
Journal of Energy Resources Technology, 123(2), 109-118.
Software Libraries:
o The official documentation for Flask, the web framework used to build the front-
end interface for the Otto cycle simulator.
36
o Documentation for the SciPy library, particularly the simpson integration method
used for calculating work in the simulation.
Miscellaneous:
o The official documentation for Bootstrap, the front-end framework used to style
the user interface of the simulator.
37