Project

data analysis using python

Objective:

  • Script should take column numbers as the input and plot the respective columns as separate images
  • Each file should be saved by the name of the column
  • The plot labels should be extracted from the file.The label information should automatically be extracted and must appear as labels in the plots. THIS SHOULD NOT BE DONE MANUALLY
  • 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\"

Outcome:

  • Calculate the area under the P-V diagram. P is in column 1 and V is in column 7.
  • Calculate the power output of this engine. Assume that RPM is 1500
  • This engine consumed 20 micro grams of fuel. Calculate its specific fuel consumption.

This program is to read data from the given file, and plot graphs of various parameters

  1. the file is read. if it is not the correct file, the program throws an error. if not it procceds to read the data ignoring the comments.
  2. column names are transposed to 0,1,2,3,.... positions and correspondingly numbers are alloted to each column name i.e.,
  3. crank angle=0, pressure=1, maximum pressure=2, minimum pressure=3,mean temperature=4, maximum temperature=5, minimum temperature=6, volume=7, mass=8, density=9, heat rejection=10, heat rejection rate=11, c_p=12, c_v=13, gamma=14, kinematic viscosity=15, dynamic viscosity=16.
  4. column names along with numbers are displayed to the user to select the x and y parameters.
  5. graph is plotted with these x and y parameters by reading all values in the column each time.
  6. x and y labels and titles of plots are generatd automatically and the plot is saved.

calculation of area under P-V diagram:

area under P-V diagram is th work done.
absolute value calculated using simpson\'s rule

power output at N rad/sec = Area*N watts

specific fuel consumption = fuel consumption * 1000/power (kg/kw-hr)

the plots and results obtained are:

\"performance

\"pressure

\"pressure

\"\"\"
Data analysis of engine using python
\"\"\"
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import simps

#take input file from user
inputfile = input(\"Enter filename with  .out extension :\\n\")


#read input file
try:
    inputdata = open(inputfile,\'r\')

#check for the correct file
except FileNotFoundError:
    print(\"File not recognised. Please provide a valid CONVERGE output file\\n\")

#skip comments
value =[]
for line in inputdata:
    if \'#\' not in line:
        value.append(line.split())

column = (np.transpose(value)).astype(float)
#column names from the file
column_names = [\'Crank Angle\',\'Pressure\',\'Maximum Pressure\',\'Minimum Pressure\',\'Mean Temperature\',\'Maximum Temperature\',\'Minimum Temperature\',\'Volume\',\'Mass\',\'Density\',\'Heat Rejection\',\'Heat Rejection Rate\',\'C_p\',\'C_v\',\'gamma\',\'Kinematic Viscosity\',\'Dynamic Viscocity\']
print(\"The column names of the file are:\")
print(column_names)

index = [\'Crank Angle=0\',\'Pressure=1\',\'Maximum Pressure=2\',\'Minimum Pressure=3\',\'Mean Temperature=4\',\'Maximum Temperature=5\',\'Minimum Temperature=6\',\'Volume=7\',\'Mass=8\',\'Density=9\',\'Heat Rejection=10\',\'Heat Rejection Rate=11\',\'C_p=12\',\'C_v=13\',\'gamma=14\',\'Kinematic Viscosity=15\',\'Dynamic Viscocity=16\']
print(\"The codes for the column names are:\")
print(index)

#take x and y parameters
print(\"Enter code for x parameter:\")
x = int(input())
print(\"Enter code for y parameter:\")
y = int(input())
#plot
plt.plot(column[x,:],column[y,:],linewidth=3,color=\'blue\')
plt.xlabel(column_names[x],fontsize=10)
plt.ylabel(column_names[y],fontsize=10)
plt.title(column_names[x]+ \' Vs \'+column_names[y],fontsize=10)
plt.savefig(column_names[x]+ \' Vs \'+column_names[y]+\'.png\')
plt.show()

# Basic performance calculation

volume = column[7,:]
pressure = column[1,:]
A = 0  # Area under the P-V curve
A = simps(pressure, volume, even=\'first\') * np.power(10, 6)  # = Calcuate work per cycle using Simpson\'s method (J)
RPM = input(\'\\nEnter the RPM of engine at which data was collected: \')  # Rotations per min.
f = input(\'\\nEnter the value of fuel consumed per cycle in micro-grams: \')  # fuel consumption  micro-gram per cycle
RPM = float(RPM)
f = float(f)
n = RPM / (2 * 60)  # Number of cycles per second for 4-stroke engine
P = A * n  # Power output (W) at speed N rad/s
f = (f * n * 3600) / np.power(10, 9)  # fuel consumtion kg per hr
sfc = (f * 1000) / P  # Specific fuel consumtion (kg per kW-hr)
print(\'\\nArea under the P-V curve i.e. work done per cycle = {} J\'.format(A))
print(\'\\nPower output at {} RPM = {} W\'.format(RPM, P))
print(\'\\nSpecific fuel consumption = {} kg/kW.hr\'.format(sfc))
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.