DATA ANALYSIS OF ENGINE WITH PYTHON
TOPIC - DATA ANALYSIS WITH PYTHON
AIM-
Calculate the area under the P-V diagram.
Calculate the power output of this engine. Assume that RPM is 1500
This engine consumed 20 micro grams of fuel (per 1 stroke cycle). Calculate its specific fuel consumption.
DATA ANALYSIS - Data analysis is a process of inspecting, transforming, and modeling data with the goal of discovering useful information, informing conclusion and supporting decision making. Data analysis has multiple facets and approaches, encompassing diverse techniques under a variety of names, and is used in different business, science, and socual science domains. In today`s business world, data analysis plays a role in making decisiona make scientific and helping businesses operate more effectively.
IN THIS REPORT WE HAVE MADE FIVE DIFFERENT VARIATION WITH DIFFERENT PARAMETERS.
FIRST CODE SAMPLE- WE HAVE TAKEN CRANK AND PRESSURE.
# Demonstrating file parsing in python
import math
import matplotlib.pyplot as plt
# Basic initialization
line_count = 1
crank = []
pressure = []
# File parsing start here
for line in open ('engine_data.out'):
if '#' not in line:
crank.append(float(line.split()[0]))
pressure.append(float(line.split()[1]))
line_count = line_count + 1
# figure
plt.plot(crank,pressure,linewidth=3)
plt.plot(crank, pressure, c='b',c='r', label='crank','pressure')
leg = plt.legend()
plt.show()
The code gives us the plot of crank and pressure of the engine . We have collected the required data for plotting through the engine data file and we have call the file by using the for loop. Here above we can say that we have used line split command to split or we can say to distinguish the crank and pressure from other parameters. The data file contains the first column as crank and the second column as pressure. Since in python the least variable we can use is 0. So, we have used 0 as first variable for crank and 1 as second variable for pressure.
Above figure, shows us the information regarding the crank and pressure. The is plot is basically generated from the engine data.
SECOND CODE SAMPLE- WE HAVE TAKEN MAXIMUM PRESSURE AND MAXIMUM TEMPERATURE.
# Demonstrating file parsing in python
import math
import matplotlib.pyplot as plt
# Basic initialization
line_count = 1
maxpressure = []
maxtemperature = []
# File parsing start here
for line in open ('engine_data.out'):
if '#' not in line:
maxpressure.append(float(line.split()[2]))
maxtemperature.append(float(line.split()[5]))
line_count = line_count + 1
# figure
plt.plot(maxpressure,linewidth=3)
plt.plot(maxtemperature,linewidth=3)
plt.plot(maxpressure, c='r', label='maxpressure')
plt.plot(maxtemperature, c='b', label='maxtemperature')
leg = plt.legend()
plt.show()
The code gives us the plot of maximum pressure and maximum temperature of the engine . We have collected the required data for plotting through the engine data file and we have call the file by using the for loop. Here above we can say that we have used line split command to split or we can say to distinguish the maximum pressure and maximum temperature from other parameters. The data file contains the third column as maximum temperature and the fifth column as maximum pressure. Since in python the least variable we can use is 0. So, we have used 2 as first variable for maximum pressure and 5 as second variable for maximum temperature.
Above figure, shows us the information regarding the maximum pressure and maximum temperature. The is plot is basically generated from the engine data.
THIRD CODE SAMPLE- WE HAVE TAKEN PRESSURE AND MASS FLOW RATE.
# Demonstrating file parsing in python
import math
import matplotlib.pyplot as plt
# Basic initialization
line_count = 1
pressure = []
cp = []
# File parsing start here
for line in open ('engine_data.out'):
if '#' not in line:
pressure.append(float(line.split()[1]))
cp.append(float(line.split()[12]))
line_count = line_count + 1
print(pressure)
print(cp)
# figure
plt.plot(pressure,linewidth=3)
plt.plot(cp,linewidth=3)
plt.plot(pressure, c='r', label='pressure')
plt.plot(cp, c='b', label='cp')
leg = plt.legend()
plt.show()
The code gives us the plot of pressure and mass flow rate of the engine . We have collected the required data for plotting through the engine data file and we have call the file by using the for loop. Here above we can say that we have used line split command to split or we can say to distinguish the pressure and mass flow rate from other parameters. The data file contains the second column as pressure and the thirteen column as mass flow rate. Since in python the least variable we can use is 0. So, we have used 1 as first variable for pressure and 12 as second variable for mass flow rate.
Above figure, shows us the information regarding the pressure and mass flow rate. The is plot is basically generated from the engine data.
FOURTH CODE SAMPLE- WE HAVE TAKEN PRESSURE AND DENSITY.
# Demonstrating file parsing in python
import math
import matplotlib.pyplot as plt
# Basic initialization
line_count = 1
pressure = []
density = []
# File parsing start here
for line in open ('engine_data.out'):
if '#' not in line:
pressure.append(float(line.split()[1]))
density.append(float(line.split()[9]))
line_count = line_count + 1
print(pressure)
print(density)
# figure
plt.plot(pressure,linewidth=3)
plt.plot(density,linewidth=3)
plt.plot(pressure, c='r', label='pressure')
plt.plot(density, c='b', label='density')
leg = plt.legend()
plt.show()
The code gives us the plot of pressure and density of the engine . We have collected the required data for plotting through the engine data file and we have call the file by using the for loop. Here above we can say that we have used line split command to split or we can say to distinguish the pressure and density from other parameters. The data file contains the second column as pressure and the tenth column as density. Since in python the least variable we can use is 0. So, we have used 1 as first variable for pressure and 9 as second variable for density.
Above figure, shows us the information regarding the pressure and density. The is plot is basically generated from the engine data.
FIFTH CODE SAMPLE- WE HAVE TAKEN PRESSURE AND VOLUME.
# Demonstrating file parsing in python
import math
import matplotlib.pyplot as plt
import numpy as np
# Basic initialization
line_count = 1
pressure = []
volume = []
# File parsing start here
for line in open ('engine_data.out'):
if '#' not in line:
pressure.append(float(line.split()[1]))
volume.append(float(line.split()[7]))
line_count = line_count + 1
# print(pressure)
# print(volume)
# figure
plt.plot(pressure,linewidth=3)
plt.plot(volume,linewidth=3)
plt.plot(pressure, c='r', label='pressure')
plt.plot(volume, c='b', label='volume')
leg = plt.legend()
plt.show()
# Calcuating the area under the pv diagram
# Basically the work done is equal to total area under the pv diagram
# So, calculating the work done by multiplying the pressure with volume
work_done = np.trapz(pressure,volume)*(pow(1,-3))
print(work_done)
# Power output of the engine
# RPM is taken as 1500
power = (work_done*(1500/(2*60)))
print(power)
# Calculate specific fuel consumption
# fuel_consumed_for_one_stroke (in micro gram)
fuel_consumed_for_one_stroke = 20
sfc = (fuel_consumed_for_one_stroke*power)
print(sfc)
The code gives us the plot of pressure and volume of the engine . We have collected the required data for plotting through the engine data file and we have call the file by using the for loop. Here above we can say that we have used line split command to split or we can say to distinguish the pressure and volume from other parameters. The data file contains the second column as pressure and the eigth column as volume. Since in python the least variable we can use is 0. So, we have used 1 as first variable for pressure and 7 as second variable for volume.
Here we have found the required area under pv diagram . Here the area found is equal to work done . For work done we multiply it by pressure and volume. Next we have found the power output of engine . So, power = (work_done*(1500/(2*60))). At last, we have found specific fuel consumption. The formula used is specific fuel consumption = (fuel consumed for one stroke * power).
In above screenshot we have determined the values of area, power and specific fuel consumption
Above figure, shows us the information regarding the pressure and volume. The is plot is basically generated from the engine data.