All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: Extract a plot between any two quantities from the given data file automatically. Compatibility check: Code should exit gracefully, if a non-compatible file is provided as an input. Calculate the area under P-V diagram. Calculate the power output of an engine running at 1500 RPM. Calculate the specific fuel…
Giridhar Lingutla
updated on 02 Mar 2021
Objective:
Governing Equations:
Power = Area * no.of cylinders * (stroke/1000)
Work done = Area under P-V diagram
Specific fuel consumption = Fuel consumption * stroke * (3600/power) * 1000
Python Code:
"""
Data Analysis by Giridhar
"""
import matplotlib.pyplot as plt
import math
import numpy as np
from scipy.integrate import simps as simps, trapz as trapz
# File compatibility check:
try:
open('engine_data.out')
except:
print('File not recognized. Please provide a valid CONVERGE output file')
# Reading the file
line_count = 1
Pressure = []
Volume = []
for line in open('engine_data.out'):
if '#' not in line:
values = line.split()
Pressure.append(float(line.split()[1]))
Volume.append(float(line.split()[7]))
number_of_columns = len(values)
line_count = line_count + 1
# Basic Performance calculation:
# Area under the P-V diagram:
area = simps(Pressure, Volume)
print('Area under the curve: ' +str(area))
area = area*1e6
print('work done:' +str(area) + ' J')
#Power Output
fuel_consumption = 20
n = 1
rpm = 1500
stroke_cycle = rpm/120
power = n*area*stroke_cycle/(1000)
print('power: ' +str(power) + ' KW')
sfc = (fuel_consumption*pow(10, -6)*stroke_cycle*3600)/(power*1000)
print('sfc:' +str(sfc) + ' kg/hr.KW')
# Extracting Parameters and units
ct = 1
for line in open('engine_data.out'):
if ct == 3:
parameter = line.split()
if ct == 4:
unit = line.split()
ct = ct + 1
# Numbering
for i in range(1,18):
print(i, parameter[i], unit[i])
print('Provide the allocated number for variable along x axis:')
x=int(input())
print('Provide the allocated number for variable along y axis:')
y=int(input())
X = []
Y = []
ct = 1
for line in open('engine_data.out'):
if ct == 3:
x_parameter = line.split()[x]
y_parameter = line.split()[y]
if ct == 4:
x_axis = x_parameter + line.split()[x]
y_axis = y_parameter + line.split()[y]
if '#' not in line:
X.append(float(line.split()[x-1]))
Y.append(float(line.split()[y-1]))
ct = ct + 1
# Plotting:
plt.plot(X,Y)
plt.xlabel(x_axis)
plt.ylabel(y_axis)
plt.title(x_axis+ 'Vs' +y_axis)
plt.savefig(x_axis+'Vs'+y_axis+'.png')
plt.show()
Basic Performance Calculation Output:
Compatability check: Compatible file is provided, so no compatability error.
Data visualizer Output: As required, by directly inputing the column number 1 and 8 in Python, Crank angle vs Volume plot is extracted automatically as shown below.
P-V Diagram:
Python Code Explanation:
Conclusion:
All the objectives has been achieved.
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 - Data analysis
https://skill-lync.com/projects/data-analysis-using-python-48
02 Mar 2021 07:35 PM IST
Data Analysis using Python
Objective: Extract a plot between any two quantities from the given data file automatically. Compatibility check: Code should exit gracefully, if a non-compatible file is provided as an input. Calculate the area under P-V diagram. Calculate the power output of an engine running at 1500 RPM. Calculate the specific fuel…
02 Mar 2021 07:35 PM IST
Curve Fitting using Python
Objective: Write a Python Program to curve fit a linear and cubic polynomial for the given Cp data and explain the results. Curve Fitting: Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points, possibly subject to…
01 Mar 2021 12:41 PM IST
Find Minimum Cushion Pressure with Newton-Raphson method of an Air Cushion Vehicle to break Ice in Python
Objective: Write a Python program to find minimum cushion pressure of an Air Cushion Vehicle to Break Ice with Newton-Raphson method. Governing Equation: The factors involved are: p - cushion pressure h - thickness of the ice field r - size of the air cushion σ - tensile strength of the ice β -…
27 Feb 2021 05:20 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.