DATA ANALYSIS (PYTHON)
AIM: DATA VISUALIZATION, COMPATIBILITY CHECK, AND BASIC PERFORMANCE CALCULATION USING PYTHON.
INTRODUCTION: Data analysis is a process of inspecting, cleansing, transforming, and modeling data with the goal of discovering useful information, informing conclusions, 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 social science domains. In today's business world, data analysis plays a role in making decisions more scientific and helping businesses operate more effectively.
The process of data analysis: -
- Data Requirements
- Data Collection
- Data Processing
- Data Cleaning
- Exploratory Data Analysis
- Modeling & algorithms
- Data Product
- Communication
OBJECTIVE:
- Plotting a graph between any two quantities mentioned in the Converge output file
- Defining the successful confirmation of opening of the file
- Calculating the area under the PV Diagram
- Calculating the Power Output for an Engine Speed of 1500 RPM
- Calculating Specific Fuel Consumption for fuel consumed per stroke cycle as 20 mg
GOVERNING EQUATIONS:
- `Power=2π×T×RPM`
- `SFC=(FC)/(Power)`
where,
`T=` Torque
`FC=` Fuel Consumption
`SFC=` Specific Fuel Consumption
PYTHON PROGRAM:
"""
Data Analysis of Port fuel Injection data obtained using Converge
"""
# Importing required modules
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import simps
# Code for successful file opening and reading
try:
open('engine_data.out')
print('File opened successfully')
print('\n')
except:
print('File not recognized. Please provide a valid CONVERGE output file')
else:
line_count = 1
column_num = []
column_name = []
column_units = []
# Empty arrays for values to be stored according to the varibles to be plotted
X = []
Y = []
# The axes values defined according to the column number of the Converge output file
x = 7
y = 1
for line in open('engine_data.out'):
for i in range(0,19):
if i >= 2:
if line_count == 2:
column_num.append(int(line.split()[i]))
for j in range(0,18):
if j>=1:
if line_count == 3:
column_name.append(line.split()[j])
elif line_count == 4:
column_units.append(line.split()[j])
if '#' not in line:
if line_count >= 6:
X.append(float(line.split()[x]))
Y.append(float(line.split()[y]))
line_count = line_count + 1
# Plotting Graphs
plt.figure()
plt.plot(X, Y, linewidth=2, color = 'blue')
plt.title(str(column_name[y]) + ' vs ' + str(column_name[x]))
plt.xlabel(str(column_name[x]) + str(column_units[x]))
plt.ylabel(str(column_name[y]) + str(column_units[y]))
plt.savefig(str(column_name[y]) + ' vs ' + str(column_name[x]) + 'for Engine')
plt.show()
# The Results are as follows:
print('RESULTS: -')
# Area under curve
area = simps(Y,X)*pow(10,6)
print('Area under PV diagram (Joule) = ' + str(area) + ' J')
# RPM
N = 1500
# Fuel Consumption (g/stroke cycle)
m = 20
# No. of Strokes
s = 4
# No. of Cylinders
c = 1
# 1 Power Cycle for every Two revolutions (constant for purpose)
k = 2
power = (c*area*N)/(60*k*1000)
print('Power output = ' + str(power) + ' kW')
# Fuel Consumption (kg/hr)
FC = N*60*m*pow(10,-9)/2
# Specific Fuel Consumption
SFC = FC/power
print('Specific Fuel Consumption = ' + str(SFC) + ' kg/hr/kW')
EXPLANATION OF PROGRAM:
- Initially, the required modules are imported and the Converge output file is opened for reading. A command for the successful opening of the file is generated.
- Empty arrays are constructed for storing the values of the parameters to be plotted. Two variables are defined for selecting the parameters to be plotted by calling their column nos. respectively.
- A 'for loop' is constructed to append the column number values ranging from 0 to 19. Another 'for loop' is constructed for appending the column names and column units.
- The condition statement is used to nullify the existence of lines with the '#' symbol. The counter variable is incremented by 1 for every time the loops are executed.
- The graphs are plotted and the title, as well as labels, are automatically assigned. This is done by mentioning the name of the column with the units.
- Now, the performance parameters are to be considered. The initial input values are assigned and the Engine Power is calculated.
- It is followed by the calculation of Fuel Consumption and Specific Fuel Consumption.
RESULTS:
Area under PV Diagram = 500.587 J
Power Output = 6.257 kW
Specific Fuel Consumption = 0.0001438 kg/hr/kW
PLOTS:
PRESSURE VS VOLUME -
A typical Pressure vs Volume graph depicting the isentropic and isobaric processes.
PRESSURE VS CRANK ANGLE -
The Pressure reaches its peak at Crank angle slightly higher than 0.
VOLUME VS CRANK ANGLE -
The Volume varies as the Piston reciprocates to and fro thereby varying the Crank Angle.
Similarly, graphs for other parameters can be plotted by varying the "x & y values" which correspond to the column no. for the specific parameter.
CONCLUSION: The above analysis gives an elaborative idea of the file extraction and plotting the values with respect to one another. Also, the necessary performance parameters are calculated for development use.