All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM:- To parse the NASA thermodynamic data file and then to evaluate thermodynamic properties such as Cp, H, and S of various gas species through MATLAB OBJECTIVE:- Writing a function that extracts the 14 co-efficient and calculation of the enthalpy, entropy, and specific heats for all the species in the data…
Damodhar Jangam
updated on 04 Dec 2020
AIM:-
To parse the NASA thermodynamic data file and then to evaluate thermodynamic properties such as Cp, H, and S of various gas species through MATLAB
OBJECTIVE:-
NASA Thermodynamic File:-
where,
R = Universal Gas constant
T = Temperature
Cp = Specific heat at constant pressure (KJ/mol)
S = Entropy (KJ/mol-K)
H = Enthalpy (KJ/mol)
Specific heat at constant pressure (Cp)
The specific heat at constant pressure is the amount of heat per unit mass required to raise the temperature at constant pressure by one degree Celsius. The relationship between heat and temperature change is usually expressed in the form shown below
Entropy (s)
Entropy, the measure of a system's thermal energy per unit temperature that is unavailable for doing useful work. Because work is obtained from ordered molecular motion, the amount of entropy is also a measure of the molecular disorder, or randomness, of a system.
Enthalpy (h)
A property of a thermodynamic system is equal to the system's internal energy plus the product of its pressure and volume. In a system contained to prevent the mass transfer, for processes at constant pressure, the heat absorbed or released equals the change in enthalpy.
clc
clearvars
close all
% converting given data into charts and finding their molecular weight
% input
R = 8.314; % Universal Gas constant f
f1 = fopen('THERMO.dat','r');
No_of_component = 53;
Coefficients = 14;
% reading section start now
fgetl(f1);
A = fscanf(f1,'%f');
global_low_temp = A(1);
global_mid_temp = A(2);
global_high_temp = A(3);
% skipping comments
for i = 1 : 3
fgetl(f1);
end
% creating new folder
mkdir('component');
% making for loop for reading components cofficient and local temperature
for i = 1 : No_of_component
tline_0 = fgetl(f1);
tline_1 = strsplit(tline_0,' ');
component(i,1) = tline_1(1);
low_temp(i,1) = str2double(tline_1{end-3});
high_temp(i,1) = str2double(tline_1{end-2});
mid_temp(i,1) = str2double(tline_1{end-1});
tline_2 = fgetl(f1);
E = strfind(tline_2,'E');
for k = 1:4
j = k + 1;
if k < 2
a(i,k) = str2double(tline_2(1:E(k)+3));
end
a(i,j) = str2double(tline_2(E(k)+4:E(j)+3));
end
tline_3 = fgetl(f1);
E = strfind(tline_3,'E');
for k = 1:4
j = k + 1;
if k < 2
a(i,k+5) = str2double(tline_3(1:E(k)+3));
end
a(i,j+5) = str2double(tline_3(E(k)+4:E(j)+3));
end
tline_4 = fgetl(f1);
E = strfind(tline_4,'E');
for k = 1:3
j = k + 1;
if k < 2
a(i,k+10) = str2double(tline_4(1:E(k)+3));
end
a(i,j+10) = str2double(tline_4(E(k)+4:E(j)+3));
end
end
%% creating new file to write coefficients and their respective molecular weights
f1 = fopen('All NASA Data seperation','w');
fprintf(f1,' S.no)Components | Molecular Weight | ');
for j = 1 : Coefficients
fprintf(f1,'| (a%.2d) |',j);
end
fprintf(f1,'n');
for i = 1 : No_of_component
fprintf(f1,' %5.f)%7st |t%8.5f t|t',i,component{i,1},Molecular_Weight(component{i,1}));
for j = 1 : Coefficients
fprintf(f1,'| %15d |',a(i,j));
end
fprintf(f1,'n');
end
fclose(f1);
%% plot and molecular weight calculation
for i = 1 : No_of_component
% calling function
W = Molecular_Weight(component{i,1});
T = linspace(mid_temp(i,1),high_temp(i,1),1000);
C_p = Constant_pressure(a(i,1),a(i,2),a(i,3),a(i,4),a(i,5),a(i,8),a(i,9),a(i,10),a(i,11),a(i,12),R,T,mid_temp(i,1));
H = Enthalpy(a(i,1),a(i,2),a(i,3),a(i,4),a(i,5),a(i,6),a(i,8),a(i,9),a(i,10),a(i,11),a(i,12),a(i,13),R,T,mid_temp(i,1));
S = Entropy(a(i,1),a(i,2),a(i,3),a(i,4),a(i,5),a(i,7),a(i,8),a(i,9),a(i,10),a(i,11),a(i,12),a(i,14),R,T,mid_temp(i,1));
cd('D:mathlabweek4nasa data segerationcomponent')
% creating folder with component name
mkdir(component{i,1});
cd(component{i,1});
temp = fopen('coefficients.txt','w');
% for printing making header
fprintf(f1,'Molecular Weight ofn %.4s : ',component{i,1});
fprintf('Molecular Weight of n %6s : ',component{i,1});
fprintf('%f',W);
fprintf(f1,'%f',W);
disp(' ')
fprintf(f1,' r Componet namet%6stn',component{i,1});
% for printing 14 Coefficients
for j = 1 : Coefficients
fprintf(f1,'ta%.2d t - t%15dn',j,a(i,j));
end
fclose(temp);
% save as Specific Heat.jpg
figure(1)
plot(T,C_p,'linewidth',2,'color','b');
xlabel('Temperature(K)');
ylabel('Specific Heat at constant pressure(KJ/mol-K)');
title(sprintf('Specific heat at constant pressure v/s Temperature range of "%s"',component{i,1}));
grid on
saveas(figure(1),'Specific Heat.jpg');
% save as Entropy.jpg
figure(2)
plot(T,S,'linewidth',2,'color','r');
xlabel('Temperature(K)');
ylabel('Entropy(KJ/mol-K)');
title(sprintf('Entropy v/s Temperature range of "%s"',component{i,1}));
grid on
saveas(figure(2),'Entropy.jpg');
% save as Enthalpy.jpg
figure(3)
plot(T,H,'linewidth',2,'color','g');
xlabel('Temperature(K)');
ylabel('Enthalpy(KJ/mol)');
title(sprintf('Enthalpy v/s Temperature range of "%s"',component{i,1}));
grid on
saveas(figure(3),'Enthalpy.jpg');
% come back to starting folder
cd('D:mathlabweek4nasa data segeration');
end
STEPS:-
Function to find Specific Heat at constant pressure
a function call with Constant_pressure with the following parameters
function Cp = Constant_pressure(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,R,t,mt)
if t > mt
Cp = R*(a1+(a2*t)+(a3*t.^2)+(a4*t.^3)+(a5*t.^4));
else
Cp = R*(a8+(a9*t)+(a10*t.^2)+(a11*t.^3)+(a12*t.^4));
end
STEPS :-
Function to find Entropy
function S = Entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,R,t,mt)
if t > mt
S = R*((a1*(log(t)))+(a2*t)+((a3*(t.^2))/2)+((a4*(t.^3))/3)+((a5*(t.^4))/4)+a7);
else
S = R*((a8*(log(t)))+(a9*t)+((a10*(t.^2))/2)+((a11*(t.^3))/3)+((a12*(t.^4))/4)+a14);
end
STEPS:-
Function to find Enthalpy
function H = Enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,R,t,mt)
if t > mt
H = R*t.*(a1+((a2*t)./2)+((a3*(t.^2))./3)+((a4*(t.^3))./4)+((a5*(t.^4))./5)+(a6./t));
else
H = R*t.*(a8+((a9*t)./2)+((a10*(t.^2))./3)+((a11*(t.^3))./4)+((a12*(t.^4))./5)+(a13./t));
end
STEPS:-
Function to find Molecular weight of the different Species
function W = Molecular_Weight(component)
% Defining Atomic name of the species
atomic_name = ['H','S','C','O','N','Ar'];
% Defining Atomic masses of main species
atomic_weight = [1.00797 32.065 12.011 15.9994 14.0067 39.948];
W=0; % Molecular weight starting range
for k=1:length(component)
for j=1:length(atomic_name)
if strcmp(component(k), atomic_name(j))
W = W + atomic_weight(j);
position = j;
end
end
n = str2num(component(k));
if n>1
W = W + atomic_weight(position)*(n-1);
end
end
end
STEPS:-
FINAL RESULTS:-
PLOTS:-
Plots of component O2
Plots of component N2
Plots of component CO2
Screenshot of the Directory where Different Component is saved
The output of the Molecular weight of the Different Component
References:-
https://www.mathworks.com/matlabcentral/answers/317006-create-new-folders-by-mkdir
https://www.mathworks.com/matlabcentral/answers/17580-how-to-define-a-path-in-saveas-command
https://www.mathworks.com/matlabcentral/answers/106320-make-a-loop-to-calculate-molecular-weight
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Final Project: Electric Rickshaw modelling
Aim of Project: Creating a MATLAB model of an electric rickshaw (three-wheel vehicle) with three driving cycles and variation temperature and driver rickshaw for 100Km constant speed driving at 45kmph. THEORY: Electric rickshaws (also known as electric tuk-tuks or e-rickshaws or toto or e-tricycles) have…
30 Jul 2021 06:33 AM IST
MBD Simulation on IC Engine Valve Train
Aim: Modelling and analysis of IC Engine Valvetrain for detecting the valve displacement and contact forces between contacts. Objectives: Obtain valve lift for given CAM lift of 3.5 mm & 6 mm at the same speed (1500 RPM) Obtain Plots between contact force of Cam & Push rod, Push rod…
18 Jul 2021 03:16 PM IST
MBD Simulation on a Piston Assembly
Aim: Modelling and assembly of Piston Assembly as well as Calculating Linear displacement of the Piston Head in all three cases of gudgeon offset with help of motion analysis and compare results. Introduction: Piston assembly consists of a piston, crank, connecting rod and piston pin known as a gudgeon pin. Functions…
18 Jul 2021 06:12 AM IST
Planetary Gear
Aim: Modelling Planetary Gear mechanism and calculating angular velocity with fixing by fixing the sun gear, ring gear and Carrier separately with help of motion analysis Introduction: A planetary gear set (also known as an epicyclic gear train ) consists of two gears mounted so that the centre…
17 Jul 2021 02:48 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.