clear all
close all
clc
f1 = fopen('THERMO.dat', 'r');
%get heading file
heading = fgetl(f1);
%global temperaturew values
global_temp = fgetl(f1);
x = strsplit(global_temp);
global_low_temp = str2double(x{2});
global_mid_temp = str2double(x{3});
global_high_temp = str2double(x{4});
fgetl(f1)
fgetl(f1)
fgetl(f1)
%their are 53 species
for i = 1 :53
line1 = fgetl(f1);
species_name = line1(1:6);
%local temperature
local_temp1 = line1(49:55);
local_temp = str2double(local_temp1);
local_temp2 = line1(58:65);
high_temp = str2double(local_temp2);
local_temp3 = line1(68:75);
mid_temp = str2double(local_temp3);
%extracting the coefficient
line2 = fgetl(f1);
line3 = fgetl(f1);
line4 = fgetl(f1);
a = strfind(line2, 'E');
b = strfind(line2, 'E');
c = strfind(line2, 'E');
%extracting coefficient og high temperature
a1 = str2double(line2(1:a(1)+3));
a2 = str2double(line2(a(1)+4:a(2)+3));
a3 = str2double(line2(a(2)+4:a(3)+3));
a4 = str2double(line2(a(3)+4:a(4)+3));
a5 = str2double(line2(a(4)+4:a(5)+3));
a6 = str2double(line3(1:b(1)+3));
a7 = str2double(line3(b(1)+4:b(2)+3));
%extracting coefficient of low temperature
a8 = str2double(line3(b(2)+4:b(3)+3));
a9 = str2double(line3(b(3)+4:b(4)+3));
a10 = str2double(line3(b(4)+4:b(5)+3));
a11 = str2double(line4(1:c(1)+3));
a12 = str2double(line4(c(1)+4:c(2)+3));
a13 = str2double(line4(c(2)+4:c(3)+3));
a14 = str2double(line4(c(3)+4:c(4)+3));
%universal gas constant
R = 8.314;
t = linspace(low_temp,high_temp,500);
%calculating specific heat
c_p = specific_heat(a1,a2,a3,a4,a8,a9,a10,a11,a12,mid_temp,R,t);
%calculating enthalpy
H = enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,R,t,mid_temp);
%calculating entropy
S = entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,R,t,mid_temp);
%creating folder
data = strcat('properties of. . . . . ',species_name);
mkdir(data);
file = pwd;
%plotting
figure(1)
plot(t,c_p)
data1 = strcat(species_name,'temperature vs specific heat');
xlabel('temperature')
ylabel('specific_heat')
title(species_name)
f = fullfile(data)
cd(f)
saveas(gcf,[pwd '/specific heat vs temperature .jpg'])
cd(file)
figure(2)
plot(t,H)
data2 = strcat(species_name,'temperature vs enthalpy');
xlabel('temperature')
ylabel('enthalpy')
title(species_name)
cd(f);
saveas(gcf,[pwd '/enthalpy vs temperature .jpg'])
cd(file)
figure(3)
plot(t,S)
data3 = strcat(species_name,'temperature vs entropy');
xlabel('temperature')
ylabel('entropy')
title(species_name)
cd(f);
saveas(gcf,[pwd '/entropy vs temperature .jpg'])
cd(file)
molecular_weight_calc = molecular_weight(species_name);
k =sprintf('%s mol_wt = %f',species_name,molecular_weight_calc);
disp(k)
end
fclose(f1)