Challenge

Data analysis of engine output data.

Problem Statement:

  • Write the program to analyse Data of Engine output using Python Language.
  • To calculate the area under the PV diagram.
  • To calculate the power output of the engine (Assume that RPM is 1500).
  • To calculate the Specific Fuel Consumption (SFC). (This engine consumed 20 micrograms of fuel (per 1 stroke cycle).

Data File: Click here to download the Engine Data File

Theory:

Data analysis is a process of inspecting, cleansing, transforming and modelling data with the goal of discovering useful information, informing conclusions and supporting decision-making. Data analysis has multiple facets and approaches, encompassing diverse techniques under a variety of names, and is used in different business, science, and social science domains. In today's business world, data analysis plays a role in making decisions more scientific and helping businesses operate more effectively.

Pressure-Volume (PV) diagrams are a primary visualization tool for the study of heat engines. Since the engines usually involve a gas as a working substance, the ideal gas law relates the PV diagram to the temperature so that the three essential state variables for the gas can be tracked through the engine cycle. Since work is done only when the volume of the gas changes, the diagram gives a visual interpretation of work done. Since the internal energy of an ideal gas depends upon its temperature, the PV diagram along with the temperatures calculated from the ideal gas law determine the changes in the internal energy of the gas so that the amount of heat added can be evaluated from the first law of thermodynamics. In summary, the PV diagram provides the framework for the analysis of any heat engine which uses gas as a working substance.

Governing Equations:

Work-done= Area under PV diagram

`Power=Area*n*10^6`

where,

n=Speed of Engine

`=(N/(2*60))` (for 4 stroke Engine)

`=(N/60)` (for 2 stroke Engine)

`(SFC)=(Fuel)/(power)`

PROCEDURE

  • Initially, we are going to import the “matplotlib.pyplot” and “NumPy” libraries to plot the graph and calculate the values.
  • First, we save the program and then data file and program file is in the same folder.
  • The “try and except” command used to check the data file is in the same folder or it has name mistake.
  • Then we are going to open the file using the “for loop” command and then we read the data line by line. And using some counting line, if and else commands to separate the heading and numerical data.
  • Using “line.split” command to split all the data present in the data file.
  • For easy to calculate we creating some input commands to plot the graphs. The data input in the x-axis and y-axis.
  • Then we create two empty arrays for the x input and they input and then we read the data again. The data created than using the float, the values float and append all the values for the x and y input arrays.
  • We create the plot command for the x and y input arrays and then we make all the labels and the title of the graph.
  • After that, we calculate the area under the curve of a PV diagram and we know that the area under the curve is work done.
  • Then we calculate the power output the engine and Specific Fuel Consumption and then we print the values.

Python Program:

#program for data analysis of Engine output data 
#coded by Asad Salah (B.E Mechanical Engineering)

"""
Demonstrating the engine converge analysis data
"""
#importing modules
import matplotlib.pyplot as plt
import math
import numpy as np



try:
	file=open('engine_data.out')
	print('Data is found successfully! Now you can proceed to the next Calculations \n')
except:
	print('unfortunately the data is not found.Please check the file or filename')
file.close()


print('Information about input parameters: \n')


pressure=[]
temperature=[]
volume=[]
column_name=[]
column_units=[]

#data parsing
count_data=1
z=[]
for line in open('engine_data.out'):

	if '#' not in line:
		
		count_data=count_data+1	

		
	else:
		count_data=count_data+1
		if count_data == 4:

			column_name=line.split()
			z.append(column_name)
		elif count_data==5:
			coulumn_units=line.split()

ct=-1
for i in z:
        for j in i:
                ct=ct+1
                print("(",ct,")",j)
#inputs
nx = int(input("Please enter the x-axis data:"))


ny = int(input("Please enter the y-axis data:"))


print("")
data_array_x=[]
data_array_y=[]




for line in open('engine_data.out'):

	if '#' not in line:
		
		data_array_x.append(float(line.split()[nx-1])) 

			

for line in open('engine_data.out'):

	if '#' not in line:
		
		data_array_y.append(float(line.split()[ny-1])) 



#plotting the data
plt.plot(data_array_x,data_array_y)
plt.xlabel(column_name[nx]+coulumn_units[nx])
plt.ylabel(column_name[ny]+coulumn_units[ny])
plt.title(column_name[nx]+" vs "+column_name[ny]+' Diagram')
plt.savefig(column_name[nx]+'VS'+column_name[ny]+'.png')
plt.show()



for line in open('engine_data.out'):

	if '#' not in line:
		
		pressure.append(float(line.split()[1]))
		volume.append(float(line.split()[7]))  

#calculating area under the pv curve
work=[]
for i in range(0,8664):
	work.append((volume[i+1]-volume[i])*(pressure[i+1]+pressure[i])*0.5)

work_done=0
for j in range(0,len(work)):
	work_done=work_done+work[j]
	work_done1=work_done*1*1e6
print('Workdone=',work_done1,'joule')


area=np.trapz(pressure,volume)
#print('the total area under the curve is',area,'m^2')

#calculating power output of the engine
rpm=1500
power=area*1e+06*rpm/9550
print('The power output of the engine=',power,'KW')

#calculating Specific fuel consumption
fps=20*1e-06
mass_flow_rate=2.99*1e-10
SFC=mass_flow_rate*36000/power
print('The specific Fuel Consumption=',SFC,'g/KW hr')

Output:

Plots:

P-V diagram

Crank-Volume Diagram

Crank-Pressure Diagram

CONCLUSIONS

  • The area under the PV Diagram curve is calculated. We know that the area under the PV diagram is work done.
  • The specific Fuel Consumption(SFC) and the power output of the engine also calculated.
  • The data visualization is shown in the output window.

References:

https://en.wikipedia.org/wiki/Data_analysis

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.