All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM A data file containing various parameters that affect the performance of an IC engine is specified.From that datasheet,we are asked to do the following. Your script should take column numbers as the input and plot the respective columns as separate images Each file should be saved by the name of the column The plot…
LAKSHMI RAJAN P
updated on 03 Jun 2021
AIM
A data file containing various parameters that affect the performance of an IC engine is specified.From that datasheet,we are asked to do the following.
INITIAL STUDY
File Parsing
The current assignment is dealing with the most important part in python,the most commonly used program to do the file parsing. Parsing means dividing a file or input into pieces of information/data that can be stored for our personal use in the future. Sometimes, we need data from an existing file stored on our computers, parsing technique can be used in such cases. The parsing includes multiple techniques used to extract data from a file. The following includes Modifying the file, Removing something from the file, Printing data, using the recursive child generator method to traverse data from the file, finding the children of tags, web scraping from a link to extract useful information, etc.
Engine
An engine or motor is a machine designed to convert one form of energy into mechanical energy. Heat engines convert heat into work via various thermodynamic processes. The internal combustion engine is perhaps the most common example of a heat engine, in which heat from the combustion of a fuel causes rapid pressurisation of the gaseous combustion products in the combustion chamber, causing them to expand and drive a piston, which turns a crankshaft. Electric motors convert electrical energy into mechanical motion, pneumatic motors use compressed air, and clockwork motors in wind up toys use elastic energy.
IC Engines
An internal combustion engine (ICE) is a heat engine in which the combustion of a fuel occurs with an oxidiser (usually air) in a combustion chamber that is an integral part of the working fluid flow circuit. In an internal combustion engine, the expansion of the high-temperature and high-pressure gases produced by combustion applies direct force to some component of the engine. The force is applied typically to pistons, turbine blades, a rotor, or a nozzle. This force moves the component over a distance, transforming chemical energy into useful work. This replaced the external combustion engine for applications where weight or size of the engine is important.
Engine power
It is the power that an engine can put out. It can be expressed in power units, most commonly kilowatt, pferdestarke (metric horsepower), or horsepower. In terms of internal combustion engines, the engine power usually describes the rated power, which is a power output that the engine can maintain over a long period of time according to a certain testing method, for example ISO 1585. In general though, an internal combustion engine has a power take-off shaft (the crankshaft), therefore, the rule for shaft power applies to internal combustion engines: Engine power is the product of the engine torque and the crankshaft's angular velocity.
Brake-specific fuel consumption (BSFC) is a measure of the fuel consumption of any prime mover that burns fuel and produces rotational, or shaft power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output.
It is the rate of fuel consumption divided by the power produced. It may also be thought of as power specific fuel consumption, for this reason. BSFC allows the fuel efficiency of different engines to be directly compared.
GOVERNING EQUATION
Brake power of the engine,
Horse power, HP= BP/0.746
where
W = Brake load in newtons,
l = Length of arm in metres, and
N = Speed of the engine in r.p.m.
To calculateBrake specific fuel consumption, use the formula
where:
PROGRAM CODE
"""
Created on Tue Jun 1 18:21:48 2021
Title: File Parsing of IC Engine parameters
@author: Lakshmi Rajan P
"""
#Importing the required modules
import numpy as np
import matplotlib.pyplot as plt
import csv
from numpy import trapz
#Checking whether right file has been uploaded with the help of try and except functions
try:
with open("engine_data.csv",'r') as i:
rawdata = list(csv.reader(i,delimiter=','))
print("You have selected the right file....Please carry on.")
print("\n")
print("IC ENGINE DATAFILE PARSING")
#Assigning each data to its specified column header
labeldata=np.array(rawdata[2:3])
unitdata=np.array(rawdata[3:4])
exampledata = np.array(rawdata[6:],dtype=float)
crank = exampledata[:,0] #crank in deg - Column number 0
pressure = exampledata[:,1] #Pressure in MPa - column number 1
max_pressure = exampledata[:,2] #Maximum Pressure in MPa - column number 2
min_pressure = exampledata[:,3] #Minimum Pressure in MPa- column number 3
mean_temp = exampledata[:,4] #Mean temperature in Kelvin -column number 4
max_temp = exampledata[:,5] #Maximum temperature in Kelvin - column number 5
min_temp = exampledata[:,6] #Minimum temperature in Kelvin - column number 6
volume = exampledata[:,7] #Volume in m^3 - column number 7
mass = exampledata[:,8] # mass in Kg-column number 8
density = exampledata[:,9] #Density in Kg/m^3 -column number 9
integrated_HR = exampledata[:,10] #Heat radiation in J-column number 10
HR_rate = exampledata[:,11] #Heat radiation in J/sec-column number 11
c_p = exampledata[:,12] # Specific heat at const pressure(J/KgK)-column number 12
c_v = exampledata[:,13] # Specific heat at const volume(J/KgK)-column number 13
gamma = exampledata[:,14] #Adiabatic index -column number 14
kin_visc = exampledata[:,15] #Kinematic viscosity in m^2/sec -column number 15
dyn_visc = exampledata[:,16] #Dynamic viscosity in Ns/m^2 -column number 16
#The x coordinate data input is asked from the user to enter and saved in i
i=int(input("Enter the column number for the x coordinate of the plot needed "))
print("The parameter you have selected is",labeldata[0,i],unitdata[0,i],"And its values are ",exampledata[:,i])
#y coordinate data is asked from the user and is saved in j
j=int(input("Enter the column number for the y coordinate of the plot needed "))
print("The parameter you have selected is",labeldata[0,j],unitdata[0,j],"And its values are ",exampledata[:,j])
#Plotting the graph between x and y
plt.plot(exampledata[:,i],exampledata[:,j])
plt.xlabel(labeldata[0,i])
plt.ylabel(labeldata[0,j])
plt.show()
#if x and are volume and pressure,then carrying out the following calculations.
if i is 7 and j is 1:
#using trapezoidal function,finding the area under the PV diagram
area = trapz(exampledata[:,1], exampledata[:,7])
print("area under the PV diagram is = ", area)
#Rotations per minute given as 1500 and assigned as rpm
rpm=1500
#The formula to find the power output in watts
poweroutput_watt=area*(rpm/60)*1000
print("power output of the engine in watts is ",poweroutput_watt)
#Converting the power outputs in watts to horsepower
hp=poweroutput_watt/0.746
print("The power output of the engine in horse power is : ",hp)
#Using the formula to find the specific fuel consumption when engine consumed 20 micrograms of fuel
spfuel_consumption=(20*pow(10,-6)*3600)/(0.08*poweroutput_watt)
print("The specific fuel consumption of the engine : ",spfuel_consumption)
except FileNotFoundError:
print("File not found. Check the path variable and filename")
#If program closes successfully
else:
print("All computations successfully completed")
PROCEDURE WITH DETAILED EXPLANATION
1)Analyse the data given to us.Check which are the operations that need to be carried out and make a flowchart to do the same.
2)Here for the purpose of easily analysing the data,I had changed the data format from out file to csv format without affecting the data structure and the values.
3)The above file has 8666 rows and 17 columns to have the numerical data as specified.And each column gives a set of values measured during experiments.We have to take up the values from the 6th row for computational purposes.
4)Import the required files needed for running the program.
import numpy as np
import matplotlib.pyplot as plt
import csv
from numpy import trapz
Here numpy module is imported to do mathematical operations like addition and subtraction within the elements of an array or between the arrays.
The matplotlib module does the plotting of the numerical data between the specified parameters.
csv is imported to run our csv file made
trapz is imported to calculate the area under the curve of PV diagram.
4)Now the required file is opened using the open command using with.This is done so that the open command closes on its own rather than closing the function separately.
5)We use try, except an else statements are used to to gracefully come out of the loop statements, to accept the opening of file if format and path correctly specified.
try:
with open("engine_data.csv",'r') as i:
rawdata = list(csv.reader(i,delimiter=','))
print("You have selected the right file....Please carry on.")
print("\n")
print("IC ENGINE DATAFILE PARSING")
except FileNotFoundError:
print("File not found. Check the path variable and filename")
else:
print("All computations successfully completed")
6)Now the columns are called and assigned each column with the column header given.The column number could be entered to see the selected column and the contents in it.
7)Some computations are also asked to perform when the graph between pressure and volume are specified as columns,after generating the graph,the area is calculated .And the Engine power output and the specific fuel consumption are calculated from the governing equations specified.
OUTPUT
The output on the console looks as below:
You have selected the right file....Please carry on.
IC ENGINE DATAFILE PARSING
Enter the column number for the x coordinate of the plot needed 7
The parameter you have selected is Volume (m^3) And its values are [0.000125 0.000126 0.000126 ... 0.000474 0.000474 0.000475]
Enter the column number for the y coordinate of the plot needed 1
The parameter you have selected is Pressure (Mpa) And its values are [0.093 0.0931 0.0931 ... 0.535 0.534 0.534 ]
area under the PV diagram is = 0.0005008259
power output of the engine in watts is 12.520647499999999
The power output of the engine in horse power is : 16.783709785522788
The specific fuel consumption of the engine : 0.07188126652395574
All computations successfully completed
Plot generated:
Output when not pressure and volume looks like:
You have selected the right file....Please carry on.
IC ENGINE DATAFILE PARSING
Enter the column number for the x coordinate of the plot needed 0
The parameter you have selected is Crank (Deg) And its values are [-320. -320. -320. ... 120. 120. 120.]
Enter the column number for the y coordinate of the plot needed 4
The parameter you have selected is Mean_Temp (K) And its values are [ 489. 489. 489. ... 1720. 1720. 1720.]
All computations successfully completed
Plot generated:
INFERENCE
In this file parsing project,we had an idea regarding how to do file parsing of big datas.We have also calculated the data requested as per the given data.All the objectives mentioned in the aim were satisfied.
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 8-3D Tetra Meshing Challenge
OBJECTIVE Create a Teramesh for Housing component with the following quality criteria. TetraMesh Generation Method: 2D to 3D Conversion Elements sizes: Min- 2 Units, Target- 5 Units, Max- 7 Units Tet collapse: 0.15 For the given model, Create a 3D Tetramesh with the following quality criteria. TetraMesh…
21 Jul 2022 08:24 AM IST
Week 6-Introduction to Ansys ACT Challenge
1. Answer the questions: What is an API? What are binary and Scripted Extensions? Ans: 1.a) ANSYS ACT is the unified and consistent tool for the customization and expansion of ANSYS products.Using ACT, you can create extensions to customize these products: workbench • Mechanical• AIM• DesignModeler•…
19 Jul 2021 07:59 AM IST
Week 1-Model Creation in DesignModeler Challenge
OBJECTIVE Model a butterfly valve from scratch for the dimensions provided in the figure in design modeller. INITIAL STUDY Butterfly valves belong to quarter-turn rotational motion valves family and used primarily to stop, regulate, or start the flow. The term “butterfly” in a butterfly valve is actually a…
06 Jul 2021 10:16 AM IST
Week 6 - Data analysis
AIM A data file containing various parameters that affect the performance of an IC engine is specified.From that datasheet,we are asked to do the following. Your script should take column numbers as the input and plot the respective columns as separate images Each file should be saved by the name of the column The plot…
03 Jun 2021 09:02 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.