Challenge

Week 6 - Data analysis

AIM: To perform the data analysis of a given data by programming in Python

PROCEDURE:

Import the modules such as Math, matplotlib, numpy,scipy for performing their respective functions

For the purpose of plotting the curves between 2 quantities as per the user input, a line counter is initiated from 1. Now an "if" loop is iterated with the condition if '#' not in line all the numerical values present in the data file is now to be stored in the data array as string. Now another "if" loop is executed with the conditon that line counter greater than or equal to 6 all the data will be stored in the pressure and volume array respectively.

3. For Engine performance calculations, the area under the PV diagram has to be calculated and we are using Simpson method for calculating it.

import math
import matplotlib.pyplot as plt
import numpy as np 
from scipy.integrate import simps


#try:
open('engine_data.out')


line_count = 1

# Creating an empty array to store the values of Volume and pressure respectively 
Volume =[]
pressure =[]

v = 8
p = 2

# Creating null array and storing all the values of data file in to it 

data =[]

for line in open('engine_data.out'):
	if '#' not in line:
	  data.append(line.split())
	  if line_count >= 6:
	  	Volume.append(float(line.split()[v-1]))
	  	pressure.append(float(line.split()[p-1]))
			
	line_count = line_count + 1

#plotting p-v diagram
plt.plot(Volume, pressure, linewidth = 2, color = 'b')
plt.xlabel('Volume')
plt.ylabel('pressure')
plt.title("p-v diagram of engine")
plt.grid()
plt.show()

area = simps(pressure,Volume)
print('Area under the curve using Simpsons Rule :' +str(area) + ' units')
print('Work done by the engine : ' + str(area) + ' MJ')
area = area * 1e6
print('Work done by engine : ' + str(area) + ' J')

	# Inputs 
	# Speed of an Engine 
rpm = 1500
rps = 1500/60
stroke_cycle = rps/2

	# Fuel consumption in micrograms per 1 stroke cycle 

fuel_consumption = 20

	# Engine specifications 
	# Number of cylinder
n = 1
	# 4 stroke engine
	# Calculation of power output and Specific fuel consumption 

power_output = n*area*stroke_cycle/(1000)
print('power output from engine : ' + str(power_output) + 'KW')
SFC = (fuel_consumption*pow(10,-6)*stroke_cycle*3600)/(power_output*1000)
print('Specific Fuel consumption, SFC = ' + str(SFC) + ' (kg/hr)/KW')
print('t')

	# Calculation of Area under PV diagram 
Area = np.trapz(pressure,Volume)
print('Area under curve using trapezoidal rule : ' + str(Area) + 'units')
print('Work done by the engine : ' + str(Area) + ' MJ' )
Area = Area * 1e6
print('Work done by engine : ' + str(Area) + ' J')
power_output = n*Area*stroke_cycle/(1000)
print('power output from the engine : ' + str(power_output) + 'KW')
SFC = (fuel_consumption*pow(10,-6)*stroke_cycle*3600)/(power_output*1000)
print('Specific Fuel consumption, SFC = ' + str(SFC) + ' (kg/hr)/KW')
print('t')



result
Area under the curve using Simpsons Rule :0.0005005864474262364 units
Work done by the engine : 0.0005005864474262364 MJ
Work done by engine : 500.58644742623636 J
power output from engine : 6.257330592827954KW
Specific Fuel consumption, SFC = 0.00014383130100742395 (kg/hr)/KW
t
Area under curve using trapezoidal rule : 0.0005005866274680075units
Work done by the engine : 0.0005005866274680075 MJ
Work done by engine : 500.58662746800746 J
power output from the engine : 6.257332843350094KW
Specific Fuel consumption, SFC = 0.00014383124927683276 (kg/hr)/KW
t
[Finished in 19.6s]

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.