All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM :- Write a code in matlab/Octave to parse the NASA themodynamic data file and then calculate the themodynamic properties of various gas species OBJECTIVE 1. Write a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species in the data file. You will…
Babilu M S
updated on 18 Nov 2021
AIM :- Write a code in matlab/Octave to parse the NASA themodynamic data file and then calculate the themodynamic properties of various gas species
OBJECTIVE
1. Write a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species in the data file. You will be reading this file NASA thermodynamic data
2. Calculate the molecular weight of each species and display it in the command window.
3. Plot the Cp, Enthalpy and Entropy for the local temperature range (low temperature : high temperature) specific for each species.
4. Save the plots as images with appropriate names and dump them in separate folders for each species with suitable name. All these should be generated automatically.
5. The main program that you will submit will just take the "THERMO.dat" file as an input and generate Cp, H and S plots.
6.Screenshot of the window where all the folders are saved.
7.Plot for O2,N2 and Co2 species to be show.
THE FORMULAE:-
Where
R = Universal Gas Constant
T = temperature
Cp = Specific Heat(K)
S = Entroy(KJ/mol-K)
H = Enthalpy(KJ/mol)
a(i)=Coefficients where, 1= i to 14
DEFINITIONS:-
File Parsing
Parsing,syntax analysis,or syntactic analysis is the process of analyzing a string of symbols,either in natrual language,computer languages or data strutures,conforming to the rules of a formal grammar.The term parsing comes from latin pars(orationis).meaning part of speech.Within computational linguistics the term is used to refer to the formal analysis by a computer of asentance or other string of words into its constituent, resulting in a parse tree showing their syntactic relation to reach other,which may also contain semantic and other information.Some parsing algorithms may generate a parse forest or list of parse trees for a syntactically ambiguous input.
Parsing a file means reading in a data stream of some sort and building an in meamory model of the semantic content of that data.This aims at facilitating performing some kind of transformation on the data.
NASA Thermodynamic File:-
NASA thermodynamic file which is THERMO.dat file in which there are temperature range and 53 species are given in these data and each species contaions 14 coefficients and temperature ranges and we have to parse these 14 coefficients to find Specific heat.Entropy and Enthalpy using formule
SPECIFIC HEAT:-
The specific heat is the amount of heat per unit mass required to rise the temperature by one degree Celsius.
ENTROPY:-
Entropy,the measure of a system's thermal eneary per unit temperature that is unavailable for doing useful work.Because work is obtained from ordered molecular motion, the amount of enotropy is also a measure of the molecular disorder,or randomness of a system.
ENTHALPY:-
Enthalpy, a thermodynamic quantity equivalent to the total heat content of a system. It is equal to the internal energy of the system plus the product of pressure and volume.In a system contained so as to prevent mass transfer,for process at constant pressure,the heat absorberved or released equal to change in enthalpy.
PROGRAM
FUNCTIONS
function of find its specific heat
%specific Heat calculation Function
function Cp = Specific_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,midtemp)
%calculating apecific heat for higher and lower temperature respectively.
for i=1:length(T)
if T(i) <= midtemp
Cp(i) = R*(a8+ (a9*T(i)) + (a10*(T(i)).^2) + (a11*(T(i)).^3) + (a12*(T(i)).^4));
else
Cp(i) = R*(a1+ (a2*T(i)) + (a3*T(i)^2) + (a4*T(i)^3) + (a5*T(i)^4));
end
end
end
STEPS:-
Function to Find the entropy
% Entropy Calculation Function
function S = Entropy (a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,tempmid)
%calculating entroy for higher and lower temperature respectively.
for i=1:length(T)
if (T(i) <= tempmid)
S(i) = R*(a8.*log(T(i)) + (a9*T(i)) + ((a10*(T(i)).^2)/2) + ((a11*(T(i)).^3)/3) + ((a12*(T(i)).^4)/4) + a14);
else
S(i) = R*(a1.*log(T(i)) + (a2*T(i)) + ((a3*(T(i)).^2)/2) + ((a4*(T(i)).^3)/3) + ((a5*(T(i)).^4)/4) + a7);
end
end
STEPS:-
Function to find Enthalpy
%Enthalpy calculation function
function H = Enthalpy (a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,tempmid)
%calculating enthaly for higher and lower temperature respectively
for i=1:length(T)
if(T(i) <= tempmid)
H(i) = R*T(i).*(a8 + ((a9*T(i))/2) + ((a10*(T(i)).^2)/3) + ((a11*(T(i)).^3)/4) + ((a12*(T(i)).^4)/5) + ((a13./T(i))));
else
H(i) = R*T(i).*(a1 + ((a2*T(i))/2) + ((a3*(T(i)).^2)/3) + ((a4*(T(i)).^3)/4) + ((a5*(T(i)).^4)/5) + ((a6./T(i))));
end
end
STEPS:-
FUNCTION TO FIND THE MOLECULAR WEIGHT OF THE SPECIES :-
% MOlecular weight Calculation Function
function MW = Molecular_weight(species)
% Defining Atomic Name of the species
atomic_name = ['H','C','O','N','Ar'];
%Hydrogen , Carbon , Oxygen, Nitrogen , Argon
%Defining Atomic masses of main species
atomic_weight = [1.008 12.011 15.999 14.007 39.948];
%Molecular weight starting range
MW = 0;
%Adding Atomic Number to obtain particular value
%Loop runs to the length of the species
for i = 1:length(species)
% Loop runs to the length of the atomic name
for j = 1:length(atomic_name)
% function to compare 2 strings
if strcmp(species(i), atomic_name(j))
MW = MW + atomic_weight(j);
position = j;
end
end
%finding more elements in the species and incrementing atomic weight of the species
n = str2num(species(i));
if n>1
MW = MW + atomic_weight(position)*(n-1);
end
end
fprintf('Molecular Weight of %s : ',species);
fprintf('%f',MW);
disp(' ');
end
STEPS:-
MAIN CODE:-
%Input
clear all
close all
clc
%Gas constant (J/(mol-K))
R = 8.314;
%reading date file
%Open and read THERMO.dat file
f1 = fopen('THERMO.dat','r')
get = fgetl(f1);
%Now reading Temperature from this file
temp = fgetl(f1);
%Spliting
s = strsplit(temp);
%Converting strings cells into numbers
templow = str2num(s{2});
tempmid = str2num(s{3});
temphigh = str2num(s{4});
%Temperature Range
%Skipping Comment lines
for i = 1:3
get = fgetl(f1);
end
%Reading the species
for j = 1:53
tline = fgetl(f1);
% Splitting cell into array
A = strsplit(tline,' ');
% To read the name of the species
species = (A{1});
% Converting strings cell into numbers
lowtemp = str2num(A{end-3});
hightemp = str2num(A{end-2});
midtemp = str2num(A{end-1});
T = linspace(lowtemp,hightemp,1000);
%Getting next line
tline1 = fgetl(f1);
%Finding the string E
a = strfind(tline1, 'E');
%Finding first 7 higher and second & lower coefficients
%Finding the Higher coefficients
a1 = tline1(1:a(1)+3);
a1 = str2num(a1);
a2 = tline1(a(1)+4:a(2)+3);
a2 = str2num(a2);
a3 = tline1(a(2)+4:a(3)+3);
a3 = str2num(a3);
a4 = tline1(a(3)+4:a(4)+3);
a4 = str2num(a4);
a5 = tline1(a(4)+4:a(5)+3);
a5 = str2num(a5);
tline2 = fgetl(f1);
b = strfind(tline2, 'E');
a6 = tline2(1:b(1)+3);
a6 = str2num(a6);
a7 = tline2(b(1)+4:b(2)+3);
a7 = str2num(a7);
% Finding lower coefficients
a8 = tline2(b(2)+4:b(3)+3);
a8 = str2num(a8);
a9 = tline2(b(3)+4:b(4)+3);
a9 = str2num(a9);
a10 = tline2(b(4)+4:b(5)+3);
a10 = str2num(a10);
tline3 = fgetl(f1);
c = strfind(tline3, 'E');
a11 = tline3(1:c(1)+3);
a11 = str2num(a11);
a12 = tline3(c(1)+4:c(2)+3);
a12 = str2num(a12);
a13 = tline3(c(2)+4:c(3)+3);
a13 = str2num(a13);
a14 = tline3(c(3)+4:c(4)+3);
a14 = str2num(a14);
% calculate specific heat
Cp = Specific_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,tempmid);
% calculate Entropy
S = Entropy (a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,tempmid);
% calculate Enthalpy
H = Enthalpy (a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,tempmid);
%calculate Molicular weight of the species
MW = Molecular_weight(species);
%writing molecular weight file
MW_file = fopen('Molecular Weight.txt','w');
fprintf(MW_file,'Molecular weight of %s is %d ',species,MW);
%closing the file
mkdir(['D:\plots\',species])
cd(['D:\plots\',species])
%Plotting Cp, H & S with temperature
%plot 1| Cp vs T
figure(1)
plot(T,Cp,'linewidth',3,'color','r');
xlabel('Temperature (K)');
ylabel('Specific heat (KJ)');
title(sprintf('Specific heat vs Temperature range of %s',species));
grid on
saveas(1,'specific_heat.jpg');
%plot 2| S vs T
figure(2)
plot(T,S,'linewidth',3,'color','g');
xlabel('Temperature (K)');
ylabel('Entropy (KJ/mol-K)');
title(sprintf('Entropy vs Temperature range of %s',species));
grid on
saveas(2,'Entropy.jpg');
%plot 3| H vs T
figure(3)
plot(T,H,'linewidth',3,'color','b');
xlabel('Temperature (K)');
ylabel('Enthalpy (KJ/mol-K)');
title(sprintf('Enthalpy vs Temperature range of %s',species));
grid on
saveas(3,'Enthalpy.jpg');
%Molecular Weight
MW = Molecular_weight(species)
end
fclose(MW_file);
STEPS:-
RESULTS AND PLOTS:-
PLOT :-
Plot for O2
PLOT FOR N2
PLOT FOR Co2
Sreeshot of the directory where different species are saved :-
Molecular Weight of all species (Text & Screenshot)
Molecular Weight of O : 15.999000
MW =
15.9990
Molecular Weight of O2 : 31.998000
Molecular Weight of O2 : 31.998000
MW =
31.9980
Molecular Weight of H : 1.008000
Molecular Weight of H : 1.008000
MW =
1.0080
Molecular Weight of H2 : 2.016000
Molecular Weight of H2 : 2.016000
MW =
2.0160
Molecular Weight of OH : 17.007000
Molecular Weight of OH : 17.007000
MW =
17.0070
Molecular Weight of H2O : 18.015000
Molecular Weight of H2O : 18.015000
MW =
18.0150
Molecular Weight of HO2 : 33.006000
Molecular Weight of HO2 : 33.006000
MW =
33.0060
Molecular Weight of H2O2 : 34.014000
Molecular Weight of H2O2 : 34.014000
MW =
34.0140
Molecular Weight of C : 12.011000
Molecular Weight of C : 12.011000
MW =
12.0110
Molecular Weight of CH : 13.019000
Molecular Weight of CH : 13.019000
MW =
13.0190
Molecular Weight of CH2 : 14.027000
Molecular Weight of CH2 : 14.027000
MW =
14.0270
Molecular Weight of CH2(S) : 14.027000
Molecular Weight of CH2(S) : 14.027000
MW =
14.0270
Molecular Weight of CH3 : 15.035000
Molecular Weight of CH3 : 15.035000
MW =
15.0350
Molecular Weight of CH4 : 16.043000
Molecular Weight of CH4 : 16.043000
MW =
16.0430
Molecular Weight of CO : 28.010000
Molecular Weight of CO : 28.010000
MW =
28.0100
Molecular Weight of CO2 : 44.009000
Molecular Weight of CO2 : 44.009000
MW =
44.0090
Molecular Weight of HCO : 29.018000
Molecular Weight of HCO : 29.018000
MW =
29.0180
Molecular Weight of CH2O : 30.026000
Molecular Weight of CH2O : 30.026000
MW =
30.0260
Molecular Weight of CH2OH : 31.034000
Molecular Weight of CH2OH : 31.034000
MW =
31.0340
Molecular Weight of CH3O : 31.034000
Molecular Weight of CH3O : 31.034000
MW =
31.0340
Molecular Weight of CH3OH : 32.042000
Molecular Weight of CH3OH : 32.042000
MW =
32.0420
Molecular Weight of C2H : 25.030000
Molecular Weight of C2H : 25.030000
MW =
25.0300
Molecular Weight of C2H2 : 26.038000
Molecular Weight of C2H2 : 26.038000
MW =
26.0380
Molecular Weight of C2H3 : 27.046000
Molecular Weight of C2H3 : 27.046000
MW =
27.0460
Molecular Weight of C2H4 : 28.054000
Molecular Weight of C2H4 : 28.054000
MW =
28.0540
Molecular Weight of C2H5 : 29.062000
Molecular Weight of C2H5 : 29.062000
MW =
29.0620
Molecular Weight of C2H6 : 30.070000
Molecular Weight of C2H6 : 30.070000
MW =
30.0700
Molecular Weight of CH2CO : 42.037000
Molecular Weight of CH2CO : 42.037000
MW =
42.0370
Molecular Weight of HCCO : 41.029000
Molecular Weight of HCCO : 41.029000
MW =
41.0290
Molecular Weight of HCCOH : 42.037000
Molecular Weight of HCCOH : 42.037000
MW =
42.0370
Molecular Weight of H2CN : 28.034000
Molecular Weight of H2CN : 28.034000
MW =
28.0340
Molecular Weight of HCN : 27.026000
Molecular Weight of HCN : 27.026000
MW =
27.0260
Molecular Weight of HNO : 31.014000
Molecular Weight of HNO : 31.014000
MW =
31.0140
Molecular Weight of N : 14.007000
Molecular Weight of N : 14.007000
MW =
14.0070
Molecular Weight of NNH : 29.022000
Molecular Weight of NNH : 29.022000
MW =
29.0220
Molecular Weight of N2O : 44.013000
Molecular Weight of N2O : 44.013000
MW =
44.0130
Molecular Weight of NH : 15.015000
Molecular Weight of NH : 15.015000
MW =
15.0150
Molecular Weight of NH2 : 16.023000
Molecular Weight of NH2 : 16.023000
MW =
16.0230
Molecular Weight of NH3 : 17.031000
Molecular Weight of NH3 : 17.031000
MW =
17.0310
Molecular Weight of NO : 30.006000
Molecular Weight of NO : 30.006000
MW =
30.0060
Molecular Weight of NO2 : 46.005000
Molecular Weight of NO2 : 46.005000
MW =
46.0050
Molecular Weight of HCNO : 43.025000
Molecular Weight of HCNO : 43.025000
MW =
43.0250
Molecular Weight of HOCN : 43.025000
Molecular Weight of HOCN : 43.025000
MW =
43.0250
Molecular Weight of HNCO : 43.025000
Molecular Weight of HNCO : 43.025000
MW =
43.0250
Molecular Weight of NCO : 42.017000
Molecular Weight of NCO : 42.017000
MW =
42.0170
Molecular Weight of CN : 26.018000
Molecular Weight of CN : 26.018000
MW =
26.0180
Molecular Weight of HCNN : 41.033000
Molecular Weight of HCNN : 41.033000
MW =
41.0330
Molecular Weight of N2 : 28.014000
Molecular Weight of N2 : 28.014000
MW =
28.0140
Molecular Weight of AR : 39.948000
Molecular Weight of AR : 39.948000
MW =
39.9480
Molecular Weight of C3H8 : 44.097000
Molecular Weight of C3H8 : 44.097000
MW =
44.0970
Molecular Weight of C3H7 : 43.089000
Molecular Weight of C3H7 : 43.089000
MW =
43.0890
Molecular Weight of CH3CHO : 44.053000
Molecular Weight of CH3CHO : 44.053000
MW =
44.0530
Molecular Weight of CH2CHO : 43.045000
Molecular Weight of CH2CHO : 43.045000
MW =
43.0450
CONCLUSION :-
Using Octave code, the necessary coefficients required to evalute various thermodynamic parameters for different species are extracted from NASA thermodynamic data file.The specific heat,entropy & enthalpy for all the species are calculated and ploted against the local temperature range.The molecular weight is calculated for all the species.
Google DRIVE LINK :-
https://drive.google.com/drive/folders/1NHimXAbWTnV2M1lGj9xo99ej4MnHY3X2?usp=sharing
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...
Underbody Coating
UNDER BODY COATING: We all are aware of the fact that the underbody of the previous models was made from durable metals such as steel, which is easily damaged and oxidized, forming rust While you are sitting on the driving seat enjoying the smooth ride, the underbody of your car is always exposed to muddy water, stones,…
11 Jul 2022 01:11 PM IST
Benchmarking
BENCHMARKING Benchmarking is a process of measuring the performance of a company's products, services, or processes against those of another business considered to be the best in the industry, "best in class." The point of benchmarking is to identify internal opportunities for improvement. By studying companies with…
11 Jul 2022 12:16 PM IST
Advanced Sheet Metal Design Using NX Cad Challenge_7_ Metal bracket-II
Advanced Sheet Metal Design Using NX Cad Challenge_7_ Meal bracket-11 Objective: The objective of this challenge is to design a metal bracket with mentioned tools and measurements in Sheet metal Application of Siemens NX. Introduction: A Bracket is a component used to support load or any attachments to structural…
06 Jul 2022 06:52 AM IST
Advanced Sheet Metal Design Using NX Cad Challenge_6_Bracket
Title of the project:- Advanced Sheet Metal Design Using NX Cad Challenge_6_Bracket Objective: To design a Bracket using Siemens NX Sheet metal application. Introduction:- 1. SIEMENS NX:- NX formerly known as "unigraphics", is an advanced high-end CAD/CAM/CAE, which has been owned since 2007 by Siemens PLM Software.…
06 Jul 2022 06:16 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.