All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: To create a data visualiser using python, perform a compatibility check of the file and then calculating some basic performance parameters Problem Statement: To visualise the complex data in the file in a sequencial and a more understandable way. Also, how can SublimeREPL adds a more two way relationship in…
Abhishek Baruah
updated on 30 Mar 2021
Objective: To create a data visualiser using python, perform a compatibility check of the file and then calculating some basic performance parameters
Problem Statement:
To visualise the complex data in the file in a sequencial and a more understandable way. Also, how can SublimeREPL adds a more two way relationship in python
Prerequisites:
1) The link for the converge file is given below:
https://drive.google.com/file/d/1L8GY56d-M8mB1KfceM-xVhGNvnCIqxjm/view
2) SublimeREPL must be installed if running the script on sublime and user inputs need to be taken.
Procedure:
The detailed code is given below:
import math
import numpy as np
import matplotlib.pyplot as plt
#initialising empty arrays to store data for the columns to be plotted
value1=[]
value2=[]
volume=[]
pressure=[]
#defining a line counter
linecount=1
#enter the name of the converge output file in name.out format
open1=('Enter file name in name.out format: ')
file=input(open1)
#taking user inputs for variables to be plotted and storing them in int form
print('List of parameters available for plotting:')
print('0. Crank Angle')
print('1. Pressure')
print('2. Max Pressure')
print('3. Min Pressure')
print('4. Mean Temperature')
print('5. Max Temperature')
print('6. Min Temperature')
print('7. Volume')
print('8. Mass')
print('9. Density')
print('10. Integrated HR')
print('11. HR Rate')
print('12. Cp')
print('13. Cv')
print('14. Gamma')
print('15. Kinematic Viscosity')
print('16. Dynamic Viscosity')
par_a=('Enter parameter 1 no (x-axis variable): ')
a=input(par_a)
a=int(a)
par_b=('Enter parameter 2 no (y-axis variable): ')
b=input(par_b)
b=int(b)
try:
#opening and reading the data file and storing values of the selected columns inside 2 variables
for line in open(file,'r'):
if '#' not in line:
value1.append(float(line.split()[a]))
value2.append(float(line.split()[b]))
pressure.append(float(line.split()[1]))
volume.append(float(line.split()[7]))
else:
#this is used to take the xlabel and ylabel from the data file itself
if linecount==3:
labels=line.split()
linecount=linecount+1
#calculating the area under the P-V diagram using trapz(y,x)
area=np.trapz(pressure,volume)
print('Area under the P-V diagram: ',area,'MJ')
#calculating the power output of the engine (assuming a RPM of 1500 and 4-stroke)
power=area*(1500/120)*1000
print('Power: ',power,'KW')
#calculating the engine specific fuel consumption (assuming it consumes 20gm of fuel in one stroke)
sfc= ((20*(1500/120)*3600)/pow(10,9))/power
print('Specific Fuel Consumption: ',sfc,'Kg/KW.H')
#plotting the graph between the 2 selected columns
plt.plot(value1,value2)
plt.xlabel(labels[a+1])
plt.ylabel(labels[b+1])
plt.show()
except:
#if wrong filename is given as input
print('File not recognized. Please provide a valid CONVERGE output file')
Results:
Examples:
a) When 7 and 1 are taken as input parameters
b) When 1 and 4 are taken as input parameters
Compatibility Check When the input program is invalid:
Performance Parameters:
Discussion:
It can be inferred from the project that python acts as a very good tool for file parsing and data analysis in some very complex scenarios too.
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...
File Parsing and data analysis using python
Objective: To create a data visualiser using python, perform a compatibility check of the file and then calculating some basic performance parameters Problem Statement: To visualise the complex data in the file in a sequencial and a more understandable way. Also, how can SublimeREPL adds a more two way relationship in…
30 Mar 2021 06:17 PM IST
Curve fitting using Python
Objective: To find a good fitting function for showing the relationship between temperature and specific heat capacity at constant pressure using the practical values from the data file Procedure: First, we define a function f(x) which will be will give the relationship between the temperature (x) and Cp (y) values Then,…
27 Mar 2021 03:37 AM IST
Analysing ice breaking pressure using a air cushion vehicle by the use of Newton-Raphson method
Objective: Euler equation: (1−β2)p3+(0.4hβ2−σh2r2)p2+(σ2h43r4)p−(σh23r2)3=0 -Equation 1 where p denotes the cushion pressure, h the thickness of the ice field, r the size of the air cushion, σ the tensile strength of the…
07 Mar 2021 05:17 PM IST
Solving the ODE for simple pendulum followed by its simulation
Objective: To solve the following ODE of a simple pendulum with damping and then plot the displacement and velocity values on a graph d2θdt2+bmdθdt+glsinθ=0 where g = gravity in ms2, …
02 Mar 2021 01:38 AM 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.