Week 6 - Data analysis
AIM: TO PERFORM THE DATA ANALYSIS OVER THE GIVEN DATA FILE AND OBTAIN SUITABLE RESULTS.
PROBLEM STATEMENT:
- script should take column numbers as the input and plot the respective columns as separate images
- if a non-compatible file is provided as an input. It should say something like "File not recognized. Please provide a valid CONVERGE output file"
- Calculate the area under the P-V diagram. P is in column 2 and V is in column 8.
- 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.
CODE TO PERFORM OPERATION OVER DATA FILE:
Data Analysis using python
import matplotlib.pyplot as plt
from scipy.integrate import simps
line_count = 1
try:
file = open('engine data.out')
print('file opened sucessfully n')
except:
print('file does not exist n')
print('the plot parameter in the given series n')
print('1-crank,2-pressure,3-maxpressure,4-min_pressure,5-Mean-temp,6-Max-tem,7-min_temp,8-volume,9-mass,10-density,11-integrate-hr,12-hr_rate,13-cp,14-cv,15-gamma,16-kin_ves,17-dyn_ves')
first_column=input('enter column you want to plote ,choose between 1 to 17')
second_column=input('entet column you want to plot(choose different from 1st choice) ')
print('n')
first_column = int(first_column)
second_column = int(second_column)
values_of_column1 =[ ]
values_of_column2= [ ]
for line in open('engine_data.out'):
if line_count is 3:
column_name1=line.split()[first_column]
column_name2=line.split()[second_column]
if '#' not in line:
values_of_column1.append(float(line.split()[first_column-1]))
values_of_column2.append(float(line.split()[second_column-1]))
line_count=1
#Area under curve that is work done
area = float(simps (values_of_column_1, values_of_column_2))
print('Area:{}in'.format(area))
rpm = 1500
speed=rpm/60
power = area*speed
print('Power: {}n'.format(power))
mass_of_fuel = 20*pow( 10,-6)
specific_fuel_consumption = mass_of_fuel/power
print('specefic_fuel_consumption:{}n'.format(specefic_fuel_consumption)
#Plotting
plt.plot(values_of_column2 , values_of_column1)
plt.xlabel(column_name_1)
plt.ylabel(column_name_2)
printf(' {} vs {}'.format(column_name_1, column_name_2))
plt.show()
OUTPUT OF SCREEN:
VARIOUS PLOTS:
CONCLUSION:
1.thus script takes column numbers as the input and plot the respective columns as separate images
2.if a non-compatible file is provided as an input. It say's error.