clear all
close all
clc
% file reading
f = fopen('THERMO.dat','r')
for i = 1:5
fgetl(f);
end
b = fgetl(f)
a = strsplit(b,' ')
species_name = a{1};
%extraction of local temperature
low_temp = str2double(a{6})
high_temp = str2double(a{7})
mid_temp = str2double(a{8})
% extract of coefficients
co_eff = fgetl(f)
pos = strfind(co_eff,'E')
a1 = str2double(co_eff(1:(pos(1)+3)))
a2 = str2double(co_eff(pos(1)+4:(pos(2)+3)))
a3 = str2double(co_eff(pos(2)+4:(pos(3)+3)))
a4 = str2double(co_eff(pos(3)+4:(pos(4)+3)))
a5 = str2double(co_eff(pos(4)+4:(pos(5)+3)))
co_eff1 = fgetl(f)
pos = strfind(co_eff1,'E')
a6 = str2double(co_eff1(1:(pos(1)+3)))
a7 = str2double(co_eff1(pos(1)+4:(pos(2)+3)))
a8 = str2double(co_eff1(pos(2)+4:(pos(3)+3)))
a9 = str2double(co_eff1(pos(3)+4:(pos(4)+3)))
a10 = str2double(co_eff1(pos(4)+4:(pos(5)+3)))
co_eff2 = fgetl(f)
pos1 = strfind(co_eff2,'E')
a11 = str2double(co_eff2(1:(pos(1)+3)))
a12 = str2double(co_eff2(pos(1)+4:(pos(2)+3)))
a13 = str2double(co_eff2(pos(2)+4:(pos(3)+3)))
a14 = str2double(co_eff2(pos(3)+4:(pos(4)+3)))
%calculation of CP,H,S
%temperature array creation
T = linspace(low_temp,high_temp,1000)
%calculation of CP,H,S(LTR)
[cp,h,s]=therm_prop(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,mid_temp,T)
%molecular weight calculation
[molecular_wt] = mw(species_name);
species_name = 'O';
%Creation of folder
mkdir(['C:\Users\kanbu\OneDrive\Desktop\Species\',species_name])
%changing the folder to species folder
cd(['C:\Users\kanbu\OneDrive\Desktop\Species\',species_name])
figure(1)
subplot(2,2,1)
plot(T,cp,'LineWidth',2,'color','y');
saveas(1,'T vs cp.jpg')
xlabel('Temperature(K)');
ylabel('co_efficient');
title('Temperature vs co_efficient');
%Creation of folder
mkdir(['C:\Users\kanbu\OneDrive\Desktop\Species\',species_name])
%changing the folder to species folder
cd(['C:\Users\kanbu\OneDrive\Desktop\Species\',species_name])
figure(2)
subplot(2,2,2)
plot(T,h,'LineWidth',2,'color','b');
saveas(2,'T vs h','jpg')
xlabel('Temperature(K)');
ylabel('Enthalpy(j)');
title('Temperature vs Enthalpy');
%Creation of folder
mkdir(['C:\Users\kanbu\OneDrive\Desktop\Species\',species_name])
%changing the folder to species folder
cd(['C:\Users\kanbu\OneDrive\Desktop\Species\',species_name])
figure(3)
subplot(2,2,3)
plot(T,s,'LineWidth',2,'color','r');
saveas(3,'T vs s','jpg')
xlabel('Temperature(K)');
ylabel('Entropy(j/K)');
title('Temperature vs Entropy');
Function of Thermo_prop
function[cp,H,S] = therm_prop(a1,a2,a3,a4,a5,a6,a7,b1,b2,b3,b4,b5,b6,b7,mid_temp,T)
R=8.314;
if (T>mid_temp)
%calculation of CP,H,S(LTR)
cp = R.*(a1+a2*T.^2+a4*T.^3+a5*T.^4);
H= R.*T.*(a1+a2(a/2)+a3*((T.^2)./3)+a4*((T.^3)./4)+a5*((T.^4)./5)+a6./T);
S = R.*(a1*log(T)+a2*T+a3((T.^2)./2)+a4*((T.^3)./3)+a5*((T.^4)./4)+a7);
else
%calculation of CP,H,S(HTR)
cp = R.*(b1+b2*T+b3*T.^2+b4*T.^3+b5*T.^4);
H= R.*T.*(b1+b2*(T./2)+b3*((T.^2)./3)+b4*((T.^3)./4)+b5*((T.^4)./5)+b6./T)
S = R.*(b1*log(T)+b2*T+b3*((T.^2)./2)+b4*((T.^3)./3)+b5*((T.^4)./4)+b7);
end
end
Molecular Weight
function[molecular_wt] = mw(species_name)
elements = ['H','C','N','O','A'];
atomic_wt = [1,12,14,16,40];
molecular_wt = 0;
for i = 1:length(species_name)
for j =1:length(elements)
if strcmpi(species_name(i),elements(j))
molecular_wt = molecular_wt+atomic_wt(j);
position = j;
end
end
n=str2num(species_name(1));
if n>=1
molecular_wt = molecular_wt+atomic_wt(position)*(n-1);
end
end
fprintf('molecular weight of %s:%f u',species_name,molecular_wt)