Project 1 - Parsing NASA thermodynamic data
OBJECTIVE :
MATLAB PROGRAMM TO FULLFILL THE FALLOWING OBJECTIVES
- Writing a code in matlab to parse to NASA Thermodynamic data file ,
- Writing a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species in the data file
- Calculating the molecular weight of each species and display it in the command window.
- Ploting the Cp, Enthalpy and Entropy for the local temperature range (low temperature : high temperature) specific for each species.
- Plot the Cp, Enthalpy and Entropy for the local temperature range (low temperature : high temperature) specific for each species.

%%PARCING THERMO DYNAMIC DATA PRGRAM DETAILS
clear all
close all
clc
file=fopen('THERMO.dat','r') % Opening the thermo file to read. here file is sclar matlab integer
%%Heading
line1=fgetl(file); %Assingning the heading to the line 1.fgetl() returns to the new line
%global temperature values
line2=fgetl(file); %Assinginfg the global temperature values to line 2.fgetl() returns to the new line
%Next three lines are comments
des_1=fgetl(file); % Assigning the next line to des_1
des_2=fgetl(file);% Assigning the next line to des_3
des_3=fgetl(file);% Assigning the next line to des_3
%Assigning the global temperature
A=strsplit(line2,' '); %splitting the line 2 using the space charector as a delimeter
Global_low_temperature=str2num(A{2});%Assigning the global low temperature from the array A as a number
Global_mid_temperature=str2num(A{3});%Assigning the global low temperature from the array A as a number
Global_high_temperature=str2num(A{4});%Assigning the global low temperature from the array A as a number
for i=1:53 % Runnig the for loop for every molecule
species=fgetl(file) % Assigning the molecule data's first line from the line to species
species_name=species(1:6) % Assigning the molecule data's first line from the line to species
%Local temperature values for each molecule
B=strsplit(species,' ') % Splitting the species using the space charector as a delimeter
local_low_temperature=str2num(B{end -3}); % Assigning the local low temperature from array B as a number
local_high_temperature=str2num(B{end -2});% Assigning the local low temperature from array B as a number
local_mid_temperature=str2num(B{end -1});% Assigning the local low temperature from array B as a number
line_1=fgetl(file); %Assigning the molecule data's 2nd line from the line 2 line 1
L1=strfind(line_1,'E'); % finding the 'E' in the line 1 to differentiate the data.
% Assigning the high temperature co efficients
c1=str2num(line_1(1:(L1(1)+3)));
c2=str2num(line_1((L1(1)+4):(L1(2)+3)));
c3=str2num(line_1((L1(2)+4):(L1(3)+3)));
c4=str2num(line_1((L1(3)+4):(L1(4)+3)));
c5=str2num(line_1((L1(4)+4):(L1(5)+3)));
line_2=fgetl(file); % Assigning the molecule data's3rd line from the file to line 2
L2=strfind(line_2,'E'); % Finding the letter 'E' in the line 2 ,to differenciate the data
c6=str2num(line_2(1:(L2(1)+3)));
c7=str2num(line_2((L2(1)+4):(L2(2)+3)));
% Assigning the low temperature co efficient
c8=str2num(line_2((L2(2)+4):(L2(3)+3)));
c9=str2num(line_2((L2(3)+4):(L2(4)+3)));
c10=str2num(line_2((L2(4)+4):(L2(5)+3)));
line3=fgetl(file); % Assigning the data's 4th line from the file to line 3
L3=strfind(line_3,'E'); %Finding the letter 'E' in the line 3
% Assigning the low temperature co efficient
c11=str2num(line_3(1:(L3(1)+3)));
c12=str2num(line_3((L2(1)+4):(L3(2)+3)));
c13=str2num(line_3((L2(2)+4):(L3(3)+3)));
c14 = str2num(line_3((L2(3)+4):(L3(4)+3)));
% Creating a folder for each species
mkdir(['C:usersUSERonedrivedocumentsMATLABFILE PARSING OF NASA THERMODYNAMIC DATASspecies',species_name]);
%Temperature ranges assumed for the calculation
Temperature=linspace(local_low_temperature,local_high_temperature,100);
%universal gas constant
R=8.314;
for j=1:lenght(temperature) % Running a for loop for every temperature
%When temperature is below the middle temperature values
if temperature(j)
end
end
end
MATLAB CODE FOR MOLECULAR MASS FUNCTION
function MM = molecular_mass(species_name)
species=upper(species_name)
constituents=['H','C','N','O','A'];
Atomic_weight=[1.00794 12.0107 14.0067 15.9994 39.948];
MM=0;
for i=1:length(species)
for j=1:length(constituents) if strcmp(species(i),constituents(j)) % camparing ith charof species with jth char of constituents
MM=MM+Automic_weight(j); %calculating molecular mass by simulation
U=j;% Assigning the j value in U variabl
end % ending the if statement
end
% Claculating the molecular mass when their is one atom is present of
% the same type
n=str2num(species(i)); % Coverting ith char of species to number
if n>1 %when n is greater then i
MM=MM+Automic_weight(u)*(n-1); %calculating molecular mass by simulation
end
end
............
EXPLANATION OF THE MATLAB CODES
- FIRST WE OPEN THE THERMO.dat FILE TO READ
- READ THE HEDDING ,GLOBAL TEMPERATURE AND NEXT 3 LINES
- RUN A FOR LOOP FOR EVERY SPECIES
- GET THE SPECIES NAME
- GET THE LOCAL TEMPERATURE AND OFTER CONVERTING THEM INTO NUMBER WE ASSIGN VARIABLE
- GET ALL 14 CO EFFICIENT BY USING strsplit(),
- PLOT THE GRAPH T-S,T-H,& T-CP AND SAVE IN SPECIFIED FOLDER
- CALCULATE THE MOLECULAR MASS CALLING THE MOLECULAR MASS FUNCTION
- CLOSE THE FILE
ERROR RECEIVED WHILE PARCING THE PROGRAM.

FILE LOCATION

1. Output O2.



2. Output N2



3.Output Co2


