Project 1 - Parsing NASA thermodynamic data
- Write a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species in the data file. You will be reading this file NASA THERMODYNAMIC DATA?
BY USING ABOVE FIG WE NEED TO CALCULATE ALL THE VALUES AND PLOTS TO ALL THE ELEMENTS
%PROJECT:1
%PRASING THE NASA THERMODYNAMICS DATA. BY USING THE TEMPERATURE FILE
clear all
close all
clc
%gettiing an reading the data file
f1=fopen('THERMO.dat', 'r'); %open file and reading the data
for i=1:5 %1:5 i s comments
l1=fgetl(f1);
end
%assing the lines
for i=1:53 %we have 53 elements/species
line_1=fgetl(f1);
split_line1=strsplit(line_1,' '); %spliting the betwwen the space
species_name=split_line1{1};
%finding local temp values
find_dot=strfind(line_1,'.'); %by the referece of dot in temperatures
loc_temp_low=str2double(line_1(find_dot(1)-3:find_dot(1)));
loc_temp_high=str2double(line_1(find_dot(2)-4:find_dot(2)));
loc_temp_mid=str2double(line_1(find_dot(3)-4:find_dot(3)));
%defining the values
line_2=fgetl(f1);
line_3=fgetl(f1);
line_4=fgetl(f1);
%we have 14 temperature values
%1-7 is high temperature : 8-14 is low temperature
%find string in values
a = strfind(line_2,'E');
% reading the 1-7 high temperature all values
a1 = line_2(1:a(1)+3);
a2 = line_2(a(1)+4:a(2)+3);
a3 = line_2(a(2)+4:a(3)+3);
a4 = line_2(a(3)+4:a(4)+3);
a5 = line_2(a(4)+4:a(5)+3);
%first high tempratues string changes into numbers
a1 = str2double(a1);
a2 = str2double(a2);
a3 = str2double(a3);
a4 = str2double(a4);
a5 = str2double(a5);
%read second line values
a = strfind(line_3,'E');
%reading all the values in line_3
a6 = line_3(1:a(1)+3);
a7 = line_3(a(1)+4:a(2)+3);
%changing tghe string to the numbers
a6 = str2double(a6);
a7 = str2double(a7);
%second 8-14 low temperature values
a8 = line_3(a(2)+4:a(3)+3);
a9 = line_3(a(3)+4:a(4)+3);
a10 = line_3(a(4)+4:a(5)+3);
%changing string to number
a8 = str2double(a8);
a9 = str2double(a9);
a10 = str2double(a10);
%read the line 4 srtings
a = strfind(line_4,'E');
%read the values in line_4
a11 = line_4(1:a(1)+3);
a12 = line_4(a(1)+4:a(2)+3);
a13 = line_4(a(2)+4:a(3)+3);
a14 = line_4(a(3)+4:a(4)+3);
%changing 11-14 string to number
a11 = str2double(a11);
a12 = str2double(a12);
a13 = str2double(a13);
a14 = str2double(a14);
% assigin the temperature and gas constant(R)
%from the data
t = linspace(loc_temp_low, loc_temp_high,1000); %taking the temperature values
R = 8.314; %universal gas constant
%then the enthalpy ,specific heat,entropy
for i=1:length(t)
if t(i)>loc_temp_mid
cp(i) = ((a1+(a2.*t(i))+(a3.*t(i).^2)+(a4.*t(i).^3)+(a5.*t(i).^4)).*R); %specific heat
H(i) = ((a1+((a2.*t(i))./2)+((a3.*t(i).^2)./3)+((a4.*t(i).^3)./4)+((a5.*t(i).^4)./5)+(a6./t(i))).*(R.*t(i))); %enthalpy
s(i) = (a1*(log(t(i)))+a2*(t(i))+((a3*(t(i).^2))./2)+((a4*(t(i).^3))./3)+((a5*(t(i).^4))./4)+(a7))*R; %entrophy
else
cp(i) = ((a8+(a9.*t(i))+(a10.*t(i).^2)+(a11.*t(i).^3)+(a12.*t(i).^4)).*R);
H(i)= ((a8+((a9.*t(i))./2)+((a10.*t(i).^2)./3)+((a11.*t(i).^3)./4)+((a12.*t(i).^4)./5)+(a13./t(i))).*R.*t(i));
s(i) = (a8*(log(t(i)))+a9*(t(i))+((a10*(t(i).^2))./2)+((a11*(t(i).^3))./3)+((a12*(t(i).^4))./4)+(a14))*R;
end
end
Molecular_weight=molecular_mass(species_name); %molecular weight
sprintf('Molecular_weight of %s=%f',species_name,Molecular_weight);
%plotting the values
%plotting the specific heat
figure(1)
plot(t,cp,'linewidth',2,'color','r');
title(species_name)
xlabel('temperature')
ylabel('specific heat')
%plotting the enthalpy
figure(2)
plot(t,H,'linewidth',2,'color','g');
title(species_name)
xlabel('temperature')
ylabel('Enthalpy')
%plotting the entrophy
figure(3)
plot(t,s,'linewidth',2,'color','c');
title(species_name)
xlabel('temperature')
ylabel('Entrophy')
q=sprintf('%s', species_name); %reading all the species
%making directory using "mkdir & cd"
mkdir (q) %saving the file
cd (q)
%saving plots
saveas(figure(1),'specific heat.jpg')
saveas(figure(2),'Enthalpy.jpg')
saveas(figure(3),'Entrophy.jpg')
cd .. %directory back
end
FOR THE ABOVE CODE ANSWER CHECK THE BELOW FILE "file_parsing"

- FINDING THE MOLECUAR_WEIGHT TO THE ELEMENTS
%calculate the molecular weight
function MM = molecular_mass(species_name)
Atoms = ['H','C','N','O','A']; %assiging all the elments connected all species
Atomic_weight = [1.0079 12.010 14.006 15.999 39.948];
MM =0;
%using for loop
for i = 1:length(species_name)
for j = 1:length(Atoms)
if strcmp(species_name(i),Atoms(j))
MM = MM + Atomic_weight(j);
K = j;
end
end
n = str2double(species_name(i));
if n>1 %then
MM = MM + Atomic_weight(K)*(n-1);
end
end
end

FOR THE ABOVE CODE CHECK THE BELOW FILE "molecular_mass"
- Plots for o2, N2 and Co2 species
- PLOTTING THE ELEMENT "O2"



2.PLOTTING THE ELEMENT "N2"



3. PLOTTING THE ELEMENT "CO2"



%SAVING THE ALL THE ELEMENTS AND PLOTS IN THE FOLDERS, THOSE ARE SCREENSHOT IN BELOW:
%screenshot of folders

%screenshot ofn plots in folder

%screenshot ofn plots in folder
- Please write a detailed report to describe your logic.
The breif report about these project we need to find all the elements temperatures and values at different tempertaures.
Here i using the matlab to find the all the values and plotting the values of elements.
Here my logic in these i find the details about project and that values to find molecular mass.
I'm using matlab inbuilt codes and function to find all the elemets values & assign all the values in simple codes .
Here i need to accurate values ';' these command in the code.