Project 1 - Parsing NASA thermodynamic data
AIM - Parsing NASA thermodynamic data
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.
The formulae are shown below.
Here R is the universal gas constant, T is the temeprature
The FIRST 7 coefficients are HIGH-temperature coefficients and the SECOND 7 coefficients are LOW-temperature coefficients.
Also use the LOCAL TEMPERATURE RANGES which is unique for each individual species, not the GLOBAL TEMPERATURE RANGE.
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. Please write a detailed report to describe your logic.
THEORY -
file parsing - This deals with the field of computational linguistics where it commonly defines the natural language processing.
Natural language processing ( NLP ) , is concerned with programming the computers to process and analyse the human written language.
Parser helps to split the large input data into smaller data and will process the data.
Why file parsing ?
- Parsing is necessary because different application needs the data to be in different forms.
- Parsing allows transforming the data in a way that can be understood by a specific software.
- The obvious example is programs they are written by humans , but they must be executed by computers .
- Parsing helps to automate the certain ings , and also reduces the human effort. And can be used for the applications of machine learning , automation etc ;
PROCEDURE -
- While start any program its better to close all window and erase previous calculations, so we use these three commands-
- clear - this command clear all previous data stored in the workspace window.
- close - this command close all the previous figure and plot.
- clc - this command clear all data in command window.
- The task includes the parsing of a ' NASA thermodynamic file ' , and to calculate the specific heat ( cp ) , Enthalpy ( H ) , Entropy ( S ) for defined local temperatures.
- The file includes the 53 different species having its own local temperature range.
- The file includes the NASA thermodynamic data.
1st we have to reading the file - The file should be loaded and opened in the script using the ' fopen ' command.
And the lines necessary for the calculation should be get from the file using ' fgetl '.
f = fopen ( ' THERMO.dat ' , ' r ' )
fgetl ( f )
- Now Using strsplit command beacause it is string type so, spliting by space because it common in this line
- Next step is to Calculate the molecular weight of each species created and function to find all molecular weight
|
% Function for calculating the moleculer weight
function [molecular_wt] = calc_of_molecular_weight(species_name)
Elements = ['H','C','N','O','A'];
Atomic_wt = [1,12,14,16,40];
molecular_wt = 0;
for i = 1:length(species_name)
for j = 1 : length(Elements)
if strcmpi(species_name(i),Elements(j))
molecular_wt = molecular_wt+Atomic_wt(j);
P=j;
end
end
G = str2double (species_name(i));
if G>1
molecular_wt = molecular_wt+Atomic_wt(P)*(G-1);
end
end
fprintf('The molecular weight of %s is %f', species_name,molecular_wt)
end
|
- Now Extraction of local temperature -
- The temperature values available in the header line of every species is known as local temperature.
- It includes ' low ' , ' high ' , ' middle ' temperatures as in the order.
- Will be used in the calculation of Cp , H , S.
|
LOCAL TEMPERATURES
08-1.00177799E - 11 1.22833691E - 15 -3.27931884E - 03 6.64306396E - 06 04 2.05193346E + 00 |
- Now we can extract the coefficient values - The coefficients are of two categories , such as high temperature coefficients ( first 7 coefficients ) and low temperature coefficients ( second 7 coefficients ).

- Here R is universal gas number
- Now Calculation of cp(specific heat), h(enthalpy), s(entropy)
|
function [cp,h,s] = calc_therm_properties(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,t,mid_temp)
R = 8.314;
% first 7 coefficients are high temperature coefficients and next 7 are low
% temperature coefficients
if (t>=mid_temp)
cp = R*(a1+(a2*t)+(a3*(t).^2)+(a4*(t).^3)+(a5*(t).^4));
h = R*(a1+(a2.*t/2)+(a3.*(t.^2)/3)+(a4.*(t.^3)/4)+(a5.*(t.^4)/5)+a6.*t);
s = R*(a1*log(t)+(a2.*t)+(a3.*(t.^2)/2)+(a4.*(t.^3)/3)+(a5.*(t.^4)/4)+a7);
else
cp = R*(a8+(a9.*t)+(a10*(t).^2)+(a11*(t).^3)+(a12*(t).^4));
h = R*(a8+(a9.*t/2)+(a10.*(t.^2)/3)+(a11.*(t.^3)/4)+(a12.*(t.^4)/5)+a13.*t);
s = R*(a8*log(t)+(a9.*t)+(a10.*(t.^2)/2)+(a11.*(t.^3)/3)+(a12.*(t.^4)/4)+a14);
end
end
|
- Now Temperature array creation
- Next step is plotting and saving the figures
By using mkdir command and cd commands
In the last END the for loop.
CODE -

