Data Analysis by PYTHON programming
Aim:- To analyze data using Python programming
Governing Equation:-
Work Done=(area/1000)*pow(10,6)
Power Output=2*(math.pi)*1500*area/60
Fuel Consumption Per Hour=FC*1500*60
Specific Fuel Cnsumption=FCH/power
Objective:- The main objective of this project is
1) to calculate the area under the PV diagram
2)to calculate the power output of the engine
3)to calculate specific fuel consumption of the engine
Brief Theory:-
Data analysis:- It is a process for collecting data and transforming, cleaning and modelling of it to obtain necessary information
Specific fuel consumption:- It is defined as the fuel consumption power of the engine divided by its power.
Need for data analysis:- When we perform large simulations then a huge amount of data is generated. Searching for required data becomes very difficult. To handle the situation to easier Python program is written to analyze and visualize the data.
Workflow:-
1)Given file is opened
2)Parameters are taken and printed
3)Area of the PV diagram is calculated
4)Power output is calculated
5)Necessary plots are plotted
6)Specific fuel consumption is calculated
Brief content of this project:- This project has been done by Python programming. The code has been attached below.
# Data analysis and data visualizer
import math
import matplotlib.pyplot as plt
import numpy as np
try :
#opening file content
file_content = open('engine_data.out','r')
except FileNotFoundError :
#printing
print("File not recognized / not found , please provide a valid converge output file !")
data = []
#using for loop
for line in file_content :
if '#'not in line :
data.append(line.split())
data1 = np.transpose(data)
data1 = data1.astype(float)
# taking necessary parameters
parameters = ['crank angle','pressure','Max_pres','min_pres','mean_temp','max_temp','min_temp','volume','mass','density','integrted_HR','HR_rate','C_p','C_v','Gamma','Kin_Visc','Dyn_visc']
print(parameters)
#choosing parameters
choose_parameter = ['crank_angle = 0','pressure=1','Max_pres=2','min_pres=3','mean_temp=4','max_temp=5','min_temp=6','volume=7','mass=8','density=9','integrted_HR=10','HR_rate=11','C_p=12','C_v=13','Gamma=14','Kin_Visc=15','Dyn_visc=16']
#printing
print(choose_parameter)
print('select the parameter by inputing corresponding parameter number and press enter : n')
#printing parameter 1 and 2
print('1st parameter')
x=int(input())
print('2nd parameter')
y=int(input())
#p-v diagram
plt.plot(data1[x,:],data1[y,:],linewidth = 3,color ='red')
plt.xlabel(choose_parameter[x])
plt.ylabel(choose_parameter[y])
plt.title(choose_parameter[y]+ ' vs ' + choose_parameter[x])
plt.savefig(choose_parameter[y]+ ' vs ' + choose_parameter[x]+ '.png')
plt.show()
# calculating area
area = np.trapz(data1[x],data1[y])
work_done = (area/ 1000 )*pow(10,6)
#printing Work done in KJ
print('area under curve =',work_done,'kJ')
# calculation of the power output of the engine
# N = 1500 RPM (assuming)
power = 2*(math.pi)*1500*area/60
print('power =' , power , 'Kw')
# calculating specific fuel consumption i.e SFC
FC = 20*pow(10,-6)
FCH = FC* 1500*60
#unit: g/kwh
SFC =FCH / (power)
#printing value
print('specific fuel consumption is :' , SFC , 'g/kWh')
Algorithm of the program:-
1)Firstly input function has used for importing the math plotlib.py,num.py etc.
2)File content is extracted and opened using the open command
3)Parameters are taken
4)Using plot command diagrams are plotted and the title is also given
5)Putting governing formulas power output, fuel consumption is calculated
6)Using print command-specific fuel consumption value is printed
Result:-
Plots:-
Conclusion:- Through this whole program we have learned to analyze necessary data to get the required output easily by Python programming which is very helpful to handle a lot of data in companies.