All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim:To be able to write the program to read the data, checking the data, calculating the workdone by the engine along withspecific fuel consumption of the engine and plotting the graphs which are required for analysis. Theory:Data analysis is a process of inspecting, cleansing, transforming, and modeling data with the…
Amol Anandrao Kumbhar
updated on 29 Jun 2021
Aim:
To be able to write the program to read the data, checking the data, calculating the workdone by the engine along withspecific fuel consumption of the engine and plotting the graphs which are required for analysis.
Theory:
Data analysis is a process of inspecting, cleansing, transforming, and modeling data with the goal of discovering usefulinformation, 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 sciencedomains. In today's business world, data analysis plays a role in making decisions more scientific and helping businesses operatemore effectively.
Python is an increasingly popular tool for data analysis. In recent years, a number of libraries have reached maturity, allowingR and Stata users to take advantage of the beauty, flexibility, and performance of Python without sacrificing the functionalitythese older programs have accumulated over the years.
Objectives:
TASK 1 - To make a Data visualizer:
The script should take column numbers as the input and plot the respective columns as separate images. Each file should besaved by the name of the column
The plot labels should be extracted from the file.
TASK 2 - Compatibility check:
code should exit gracefully 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"
TASK3 - Basic performance calculation:
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 micrograms of fuel (per 1 stroke cycle). Calculate its specific fuel consumption.
Solution Flow:
1. First, we have to check for file compatibility and then whether the file is present or not. Once that is done, we have to takecolumn number inputs from the user.
2. Then, using a for loop, we’ll iterate line by line and obtain the labels for the plots and the data. We’ll then store the data in emptyarrays.
3. Using the matplotlib, we can then plot the graphs and label them accordingly.
Using the governing equations, we can calculate all the required parameters.
import matplotlib.pyplot as plt
import numpy as np
from numpy import trapz
filename = input("Input_File_Name : ")
if filename == 'engine_data.out':
print('valid file')
else:
print('invalid file')
exit()
def compatibility_check(a):
if 'CONVERGE' not in a:
print('please provide converge output file to process')
exit()
else:
print('compatibility check is successful')
pass
FILE = []
for line in open(filename):
if '#' in line:
FILE.append(line.split())
compatibility_check(FILE[0])
noc = len(FILE[1])
head = len(FILE[2])
col_no = []
col_val = []
col_units = []
z = FILE[1].index('column')
for i in range(z,noc-1):
col_no.append(i)
for j in FILE[2]:
if j is not'#':
col_val.append(j)
for k in FILE[3]:
if k is not'#':
col_units.append(k)
print('available data are:')
for a in range(0,len(col_no)):
print(col_no[a],col_val[a],col_units[a])
xaxis = int(input('Enter xaxis column no:'))-1
yaxis = int(input('Enter yaxis column no:'))-1
x = []
y = []
for line in open(filename):
if '#' not in line:
x.append(float(line.split()[xaxis]))
y.append(float(line.split()[yaxis]))
plt.plot(x,y,linewidth=1.5)
plt.xlabel(col_val[xaxis])
plt.ylabel(col_val[yaxis])
plt.show()
pressure = []
volume = []
for line in open(filename):
if '#' not in line:
pressure.append(float(line.split()[1]))
volume.append(float(line.split()[7]))
Pressure = 1e6*np.array(pressure)
Volume = np.array(volume)
area = np.trapz(Pressure,Volume)
print('workdone =',area, 'joules')
cyclepersec = 750/60
power = area*(cyclepersec/1000)
print('power=',power,'kw')
mass_flow = 20e-6
sfc = mass_flow*3600/power
print('specific fuel consumption =',sfc,'g/kwh')
Code Explanation:
1. In the first few lines, the required modules are imported. Then, we are defining a conditionally recursive function to check thefile format. If the file is not in the CONVERGE output format, we are prompting the user to enter the file name again.
2. If the file isnot found, the code exits with an error message to the terminal.
If everything is correct, the user will be prompted to enter the two-column numbers to plot the graph. After the user enters thecolumn numbers, we are using for loop to get the names and the values of those columns and storing them.
3. Then we are calculating basic performance as asked in the question. The governing equations are used to calculate the requiredparameters. Then, we are plotting the graph between the user-entered columns, and the PV area curve.
FILE PARSING:
>Import the Plotting module:
We need to import the plotting module as shown in the above snap for plotting the different types of graphs for showingthe variation with respect to two parameters like volume, pressure and temperature etc.
>Import the numpy module:
To give a power to each element of an array or to perform any mathematical operations (like addition or subtraction) eitheron every element of an array or between the arrays, we need to import the numpy library as shown above.
>Import the tarpz from numpy
To import the tarpz from numpy library as shown above to find out the area by trapezoidal numerical method.
> Checking the input file and compactibility:
As per data analysis we need to import the correct file into the software and we need to read the entire file to analyze thedata. So, we can input the correct file and checking the compactability through converge thus it will be pass as shown in abovepic.
>Appending the converge data:
In beginning we need to check the converge is starting with the # key. Splitting the line by line using the split function.Assignning the splitted lines to the loop with variables i, j and k as shown in the above screenshot. Then finally append the datato the program. The program is about the method of indexing the specified value for analysis.
>>Program for asking the parameters for x-axis and y-axis for plotting the graphs:
This about to create the input variables which we need to plotting for x-axis and y-axis. This is user friendly by the inputvariables it will recognize the data and giving the results which are required.
>>Calculating the required output:
The above program is basic one in which the input the formulaes to find out the workdone, power and specific fuel consumption.
Results:
We obtained the required graphs and the compatibility check was successful. From the output code, we can see that,
The area under the PV curve is 0.500050058 m
The engine power output is 0.0125 KiloWatts
Specific Fuel Consumption is 0.001598 g/KWhr
Conclusion:
The necessary plots are obtained, and the parameters are calculated.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 6 - CHT Analysis on a Graphics card
Objective: To perform a steady state conjugate heat transfer analysis on a model of graphics card. Introduction :The term conjugate heat transfer (CHT) describes the process which involves variation of temperature within solids and fluids, due to thermal interaction between the solids and fluids, the exchange of thermal…
23 Mar 2022 04:17 AM IST
Week 5 - Rayleigh Taylor Instability
Rayleigh Taylor Instability INTRODUCTIONThe Rayleigh–Taylor instability, is the instability of an interface between two fluids of different densities which occurs when the lighter fluid is pushing the heavier fluid with the effect of gravity. Here we have prepared a model with two surfaces on over the above and considered…
07 Mar 2022 05:33 PM IST
Week 3 - External flow simulation over an Ahmed body.
External flow simulation over an Ahmed body. AIM:To simulate flow over ahmed body & to address the below given tasks.1. Describe Ahmed body & its importance.2. Explain the negative pressure in wake.3. Explain significance of the point of seperation. Expected results:1. Velocity & pressure contour of the Ahmed…
07 Mar 2022 02:44 PM IST
Week 4 - CHT Analysis on Exhaust port
CHT Analysis on Exhaust port Objective :In this challenge,1. brief description of why and where a CHT analysis is used.2. simulate both fluid flow and also the heat transfer to the solid i.e., CHT Analysis on an Exhaust port3.calculate the wall heat transfer coefficient on the internal solid surface & show the velocity…
27 Feb 2022 03:12 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.