Challenge

Week 6 - Data analysis

1. AIM:- Write a programme read data from the file containing the engine's data and plot PV diagram.

2. BODY:-

import matplotlib.pyplot as plt
import numpy as np
from numpy import trapz
import time


# Basic Initilization
line_count =1
crank = []
volume = []
# FILE PARSING  STARTS HERE

try :
	open('engine_data.out')

except :
	print('File not recognized. Please provide a valid CONVERGE output fileFile not recognized. Please provide a valid CONVERGE output file"')

for line in open('engine_data.out'):
	if '#' not in line:
		crank.append(float(line.split()[0]))
		volume.append(float(line.split()[7]))
		line_count = line_count +1

#figure
plt.plot(crank, volume,linewidth=3)
plt.xlabel('CRANK')
plt.ylabel('VOLUME')
plt.title('PLOT BETWEEN CRANK AND VOLUME')
plt.show()


# AREA UNDER PV DIAGRAM


volume = []
pressure = []

for k in open('engine_data.out','r'):
	if '#' not in k:
		pressure.append(float(k.split()[1]))
		volume.append(float(k.split()[7]))


# calculating area under pv diagram

area = np.trapz(pressure,volume)
print('Area under PV diagram',area)

#calculating Power

rpm = 1500
power = area * 1e+06 * rpm/1500
print('Power output of the engine',power,'kw')

##calculating specific fuel consumption

fuel_per_stroke = 20*1e-06
mass_flow_rate =  2.99*1e-10
specific_fuel_consumption = mass_flow_rate/(power)
print('The specific fuel consumption is',specific_fuel_consumption,'g/kw')


plt.plot(volume,pressure)
plt.xlabel("VOLUME")
plt.ylabel("PRESSURE")
plt.show()

STEPS TAKEN WRITE A PROGRAMME

  1. Get an empty array for crank and volume.
  2. Give a condition for reading the file.
  3. use append the command to store a value in crank and volume.
  4. plot the result between crank and volume. Labels it.
  5. then put get empty array for pressure and volume
  6. again use append command for storing values in Array.
  7. calculate the area, power and specific fuel consumption.
  8. Plot the graph between pressure and volume. and label it

PLOT

PLOT

RESULT

3.CONCLUSION

With this we can store any value.

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.