clear all
close all
clc
% inputs
R=8.314; % Gas constant
% T=Temperature
% Cp = Specific Heat (Kj)
% S = Entropy (Kj/mol-K)
% H = Enthalpy (Kj/mol)
% a(i) = Coefficients where, i=1 to 14
% Reading data file
% open file and reading THERMO.dat file
f1 = fopen('THERMO.dat','r')
get = fgetl(f1);
% Now reading Temperature from this file
temp = fgetl (f1);
% spliting
s = strsplit(temp);
% converting strings cells into numbers
templow = str2num(s{2});
templow = str2num(s{3});
templow = str2num(s{4});
% Temperature Range
T = linspace(templow,temphigh,1000);
% Skipping comment lines
for i=1:3
get = fgetl(f1);
end
% Reading the Species
for j=1:53
tline=fgetl(f1);
A=strsplit(tline,' '); % spliting into cell array
species = (A{1}); % To read the name of the species
% Converting string to number
lowtemp = str2num(A{end-3});
lowtemp = str2num(A{end-2});
lowtemp = str2num(A{end-1});
tline1 = fget(f1); % getting next line
a = strfind(tline1,'E'); % Finding the string E
% Finding first 7 higher & sencond 7 lower coefficients
% Finding Higher coefficients
a1 = tline (1:a(1)+3);
a1 = str2num(a1);
a2 = tline (a(1)+4:a(2)+3);
a2 = str2num(a2);
a3 = tline (a(2)+4:a(3)+3);
a3 = str2num(a3);
a4 = tline (a(3)+4:a(4)+3);
a4 = str2num(a4);
a5 = tline (a(4)+4:a(5)+3);
a5 = str2num(a5);
tline = fgetl(f1);
b=strfind(tline2,'E');
a6=tline2(1:b(1)+3);
a6=str2num(a6);
a7=tline2(b(1)+4:b(2)+3);
a7=str2num(a7);
%finding lower coefficients
a8=tline2(b(2)+4:b(3)+3);
a8=str2num(a8);
a9=tline2(b(3)+4:b(4)+3);
a9=str2num(a9);
a10=tline2(b(4)+4:b(5)+3);
a10=str2num(a10);
tline = fgetl(f1);
c = strfind(tline3,'E');
a11 = tline3(1:c(1)+3);
a11 = str2num(a11);
a12 = tline3(c(1)+4:c(2)+3);
a12 = str2num(a12);
a13 = tline3(c(2)+4:c(3)+3);
a13 = str2num(a13);
a14 = tline3(c(3)+4:c(4)+3);
a14 = str2num(a14);
% calculate specific heat
Cp = Specific_heat (a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R)
% calculate Entropy
S = Entropy (a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R)
% calculate Enthalpy
H = Enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T)
% Calculte Molecular Wt of the Species
W = Molecular_weight(species);
% writting molecular weight file
MW_file = fopen('Molecular Weight.txt','w');
fprintf(MW_file,'Molecular weight of %s is %d',species)
fclose(MW_file); % Closing the file
% Plot 2 S Vs T
figure(2)
plot(T,S,'LineWidth',2,'Color','r');
xlabel('Temp');
ylabel('Entropy(KJ/mol-K');
title(sprint('Entropy Vs Temp range of %s', species));
grid on
saveas(figure(2),'Entropy.jpg');
% plot3 Cp Vs T
figure(3)
plot(T,H,'LineWidth',2,'Color','g');
xlabel('Temp');
ylabel('Enthalpy(KJ/mol)');
title(sprintf('Enthlpy Vs Temp range of %s', species));
grid on
saveas(figure(3),'Enthalpy.jpg');
cd('C/User/Vishal Chitare/Desktop/skill lync')
% Molecular weight
W=Molecular_weight(spacies)
end