All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
* PARSEING THE NASA THERMODYNAMIC DATA FILE AND CALCULATING THERMODYNAMIC PROPERTIES OF VARIOUS GAS SPECIES. PROGRAM close all clear all clc file=fopen('THERMO.dat','r') %reading the nasa thermo data file line1=fgetl(file) % heading of data line2=fgetl(file) % global temp value comment1=fgetl(file) %comments comment2=fgetl(file)…
Arun Reddy
updated on 15 Dec 2021
* PARSEING THE NASA THERMODYNAMIC DATA FILE AND CALCULATING THERMODYNAMIC PROPERTIES OF VARIOUS GAS SPECIES.
PROGRAM
close all
clear all
clc
file=fopen('THERMO.dat','r') %reading the nasa thermo data file
line1=fgetl(file) % heading of data
line2=fgetl(file) % global temp value
comment1=fgetl(file) %comments
comment2=fgetl(file) %comments
comment3=fgetl(file) %comments
A =strsplit(line2,' '); %splitting the line2
global_low = str2num(A{2}); %global low temp
global_mid = str2num(A{3}); %global mid temp
global_high = str2num(A{4}); % global high temp
%extrading species information individual
for i=1:53 % 53 individual species
species=fgetl(file);
T1 = strfind(species,'.');
temp1 = species(T1(1)-3:T1(1)+3);
t_min = str2double(temp1);
temp2 = species(T1(2)-4:T1(2)+3);
t_max = str2double(temp2);
temp3 = species(T1(3)-4:T1(3)+3);
t_high = str2double(temp3);
species_name=species(1:6);
line_1 = fgetl(file);
%extracting 1st spices line
L1 = strfind(line_1,'E');
c1 = str2num(line_1(1:(L1(1)+3)));
c2 = str2num(line_1((L1(1)+4):(L1(2)+3)));
c3 = str2num(line_1((L1(2)+4):(L1(3)+3)));
c4 = str2num(line_1((L1(3)+4):(L1(4)+3)));
c5 = str2num(line_1((L1(4)+4):(L1(5)+3)));
line_2=fgetl(file);
% extracting 2nd species line
L2 = strfind(line_2,'E');
c6 = str2num(line_2(1:(L2(1)+3)));
c7 = str2num(line_2((L2(1)+4):(L1(2)+3)));
c8 = str2num(line_2((L2(2)+4):(L1(3)+3)));
c9 = str2num(line_2((L2(3)+4):(L1(4)+3)));
c10 = str2num(line_2((L2(4)+4):(L1(5)+3)));
line_3=fgetl(file);
% extracting 3rd line of species
L3 = strfind(line_3,'E');
c11 = str2num(line_3(1:(L3(1)+3)));
c12= str2num(line_3((L3(1)+4):(L1(2)+3)));
c13= str2num(line_3((L3(2)+4):(L1(3)+3)));
c14= str2num(line_3((L3(3)+4):(L1(4)+3)));
R=8.314
T = linspace(global_low,global_high,100);
mkdir(species);
cp=specific_heat(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,global_low,global_mid,global_high,T,R);
s=entropy(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,global_low,global_mid,global_high,T,R);
H=enthalpy(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,global_low,global_mid,global_high,T,R);
W=molecular_weight(species);
figure(1)
plot(T,cp)
xlabel('Temperature [K]')
ylabel('Specific Heat [J/Kg.K]')
title('Temperature vs Specific Heat')
figure(2)
plot(T,H)
xlabel('Temperature [K]')
ylabel('Enthalpy [KJ]')
title('Temperature vs Enthalpy')
figure(3)
plot(T,s)
xlabel('Temperature [K]')
ylabel('Entropy [J/k]')
title('Temperature vs Entropy')
end
FUNCTIONS
FOR SPECIFIC HEAT
function cp=specific_heat(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,global_low,global_mid,global_high,T,R);
if(T<=global_mid)
cp=R*(c8+(c9*T)+(c10*(T).^2)+(c11*(T).^3)+(c12*(T).^4));
else
cp=R*(c1+(c2*T)+(c3*(T).^2)+(c4*(T).^3)+(c5*(T).^4));
end
end
FOR ENTHALPY
function H=enthalpy(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,global_low,global_mid,global_high,T,R);
if (T<=global_mid)
H=R*T.*(c8+((c9*T)/2)+((c10*(T).^2)/3)+((c11*(T).^3)/4)+((c12*(T).^4)/5)+((c13./T)));
else
H=R*T.*(c1+((c2*T)/2)+((c3*(T).^2)/3)+((c4*(T).^3)/4)+((c5*(T).^4)/5)+((c6./T)));
end
end
FOR ENTROPY
function s=entropy(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,global_low,global_mid,global_high,T,R);
if (T<= global_mid)
s=R*(c8.*log(T)+(c9*T)+((c10*(T).^2)/2)+((c11*(T).^3)/3)+((c12*(T).^4)/4)+c14);
else
s =R*(c1.*log(T)+(c2*T)+((c3*(T).^2)/2)+((c4*(T).^3)/3)+((c5*(T).^4)/4)+c7);
end
end
FOR MOLECULAR WEIGHT
function W = molecular_weight(species)
atomic_name = ['H','C','O','N','Ar'];
atomic_weight = [1.008 12.011 15.999 14.007 39.948];
W=0
for i=1:length(species)
for j=1:length(atomic_name)
if strcmp(species(i),atomic_name(j))
W=W+atomic_weight(j);
position = j
end
end
n=str2num(species);
if n>1
W=W+atomic_weight(position)*(n-1);
end
fprintf('molecular weight of %s :-',species);
fprintf('%f',W);
disp(' ')
end
OUTPUT:
FOR 02
FOR N2
FOR CO2
WORK SPACE
MOLECULAR WEIGHT
RESULT
The code for file parsing is done
the graph for n2 o2 co2 is plotted
molecular weight is found out.
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...
Project 1-Meshing of Rear Wheel Holder challenge
Aim :- Meshing of Rear Wheel Holder with mentioned quality criteria. OBJECTIVE: Extract the mid surface Geometry cleanup Meshing given door model using the given quality criteria checks Good mesh flow. Assign thickness PROCEDURE : Import the component and click F to see the component in the GUI area as shown below. As…
10 Jun 2023 03:22 PM IST
Week 7- Meshing of Backdoor Challenge
AIM: Mesh the backdoor model as per the given quality criteria using Hypermesh. OBJECTIVE: Extract the mid surface Geometry cleanup Meshing given hood model using the given quality criteria checks Good mesh flow. Assign thickness PROCEDURE : Import the component and click F to see the component in the GUI area as shown…
10 Jun 2023 03:21 PM IST
Week 6-Meshing of Hood Challenge
AIM: To extract the mid surface of the given component individually, mesh the obtained mid surface, and assign the thickness. The given model has to be imported and auto cleanup has to be done on the component then the mid surface has to be extracted from the components and have to be meshed individually with an average…
22 Jan 2023 12:06 PM IST
Week 4-1D Element Creation Challenge
THEORY: PROJECT METHODOLOGY: 1. MID SURFACE: Auto mid surface has been used to extract the midsurface for this simple bracket. Components has been created and assigned to the particular mid surfaces. 2. ASSIGN MATERIAL: Create material. Here I have created a material and assigned to steel. …
04 Jan 2023 11:52 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.