Challenge

Project 1 - Parsing NASA thermodynamic data

Project 1 - Parsing NASA thermodynamic data

AIM: The thermodynamic data for various species are studied and the coefficients of temperature in the characteristic equations for entropy. enthalpy and specific heat are obtained using a Matlab code.

The equations are as follows:

`C_p=R*(a1+a2t+a3t^2+a4t^3+a5t^4+a6t^5+a7t^6+a8t^7+a9t^8+a10t^9+a11t^(10)+a12t^(11)+a13t^(12))+a14t^(13))`

`H=RT*(a1+a2t/2+a3t^2/3+a4t^3/4+a5t^4/5+a6t^5/6+a7t^6/7+a8t^7/8+a9t^8/9+a10t^9/10+a11t^10/11+a12t^11/12+a13t^12/13+a14t^13/14)`

`S=R*(a1log(t)+a2t+a3t^2/2+a4t^3/3+a5t^4/4+a6t^5/5+a7t^6/6+a8t^7/7+a9t^8/8+a10t^9/9+a11t^10/10+a12t^11/11+a13t^12/12+a14t^13/13)`

  • 14 Cofiicients are obtained from the thermodynamic data file of which the first 7 coefficients are used for low-temperature coefficients and the remaining 7 coefficients are used as high-temperature conditions.
  • The temperature of each species is mentioned data file.
  • The code is used to solve the equations and plot the results and save the plots in species-specific folders.

CODE:

  • Code start with close, clear, clc commands
  • the next thing is to do open the file by using 'open function'
  • The global temperature rages high low mid - temperature ranges
  • Temperature ranges caluculated by using 'strfind option'
  • Low temperature caluculate with low-mid temperature ranges
  • High temperature ranges caluculated with mid-high temperature ranges
  • than code is wrtten to caluculation of specific heat, enthalphy, entropy for low temperature to high temperatures.
  • The values are stored in each array
  • creating individual folders for each file
  • Write a function for caluculating molecular weight
  • plotting graphs for specific heat vs temperature, enthalphy vs remperature and entrophy vs temperature.
clear all
close all
clc

f1=fopen('THERMO.dat','r');


for i=1:5
fgetl(f1);
end
for j=1:53
tline1=fgetl(f1);
A=strsplit(tline1,' ');
species_cell=char(A(1));
p=strfind(tline1,'.');
low_local_temp=str2double(tline1(p(1)-3:p(1)+3));
high_local_temp=str2double(tline1(p(2)-4:p(2)+3));
mid_local_temp=str2double(tline1(p(3)-4:p(3)+3));

tline2=fgetl(f1);
y=strfind(tline2,'E');
a1=str2double(tline2(1:y(1)+3));
a2=str2double(tline2(y(1)+4:y(2)+3));
a3=str2double(tline2(y(2)+4:y(3)+3));
a4=str2double(tline2(y(3)+4:y(4)+3));
a5=str2double(tline2(y(4)+4:y(5)+3));

tline3=fgetl(f1);
z=strfind(tline2,'E');
a6=str2double(tline3(1:z(1)+3));
a7=str2double(tline3(z(1)+4:z(2)+3));
a8=str2double(tline3(z(3)+4:z(4)+3));
a9=str2double(tline3(z(4)+4:z(5)+3));

tline4=fgetl(f1);
x=strfind(tline2,'E');
a10=str2double(tline4(1:x(1)+3));
a11=str2double(tline4(x(1)+4:x(2)+3));
a12=str2double(tline4(x(2)+4:x(3)+3));
a13=str2double(tline4(x(3)+4:x(4)+3));
a14=str2double(tline4(x(3)+4:x(4)+3));

%universal gas constant
R=8.314;
t = low_local_temp:high_local_temp;

C_p=R*(a1+(a2*t)+(a3*(t.^2))+(a4*(t.^3))+(a5*(t.^4))+(a6*(t.^5))+(a7*(t.^6))+(a8*(t.^7))+(a9*(t.^8))+(a10*(t.^9))+(a11*(t.^(10)))+(a12*(t.^(11)))+(a13*(t.^(12)))+(a14*(t.^(13))));
H = R*(a1+a2*(t/2)+a3*(t.^2)/3+a4*(t.^3)/4+a5*(t.^4)/5+a6*(t.^5)/6+a7*(t.^6)/7+a8*(t.^7)/8+a9*(t.^8)/9+a10*(t.^9)/10+a11*(t.^10)/11+a12*(t.^11)/12+a13*(t.^12)/13+a14*(t.^13)/14);
S=R*((a1*log(t))+(a2*t)+(a3*((t.^2)/2))+(a4*((t.^3)/3))+(a5*((t.^4)/4))+(a6*((t.^5)/5))+(a7*((t.^6)/6))+(a8*((t.^7)/7))+(a9*((t.^8)/8))+(a10*((t.^9)/9))+(a11*((t.^10)/10))+(a12*((t.^11)/11))+(a13*((t.^12)/12))+(a14*((t.^13)/13)));

%calaculate molecular weight
molecular_weight = func_molecular_weight(species_cell)

q=sprintf('%s',species_cell);
mkdir(q)
cd(q)
figure(1)
%specific heat vs temperature
plot(C_p,t,'r')
xlabel('specific heat');
ylabel('temperature');
title('Specific_heat');
saveas(1,'C_p.jpeg')

figure(2)
%Enthalphy vs temperature
plot(H,t,'r')
xlabel('Enthalphy');
ylabel('temperature');
title('Enthalpy');
saveas(2,'H.jpeg')

figure(3)
%Entropy vs temperature
plot(S,t,'r')
xlabel('Entropy');
ylabel('temperature');
title('Entropy');
saveas(3,'S.jpeg')


cd ..
 end

Function code:

function[out] = func_molecular_weight(species)

elements = ['H','C','N','O','R'];

Atomic_weight = [1 12 14 16 40];
out = 0;

for i=1:length(species)
    for j=1:length(elements)
    if strcmp(species(i),elements(j))
        out=out+Atomic_weight(j);
        p=j;
    end
end
n=str2double(species(i));
if n>1
out = (out+Atomic_weight(p))*(n-1);
end
end

RESULTS:

SPECIFIC HEAT:

ENTHALPHY:

ENTROPHY:

FORDERS:

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.