DATA ANALYSIS
AIM :
To read the data from the file provided and perform some calculations and also to plot the graphs between different parameter.
OBJECTIVE :
1.Data visualizer
2.Compatability check
3.Basic performance calculations
CONCEPT :
The concept is to read the data file(engine_data.out) provided.Actually the data file name with extension is taken from the user and then the data file is read.Then the parameters present in the data file is printed with the numbers.The user is asked to enter the parameters for which the plot is to be obtained.
Then Basic performance calculations are calculated but not manually.
FORMULAS :
1.`W = (Area) * (100)`
2. `Power = 2*pi*RPM*W/60`
3. Fuel consumption(F) = `20*(1e-6)*RPM*(0.5)/(60)`
4. `BSFC = (F/P)*3600`
PROCEDURE(CODE EXPLANATION) :
1.Import the required libraries.
2.Accepting the data file name with extension as a input from the user.
3.Then validate that the input given by the user is correct or not by using try and except() method.
4.Then read the data file.
5.Print all the parameters name so that the user can choose to plot the graph between them.
6.Plot the graphs according to the user input.
7.The basic performance calculations should be done only when the user input is pressure and volume.So if condition is used.
PYTHON CODE :
import matplotlib.pyplot as plt
import numpy as np
import math
#ACCEPTING THE FILE WITH EXTENSION .OUT ONLY
try:
var1 = input("Please enter the file name with .out extension: ")
print("Input received from the user:",var1)
except FileNotFoundError:
print("File not recognized. Please provide a valid CONVERGE output file")
#READING THE DATA FROM THE DATAFILE
file_object = open(var1,'r')
name=[]
units=[]
crank=[]
line_count = 1
#TO PRINT THE PARAMETERS PRESENT INSIDE THE DATAFILE
for i in file_object:
crank.append(i)
if len(crank)==5:
a=crank[2]
b=crank[3]
a=a.split()
b=b.split()
c=0
a.pop(0)
for i in a:
c=c+1
name.append(i)
units.append(b[c])
print(str(c)+" "+i+" "+b[c])
def value(var2,var3):
x_data = []
y_data = []
file_object = open(var1,'r')
for line in file_object:
if '#' not in line:
x_data.append(float(line.split()[var2-1])) #STORING THE VALUES OF DIFFERENT PARAMETERS
y_data.append(float(line.split()[var3-1]))
#PLOTTING THE GRAPHS
ax=plt.axes()
ax.set_facecolor('lightgrey')
plt.figure(1)
plt.xlabel(name[var2-1]+units[var2-1],color='green',fontsize='large',fontweight='bold')
plt.ylabel(name[var3-1]+units[var3-1],color='purple',fontsize='large',fontweight='bold')
plt.title(name[var2-1]+units[var2-1] + ' V/S '+ name[var3-1]+units[var3-1])
plt.plot(x_data,y_data)
plt.show()
#BASIC PERFORMANCE CALCULATIONS
if (var2==8 and var3==2):
rpm=1500
area=np.trapz(y_data,x_data) #IN MJ
print("AREA =",area,"MJ")
Workdone=area*1000 #IN KJ
print("WORKDONE =",Workdone,"KJ")
Power = 2*math.pi*rpm*Workdone/60 #IN KW
print("POWER =",Power,"KW")
Fuelconsumption = (20*(1e-6))*rpm*(0.5/60) #IN GRAMS PER HOUR
BSFC = ((Fuelconsumption)/(Power))*3600 #IN G/KW HR
print("BSFC = ",BSFC,"g/KWhr")
loop='yes'
while loop=='yes':
g = int(input("Enter the number from the above list to plot at x-axis:")) #TAKING THE INPUT FROM THE USER WHAT VALUES TO TAKE AT X AXIS
u = int(input("Enter the number from the above list to plot at y axis:")) #TAKING THE INPUT FROM THE USER WHAT VALUES TO TAKE AT Y AXIS
value(g,u) #FUNCTION CALL
loop=input('If you want to give more inputs for x and y press yes or no: ')
OUTPUT :

GRAPHS/PLOTS :





CONCLUSION :
The basic performance calculations and the plots has been obtained using python code.