Parsing of the NASA Thermodynamic Data file
The NASA thermodynamic data file is a collection of various coefficient values for thermodynamic equations defined for 53 different chemical species. The thermodynamic equations are given by:
Cp/R = a1 + a2 T + a3 T^2 + a4 T^3 + a5 T^4
H/RT = a1 + a2 T /2 + a3 T^2 /3 + a4 T^3 /4 + a5 T^4 /5 + a6/T
S/R = a1 lnT + a2 T + a3 T^2 /2 + a4 T^3 /3 + a5 T^4 /4 + a7
The H in the above equations denotes the enthalpy difference of formation at a particular temperature T. It is convinient to combine sensible enthalpies and energies of chemical and physical changes into one numerical value. An arbritary base (H(298) = deltaH(298) = 0) is adopted for assigning absolute values to the enthalpies of various substances inasmuch as only differences in enthalpies are measurable.
The thermodynamic equations are basically 3 equations, all of them establishing some thermodynamic property as a function of the temperature.
The first equation establishes the specific heat of the species, the second establishes the enthalpy of formation and the third establishes the entropy of the species as functions of temperature.
The values of the 7 coefficients (a1,a2,a3,a4,a5,a6,a7) are derived with the help of least squared error method, a type of linear regression/curve fitting. Experimental data for the thermodynamic properties are taken with respect to variation in temperature and curve fitting is carried out. The coefficient values for which the sum of squared errors (SSE) comes out as minimum are taken.
The thermodynamic data file is arranged in the following manner:
HEADER BLOCK
THERMO
global temperature lower bound global temperature intermediate global temperature upper bound
COMMENT (start with !)
COMMENT (start with !)
COMMENT (start with !)
SPECIES BLOCK
Specie chemical formula_____ _____ _________ Tl Ti Th 1
a1 a2 a3 a4 a5 2
a6 a7 a8 a9 a10 3
a11 a12 a13 a14 4
Each specie block has the format as shown above and there are a total of 53 specie blocks for 53 species. Coefficients a1 to a7 (the first seven) are for the higher temperature zone. The zone between the intermediate local temperature and the upper bound of local temperature is called the higher temperature zone. The rest of the 7 coefficients (a8 to a14) are for the lower temperature zone (betweem local temperature lower bound and the intermediate local temperature).
To parse the file, we will be using the fopen command in MATLAB. The file is saved locally as 'THERMO.dat' as a dat file.
1). Header block:
%parsing the header file
f1 = fopen('THERMO.dat','r');
%getting the heading THERMO from the file
heading = fgetl(f1)
raw_global_temp_data = fgetl(f1)%the numbers 300,1000 and 5000 are stored as characters in A2 string
%splitting the string
%after splitting, the string converts into a cell matrix
global_temp_cell_mat = strsplit(raw_global_temp_data,' ')%global_temp_cell_mat is a cell matrix now
%converting the numbers from character to numerical values
%converting the cell elements to character strings by putting {}
global_low_temp = str2num(global_temp_cell_mat{1})
global_mid_temp = str2num(global_temp_cell_mat{2})
global_high_temp = str2num(global_temp_cell_mat{3})
%we will not be closing the file f1 as of now as we still need to read
To get the global temperature values, the fgetl command is used which reads the line into MATLAB in the form of a string. Since we want to allot those values to individual variables, the string is split up using the strsplit command which makes a cell array (global_temp_cell_mat) containing the strings '300', '1000' and '5000'. Using the str2num command to convert the string elements into numerical values, we can store the golbal temperatures in individual varaibles.
The next three lines are comments which hold no special significance. In order to start parsing the species blocks, we first need to parse the three comments.
Parsing the 3 line comments from the file:
%parsing the first 3 line comments
fgetl(f1);%1st line comment in file
fgetl(f1);%2nd line comment in file
fgetl(f1);%3rd line comment in file
2). Species Block:
There are a total of 53 of species blocks in the original file and all of them are parsed into MATLAB using fgetl in a loop of 212 iterations (since there are a total of 212 lines when all the species blocks are combined).
%extracting all the specie data into a cell matrix 'line'
for i=1:212
line{i} = fgetl(f1);
end
%converting row cell matrix to column cell matrix
line = line';
All the lines parsed are stored in a 1x212 cell array with each line as an individual string of the cell array. The cell array is arranged as a column matrix.
Since we will be inputing the formula of the species from the user, the lines containing the species header (containing the name of the species) need to be weeded out from the above 212 lines. The species headers are at every 4th position starting from the first header (O) at #1. Thus, all the positions which form an arithmetic progression with a common difference of 4 starting from #1 are the species header positions. A seperate cell array (species_num) is formed with all the species header lines as string elements.
%creating a cell matrix which stores all the specie names and local temp ranges
%all such lines are at poistions which are in AP of common difference 4
for j = 1:53
species_num{j} = line{4*j-3};
end
%converting row cell matrix into column
species_num = species_num';
Since the species header lines contain not only the species formula, but also the local temperature data and other species exclusive data, we need to again split the individual strings. A cell array (b) containing multiple cell arrays is formed.
%splitting each character element of the species_num string
%since we are splitting each character element instead of the whole string
%we will get a cell matrix containing 53 cell matrices
%each cell matrix will have the split elements of the individual characters
for k = 1:53
b{k} = strsplit(species_num{k},' ');
end
%converting row cell matrix into column cell matrix
b = b';
The image below shows the string elements in the individual cell array elements of the cell array 'b'.
When the user inputs the chemical formula of the species, we need to compare the input string of characters with the first string of each cell array of 'b' (b{1,1}{1,1} in the above image).
%user to input the species for which the coeffs are to be calculated
prompt = 'WHAT SPECIES?'
species = input(prompt,'s')%species is the string holding whatever characters the user inputs
species = upper(species);
%deriving the serial number of the specie the user has input
%comparing the comparing the characters in the string 'species'(input by user) and the first character of each cell matrix
%if the character in 'species' and the first character element of the cell
%matrix match then spec_input stores the value of that serial number
for m = 1:53
if strcmp(species,b{m,1}{1,1})%comparing the two strings species and b{m,1}{1,1}
spec_input = m; %if both are same, then strcmp returns TRUE (1 in boolean) and the conditional statement works
end
end
%translating the value of spec_input to the serial number of the species in
%the original file
L = 4*spec_input - 3;
The strcmp command is used to compare the input string and the first string element of each cell array. If both the strings match, the conditional statement gets executed and we will get the serial number of the species the user wants in the 'b' cell matrix.
Note: The input species formula is case insensitive as the species input by the user gets converted to all caps by using the upper(str) command.
Since, we have to read the lines from the original file, thus we need to convert the serial number of the species in the cell matrix 'b' to the serial number in the cell matrix 'line'. Since each element of b (or each species header) occurs in an arithmetic progression in the original file, we can get the serial number of the input speicies by the following conversion: L = 4*spec_input - 3 , where L is the serial number of the input species header in the original file and spec_input is the serial number of the input species header in the cell matrix containing only the species headers.
The parsing of the coefficients will happen in the following way:
L: Species Formula Speicies exclusive data 1
L+1: Coefficients a1 a2 a3 a4 a5 2
L+2: Coefficients a6 a7 a8 a9 a10 3
L+3: Coefficients a11 a12 a13 a14 4
To parse the first 5 coefficients, we need to go to the (L+1)th string of the cell matrix 'line'. For the next 5, (L+2)th and for the last 4, (L+3)th.
Since in each string, all the coefficients are together, they are split into different numbers using the position of the exponential element ('E'). All the coefficients start from the 4th position from the previous E position and end on the 3rd position from the next E position.
After demarketing the coefficients into different strings, we need to convert them into numerical values and store them as coefficients.
The same procedure is carried out for the next two lines.
%for any species at serial number L in the original file
%locating the postion of each exponential element in first string 'line'
e_pos = findstr(line{L+1},'E');
%grouping the strings according to the different coefficient values and alloting them to variables
a1 = line{L+1}(1:e_pos(1)+3);
%converting the grouped strings into numerical values which are the coefficient
coeffs(1) = str2num(a1);
%repeating this process for each grouped string in the line
a2 = line{L+1}(e_pos(1)+4:e_pos(2)+3);
coeffs(2) = str2num(a2);
a3 = line{L+1}(e_pos(2)+4:e_pos(3)+3);
coeffs(3) = str2num(a3);
a4 = line{L+1}(e_pos(3)+4:e_pos(4)+3);
coeffs(4) = str2num(a4);
a5 = line{L+1}(e_pos(4)+4:e_pos(5)+3);
coeffs(5) = str2num(a5);
%transferring to the next line/string of cell matrix 'line'
%repeating the same procedure
e_pos = findstr(line{L+2},'E');
a6 = line{L+2}(1:e_pos(1)+3);
coeffs(6) = str2num(a6);
a7 = line{L+2}(e_pos(1)+4:e_pos(2)+3);
coeffs(7) = str2num(a7);
a8 = line{L+2}(e_pos(2)+4:e_pos(3)+3);
coeffs(8) = str2num(a8);
a9 = line{L+2}(e_pos(3)+4:e_pos(4)+3);
coeffs(9) = str2num(a9);
a10 = line{L+2}(e_pos(4)+4:e_pos(5)+3);
coeffs(10) = str2num(a10);
%transferring to the last line of the species
%repeating the same procedure
e_pos = findstr(line{L+3},'E');
a11 = line{L+3}(1:e_pos(1)+3);
coeffs(11) = str2num(a11);
a12 = line{L+3}(e_pos(1)+4:e_pos(2 )+3);
coeffs(12) = str2num(a12);
a13 = line{L+3}(e_pos(2)+4:e_pos(3)+3);
coeffs(13) = str2num(a13);
a14 = line{L+3}(e_pos(3)+4:e_pos(4)+3);
coeffs(14) = str2num(a14);
Now we need the local temperature values exclusive to a particular species. In the cell array 'b', there exist different cell matrices of different sizes, varying from 1x8 to 1x12. For each case, the location of the string specifying the lower, intermediate and upper local temperature bounds is noted. For each cell matrix size consideration, the strings containing the temperature values are converted into numerical values and are assigned to corresponding variables.
%extracting the temperature range of the species
%since the sizesof each cell matrix varies in b thus we have to accomodate
%the sizes in the cell matrix are 8/9/10/11/12
size_b = size(b{spec_input,1})
c = size_b(2)
if c == 8
low_temp = str2num(b{spec_input,1}{1,5}) %lower bound of temperature
int_temp = str2num(b{spec_input,1}{1,7}) %intermediate temperature below which is the lower temperature zone and above which is the higher temperature zone
high_temp = str2num(b{spec_input,1}{1,6}) %upper bound of temperature
elseif c == 9
low_temp = str2num(b{spec_input,1}{1,6})
int_temp = str2num(b{spec_input,1}{1,8})
high_temp =str2num(b{spec_input,1}{1,7})
elseif c == 10
low_temp = str2num(b{spec_input,1}{1,7})
int_temp = str2num(b{spec_input,1}{1,9})
high_temp = str2num(b{spec_input,1}{1,8})
elseif c==11
low_temp = str2num(b{spec_input,1}{1,8})
int_temp = str2num(b{spec_input,1}{1,10})
high_temp = str2num(b{spec_input,1}{1,9})
elseif c==12
low_temp = str2num(b{spec_input,1}{1,9})
int_temp = str2num(b{spec_input,1}{1,11})
high_temp = str2num(b{spec_input,1}{1,10})
end
The lower temperature zone is taken as an array of 10 temperature values starting from the lower bound temperature to the intermediate temperature and the higher temperature zone is taken as an array of 10 temperature values starting from the intermediate temperature to the upper bound temperature.
The 1x14 coefficient matrix which was obtained is split into 2 matrices. The first matrix containing the first 7 coefficients thus making it the higher temperature zone coefficient matrix, and the second matrix containin the last 7 coefficients, making it the lower temperature zone coefficient matrix.
%array containing 10 values in the lower tempearture zone
temperature_low = linspace(low_temp,int_temp,10);
%array contaning 10 vlues in the higher temperature zone
temperature_high = linspace(int_temp,high_temp,10);
%calculating the specific heat of the species
%universal gas constant in J/mol.K
r = 8.314;
%specific heat equation according to NASA polynomials
%first 7 obtained coeffcients are for high temperature zones
%last 7 obtained coefficients are for low temperature zones
coeffs_high = coeffs(1:7);
coeffs_low = coeffs(8:14);
The calculation of the thermodynamic propertiies is done according to the NASA polynomials.
Functions for the specific heat, entropy, enthalpy and molecular weight are formed.
Function for specific heat:
function [cp] = c_p_calculator(a1,a2,a3,a4,a5,T)
%universal gas constant in J/k.mol
r = 8.314
%NASA Polynomial equation for specific heat
cp = r*(a1 + a2.*T + a3.*(T.^2) + a4.*(T.^3) + a5.*(T.^4))
end
Function for enthalpy:
function [H] = enthalpy_calculator(a1,a2,a3,a4,a5,a6,T)
%universal gas constant in J/K.mol
r = 8.314;
%NASA Polynomial equation for enthalpy
H = r*(a1 + (a2/2).*(T) + (a3/3).*(T.^2) + (a4/4).*(T.^3) + (a5/5).*(T.^4) + a6./T).*T
end
Function for entropy:
function [S] = entropy_calculator(a1,a2,a3,a4,a5,a6,a7,T)
%universal gas constant in J/k.mol
r = 8.314
%NASA Polynomial equation for entropy
S = r*(a1.*log(T) + a2.*T + (a3/2).*(T.^2) + (a4/3).*(T.^3) + (a5/4).*(T.^4) + a7)
end
Function for molecular weight:
For the molecular weight, 2 cell matrices are taken, one containing all the possible alphapbet letters that can be part of the input species, and the second containing the possible numbers which can ne a part of the input speices. A number array is defined with the corresponding atomic weights.
Each character of the input species string is compared with the 'elements' cell matrix and if they match, the corresponding atomic weight is added to the variable representing the molecular weight.
The similar thing is done for the number characters in the input spicies in case of multiple atoms of a certain element.
function [molecular_weight] = molecular_weight_calculator(compound)
%creating a cell array containing all the probable elements as strings
%dissecting AR into 'A' and 'R' otherwise species element will never match
elements = {'C','N','O','H','A','R'};
%creating a numerical array containing the corresponding atomic weights
%weight for 'A' as 40 and for 'R' as 0 thus making net weight 40 for AR
atomic_weight = [12 14 16 1 40 0];
%creating a cell array containing all the probable numbers in input species
numbers = {'1','2','3','4','5','6','7','8'};
%taking the initial value of molecular weight variable as 0
mol_weight = 0;
for i=1:length(compound)
for j = 1:length(elements)
if strcmp(compound(i),elements{j}) %comparing the species individual characters and the cell matrix characters
mol_weight = mol_weight + atomic_weight(j);%adding on to the initial value of molecular weight
end
end
for k = 1:length(numbers)
if strcmp(compound(i),numbers{k})%checking if the species has any numerical elements inside it
for m = 1:length(elements)
%checking which element has multiple atoms (numerical
%element next to it)
if strcmp(compound(i-1),elements{m})%comparing the element just before the numerical element in the species and the cell matrix 'elements'
mol_weight = mol_weight + (str2num(numbers{k})-1)*atomic_weight(m);%if it has, the corresponding amount of additional molecular weight gets added
end
end
end
end
end
molecular_weight = mol_weight %gives the final molecular weight value
end
Using the above functions, the thermodynamic properties and the moelcular weights are calculated for the species which the user inputs.
%for low temperature zones+++00
c_p_low = c_p_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),temperature_low)
%for high temperature zones
c_p_high = c_p_calculator(coeffs_high(1),coeffs_high(2),coeffs_high(3),coeffs_high(4),coeffs_high(5),temperature_high)
%plotting specific heat against temperature values
figure(1)
hold on
plot(temperature_low,c_p_low,'-*','color','b')
plot(temperature_high,c_p_high,'-*','color','r')
xlabel('TEMPERATURE')
ylabel('SPECIFIC HEAT')
title('SPECIFIC HEAT v/s TEMPERATURE')
legend('LOW TEMPERATURE ZONE','HIGH TEMPERATURE ZONE')
%calculating enthalpy of the species
%for low temperature zones
enthalpy_low = enthalpy_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),coeffs_low(6),temperature_low)
%for high temperature zones
enthalpy_high = enthalpy_calculator(coeffs_high(1),coeffs_high(2),coeffs_high(3),coeffs_high(4),coeffs_high(5),coeffs_high(6),temperature_high)
%plotting enthalpies against temperatures
figure(2)
hold on
plot(temperature_low,enthalpy_low,'-*','color','b')
plot(temperature_high,enthalpy_high,'-*','color','r')
xlabel('TEMPERATURE')
ylabel('ENTHALPY')
title('ENTHALPY v/s TEMPERATURE')
legend('LOW TEMPERATURE ZONE','HIGH TEMPERATURE ZONE')
%calculating entropy of species
%for low temperature zones
entropy_low = entropy_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),coeffs_low(6),coeffs_low(7),temperature_low)
%for high temperature zones
entropy_high = entropy_calculator(coeffs_high(1),coeffs_high(2),coeffs_high(3),coeffs_high(4),coeffs_high(5),coeffs_high(6),coeffs_high(7),temperature_high)
%plotting entropy of species against temperture values
figure(3)
hold on
plot(temperature_low,entropy_low,'-*','color','b')
plot(temperature_high,entropy_high,'-*','color','r')
xlabel('TEMPERATURE')
ylabel('ENTROPY')
title('ENTROPY v/s TEMPERATURE')
legend('LOW TEMPERATURE ZONE','HIGH TEMPERATURE ZONE')
%calculating molecular weight of the species
molecular_weight = molecular_weight_calculator(species)
Taking the case of the species O2 (second species):
The molecular weight:
Specific Heat vs Temperature:
Enthalpy vs Temperature:
Entropy vs Temperature:
CO2:
Molecular Weight:
Specific Heat vs Temperature:
Enthalpy vs Temperature:
Entropy vs Temperature:
N2:
Molecular Weight:
Specific Heat vs Temperature:
Enthalpy vs Temperature:
Entropy vs Temperature:
The complete code with appropriate comments is given below:
clear all
close all
clc
%parsing the header file
f1 = fopen('THERMO.dat','r');
%getting the heading THERMO from the file
heading = fgetl(f1)
raw_global_temp_data = fgetl(f1)%the numbers 300,1000 and 5000 are stored as characters in A2 string
%splitting the string
%after splitting, the string converts into a cell matrix
global_temp_cell_mat = strsplit(raw_global_temp_data,' ')%global_temp_cell_mat is a cell matrix now
%converting the numbers from character to numerical values
%converting the cell elements to character strings by putting {}
global_low_temp = str2num(global_temp_cell_mat{1})
global_mid_temp = str2num(global_temp_cell_mat{2})
global_high_temp = str2num(global_temp_cell_mat{3})
%we will not be closing the file f1 as of now as we still need to read
%parsing the first 3 line comments
fgetl(f1);%1st line comment in file
fgetl(f1);%2nd line comment in file
fgetl(f1);%3rd line comment in file
%parsing coefficients from species block
%extracting all the specie data into a cell matrix 'line'
for i=1:212
line{i} = fgetl(f1);
end
%converting row cell matrix to column cell matrix
line = line';
%creating a cell matrix which stores all the specie names and local temp ranges
%all such lines are at poistions which are in AP of common difference 4
for j = 1:53
species_num{j} = line{4*j-3};
end
%converting row cell matrix into column
species_num = species_num';
%splitting each character element of the species_num string
%since we are splitting each character element instead of the whole string
%we will get a cell matrix containing 53 cell matrices
%each cell matrix will have the split elements of the individual characters
for k = 1:53
b{k} = strsplit(species_num{k},' ');
end
%converting row cell matrix into column cell matrix
b = b';
%the below code is if the user wants to input the serial number of the
%species from the original file
%prompt = 'WHAT IS THE SPECIES NUMBER?'
%spec_input = input(prompt)
%user to input the species for which the coeffs are to be calculated
prompt = 'WHAT SPECIES?'
species = input(prompt,'s')%species is the string holding whatever characters the user inputs
species = upper(species);
%deriving the serial number of the specie the user has input
%comparing the comparing the characters in the string 'species'(input by user) and the first character of each cell matrix
%if the character in 'species' and the first character element of the cell
%matrix match then spec_input stores the value of that serial number
for m = 1:53
if strcmp(species,b{m,1}{1,1})%comparing the two strings species and b{m,1}{1,1}
spec_input = m; %if both are same, then strcmp returns TRUE (1 in boolean) and the conditional statement works
end
end
%translating the value of spec_input to the serial number of the species in
%the original file
L = 4*spec_input - 3;
%for any species at serial number L in the original file
%locating the postion of each exponential element in first string 'line'
e_pos = findstr(line{L+1},'E');
%grouping the strings according to the different coefficient values and alloting them to variables
a1 = line{L+1}(1:e_pos(1)+3);
%converting the grouped strings into numerical values which are the coefficient
coeffs(1) = str2num(a1);
%repeating this process for each grouped string in the line
a2 = line{L+1}(e_pos(1)+4:e_pos(2)+3);
coeffs(2) = str2num(a2);
a3 = line{L+1}(e_pos(2)+4:e_pos(3)+3);
coeffs(3) = str2num(a3);
a4 = line{L+1}(e_pos(3)+4:e_pos(4)+3);
coeffs(4) = str2num(a4);
a5 = line{L+1}(e_pos(4)+4:e_pos(5)+3);
coeffs(5) = str2num(a5);
%transferring to the next line/string of cell matrix 'line'
%repeating the same procedure
e_pos = findstr(line{L+2},'E');
a6 = line{L+2}(1:e_pos(1)+3);
coeffs(6) = str2num(a6);
a7 = line{L+2}(e_pos(1)+4:e_pos(2)+3);
coeffs(7) = str2num(a7);
a8 = line{L+2}(e_pos(2)+4:e_pos(3)+3);
coeffs(8) = str2num(a8);
a9 = line{L+2}(e_pos(3)+4:e_pos(4)+3);
coeffs(9) = str2num(a9);
a10 = line{L+2}(e_pos(4)+4:e_pos(5)+3);
coeffs(10) = str2num(a10);
%transferring to the last line of the species
%repeating the same procedure
e_pos = findstr(line{L+3},'E');
a11 = line{L+3}(1:e_pos(1)+3);
coeffs(11) = str2num(a11);
a12 = line{L+3}(e_pos(1)+4:e_pos(2 )+3);
coeffs(12) = str2num(a12);
a13 = line{L+3}(e_pos(2)+4:e_pos(3)+3);
coeffs(13) = str2num(a13);
a14 = line{L+3}(e_pos(3)+4:e_pos(4)+3);
coeffs(14) = str2num(a14);
%extracting the temperature range of the species
%since the sizesof each cell matrix varies in b thus we have to accomodate
%the sizes in the cell matrix are 8/9/10/11/12
size_b = size(b{spec_input,1})
c = size_b(2)
if c == 8
low_temp = str2num(b{spec_input,1}{1,5}) %lower bound of temperature
int_temp = str2num(b{spec_input,1}{1,7}) %intermediate temperature below which is the lower temperature zone and above which is the higher temperature zone
high_temp = str2num(b{spec_input,1}{1,6}) %upper bound of temperature
elseif c == 9
low_temp = str2num(b{spec_input,1}{1,6})
int_temp = str2num(b{spec_input,1}{1,8})
high_temp =str2num(b{spec_input,1}{1,7})
elseif c == 10
low_temp = str2num(b{spec_input,1}{1,7})
int_temp = str2num(b{spec_input,1}{1,9})
high_temp = str2num(b{spec_input,1}{1,8})
elseif c==11
low_temp = str2num(b{spec_input,1}{1,8})
int_temp = str2num(b{spec_input,1}{1,10})
high_temp = str2num(b{spec_input,1}{1,9})
elseif c==12
low_temp = str2num(b{spec_input,1}{1,9})
int_temp = str2num(b{spec_input,1}{1,11})
high_temp = str2num(b{spec_input,1}{1,10})
end
%array containing 10 values in the lower tempearture zone
temperature_low = linspace(low_temp,int_temp,10);
%array contaning 10 vlues in the higher temperature zone
temperature_high = linspace(int_temp,high_temp,10);
%calculating the specific heat of the species
%universal gas constant in J/mol.K
r = 8.314;
%specific heat equation according to NASA polynomials
%first 7 obtained coeffcients are for high temperature zones
%last 7 obtained coefficients are for low temperature zones
coeffs_high = coeffs(1:7);
coeffs_low = coeffs(8:14);
%for low temperature zones+++00
c_p_low = c_p_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),temperature_low)
%for high temperature zones
c_p_high = c_p_calculator(coeffs_high(1),coeffs_high(2),coeffs_high(3),coeffs_high(4),coeffs_high(5),temperature_high)
%plotting specific heat against temperature values
figure(1)
hold on
plot(temperature_low,c_p_low,'-*','color','b')
plot(temperature_high,c_p_high,'-*','color','r')
xlabel('TEMPERATURE')
ylabel('SPECIFIC HEAT')
title('SPECIFIC HEAT v/s TEMPERATURE')
legend('LOW TEMPERATURE ZONE','HIGH TEMPERATURE ZONE')
%calculating enthalpy of the species
%for low temperature zones
enthalpy_low = enthalpy_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),coeffs_low(6),temperature_low)
%for high temperature zones
enthalpy_high = enthalpy_calculator(coeffs_high(1),coeffs_high(2),coeffs_high(3),coeffs_high(4),coeffs_high(5),coeffs_high(6),temperature_high)
%plotting enthalpies against temperatures
figure(2)
hold on
plot(temperature_low,enthalpy_low,'-*','color','b')
plot(temperature_high,enthalpy_high,'-*','color','r')
xlabel('TEMPERATURE')
ylabel('ENTHALPY')
title('ENTHALPY v/s TEMPERATURE')
legend('LOW TEMPERATURE ZONE','HIGH TEMPERATURE ZONE')
%calculating entropy of species
%for low temperature zones
entropy_low = entropy_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),coeffs_low(6),coeffs_low(7),temperature_low)
%for high temperature zones
entropy_high = entropy_calculator(coeffs_high(1),coeffs_high(2),coeffs_high(3),coeffs_high(4),coeffs_high(5),coeffs_high(6),coeffs_high(7),temperature_high)
%plotting entropy of species against temperture values
figure(3)
hold on
plot(temperature_low,entropy_low,'-*','color','b')
plot(temperature_high,entropy_high,'-*','color','r')
xlabel('TEMPERATURE')
ylabel('ENTROPY')
title('ENTROPY v/s TEMPERATURE')
legend('LOW TEMPERATURE ZONE','HIGH TEMPERATURE ZONE')
%calculating molecular weight of the species
molecular_weight = molecular_weight_calculator(species)
VERIFICATION OF DATA:
Enthalpy of formattion of CO2 at 298 K:
h298 = enthalpy_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),coeffs_low(6),298)
Output:
Entropy at 298K:
s298 = entropy_calculator(coeffs_low(1),coeffs_low(2),coeffs_low(3),coeffs_low(4),coeffs_low(5),coeffs_low(6),coeffs_low(7),298)
Output:
Official Thermodynamic Data:
In the above picture, the left most value is the enthalpy of formation at 298K and the right most value is the entropy of CO2 at 298K. The values abotained from the program are a perfect match.