Project 1 - Parsing NASA thermodynamic data
Aim – To parse a data file and plot the required properties by calculation.
Objectives –
- To extract the 14 coefficients and calculate the specific heat, entropy, and enthalpy for all species in the data file.
- To calculate the molecular weight of each species.
- To plot Specific heat, Enthalpy, and Entropy with a local temperature range from low temperature to high temperature for each species.
Introduction –
File parsing refers to how to read the information from a particular text file or any type of file and store that information in a computer program. Sometimes it is crucial to read the data from external files or data places to include it in the calculation. This is done by partially analyzing the data, understanding its structure, and then representing this data for further calculation by writing a code. NASA’s thermodynamic data is parsed in this project. The code for parsing is shown below.
Code for Parsing NASA’s Thermodynamic Data:-
clear all
close all
clc
Explanation of the code –
To read the given Nasa file, fopen command is used and fgetl command is used to skip the line (i.e. to go to next line) First, the three lines of code (i.e. Header information) are read by strsplit command, which reads the individual strings by splitting the information with space between them. Str2num is used to convert strings to numbers.
From given data file, 53 species blocks are read using a for loop, which will run 53 times to read species. The line is read by the same strsplit command and given space to distinguish the information. The species name is given as first element as per the given data file.
To read the local temperatures of each and every species, the flip command is used to easily read the line from the end and then the elements are read by converting strings to numbers. Temperature is plotted from low local temperature to high local temperature with 500 parts using linspace command.
Then to read the coefficients, findstr command is used, by which Exponential (E) is located in each coefficient. With reference to that exponential, high temp and low temp coefficients are plotted as given in the problem. Then the functions of enthalpy, entropy, specific heat and molecular weight called in the main program and graph of temp vs enthalpy, entropy and specific heat are plotted for each species. By calling molecular weight, molecular weight of each element is displayed in the command window.
Function to plot the Enthalpy –
Function formula for enthalpy given in the problem is given as,
Function to plot the Entropy –
Function formula for entropy given in the problem is given as,
Function to plot the Specific Heat –
Function formula for specific heat given in the problem is given as,
Function to plot the Molecular Weight –
function[Mw] = molecular_weight_file_pa(species_name)
Explanation of the molecular weight code –
All the primary elements and their respective atomic weights are taken inside the program. Initially, molecular weight is given as 0.
To get the molecular weight of the primary elements, for loops are used with species name and elements name. Both conditions are verified by strcmp command. Mw is taken as the initial Mw and atomic weight for each and every element, so the molecular weight of the primary elements has been plotted.
To get the molecular weight of the species, n is given as a numerical value for the concentration of each element. If a condition is used when n is greater than 1, (i.e. concentration of one element is more in the given species for example. H2O) then the molecular weight will get from the above formula as the molecular weight of the first element plus the molecular weight of second element as per the list of elements from first to last and this is then multiplied by n-1 in order to get the actual weight. (For example, Mw of O + Mw of H2*(2-1) will get the molecular weight of H2O).
Results –
Plots of O2:-
1. Temperature Vs Enthalpy –

2. Temperature Vs Entropy –

3. Temperature Vs Specific Heat -

Plots of N2:-
1. Temperature Vs Enthalpy –

2. Temperature Vs Entropy –

3. Temperature Vs Specific Heat -

Plots of CO2:-
1. Temperature Vs Enthalpy –

2. Temperature Vs Entropy –

3. Temperature Vs Specific Heat -

Molecular Weight results –










