Parsing NASA Thermodynamic Data
INTRODUCTION:-
Parsing - It is the process of syntactic analysis of the input code into its components, in order to facilitate the writing of compilers and interpreters. In other words, breakdown of the input code into small parts using set of rules so that it can be easily interpreted, managed and transmitted by a computer.
Compiler - Computer program that translates computer code written in one programming language into another language. Compiler term used primarily for programs that translates source code from a high-level programming language into another language to create an executable program.
Interpreter - Computer program that directly executes instructions written in a programming language without requiring them previously to have been compiled into machine language program.
File Parsing - Parsing a file means reading in some sort of data stream (\'.dat\' which means data file in our case) and building an in memory model (variables like coefficients, molecular weight of species in our case) of the semantic content (which gives meaining of the data) of that data. File parsing facilitates performing some kind of transformation on the data. In simple words, file parsing means splitting a large data chunk into small data blocks/pieces, so that the data can be easily stored or manipulated.
In our case, we have a file from NASA, containing thermodynamic data like high and low temperature coefficients, global temperatures, local temperatures for each species and species name, which needs to be parsed.
AIM:- The aim of this project is to write a MATLAB/OCTAVE for performing parsing of NASA Thermodynamic Data File and calculation of thermodynamic properties of each species.
OBJECTIVES:-
a) Extraction of all 14 coefficients for all the given species from the given file by writing a function.
b) Calculation of specific heat(Cp), enthalpy(H) and entropy(S) for the local temperature range by writing a function.
c) Calculation of molecular weight of species by writing a function.
d) Plotting the specific heat(Cp), enthalpy(H) and entropy(S) for the local temperature range by writing a function.
PROCEDURE :-
1. Code to write function for obtaining low and high temperature coefficients:-
Description -
i) Definition of function which says \'coefficients\' is the function name and the variables having datatype string, str1, str2, str3 are passed as input arguments and high and low temperature coefficients i.e ah1, ah2, ah3, ah4, ah5, ah6, ah7 and al1, al2, al3, al4, al5, al6, al7 respectively both are obtained as output arguments.
ii) Using the command find string i.e \'findstr\' location/position of exponential symbol E in the first string i.e \'str1\' is stored in the variable \'n1\'.
iii) After storing the position of symbol E, the characters from start to the position of E and three characters after E are stored in the variable which is the value of first coefficient.
iv) Then the value of second coefficient is obtained by storing the characters start from the fourth character after the positionof first symbol E upto the position of second E and three characters after the position of second E are stored in the variable which gives the value of second coefficient.
v) This similar process is repeated to obtain all other remaining coefficients from the string 1 i.e str1.
vi) As the variables i.e coefficients are in the form of string, these are converted to numeric value using \'str2num\' command.
vii) Similarly, the other coefficients are extracted from second and third strings i.e \'str2\' and \'str3\' respectively by identifying the location of coefficients.
viii) After identifying the coefficients having numeric value are given as output arguments.
ix) Finally, the function \'coefficients\' is terminated by using the command \'end\'.
%Function to obtain the values of coefficients
function [ah1, ah2, ah3, ah4, ah5, ah6, ah7, al1, al2, al3, al4, al5, al6, al7] = coefficients(str1, str2, str3)
%Coefficients in line 1 i.e str1
%Identifying the location of exponential symbol E
n1 = findstr(str1, \'E\');
%Variables to stores the coefficients in line 1 i.e str1 in the form of string
a1 = str1(1:n1(1)+3);
a2 = str1(n1(1)+4:n1(2)+3);
a3 = str1(n1(2)+4:n1(3)+3);
a4 = str1(n1(3)+4:n1(4)+3);
a5 = str1(n1(4)+4:n1(5)+3);
%Conversion of string to number
ah1 = str2num(a1);
ah2 = str2num(a2);
ah3 = str2num(a3);
ah4 = str2num(a4);
ah5 = str2num(a5);
%Coefficients in line 2 i.e str2
%Identifying the location of exponential symbol E
n2 = findstr(str2, \'E\');
%Variables to stores the coefficients in line 2 i.e str2 in the form of string
a6 = str2(1:n2(1)+3);
a7 = str2(n2(1)+4:n2(2)+3);
a8 = str2(n2(2)+4:n2(3)+3);
a9 = str2(n2(3)+4:n2(4)+3);
a10 = str2(n2(4)+4:n2(5)+3);
%Conversion of string to number
ah6 = str2num(a6);
ah7 = str2num(a7);
al1 = str2num(a8);
al2 = str2num(a9);
al3 = str2num(a10);
%Coefficients in line 3 i.e str3
%Identifying the location of exponential symbol E
n3 = findstr(str3, \'E\');
%Variables to stores the coefficients in line 3 i.e str3 in the form of string
a11 = str3(1:n3(1)+3);
a12 = str3(n3(1)+4:n3(2)+3);
a13 = str3(n3(2)+4:n3(3)+3);
a14 = str3(n3(3)+4:n3(4)+3);
%Conversion of string to number
al4 = str2num(a11);
al5 = str2num(a12);
al6 = str2num(a13);
al7 = str2num(a14);
end
2. Code to write a function for calculating the values of specific heat, enthalpy and entropy for all species:-
Description -
i) Definition of function which says \'thermo_func\' is the function name, the variables i.e high and low temperature coefficients i.e ah1, ah2, ah3, ah4, ah5, ah6, ah7 and al1, al2, al3, al4, al5, al6, al7, R(Universal Gas Constant), T(array of local temp range) and Local_mid_temp(local mid temperature) respectively are passed as input arguments and values of Cp(specific heat), H(enthalpy) and S(entropy) are obtained as output argument.
ii) Condition saying that if T(array of local temperature range) is less than or equal to Local_mid_temp(local mid temperature) then Cp, H and S are calculated using low temperature coefficients and else[i.e T(array of local temperature range) greater than Local_mid_temp(local mid temperature)] then Cp, H and S are calculated using high temperature coefficients.
iii) Finally, the function \'thermo_func\' is terminated by using the command \'end\'.
%Function to calculate Cp, H and S
function [Cp, H, S] = thermo_func(ah1, ah2, ah3, ah4, ah5, ah6, ah7, al1, al2, al3, al4, al5, al6, al7, R, T, Local_mid_temp)
if T <= Local_mid_temp
Cp = R.*(al1 + al2.*T + al3.*(T.^2) + al4.*(T.^3) + al5.*(T.^4));
H = R.*T.*(al1 + al2.*T./2 + al3.*(T.^2)./3 + al4.*(T.^3)./4 + al5.*(T.^4)./5 + al6./T);
S = R.*(al1.*log(T) + al2.*T + al3.*(T.^2)./2 + al4.*(T.^3)./3 + al5.*(T.^4)./4 + al7);
else
Cp = R.*(ah1 + ah2.*T + ah3.*(T.^2) + ah4.*(T.^3) + ah5.*(T.^4));
H = R.*T.*(ah1 + ah2.*T./2 + ah3.*(T.^2)./3 + ah4.*(T.^3)./4 + ah5.*(T.^4)./5 + ah6./T);
S = R.*(ah1.*log(T) + ah2.*T + ah3.*(T.^2)./2 + ah4.*(T.^3)./3 + ah5.*(T.^4)./4 + ah7);
end
3. Code to write a function for calculating the molecular weight of each species:-
Description -
i) Definition of function which says \'molecular_weight\' is the function name, the variable (a character array) \'species_name\' which is used to store the name of the species is passed as input arguments and values of variable \'M\' i.e molecular weight is obtained as output argument.
ii) An array, more specifically cell array, named as \'Elements\' having 1 row and 5 columns consisting of basic individual elements H(Hydrogen), C(Carbon), N(Nitrogen), O(Oxygen) and Argon(AR) is created and also one more array named as \'Atomic_Weight\' with atomic weights of Hydrogen, Carbon, Nitrogen, Oxygen and Argon having as its elements is created and initially the value of variable \'M\' is defined as zero.
iii) Further, two for loops are used. Primary for loop in which the counter variable \'i\' varying from 1 to length(species_name) i.e 53 is used for calulating molecular weight of all species in the Nasa file. Secondary for loop in which the counter variable \'j\' varying from 1 to length(Atomic_Weight) i.e 5 is used for calculating molecular weight \'M\' of each species by comparing two strings [which are \'species_name(i)\' i.e each element of the of the character array \'species_name\' and \'Elements(j)\' i.e each element of the array \'Elements\'] element wise using command \'strcmp\'. Also, for each iteration of secondary for loop the value of counter variable \'j\' is stored in the variable\'position\'. Then the secondary for loop is terminated by using the command \'end\'.
iv) Inside the primary loop, the secondary for loop is defined. After completion of all iterations of secondary for loop, if there is repitition of atoms of any element then the command \'str2num\' is used to identify that and the value of the operation is stored in the variable \'number_of_atom\' and then the (number_of_atom - 1) is multilplied with the atomic weight of corresponding element and added to the value of variable \'M\'. After that the primary for loop is terminated by using the command \'end\'.
v) Finally, the function \'molecular_weight\' is terminated by using the command \'end\'.
%Function to calculate the molecular weight of the species
function [M] = molecular_weight(species_name)
Elements = {\'H\' \'C\' \'N\' \'O\' \'A\'};
%Atomic weight of each element
Atomic_Weight = [1 12 14 16 40];
M = 0;
for i = 1:length(species_name)
for j = 1:length(Atomic_Weight)
%Comparing the input elements with defined elements
if (strcmp(species_name(i), Elements(j)) == 1)
M = M + Atomic_Weight(j);
%Storing the position of matched elements
position = j;
end
end
%Adding weight of elements having more than one atom in the species
number_of_atom = str2num(species_name(i));
if number_of_atom > 1
M = M + ((Atomic_Weight(position)).*(number_of_atom - 1));
end
end
end
4. Code to write a function for writing a values of molecular weights of all species to a new file \'Molecular Weight.txt\':-
Description -
i) Definition of function which says \'writing_to_file\' is the function name, the variables (a character array) \'species_name\' which is used to store the name of the species and \'Weight\' i.e molecular weight of each species are passed as input arguments.
ii) \'Molecular_Weight.dat\' named data file is opened using the command \'fopen\' and that too in appended mode (by writing \'a+\') so that every new line can be added at the end and there is no overwriting which ensures that molecular weights of all species is printed in the file. Using the command \'fprintf\' molecular weight of each species is printed in the file. The file is closed y using \'fclose\' command.
iii) Finally, the function \'writing_to_file\' is terminated by using the command \'end\'.
%Program to write molecular weight to the file
function writing_to_file(Species_Name, Weight)
weight_file = fopen(\'Molecular Weight.txt\', \'a+\');
fprintf(weight_file, \'Molecular Weight of the species %s is %d \\n\', Species_Name, Weight);
fclose(weight_file);
end
5. Code to write a function for plotting Cp (specific heat), H(enthalpy) and S(entropy) for the local temperature range and saving the plots as images:-
Description -
i) Definition of function which says \'plotting\' is the function name, the variables Cp(specific heat), H(enthalpy), S(entropy), local_temp_range(local temperature range) and Species_Name(a character array containing name of species) are passed as input arguments.
ii) A new folder (named as Cp, H and S Plots) is creted first manually by the coder and then the diectory address is stored in the variable \'dir_name_initial\'. Then using the command \'cd\' the directory of MATLAB is changed to new folder. i.e Cp, H and S Plots.
iii) A new variable \'dir_name_main\' is defined and \'Species_Name\' i.e name of the species is stored in it. A new folder is created in the current directory of MATLAB that was created in the above step i.e Cp, H and S Plots named folder using the command \'mkdir\'. Then the current directory is changed to to new folder.
iv) Using \'plot\' command a plot of Cp(specific heat) versus local_temp_range(local temperature range), which is titled using \'title\' command. X and Y axes are labbeled using the commands \'xlabel\' and \'ylabel\' respectively.
v) Similarly plots of H(enthalpy) versus local_temp_range(local temperature range) and S(entropy) versus local_temp_range(local temperature range) are created and labelled.
vi) Further, using \'saveas\' command and syntax saveas(fig, filename, format) all three plots are saved as images in the required format.
vii) Then a new variable \'old_folder\' is defined which stores the directory address of initial folder (named as Project- File of Parsing of NASA Thermodynamic Data) which contains the main program and all other functions and command \'cd\' is used to change the directory to a old folder.
viii) Finally, the function \'plotting\' is terminated by using the command \'end\'.
%Program to save the plots as images into required directory/folder
function plotting(Cp, H, S, local_temp_range, Species_Name)
%Defining initial folder name
dir_name_initial = \'E:\\Skill-Lync MATLAB and Python Course\\MATLAB\\MATLAB_Programming\\Challenges\\Project - File Parsing of NASA Thermodynamic Data\\Cp, H and S Plots\';
%Changes current directory to new folder
cd(dir_name_initial)
%Defining main folder name
dir_name_main = Species_Name;
%Creates a new folder in the current directory
mkdir(dir_name_main)
%Changes current directory to new folder
cd(dir_name_main)
%Plotting Specific Heat vs Local Temperature Range
figure(1)
plot(local_temp_range, Cp, \'color\', \'r\', \'linewidth\', 2)
title(\'Specific Heat vs Local Temperature Range\')
xlabel(\'Local Temperature Range [K]\')
ylabel(\'Specific Heat [kJ]\')
%Plotting Enthalpy vs Local Temperature Range
figure(2)
plot(local_temp_range, H, \'color\', \'b\', \'linewidth\', 2)
title(\'Enthalpy vs Local Temperature Range\')
xlabel(\'Local Temperature Range [K]\')
ylabel(\'Enthalpy [kJ/mol]\')
%Plotting Entropy vs Local Temperature Range
figure(3)
plot(local_temp_range, S, \'color\', \'y\', \'linewidth\', 2)
title(\'Entropy vs Local Temperature Range\')
xlabel(\'Local Temperature Range [K]\')
ylabel(\'Entropy [kJ/mol-K]\')
%Saving the plot as images (PNG form)
saveas(figure(1), \'Plot of Specific Heat vs Local Temperature Range.png\')
saveas(figure(2), \'Plot of Enthalpy vs Local Temperature Range.png\')
saveas(figure(3), \'Plot of Entropy vs Local Temperature Range.png\')
old_folder = \'E:\\Skill-Lync MATLAB and Python Course\\MATLAB\\MATLAB_Programming\\Challenges\\Project - File Parsing of NASA Thermodynamic Data\';
cd(old_folder);
end
6. Code to write a main program for parsing nasa thermodynamic data file:-
Description -
i) Basic commands are used to clear the command window and workspace ad close the plots or figures.
ii) A variable \'nasa\' is used to the value of operation of opening already existing file \'Thermo.dat\'. The file is opened with the type of access defined by the permission i.e \'r\' which means the file can be read.
iii) The data is read using \'textscan\' command and stored in the variable \'x\'. The total number of rows in the file is obtained by using the \'length\' command and passing variable \'x\' as the input and the value is stored in the variable \'Total_number_of_rows\'. After that the file is close and opened again.
iv) By using the \'fgetl\' command and passing the variable \'nasa\' the file can be read line by line. using the same command the first line of the header of the file is read.
v) Similarly, the second line of the header is read and stores as a string in the variable \'second_line\'. Using \'strsplit\' command, the string is splitted by passing string and using space as a delimiter and the the values stored in the form of cell array in the variable \'A\'. After this using the command \'str2num\' the strings i.e elements of the cell array \'A\' are converted into numeric values and stored in the variables as global temperatures.
vi) The next three lines of the header of the file are eliminated.
vii) Value of Universal Gas Constant is stored in the variable \'R\'.
viii) Total number of species are calculated by using a logic that number of extra lines like header lines, end line and blank lines in the file which is equal to 10 is subtracted from the total number of rows and then the the resulting value is divided by 4 as in remaining lines every speicies has data in 4 lines.
ix) Then the for loop is defined with counter variable \'i\' which varies from 1 to Total number of species i.e 53 to calculate the values like high and low temperature coefficients, Cp(specific heat), H(enthalpy), S(entropy) and molecular weight and writing the molecular weight of all species into a new file and creating plots for all species.
x) Inside the for loop, the line after the last line of header is read using \'fgetl\' command and is stored in the form of character array in the variable \'Line\'. The string is then splitted using \'strsplit\' command and the resulting cell array \'s\' iis obtained and the first element of the string is stored in the variable \'Species_Name\' in the form of character array, which gives the name of the species. Then using \'length\' command the value of number of columns is stored in the variable \'e\'.
xi) After that, values of lowest, middle and highest value of local temperatures are obtained by extracting the elements from the cell array \'s\' and then converting them to numeric values using \'str2num\' command and stored in the variables.
xii) A \'local_temp_range\' named array of size 1x500 is created by using \'linspace\' command and passing lowest and highest value of local temperatures as input arguments.
xiii) The next three lines are read using \'fgetl\' command and stored as character arrays in the variables \'str1\', \'str2\' and \'str3\'.
xiv) After that, values of high and low temperature coefficients are obtained by calling a function named as \'coefficients\'.
xv) Molecular weight is calulated for all species by calling a function named as \'molecular_weight\' and then written into a file \'Molecular_Weight.dat\' by calling a function named as \'writing_to_file\'.
xvi) The plots of Cp(specific heat), H(enthalpy) and S(entropy) are obtained and saved as images and dumped in seperate folders with suitable names by calling a function named as \'plotting\'.
xvii) Then the for loop is terminated by using the command \'end\'.
xviii) At last, finally, the file \'Thermo.dat\' is closed by using the command \'fclose\'.
%Program to parse the NASA thermodynamic data file
clear all
close all
clc
%Opening the nasa thermodynamic data file
nasa = fopen(\'THERMO.dat\', \'r\')
x = textscan(nasa, \'%s\', \'delimiter\', \'\\n\');
%Number of rows in the file
Total_number_of_rows = length(x{1});
fclose(nasa)
%Opening the file again
nasa = fopen(\'THERMO.dat\', \'r\')
%Reading the first line of the file
first_line = fgetl(nasa);
%Reading second line and obtaining the global temperature variables
second_line = fgetl(nasa);
A = strsplit(second_line, \' \');
Global_low_temp = str2num(A{1})
Global_mid_temp = str2num(A{2})
Global_high_temp = str2num(A{3})
%Neglecting the comments
for i = 1:3
fgetl(nasa);
end
%Value of Universal Gas Constant J/(mol*K)
R = 8.31451;
%calculating the total no of species by dividing by 4 the value equal to
%the no of rows minus extra lines i.e
%lines like header lines and the end line and the line with blank
%spaces from the total no of rows (i.e subtracting 10 lines from the total no of
%rows as values of total number of rows is equal to 222 which includes
%6 lines i.e 5 header lines and one end line and 4 lines with no data)
Total_number_of_species = (Total_number_of_rows - 10)/4;
%Defining the loop
for i = 1:Total_number_of_species
%Reading the line having defining the species name
Line = fgetl(nasa);
%Species name
s = strsplit(Line);
Species_Name = s{1};
%Determination of no of columns in array s
e = length(s);
%Extracting local temperatures
Local_low_temp = str2num(s{e-3});
Local_high_temp = str2num(s{e-2});
Local_mid_temp = str2num(s{e-1});
%Defining Local Temperature Range
local_temp_range = linspace(Local_low_temp, Local_high_temp, 500);
%Reading the lines for obtaining the value of 7 high and 7 low temperature coefficients
str1 = fgetl(nasa);
str2 = fgetl(nasa);
str3 = fgetl(nasa);
%Obtaining the values of coefficients using function named as coefficient
[ah1, ah2, ah3, ah4, ah5, ah6, ah7, al1, al2, al3, al4, al5, al6, al7] = coefficients(str1, str2, str3);
%Function to calculate Cp, H and S
[Cp, H, S] = thermo_func(ah1, ah2, ah3, ah4, ah5, ah6, ah7, al1, al2, al3, al4, al5, al6, al7, R, local_temp_range, Local_mid_temp);
%Calculating Molecular Weight using function named as molecular_weight
Weight = molecular_weight(Species_Name);
Molecular_Weight = sprintf(\'Molecular Weight of the species name %s is %d\', Species_Name, Weight)
%Writing molecular weight of an element to the file
writing_to_file(Species_Name, Weight)
%Plotting of Cp vs local_temp_range plot, H vs local_temp_range plot
%and S vs local_temp_range plot
plotting(Cp, H, S, local_temp_range, Species_Name)
end
fclose(nasa)
Errors Encountered:-
1. Error 1 - Error due to use of invalid input argument in strsplit command
Description - Error occured because the first cell array i.e \'x\' was created by opening the data file and using \'textscan\' command and the data-type stored in it was \'integer\' and then \'strsplit\' command was used to generate a new cell array i.e \'A\' which should store the data in the form of \'character\' but from the start the data type that was being stored in cell array was integer type, which was considered as invalid data-type for \'strsplit\' command.
Step Taken - The file was opened and read to generate the cell array having \'integer\' data-type to find the total no of rows once and then closed. Once again the file was opened to generate a cell array with \'char\' data-type while using \'strsplit\' command.
2. Error 2 - Error due to not using the command \'cd\' at the end of \'plotting\' function to change the directory as the initial directory containing main program and all functions was changed to new one at start of the function, which didn\'t contain the main program and other functions like \'coefficients\' which are called for every iteration.
Description - Error occured because in the program for \'plotting\' named function the directory was changed to new folder \'species_name\' which remained same after first iteration of for loop in the main program also and then for the next iteration directory remained same i.e \'species_name\' i.e \'O\' which didn\'t contain the function \'coefficients\'.
Step Taken - This error was encountered by using a new variable name \'old_folder\' and changing the directory using command \'cd\' and passing variable \'ol_folder\' as an input argument.
OUTPUT OF THE CODE:-
1. High temperature and low temperature coefficients are obtained for each species after calling the function \'coefficients\' in the main program.
Logic used to obtain the particular output- The thermodynamic data file contains 14 coefficients and first seven are high temperature coefficients and next seven are low temperature coefficients. So, in order to extract all the coefficients the file is read line by line and then after reading the line, it is stored in a variable in the form of character array/string. Further,the location of exponential symbol \'E\' is identified in line and as we know that the characters before \'E\' and after \'E\' forms the coeficients, the characters upto before the position of \'E\' from the start and the three characters after the position of \'E\' are stored in one variable which gives coefficients. Similarly, all other remaining coefficients are obtained.
2. Thermodynamic properties like specific heat (Cp), enthalpy (H) and entropy (S) are obtained after calling the function \'thermo_func\'.
Logic used to obtain the particular output - The formulae for calculating the values of specific heat, enthalpy and entropy are given. But, the main thing is to obtain the condition that when the high temperature coefficients needs to be used and when the low temperature coefficients needs to be used. If the values of local temperature is less than the middle value of local temperature, then low temperature coefficients are used, otherwise high temperature coefficients are used for calculating the values of specific heat, enthalpy and entropy.
3. Molecular weight of each species is obtained after calling the function \'molecular_weight\'.
Logic - When the molecular weight of any species needs to be calculated, then its necessary to add the atomic weight of each element which the species consists of. Also, if any elements has more than one atom, then the atomic weight of that particular element should be multiplied by the no of atoms and thyen the resulting value should be added to the sum of atomic weight of the remaining elements. So, the program was written based on this logic.
4. \'Molecular Weight\' named text file with \'.txt\' is created by writing a function \'writing_to_file\' and after calling it in the main program.
Logic used to obtain the particular output - A text file is created and data is written into it in a way, so, that molecular weight of all species is written into the file (basically by opening the file in appended mode) without any overwriting.
5. Plots of Cp(specific heat), H(enthalpy) and S(entropy) for the local temperature range are obtained for all species and in the form of an image which is stored in the different folder named as species name for the particular species.
Logic used to obtain the particular output - According to the requirement the plot needs to be saved in the form of an image and that also in seperate folder for each species. So, firstly, a new folder needs to be created and then the directory of MATLAB needs to be changed to that folder. Inside the new directory, again a new folder with name as of species like O or O2 or N2 needs to be created and then the directory again needs to be changed to this species named folder so that the plots in the image form are saved in the particular folder. After creation and saving of the plots, in the particular folder, the directory needs to be changed to the initial one which contains the main program and all other functions, so that the program can be ran for next iteration successfully w/o any error.
Plots for O2 :-
Plots for N2 :-
Plots for CO2 :-
Conclusion from the particular output :- In general, for all species, specific heat, enthalpy and entropy varies directly with local temperature i.e as temperature increases, the specific heat, enthalpy and entropy all increases. Also, for any species within the data file, all three plots are obtained.
Screenshot of location of the folder which consists of individual folder contain images of plots:-
Logic of the main program - The program is used to obtain the coefficients, values of specific heat (Cp), enthalpy (H) and entropy (S), plots of Cp, H and S for local temperature range and molecular weight. These values are calculated for all species by running the for loop for the number of times equal to total number of species which is calculated by obtaining total no of rows in the file and then subtracting the extra number of rows fromtotal no of rows. Further, local temperature range array is obtained for each species by reading the lines (i.e by doing file parsing) from the data file \'Thermo.dat\' and saving the lower and higher local temperature values and then diving the the difference between lower and higher local temperature into 500 values. Finally, the values of thermodynamic properties and molecular weight are calculated and plots are are obtained for all species by calling the functions (written seperately and individually) respectively.
https://drive.google.com/folderview?id=1io8y0MOQTG0eAqxXJEdiNUMB6qgjVPbA
The above link contains the folder having images of command window displaying molecular weight of all species, the text file having molecular weight of each species and the folder having images of plots of Cp, H and S for the local temperature range for all species.
FINAL CONCLUSION :-
The complete challenge was about file parsing. Firstlty, from the data file \'Thermo.dat\', the data(global temperatures) from header lines was read line by line using \'fgetl\' command. Further, manipulation like transformation was performed on the data like splitting the obtained string using \'strsplit\' command was done in this challenge and then the data was stored in . Similarly, local temperatures were also obtained and local temperature range was obtained by using \'linspace\' command. Another manipulation i.e finding the particular string(like exponential symbol \'E\') in the data obtained after reading the lines of the data file and storing the data resulting from the operation, high and low temperature coefficients were extracted from the file. Using the local temperature range and high and low temperature coefficients, further calculations were done to obtain the values of thermodynamic properties like specific heat (Cp), enthalpy (H) and entropy (S). Similarly, molecular weight was also calculated using the data obtained from file parsing. Plots of Cp, H and S were also obtained by using the data resulting from file parsing i.e values of thermodynamic properties like specific heat (Cp), enthalpy (H) and entropy (S) and local temperature range. Finally, overall challenge was completed with the aid of file parsing process.