PYTHON - Project 2 - Data analysis.
Aim:
To write a program to analyze the data and to visualize the data using plots and to perform the following
1. Calculate the area under the P-V diagram. *P* is in column 2 and *V* is in column 8.
2. Calculate the power output of this engine. Assume that RPM is 1500
3. This engine consumed 20 micrograms of fuel (per 1 stroke cycle). Calculate its specific fuel consumption.
Description:
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 visualization:
Data visualization is the graphical representation of information and data. By using visual elements like graphs, charts and maps, data visualization tools provide an accessible way to see and understand trends, outliers, and patterns in data.
power output of the engine:
Engine power or horsepower is the maximum power that an engine can put out. It can be expressed in kilowatts or horsepower. The power output depends on the size and design of the engine, but also on the speed at which it is running and the load or torque.
Specific fuel consumption:
specific fuel consumption (SFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. It is the rate of fuel consumption divided by the power produced.
Procedure:
Firstly try to import all the necessary libraries you need
We then check if the data file is compatible or not and we open andread it. And use the command try or except to run the program further
To read and append the column values we used the ' if '#' not in
line ' statement and proceeded for the further calculations.
Plotting the graphs and saving the names of the given axis bysplitting the names into different columns and labeling the axis bythem.
To calculate the area under the PV curve we use 'simps' tool tocalculate it
To calculate the power use the formula:
power=`(2*Pi*area*1500*10^6)/0.06`.
To calculate specific fuel consumption use the formula:
`s_s_c=(3600*20e^-6*1500)/(60*power)`.
Program code:
#program to analyze the data and visuvalize by using plots
#programmed by hariprasad
import matplotlib.pyplot as plt
from scipy.integrate import simps
#line to find file is exist or not
try:
file= open('engine_data.out')
print('file opened successfully n')
except:
print('file does not existn')
#parameters given below for plot
print('The plot paramters given below in the series n')
print('1-crank,2-Pressure, 3-Max_Pressure, 4-Min_Pressure, 5-Mean_Temp, 6-Max_Temp, 7-Min_Temp, 8-Volume, 9-Mass'
'10-density, 11-integrated_HR, 12-HR_Rate, 13-C_p, 14-C_v, 15-Gamma, 16-kin-Vics, 17-Dyn_Visc')
#getting input from the user
x=input('Enter the first parameter you need to plot):' )
y=input('Enter the second parameter you need to plot):' )
#declaring the inputs as integers
x=int(x)
y=int(y)
#used to store the values
column_1=[]
column_2=[]
count=1
#loop for taking the required data
for line in open('engine_data.out'):
if count == 3:
name_1=line.split()[x]
name_2=line.split()[y]
if '#' not in line:
column_1.append(float(line.split()[x-1]))
column_2.append(float(line.split()[y-1]))
count=count+1
#Area under curve that is work done
area=float(simps( column_1, column_2))
print('area:{}n'.format(area))
#power output of the enigne
rpm=1500
speed=rpm/60
power=area*speed
print('power:{} n'.format(power))
#specific fuel consuption
mass_of_fuel=20*pow(10,-6)
specific_fuel_consumption=mass_of_fuel/power
print('specific_fuel_consumption: {}n'.format(specific_fuel_consumption))
#plotting the values
plt.plot(column_2,column_1)
plt.xlabel(name_1)
plt.ylabel(name_2)
print('{} vs {}'.format( name_1,name_2))
plt.show()
Plots:
1.Pressure vs volume:
2.Crank vs volume
3.pressure vs temperature:
OUTPUT
Result:
Thus the data is analyzed successfully and visualized by using the plots. Then the required values of the plot are obtained such as area , power of an engine, and specific fuel consumption value for the engine