## Data Analysis using Python

OBJECTIVE – We have to write the script which should take column numbers as the input and plot the respective columns as separate images. The plot labels should be extracted from the file. If there is a request for a plot between column 1(crank angle) and column 8(volume) , then label information should automatically be extracted and must appear as labels in the plots.Also to calculate the area under the P-V diagram. P is in the column 2 and V is in column 8,the power output of this engine(Assume RPM is 1500) and its specific fuel consumption.

SCRIPT –

import matplotlib.pyplot as plt
import numpy as np
import math

Crank = []
Pressure = []
Max_Pres = []
Min_Pres = []
Mean_Temp = []
Max_Temp = []
Min_Temp = []
Volume = []
Mass = []
Density = []
Integrated_HR = []
HR_Rate = []
C_v = []
C_p = []
Gamma = []
Kin_Visc = []
Dyn_Visc =[]
label = []
Units = []

filename = input('Enter a Converge output file: ')
try:
file = open(filename,'r')
line_count = 1
for line in file:
if '#' in line:
if line_count is 3:
for j in range(1,18):
label.append(line.split()[j])

if line_count is 4:
for k in range(1,18):
Units.append(line.split([k]))

line_count = line_count + 1

if '#'	not in line:
Crank.append(float(line.split()[0]))
Pressure.append(float(line.split()[1]))
Max_Pres.append(float(line.split()[2]))
Min_Pres.append(float(line.split()[3]))
Mean_Temp.append(float(line.split()[4]))
Max_Temp.append(float(line.split()[5]))
Min_Temp.append(float(line.split()[6]))
Volume.append(float(line.split()[7]))
Mass.append(float(line.split()[8]))
Density.append(float(line.split()[9]))
Integrated_HR.append(float(line.split()[10]))
HR_Rate.append(float(line.split()[11]))
C_p.append(float(line.split()[12]))
C_v.append(float(line.split()[13]))
Gamma.append(float(line.split()[14]))
Kin_Visc.append(float(line.split()[15]))
Dyn_Visc.append(float(line.split()[16]))

Inp = np.array([[0], Crank, Pressure, Max_Pres, Min_Pres, Mean_Temp, Max_Temp, Min_Temp, Volume, Mass, Density, Integrated_HR, HR_Rate, C_v, C_p, Gamma, Kin_Visc, Dyn_Visc])

print('\n Enter the Engine Parameters: ')

x = input("Engine parameter the x axis: ")
x = int(x)

y = input("Engine parameter on the y axis: ")
y = int(y)

plt.plot(Inp[x],Inp[y])
plt.Title(str(label[x-1]) + ' v ' + str(label[y-1]) + 'plot')
plt.xlabel(str(label[x-1]) + str(Units[x-1]))
plt.ylabel(str(label[y-1]) + str(Units[y-1]))
plt.savefig(str(label[x-1]) + 'v' + str(label[y-1]))
plt.show()

if x == 2 and y == 8 or x == 8 and y == 2:
rpm = input('\nWhat is the engine rpm? ')
rpm = float(rpm)
r = input('\nWhat is the fuel consumption?')
r = float(r)
T = np.trapz(Inp[x], Inp[y])
P = (2*math.pi*rpm*T)/(60)
SFC = ((r*rpm)*(pow(10,-6))*(3600))/(P*1000*60)
print('\nArea under the pv plt = t = ',T,'N-m')
print('\nPower = ', P,'Mw')
print('\nSFC = ', SFC, 'g/KW-h')

except:
print('Enter a valid Converge output file')



The P-V plot obtained by the code.

The command line arguments inputs to obtain the results:

The code is written such that the rpm and fuel consumption values can be input for different running conditions.Sublime text is modified with a package such that it is able to take in user input and read the input to provide the output. The results for the Power and SFC calculations are as above and the P-V plot is added below.

For any other variables, the area under the plot isn’t a case of study and it will not be printed as part of the output.

As we can see, the area under the graph and subsequent calculations haven’t been done for this case plotting crank angle and pressure.

The result as obtained from this.

Finally the script is written such that the file must be an output file from Converge. If not an error will be displayed.

The script has been written to be modular and find any data that the user required from the data file.

### Pipe Flow simulation using Solidworks Habishek Umapathy · 2019-10-23 12:06:35

AIM – To run a pipe flow simulation with an inlet Reynolds number of 100, 1000 and 10000. For each of these cases do the following Place the line probes at 95%, 90%, 85%of the pipe length. Compare the normalized velocity profile at each of these locations. N Read more

### Curve Fitting using Python Habishek Umapathy · 2019-08-01 06:59:25

OBJECTIVE – To write a program to perform curve fitting.   Curve Fitting is the process of constructing a curve or mathematical functions, which possess the closest proximity to the real series of data. By curve fitting, we can mathematically constr Read more

### Breaking Ice with Air cushion Vehicle - Find minimum pressure with Newton-Raphson method Habishek Umapathy · 2019-07-29 18:24:30

The Newton Raphson method is an iterative technique that is used to find out the roots of a real valued function. It uses the idea that a continuous and differentiable function can be approximated by a straight-line tangent to it. In this case Newton Raphson method is Read more

### Simulation of Transient behaviour of a Simple Pendulum Habishek Umapathy · 2019-07-15 19:12:38

OBJECTIVE – To write a program to simulate the transient behaviour of a simple pendulum and to create an animation of its motion.   PROCEDURE – In Engineering, ODE is used to describe the transient behavior of a system. A simple example is a pendulum Read more

### Otto Cycle using Python Habishek Umapathy · 2019-07-08 04:43:31

OBJECTIVE - To write a code for P_V diagram of an Otto cycle and calculate thermal efficiency

PROCEDURE –

ASSUMPTIONS

• Initially state variables p1,t1,t3 and gamma a Read more

### Parsing NASA Thermodynamic file Using MATLAB Habishek Umapathy · 2019-06-12 15:23:18

OBJECTIVE - 1. Write a function that extracts the 14 co-efficient and calculates the enthalpy, entropy and specific heats for all the species in the data file. Calculate the molecular weight of each species and display it in the command window. Plot the Cp, Ent Read more

### Genetic Algorithm Using MATLAB Habishek Umapathy · 2019-06-06 16:17:05

OBJECTIVE - Write a code in MATLAB to optimise the stalagmite function and find the global maxima of the function. PROCEDURE- The genetic algorithm is a method for solving both constrained and unconstrained optimization problems that is based on natural sele Read more

### Curve Fitting Using MATLAB Habishek Umapathy · 2019-06-04 07:59:31

OBJECTIVE – To write code to fit a linear and cubic polynomial for the Cp data and plot the linear and cubic fit curves along with the raw data points.   PROCEDURE – Curve Fitting is the process of constructing a curve or mathematical functions, whic Read more