All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: - Write a Matlab program that extracts 14 co-efficient and to calculate the entropy, enthalpy, and specific heats for all the species in the given NASA Thermodynamic data file data. Also, to calculate the molecular weight of each species. File Parsing: - Parsing, which is the process of identifying…
MANAPRAGADA BHANU MURTHY
updated on 03 May 2022
Aim: -
Write a Matlab program that extracts 14 co-efficient and to calculate the entropy, enthalpy, and specific heats for all the species in the given NASA Thermodynamic data file data. Also, to calculate the molecular weight of each species.
File Parsing: -
Parsing, which is the process of identifying tokens within a data instance and looking for recognizable patterns. The parsing process segregates each word, attempts to determine the relationship between the word and previously defined token sets, and then forms patterns from sequences of tokens.
Program to calculate the Molecular weight of each species: -
%% Creating function file to calculate molecular weight of the species
function molecular_weight_calulation = molecular_weight(Species_name)
Species = (Species_name);
Elements = ['H','C','O','N','A','S'];
Atomic_weight = [1.00794 12.0107 15.999 14.0067 39.948 32];
molecular_weight_calulation = 0;
for i = 1:length(Species)
for j = 1:length(Elements)
if strcmp(Species(i),Elements(j))
molecular_weight_calulation = molecular_weight_calulation + Atomic_weight(j);
a = j;
end
end
n = str2double(Species(i));
if n>1
molecular_weight_calulation = molecular_weight_calulation + Atomic_weight(a)*(n-1);
end
end
end
Program to calculate the entropy, enthalpy, specific heat: -
%% Creating the function file to give the inputs to calulate the values of Cp, H, S
function [Cp,H,S] = inputs(T,R,T_med_1,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14)
for i = 1:length(T)
if T(i)>T_med_1
Cp = (c1 + c2.*T + c3.*T.^2 + c4.*T.^3+c5.*T.^4).*R;
H = (c1 + (c2.*T)./2 + (c3.*T.^2)./2 + (c4.*T.^3)./4 +(c5.*T.^4)./5 + c6./T).*T.*R;
S = (c1.*log(T) + c2.*T + (c3.*T.^2)./2 + (c4.*T.^3)./3 + (c5.*T.^4)./4 + c7)*R;
else
Cp = (c8 + c9.*T + c10.*T.^2 + c11.*T.^3 + c12.*T.^3 + c12.*T.^4)*R;
H = (c8 + (c9.*T)./2 + (c10.*T.^2)./2 + (c11.*T.^3)./4 + (c12.*T.^4)./5 + c13./T)*R;
S = (c8.*log(T) + (c9.*T) + (c10.*T.^2)./2 + (c11.*T.^3)./3 + (c12.*T.^4)./4 + c14)*R;
end
end
end
Main Program: -
%% Program to find the molecular weight of the species and to make the directory
clear all
close all
clc
%% Opening the .dat file of temp
F_1 = fopen("THERMO.dat",'r');
% Reading the lines from file using fgetl command to convert the string to integers
fgetl(F_1);
T_line = fgetl(F_1);
% Splitting the string
A = strsplit(T_line, ' ');
%% Converting the global temperatures from string to double precision value.
global_low_temp = str2double(A{2});
global_mid_temp = str2double(A{3});
global_high_temp = str2double(A{4});
for i = 3:5
g = fgetl(F_1);
end
%% Finding the Temperature and converting to string to double precision value.
for j = 1:53
Species =fgetl(F_1);
t = strfind(Species, '.');
Species(52-3:53+3);
T_low = Species(52-3:t(1)+3);
T_low_1 = str2double(T_low);
Species(t(1)+6:62+3);
T_high = Species(t(1)+6:t(2)+3);
T_high_1 = str2double(T_high);
Species(t(2)+6:72+3);
T_med = Species(t(2)+6:t(3)+3);
T_med_1 = str2double(T_med);
%% Now finding the co-effcients of line 1
Species_name = Species(1:6);
coeff_line_1 =fgetl(F_1);
A_11 = strfind(coeff_line_1, 'E');
coeff_line_1(1:12+3);
a1 = coeff_line_1(1:A_11(1)+3);
c1 = str2double(a1);
a2 = coeff_line_1(A_11(1)+4:A_11(2)+3);
c2 = str2double(a2);
a3 = coeff_line_1(A_11(2)+4:A_11(3)+3);
c3 = str2double(a3);
a4 = coeff_line_1(A_11(3)+4:A_11(4)+3);
c4 = str2double(a4);
a5 = coeff_line_1(A_11(4)+4:A_11(5)+3);
c5 = str2double(a5);
%% Now finding the co-effcients of line 1
coeff_line_2 =fgetl(F_1);
A_12 = strfind(coeff_line_2, 'E');
coeff_line_2(1:12+3);
a6 = coeff_line_2(1:A_12(1)+3);
c6 = str2double(a6);
a7 = coeff_line_2(A_12(1)+4:A_12(2)+3);
c7 = str2double(a7);
a8 = coeff_line_2(A_12(2)+4:A_12(3)+3);
c8 = str2double(a8);
a9 = coeff_line_2(A_12(3)+4:A_12(4)+3);
c9 = str2double(a9);
a10 = coeff_line_2(A_12(4)+4:A_12(5)+3);
c10 = str2double(a10);
%% Now finding the co-effcients of line 3
coeff_line_3 =fgetl(F_1);
A_13 = strfind(coeff_line_3, 'E');
coeff_line_3(1:12+3);
a11 = coeff_line_3(1:A_12(1)+3);
c11 = str2double(a11);
a12 = coeff_line_2(A_12(1)+4:A_12(2)+3);
c12 = str2double(a12);
a13 = coeff_line_2(A_12(2)+4:A_12(3)+3);
c13 = str2double(a13);
a14 = coeff_line_2(A_12(3)+4:A_12(4)+3);
c14 = str2double(a14);
%% Giving the input values
T =linspace(T_low_1, T_high_1,100);
R = 8.314; % Universal gas constant
% calling the function files
[Cp, H, S] = inputs(T, R, T_med_1, c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14);
molecular_weight_calculation = molecular_weight(Species_name)
%% Plotting
% Plot b/w Temperatue and Specific Heat
figure(1)
plot(T,Cp,'LineWidth',3,'Color','b');
xlabel('Temperature');
ylabel('Specific Heat');
title(Species_name);
% Plot b/w Temperature and Entropy
figure(2)
plot(T,H,'LineWidth',3,'Color','b');
xlabel('Temperature');
ylabel('Entropy');
title(Species_name);
% Plot b/w Temperature and Enthalpy
figure(3)
plot(T,S,'LineWidth',3,'Color','b');
xlabel('Temperature');
ylabel('Enthaply');
title(Species_name);
%% Making Directory and saving the species in different folders
mkdir ('E:\SKill_lync\Challenges\Nasa file parsing\species',Species_name)
cd('E:\SKill_lync\Challenges\Nasa file parsing\species')
% Saving as .png file
saveas(1,'Specific Heat.png')
saveas(2,'Entropy.png')
saveas(3,'Enthalpy.png')
end
fclose(F_1)
Explanation of code: -
Results: -
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 - Parsing NASA thermodynamic data
Aim: - Write a Matlab program that extracts 14 co-efficient and to calculate the entropy, enthalpy, and specific heats for all the species in the given NASA Thermodynamic data file data. Also, to calculate the molecular weight of each species. File Parsing: - Parsing, which is the process of identifying…
03 May 2022 06:52 PM IST
FINAL INDEPENDENT PROJECT
Final Independent Project: - Topic: - Multi-objective optimal design of cycloid speed reducer based on genetic algorithm. Platform used to Solve the problem: - Matlab Introduction: - Cycloid speed reducers have found wide applications in the automation field as industry robots, machine tools, automatic machinery and other…
10 Apr 2022 10:32 AM IST
Project 2 - Rankine cycle Simulator
Aim: To create a Rankine Cycle simulator using Matlab. Objective: To calculate the state points of the Rankine cycle. To plot the T-S, H-S Diagrams of Rankine cycle. Theory: The Rankine cycle is an idealized thermodynamic cycle describing the process by which certain heat engines, such as steam turbines…
03 Apr 2022 07:27 PM IST
Week 4.1 - Genetic Algorithm
Genetic Algorithm: - A genetic algorithm is a search heuristic that is inspired by Charles Darwin’s theory of natural evolution. This algorithm reflects the process of natural selection where the fittest individuals are selected for reproduction in order to produce offspring of the next generation. …
23 Jan 2022 07:40 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.