Project 1 - Parsing NASA thermodynamic data
File Parsing NASA thermodynamic data
NASA came up with polynomials that can be used to evaluate thermodynamic properties such as Cp, H and S. They have also documented the co-efficients that are required to evaluate these polynomials for 1000+ species.
Here we are PARSING 53 species from NASA thermodynamic data file
THEORY
Specific heat (cp): Specific heat is defined by the amount of heat needed to raise the temperature of 1 gram of a substance 1 degree Celsius (°C). Water has a high specific heat capacity which we'll refer to as simply "heat capacity", meaning it takes more energy to increase the temperature of water compared to other substances.

Entropy (S): Entropy, the measure of a system's thermal energy per unit temperature that is unavailable for doing useful work. Because work is obtained from ordered molecular motion, the amount of entropy is also a measure of the molecular disorder, or randomness, of a system.

Enthalpy (H): Enthalpy is a property of a thermodynamic system, defined as the sum of the system's internal energy and the product of its pressure and volume. It is a convenient state function standardly used in many measurements in chemical, biological, and physical systems at a constant pressure.

CODE EXPLANATION
- Starting with clear all, close all and clc
- By using fopen command we are opening the file of THERMO.dat and 'r' repersents to read the file
fgetl: is used to read the line in the file of which we have given and for every fgetl it will be reading the next line in the file So the fgetl is used to read the line in the file
- By using fgetl we will be reading the first line of the file which is THERMO and for next fgetl we ill be getting the second line which is the Global_temperature and we are assinging to the G_temp
- G_low = G_temp(1)
G_mid = G_temp(2)
G_high= G_temp(3) - And we are skipping the next three lines by creating the for loop because those are the comments

- And then in the 4TH line we have species name in the first position and then the local_temperature and we are assinging this line to the line
- By using the strsplit we are splitting the line with the reference of the 'space'
strsplit : Split string or character vector at specified delimiter
Delimiting characters, specified as a character vector, a 1-by-n cell array of character vectors, or a 1-by-n string array. Text specified in delimiter does not appear in the output C.
Specify multiple delimiters in a cell array or a string array. The strsplit function splits str on the elements of delimiter. The order in which delimiters appear in delimiter does not matter unless multiple delimiters begin a match at the same character in str. In that case strsplit splits on the first matching delimiter in delimiter.
- Strsplit is used to split the line and it is assigned to the variable A so the A(1) is the species name and for the local_temp we ill be taking from the end
- Low = str2num(A{end-3})
High = str2num(A{end-2})
Mid = str2num(A{end-1})
str2num: Convert character array or string to numeric array
- And then we have to read the co-efficients which are from the next line and then by using fgetl read the next line and assigned to a variable
- To assign each value to a variable we used findstr
findstr: Find strings within other strings
- We ill be finding the E in the string (line) and by refering that we ill be taking the separate value and assign to a variable as shown
-
a_line = fgetl(f1);
a = findstr(a_line,'E')A1 = a_line(1:a(1)+3)
- Here a will be getting the position of the E in the line and by using the position and number of numbers to left and right we ill be getting the co_efficiants and for the second number we have to start from the first number position as shown
A2 = a_line(a(1)+4:a(2)+3)
- lly to all co_efficiants as shown
- We have to write a formula for low and high temperatures The FIRST 7 coefficients are HIGH-temperature coefficients and the SECOND 7 coefficients are LOW-temperature coefficients.
- And then we have to create a folder to save the plots in thier respective folders to do that we will be using the mkdir
mkdir: To create a folder
cd: Change current folder
- str = sprintf('D:viratNasa thermodynamics data%s',Spices);
mkdir(str);
cd(str); - plotting the enthalpy, entropy and specific heats for the low and high temperatures co_efficiants
- after every plot saveas will save the plot as fig in the respective folder
saveas: Save figure to specific file format gcf is the handle to save the plot as image
- And the we have to give the cd.. command to come out from the particular folder
cd.. : Change current folder
- Calculating the molecular weight
- Create two strings of atom symbol and the atomic weight as shown
- elements = ['H','C','N','O','AR','(S)'];
Atomic_weight = [1,12,14,16,40,0,0,0,0]; - Create a for loop to the length of the species convert the species to number by using str2num command with 2 results
- In species if it is number status will be 1 it is true if it is an letter(element) the status will be 0
- By applying if condition status == 0
- ind = find(elements == species(k)) we are finding the elements in species in the elements array by using find command
- Then the molecular_wt = atomic_weight(ind) else
- molecular_wt(k-1) is it will take the previous position of the species equals to number in the species multiply to the molecular_wt(k-1) so that the previous position to the number in the species will be changed
- And then display the molecular_wt
RESULTS

- molecular weight of each species display it in the command window.

- Save the plots as images with appropriate names and dump them in separate folders for each species with suitable name is done AUTOMATICALLY
- Plots for o2, N2 and Co2 species
PLOTS OF O2



specific heats(cp) enthalpy(H) entropy(S)
PLOTS OF N2



specific heats(cp) enthalpy(H) entropy(S)
PLOTS OF CO2



specific heats(cp) enthalpy(H) entropy(S)