Challenge

Project 1 - Parsing NASA thermodynamic data

AIM : TO PARSE THE THERMODYNAMIC FROM NASA USING MATLAB.

THEORY:

The official record of thermodynsmic values at difrant temprature has been stored b nasa in the polynomial with soecific constant from one to fourteen for various species in order to quantity the values. the polynomial can be soled with defined temprature values in accordance with our requarment .The term parsing refer to matlab reading on m file (script)transisting in to an internal code that it stores in memory .

GROVING EQUATIONS :

SPECIFIC HEAT :

cp = R*(a1 + a2*T +a3*T^2 + a4*T^3 + a5*T^4)

ENTHALPY :

h = (a1 + (a2*T)/2 + (a3*T^2)/3 + (a4*T^3)/4 + (a5*T^4)/5 + (a6/T)*R
ENTROPY :

s = (a1log(T) + a2*T + (a3*T^2)/2 +(a4*T^2)/3 + (a5.*T^2)/4 + a7 )*R

where

Cp = specific heat

H = Enthalpy

S =Entropy

R = Univarsal gas constant

T = Temprature

The first 7 coefficant is high temprature and second 7 is low temprature coefficant

OBJECTIVE :

  1. To write a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species
  2. To Calculate the molecular weight of each species and display it in the command window.
  3. Plot the specific heat Enthalpy and Entropy for the local temperature range global low temperature to global high temperature.
  4. Save the plots as images with appropriate names and dump them in separate folders for each species

FUNCTIONS of PROGRAM :Calculate thermodynamic properties(SPECIFIC HEAT,ENTHALPY ,ENTROPY)

SPECIFIC HEAT :

function [cp] = specific_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,global_mid_temp)

if T <= global_mid_temp
cp = R*(a1 + a2*T +a3*T.^2 + a4*T.^3 + a5*T.^4)
else
cp = (a8 + a9*T +a10*T.^2 + a11*T.^3 + a12 *T.^4).*R
end
end

ENTHALPY :

function [h] = enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,global_mid_temp)
if T<=global_mid_temp
h = R*T.*(a8 + (a9*T)/2 + (a10*T.^2)/3 + (a11*T.^3)/4 + (a12*T.^4)/5 + (a13./T));
else
h = R*T.*(a1 + (a2*T)/2 + (a3*T.^2)/3 + (a4*T.^3)/4 + (a5*T.^4)/5 + (a6./T));
end
end

ENTROPY:

function [s] = entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,global_mid_temp)
if T<=global_mid_temp
s = (a8*log(T) + a9*T + (a10*T.^2)/2 +(a11*T.^3)/3 + (a12*T.^4)/4 + a14 )*R;
else
s = (a1*log(T) + a2*T + (a3*T.^2)/2 +(a4*T.^3)/3 + (a5*T.^4)/4 + a7 )*R;
end
end

MOLECULAR WEIGTH :

%calculating molecular weight of species mentioned in data file
function[molecular_weight] =mole_wt(species_name)
SPECIES = (species_name)
constituents = ['H','C','N','O','A'];
atomic_weight =[1 12 14 16 40];
molecular_weight = 0;
for i = 1:length(SPECIES)
for j = 1: length (constituents)
if strcmp(SPECIES(i),constituents(j))
molecular_weight = molecular_weight + atomic_weight(j);
u = j;
end
end
n = str2double(SPECIES(i));
if (n >1)
molecular_weight = molecular_weight + atomic_weight(u)*(n-1)
end
end
fprintf('molecular_weightof %s:-, species_name')
end

MAIN PROGRAM :

close all

clear all
clc
%reading the thermodynamic data file
f1 = fopen('THERMO.dat','r');
file_name = fgetl(f1);
t_line = fgetl(f1);
A = strsplit(t_line);
R = 8.314
%Defiining the temprature extreacted from data file
%
for i = (1:3);
comments = fgetl(f1);
end
for i = 1:53;
%exteract species name
species = fgetl(f1);
B=strsplit(species,' ')
species_name = B{1};
global_low_temp = str2double(B{end-3});
global_mid_temp = str2double(B{end-1});
global_high_temp = str2double(B{end-2});
T = linspace(global_low_temp,global_high_temp,500)
%Exteracting coefficent from first line
line_1 = fgetl(f1);
l1 = strfind(line_1,'E');
a1 = str2double(line_1(1:(l1(1)+3)));
a2 = str2double(line_1((l1(1)+4):(l1(2)+3)));
a3 = str2double(line_1((l1(2)+4):(l1(3)+3)));
a4 = str2double(line_1((l1(3)+4):(l1(4)+3)));
a5 = str2double(line_1((l1(4)+4):(l1(5)+3)));
%Exteracting coefficent from second line
line_2 = fgetl(f1);
l2 = strfind(line_2,'E');
a6 = str2double(line_2((l2(1)+4):(l1(2)+3)));
a7 = str2double(line_2((l2(1)+4):(l1(2)+3)));
a8 = str2double(line_2((l2(2)+4):(l1(3)+3)))
a9 = str2double(line_2((l2(3)+4):(l1(4)+3)))
a10 = str2double(line_2((l2(4)+4):(l1(5)+3)))
%Exteracting coefficent from third line
line_3 = fgetl(f1)
l3 = strfind(line_3,'E')
a11 = str2double(line_3(1:(l3(1)+3)))
a12 = str2double(line_3((l3(1)+4):(l3(2)+3)))
a13 = str2double(line_3((l3(2)+4):(l3(3)+3)))
a14 = str2double(line_3((l3(3)+4):(l3(4)+3)))
%calling the thermodaynamic equation function
cp = specific_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,global_mid_temp);
h = enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,global_mid_temp);
s = entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,global_mid_temp);
%creating a folder "SPEACS' to save the thermodaynamic plot of species
mkdir(species_name)
cd(species_name)
%plotting
%plotting between temprature and specific heat
figure(1)
plot(T,h,'linewidth',3,'color','b')
title('species name')
ylabel('TEMPRATURE')
xlabel('ENTHALPY')
%plotting between temprature and enthalpy
figure(2)
plot(T,h,'linewidth',3,'color','g')
title('species name')
ylabel('TEMPRATURE')
xlabel('ENTHALPY')
%plotting between temprature and entropy
figure(2)
plot(T,h,'linewidth',3,'color','g')
title('species name')
ylabel('TEMPRATURE')
xlabel('ENTHALPY')
%save plots
saveas(1,'specific_heat.png')
saveas(1,'enthalpy.png')
saveas(1,'entropy_heat.png')
%change dirctory for calculating molecular weight
cd ..
molecular_weight = mole_wt(species_name)
end
fclose(f1)

EXPLANATION

  • initially a code write the desired data fie an value is assaned difrant value or variables.
  • data is read with difrant comand
  • difrant folder with the species name is desired location
  • creating difrant plots in difrant folder
  • creating a difrant function comands like specific heat ,enthalpy, entropy and mole weight
  • plots are saveing in specifed folder.

CONCLUTION :

The parsing thermodaynamic data fle by NASA is done using certain comands on matlab the plot of themodayanmic property vs temprature by certain speart moving folder. fucntion has to be coded to calculate the molecular waight of the species mentioned in the given data form the above progaram.it can be extreact new foulder.

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.