Project

Data analysis with Python

import matplotlib.pyplot as mol
import numpy as np
import sys
import math
import time

value=[]
dx=[]
k=0
W=[]
Work=0
t=0
i=1
res=\'y\'

try:
  f=open(\'engine_data.out\',\'r\')
except FileNotFoundError:
  print(\'File not recognized. Please provide a valid CONVERGE output file\')
  sys.exit(1)

for line in f:
  if \'#\' not in line:
    l=line.split()   
    value.append(l)

column=np.transpose(value)
column=column.astype(np.float)

name=[\'Crank\',\'Pressure\',\'Max_Pres\',\'Min_Pres\',\'Mean_Temp\',\'Max_Temp\',\'Min_Temp\',\'Volume\',\'Mass\',\'Density\',\'Integrated_HR\',\'HR_Rate\',\'C_p\',\'C_v\',\'Gamma\',\'Kin_Visc\',\'Dyn_Visc\']

print(\'***FOR PLOTTING***\')
print(\'MENU \\n 1 Crank \\n 2 Pressure \\n 3 Max_Pres \\n 4 Min_Pres \\n 5 Mean_Temp \\n 6 Max_Temp \\n 7 Min_Temp \\n 8 Volume \\n 9 Mass \\n 10 Density \\n 11 Integrated_HR \\n 12 HR_Rate \\n 13 C_p \\n 14 C_v \\n 15 Gamma \\n 16 Kin_Visc \\n 17 Dyn_Visc\')

while res==\'y\':
  x=int(input(\'Enter X-axis parameter & then press enter\\n\'))
  y=int(input(\'Enter Y-axis parameter & then press enter \\n\'))
  
  mol.figure(i)
  mol.plot(column[x-1],column[y-1])
  mol.title(name[y-1]+\' vs \'+name[x-1]+\' Plot \',color=\'blue\')
  mol.xlabel(name[x-1])
  mol.ylabel(name[y-1])
  mol.savefig(name[x-1] + \' vs \' + name[y-1] + \'.png\')
  mol.show()

  res=input(\'Want to plot more?(y/n)\\n\')
  i=i+1

Pressure=column[1]
Volume=column[7]

while k<8664:
  dif=Pressure[k+1]-Pressure[k]
  dx.append(dif)
  k=k+1

while t<8664:
  W.append((dx[t]/2)*(Volume[0]+2*Volume[t+1]+Volume[8664]))
  t=t+1

for n in range(0,len(W)):
  Work=Work+W[n]

Work=Work*1000000
print(\'\\nWork Output:\')
print(abs(Work),\'J\\n\')

power=(Work*math.pi)/20
print(\'Power Output is:\')
print(abs(power),\'W\\n\')

print(\'Specific fuel consumption is:\')
print(20/abs(power),\'g/kJ\\n\')

print(\'Waiting for 10seconds\\n\')
time.sleep(10)

mol.figure(i+1)
mol.plot(Volume,Pressure)
mol.title(\'Pressure vs Volume Plot\',fontsize=16,color=\'black\')
mol.xlabel(\'Volume\',)
mol.ylabel(\'Pressure\')
mol.savefig(\'Pressure vs Volume.png\')
mol.show()

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.