Week 6 - Data analysis
Aim: To do Data Analysis for the Engine Output data and nd the PV diagram and to nd work, power, and specific fuel consumption.
Theory: Data analytics is the science of analyzing raw data in order to make conclusions about that information. Many of the techniques and processes of data analytics have been automated into mechanical processes and algorithms that work over raw data for human consumption.
Data analytics techniques can reveal trends and metrics that would otherwise be lost in the mass of information. This information can then be used to optimize processes to increase the overall efficiency of a business or system.
Formula Used:
`Power = (n ⋅ M) /9550`
n = engine speed [rpm]
M = torque [Nm]
9550 = constant derived from the calculation of all factors when the numerical values for nare entered in rpm and M, in Nm
`(sc) = (mf)/(Power)`
Sfc = specific fuel consumption
Mf = mass flow rate
Program Code:`
#Writing a Program on Data Analysis for the Output Data
'''Importing the Libraries'''
import matplotlib.pyplot as plt
import math
import numpy as np
from numpy import trapz as trp
#Compatibility Check of The File
try:
data = open('engine_data.out','r')
except FileNotFoundError:
print(' "File not recognized. Please provide a valid CONVERGE output file"')
datafile = 'engine_data.out'
count_row = 0
count_column = 0
count_header =0
column_title = []
column_unit = []
# Reading the Data and the Parameters of Data File
for line in open(datafile,'r'):#Using the for loop to read the lines
if '#' not in line: #Using if elseif statement for the range
count_row = count_row +1
count_column = len(str.split(line))
else:
count_header = count_header + 1
if count_header == 3:
line_content = str.split(line)
for i in range(1,len(line_content)):
column_title.append(line_content[i])
elif count_header ==4:
line_content = str.split(line)
for j in range(1,len(line_content)):
column_unit.append(line_content[j])
#To print the parameters correctly
for i in range(0,count_column):
print(column_title[i],i+1)
#For Input of the Column number from 1 to 17
x=input("Please give required x axis data column number (1-17) 1-Crank to 17-Dynamic Viscosity ")
nx=int(x)
print('Parameter choosen on X-axis is ',column_title[nx-1])
y=input("Please give required y axis data column number (1-17) 1-Crank to 17-Dynamic Viscosity ")
ny=int(y)
print('Parameter choosen on Y-axis is ',column_title[ny-1])
print("The Graph you requested is for ",column_title[ny-1],"vs",column_title[nx-1])
#Taking the empty array file for both x and y
data_array_x=[]
data_array_y=[]
for i in open(datafile,'r'):
if '#' not in i:
data_array_x.append(float(i.split()[nx-1]))
for j in open(datafile,'r'):
if '#' not in j:
data_array_y.append(float(j.split()[ny-1]))
#Plotting and Saving the file of the data
plt.plot(data_array_x,data_array_y)
plt.xlabel(column_title[nx-1]+column_unit[nx-1])
plt.ylabel(column_title[ny-1]+column_unit[ny-1])
plt.savefig(column_title[ny-1] +' vs '+ column_title[nx-1]+'.png')
plt.show()
#Area for PV diagram
volume = [] # Empty array for Volume
pressure = [] # Empty array for Pressure
for line in open(datafile,'r'):
if '#' not in line:
volume.append(float(line.split()[8])) #Appending Volume value
pressure.append(float(line.split()[1])) #Appending Pressure value
area = np.trapz(pressure,volume) #Calculating area using Trapeziodal rule print('Area under the PV curve is ',area)
#Calculating Power of the Engine Data given
rpm = 1500
power = (area*1e+06*rpm)/9550
print('The power output of the engine is ',power,'KW')
#Calculating Specific Fuel Consumption
Fuel_per_stroke = 20*1e-06
Mf=2.99*1e-10 #Mass Flow Rate(grams)
Sfc = Mf/ (power) #Specific Fuel Consumption in (g/KW)
print('The Specific Fuel Consumption is :',Sfc,'g/KW')
Results and Plots:
Conclusion:
From this, we can conclude that we can use python for data analytics in automation to find the required le in a bunch of data le and to plot the specific file plots and result whichever is needed.