Week 6 - Data analysis
Aim :- Data analysis of IC Engine data and perform operation to get following results.
- 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.
Introduction :- Data analysis is a process of inspecting, cleansing, transforming and modelling 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. Data mining is a particular data analysis technique that focuses on statistical modelling and knowledge discovery for predictive rather than purely descriptive purposes, while business intelligence covers data analysis that relies heavily on aggregation, focusing mainly on business information. In statistical applications, data analysis can be divided into descriptive statistics, exploratory data analysis (EDA), and confirmatory data analysis (CDA). EDA focuses on discovering new features in the data while CDA focuses on confirming or falsifying existing hypotheses. Predictive analytics focuses on application of statistical models for predictive forecasting or classification, while text analytics applies statistical, linguistic, and structural techniques to extract and classify information from textual sources, a species of unstructured data. All of the above are varieties of data analysis.
##Steps of data analysis for IC engine data:-
- The required libraries including matplotlib.pyplot and numpy is imported
- The first compaitablity test is done using try and except function
- using for loop the the names of the coloumns as well as their units are stored in arrays.
- Data Visualizer
- Graph plot for crank Angle and Volume
- Calulation for P V graph
- Graph plot for P V Graph
- Basic Performance calculation
############""""""""""" Code for graph of crank Angle and Volume''''''''''''''''''''#########
""" PROGRAM TO PERFORM DATA ANALYSIS of giveN IC Engine Data"""
import math
import matplotlib.pyplot as plt
import numpy as np
try :
open('engine_data.out','r')
except : # if the output displays FileNotFoundError then we print the below
print('File not recognized. Please provide a valid CONVERGE output file.')
file_name = open('engine_data.out','r') # opening and reading the file
for i,l in enumerate(file_name): # enumerate keyword stores assigned values in the 'i' variable
if '#' in l :
if i == 2:
c = l.split()
# DATA VISUALIZER
crank_angle = 1 # crank angle
volume= 8 # volume
x_data = []
y_data = []
for line in open('engine_data.out','r'): # feeding data into the file name arrays
if '#' not in line:
x_data.append(float(line.split()[crank_angle-1])) # appending the data into the specific file name
y_data.append(float(line.split()[volume-1]))
# GRAPH PLOTS FOR CRANK ANGLE AND VOLUME
plt.plot(x_data,y_data)
plt.xlabel(c[crank_angle])
plt.ylabel(c[volume])
plt.savefig('volume&crank.png')
plt.show()
""" PROGRAM TO PERFORM DATA ANALYSIS of giveN IC Engine Data"""
import math
import matplotlib.pyplot as plt
import numpy as np
try :
open('engine_data.out','r')
except : # if the output displays FileNotFoundError then we print the below
print('File not recognized. Please provide a valid CONVERGE output file.')
file_name = open('engine_data.out','r') # opening and reading the file
for i,l in enumerate(file_name): # enumerate keyword stores assigned values in the 'i' variable
if '#' in l :
if i == 2:
c = l.split()
# INPUTS FOR PV GRAPH
crank_angle = 2 # pressure
volume_v = 8 # volume
pressure = []
volume = []
for line in open('engine_data.out','r'):
if '#' not in line:
pressure.append(float(line.split()[crank_angle]))
volume.append(float(line.split()[volume_v]))
# GRAPH PLOTS FOR PRESSURE AND VOLUME
plt.plot(volume,pressure)
plt.xlabel('volume (m^3)')
plt.ylabel('pressure (MPa)')
plt.savefig('Pressure Vs Volume.png')
plt.show()
# BASIC PERFORMANCE CALCULATION
area = np.trapz(pressure,volume) # curve area calculation
print('Area under the PV curve = {:.9f} unit'.format(area))
power = 2*math.pi*area*pow(10,6)*1500/(60/1000) # power calculation
print('Power = {:.3f} watt'.format(power))
sfc = (3600*20e-6*1500)/(60*power) # specific fuel consumption calculation
print('Specific fuel consumption = {:.9f} gram/KW*hr'.format(sfc))
Output Of The code :-
- Volume Vs Crank angle
- Pressure Vs Volume
- Basic Performance calculation value
########## Error : No Major errors except some syntax mistakes