Challenge

Week 6 - Data analysis

AIM - Write a script that does data analysis.

Objectives - To ensure

  1. Data visualizer
  2. Compatibility check
  3. Basic performance calculation

Theory

This code takes information from user-specified CONVERGE file. It also checks the file for the appropriate format i.e. If the file is not a CONVERGE output data format then the code will drop the error statement "This is not a valid CONVERGE output file." Also, if the file format is correct however, no data is present in the file the code will wake the user "No data available in the file".

If the format is correct and the data is available, the code will apply the following steps: -

1) Data Extraction - Extracting data with column name and column number in the CONVERGE output file. Complete data in a file is stored in separate 'databases' in two columns. The matrix / 2D data columns contain the details of each parameter.

2) Data display - Provide an "input map" to the user so that he can use numbers such as input to enter objects that are edited. Ask the user if conspiracy between the two versions is required. If the input is 'y' representing 'yes' then, ask for the numbers representing the variable that should be written down (Visible Input Map). Ask the user if the plot will be saved. After that, show off. The above step while looping and running the uninstalled user gives the input 'n' in the question "Do you want to edit some flexibility? (Y / n):".

3) Basic functionality - Extract volume and pressure data from the 'data' matrix and keep the same 'volume' and 'pressure' respectively. Next, mathematically combine pressure and volume data using the 'Simps' function (Simphson's value-added function function) from the scipy.integrate library. This integration is the subject of the P-V curve function.e. the work done in each cycle. Subsequently, the RPM of the engine in which data was collected and oil consumption per microgram per cycle was considered user input. Next, the power generated by the engine in this RPM is calculated. Finally, Specific fuel consumption is calculated and Location below the curve, Power output and direct air consumption are shown.

A=Area under the P-V curve=Work done per cycle (MJ)A=Area under the P-V curve=Work done per cycle (MJ)

Power output =A⋅n⋅106 WPower output =A⋅n⋅106 W

n=Number of cycles per secondn=Number of cycles per second

n=N2⋅60n=N2⋅60` for 4-stroke engine

n=N60n=N60 for 2-stroke engine

N = Rotations per min.N = Rotations per min.

SFC(Specific Fuel consumption)=Fuel consumed in kg/hrPower output in kW

Python Code

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

line_count = 1

try:
	data = open('engine_data.out','r')
except FileNotFoundError:
	print('"File not recognized. Please provide a valid output file"')



parameter = ['Crank Angle','Pressure','Maximum Pressure','Minimum Pressure','Mean Temperature','Maximum Temperature','Minimum Temperature','volume','Mass','Density','Heat Rejection Rate','C_p','C_v','gamma','Kinematic Viscosity','Dynamic Viscosity']
print(parameter)
print('Followings are the codes for corresponding parameters,Please follow the Instructions')
corresponding_num = ['crank_angle=0','pressure=1','max_pres=2','min_pres=3','mean_temp=4','max_temp=5','min_temp=6','volume=7','mass=8','density=9','Heat Rejection=10','Heat Rejection=11','C_p=12','C_v=13','gamma=14','Kinematic Viscosity=15','Dynamic Viscosity=16']
print(corresponding_num)

first_column=input('Enter the first column:')
second_column=input('Enter the second column:')
print('n')


first_column=int(first_column)
second_column=int(second_column)

values_of_column_1=[]
values_of_column_2=[]

for line in open('engine_data.out'):
	if line_count is 3:
		column_name_1=line.split()[first_column]
		column_name_2=line.split()[second_column]
	if'#' not in line:
		values_of_column_1.append(float(line.split()[first_column-1]))
		values_of_column_2.append(float(line.split()[second_column-1]))

		line_count+=1

area=float(simps(values_of_column_1, values_of_column_2))
print('area:{}n' .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('specific_fuel_consumption: {}n'.format(specific_fuel_consumption))




plt.plot(values_of_column_2,values_of_column_1 ,linewidth=3,color='red')
plt.xlabel(column_name_1,color='green',fontsize=12)
plt.ylabel(column_name_2,color='green',fontsize=12)
plt.title(column_name_2+'  VS  '+column_name_1,color='b',fontsize=15)
plt.savefig(column_name_2+'VS'+column_name_1+'.png')
plt.show()

Results

Results Explanation

Location under p-v diagram i.e., Done Work: 500.58662746800763 J

Power: 12.51466568670019 KW

Specific Fuel Consumption: 5.753249971073308 at 06 gm / KWhr

These are the results of the Input Pressure and Volume.

Conclusion

Therefore, data analysis was performed and all questions were answered.

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.