All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
PARSING NASA THERMODYNAMIC DATA OBJECTIVES 1. Write a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species in the data file. Here R is the universal gas constant, T is the temeprature 2. Calculate the molecular weight of each…
Anandita Gautam
updated on 22 Sep 2020
PARSING NASA THERMODYNAMIC DATA
1. Write a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species in the data file.
Here R is the universal gas constant, T is the temeprature
2. Calculate the molecular weight of each species and display it in the command window.3. Plot the Cp, Enthalpy and Entropy for the local temperature range (low temperature : high temperature) specific for each species.
3. Save the plots as images with appropriate names and dump them in separate folders for each species with suitable name. All these should be generated automatically.
MAIN PROGRAM
clear all
close all
clc
R = 8.31490;
%To ready the THERMO.dat file
f1 = fopen('THERMO.dat','r');
fgetl(f1)
tempL = str2num(fgetl(f1));
% global_low_temperature = tempL(1)
% global_mid_temperature = tempL(2)
% global_high_temperature = tempL(3)
%for skipping the unwanted lines
for i = 1:3
fgetl(f1);
end
for y=1:53
%for reading local temperatures
line0 = fgetl(f1);
a = strfind(line0,'.');
tlin0= strtok(line0);
lt1 = line0(52-3:a(1)+3);
lt2 = line0(a(1)+4:62+3);
lt3 = line0(a(2)+4:72+3);
Local_Temp_low = str2num(lt1);
Local_Temp_high = str2num(lt2);
Local_Temp_mid = str2num(lt3);
%To read the lines for coefficient %Reading the first line of Coefficient
linel = fgetl(f1);
b = findstr(linel,'E');
a1 = str2num(linel(1:b(1)+3));
a2 = str2num(linel(b(1)+4:b(2)+3));
a3 = str2num(linel(b(2)+4:b(3)+3));
a4 = str2num(linel(b(3)+4:b(4)+3));
a5 = str2num(linel(b(4)+4:b(5)+3));
%reading the second line of coefficient
line2 = fgetl(f1);
c = findstr(line2,'E');
a6 = str2num(line2(1:c(1)+3));
a7 = str2num(line2(c(1)+4:c(2)+3));
a8 = str2num(line2(c(2)+4:c(3)+3));
a9 = str2num(line2(c(3)+4:c(4)+3));
a10= str2num(line2(c(4)+4:c(5)+3));
%Reading the third line of coefficient
line3 = fgetl(f1);
d = findstr(line3,'E');
a11 = str2num(line3(1:d(1)+3));
a12 = str2num(line3(d(1)+4:d(2)+3));
a13 = str2num(line3(d(2)+4:d(3)+3));
a14 = str2num(line3(d(3)+4:d(4)+3));
Lower_Temp = linspace(Local_Temp_low,Local_Temp_mid,100);
Higher_Temp = linspace(Local_Temp_mid,Local_Temp_high,100);
%Cp of the given data
Cp_High = (a1 + a2*Higher_Temp + a3*Higher_Temp.^2 + a4*Higher_Temp.^3 + a5*Higher_Temp.^4 + a6*Higher_Temp.^5 + a7*Higher_Temp.^6 )*R ;
Cp_Low = (a8 + a9*Lower_Temp + a10*Lower_Temp.^2 + a11*Lower_Temp.^3 + a12*Lower_Temp.^4 + a13*Lower_Temp.^5 + a14*Lower_Temp.^6)*R ;
%Enthalphy of the given data
H_High = (a1 + a2 * (Higher_Temp/2) + a3 * ((Higher_Temp).^2)/3 + a4 * ((Higher_Temp).^3)/4 + a5 * ((Higher_Temp).^4)/5 + a6 *((Higher_Temp).^5)/6 + a7 * ((Higher_Temp).^6)/7)*R.*Higher_Temp;
H_Low = (a8 + a9 * (Lower_Temp/2) + a10 * ((Lower_Temp).^2)/3 + a11 * ((Lower_Temp).^3)/4 + a12 * ((Lower_Temp).^4)/5 + a13 * ((Lower_Temp).^5)/6 + a14 * ((Lower_Temp).^6)/7)*R.*Lower_Temp;
%Entrophy Calculation for the given data
S_High = (a1*log(Higher_Temp) + a2*Higher_Temp + (a3*Higher_Temp)/2 + (a4*Higher_Temp)/3 + (a5*Higher_Temp)/4 + a7)*R;
S_Low = (a8*log(Lower_Temp) + a9*Lower_Temp + (a10*Lower_Temp)/2 + (a11*Lower_Temp)/3 + (a12*Lower_Temp)/4 + a14)*R;
MolW(y) = molecular_weight(tlin0)
cd('D:/Project1/species')
mkdir(tlin0)
cd(tlin0)
figure(1)
plot(Lower_Temp,Cp_Low,'linewidth',3)
hold on
plot(Higher_Temp,Cp_High,'linewidth',3)
hold off
saveas(gcf,'file1.png')
figure(2)
plot(Lower_Temp,H_Low,'linewidth',3 )
hold on
plot(Higher_Temp,H_High,'linewidth',3)
hold off
saveas(gcf,'file2.png')
figure(3)
plot(Lower_Temp,S_Low,'linewidth',3)
hold on
plot(Higher_Temp,S_High,'linewidth',3)
hold off
saveas(gcf,'file3.png')
cd('D:/Project1')
end
EXPLAINATION OF CODE
2. FUNCTION TO CALCULATE MOLECULAR MASS
function MW = molecular_weight(line0)
elements = ['H','C','O','N','A','S'];
atomic_wt = [1.00 12.01 15.99 14.00 39.94 32.06];
MW = 0;
for i = 1:length(line0)
for j = 1:length(elements)
if strcmp(line0(i),elements(j))
MW = MW + atomic_wt(j);
a = j;
end
end
n = str2num(line0(i));
if n>1
MW=MW+atomic_wt(a)*(n-1);
end
end
EXPLAINATION OF CODE
3. OUTPUTS
a. O2
b. N2
c. CO2
Google Drive LINK :
https://drive.google.com/drive/folders/1PXNrSC-KQDJ96zFnnAUSOdOt8OuqPLO3?usp=sharing
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...
Frequency Analysis of a rotating shaft
Introduction: An object's natural frequency is the frequency or rate that it vibrates naturally when disturbed. Objects can possess more than one natural frequency and we typically use harmonic oscillators as a tool for modeling the natural frequency of a particular object. We can apply an unnatural or forced frequency…
09 Sep 2022 01:53 PM IST
MBD Simulation on IC Engine Valve Train
Aim: To model and perform motion analysis on Valve Train Introduction: A valvetrain is a component that is designed to open and close the intake and exhaust valves so that air/fuel mixture can enter and leave the combustion chamber as gases. Nowadays, engines are designed with overhead cam assemblies which are known…
22 Dec 2020 04:18 PM IST
MBD Simulation on a Piston Assembly
Aim: To model and perform motion analysis with different piston positions Introduction: A piston is a component of reciprocating engines, reciprocating pumps, gas compressors, hydraulic cylinders and pneumatic cylinders, among other similar mechanisms. It is the moving component that is contained by a…
20 Dec 2020 07:37 PM IST
Planetary Gear
Aim: To model and run a motion analysis on Planetary Gear System. Introduction: An epicyclic gear train or planetary gear consists of 2-4 gears mounted so that the center of one gear revolves around the center of the other. The planet and sun gears mesh so that their pitch circles roll…
15 Dec 2020 03:36 PM 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.