## Parsing NASA Thermodynamic file Using MATLAB

OBJECTIVE - 1. Write a function that extracts the 14 co-efficient and calculates the enthalpy, entropy and specific heats for all the species in the data file.

1. Calculate the molecular weight of each species and display it in the command window.
2. 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.
4. The main program that you will submit will just take the "THERMO.dat" file as an input and generate Cp, H and S plots for all species that are included in the file.

PROCEDURE-

In this project, we will be reading the NASA thermodynamic data and them calculate the thermodynamic properties such as specific heat, enthalpy ,entropy and molecular weight of various species and plot the respective graphs.

The required data is stored in the file named ‘THERMO.dat’ and the data is used for this project.

The formula used for finding the Cp, H, S are given below,

Cp/R = a1 + a2T +a3T^2 + a4 T^3 + a5T^4

H/RT = a1 + a2 T/2 + a3 T^2/3 + a4 T^3/4 +a5 T^4/5 +a6/T

S/R = a1 lnT + a2 T + a3 T^2 /2 +a4 T^3/3 +a5 T^4/4 +a7

The first seven coefficients are low temperature coefficients and the second 7 coefficients are high temperature coefficients. The mid temperature range is 100k and if anything goes higher than that its is considered as high temperature.

• Using the fopen command the data is read.
• Skip the first four command lines and initiate the value of Universal gas constant.
• Then separate the coefficients simultaneously using the strfind command to find E.
• Using the str2double command change the string value into numerical value.
• Repeat the above two steps for all the values of ‘a’.
• Then using the if command the values of Cp, H and S are calculated for the low temperature or high temperature values.
• The ‘mkdir’ command is used to save the outputs graphs in the same directory.
• Then the respective graphs are plotted.

PROGRAM-

clear all
close all
clc

f1 = fopen('THERMO.dat','r');
tline = fgetl(f1);
R = 8.314;
for i = 1:4
fgetl(f1);
end

for i = 1:52

tline1 = fgetl(f1);
a = strsplit(tline1,' ');
species_cell =a(1);
species =char(species_cell);

str1 = strfind(tline1,'.');
low_temp_range = str2double(tline1(str1(1)-4:str1(1)+3));
high_temp_range = str2double(tline1(str1(2)-4:str1(2)+3));
mid_temp_range = str2double(tline1(str1(3)-4:str1(3)+3));

tline2 = fgetl(f1);
str = strfind(tline2,'E');
a1 = str2double(tline2(1:str(1)+3));
a2 = str2double(tline2(str(1)+4:str(2)+3));
a3 = str2double(tline2(str(2)+4:str(3)+3));
a4 = str2double(tline2(str(3)+4:str(4)+3));
a5 = str2double(tline2(str(4)+4:str(5)+3));

tline3 = fgetl(f1);
a6 = str2double(tline3(1:str(1)+3));
a7 = str2double(tline3(str(1)+4:str(2)+3));
a8 = str2double(tline3(str(2)+4:str(3)+3));
a9 = str2double(tline3(str(3)+4:str(4)+3));
a10 = str2double(tline3(str(4)+4:str(5)+3));

tline4 = fgetl(f1);
a11 = str2double(tline4(1:str(1)+3));
a12 = str2double(tline4(str(1)+4:str(2)+3));
a13 = str2double(tline4(str(2)+4:str(3)+3));
a14 = str2double(tline4(str(3)+4:str(4)+3));
a15 = str2double(tline4(str(4)+4:str(5)+3));

Molecular_weight = m_wt(species);
sprintf('Molecular weight of %s = %d',species,Molecular_weight)

T = low_temp_range:high_temp_range;

if (T>low_temp_range)
Cp = R*(a1 + (a2*T) + (a3*(T.^2)) + (a4*(T.^3)) + (a5*(T.^4)));

H = R*(a1*a2*T/2) + (a3*(T.^2)/3) + (a4*(T.^3)/3) + (a5*(T.^4)/5) + (a6*(T));

S = R*(a1*log(T)) + (a2*T) + (a3*(T.^2)/2) + (a4*(T.^3)/3) + (a5*(T.^4)/4) +a7;

else
Cp = R*(a8 + (a9*T) + (a10*(T.^2)) + (a11*(T.^3)) + (a12*(T.^4)));

H = R*(a8*a9*T/2) + (a10*(T.^2)/3) + (a11*(T.^3)/3) + (a12*(T.^4)/5) + (a13*(T));

S = R*(a8*log(T)) + (a9*T) + (a10*(T.^2)/2) + (a11*(T.^3)/3) + (a12*(T.^4)/4) +a14;

end

t = sprintf('%s',species);
mkdir(t);

cd(t);

%plotting
figure(1)
plot(Cp,T,'b');
xlabel('sph heat');
ylabel('temp');
Cp_text = sprintf('Specific heat v temperatur for %s',species);
title(Cp_text);
saveas(gcf,'Cp.jpg');

figure(2)
plot(H,T,'r');
xlabel('Enthaly');
ylabel('temp');
H_text = sprintf('Enthalpy v temperatur for %s',species);
title(H_text);
saveas(gcf,'H.jpg');

figure(3)
plot(S,T,'g');
xlabel('Entrpy');
ylabel('temp');
S_text = sprintf('Entropy v temperatur for %s',species);
title(S_text);
saveas(gcf,'S.jpg');

cd ..;

end


OUTPUT OF CODE-

PLOT OF O2-

FIGURE 1

FIGURE 2

FIGURE 3

PLOT OF N2-

FIGURE 1

FIGURE 2

FIGURE 3

PLOT OF CO2-

FIGURE 1

FIGURE 2

FIGURE 3

SCREENSHOT OF THE FOLDER CONTAINING THE PLOTS-

CONCLUSION- Thus the code was written to extract the coefficients and the values were calculated using the given data.

### Pipe Flow simulation using Solidworks Habishek Umapathy · 2019-10-23 12:06:35

AIM – To run a pipe flow simulation with an inlet Reynolds number of 100, 1000 and 10000. For each of these cases do the following Place the line probes at 95%, 90%, 85%of the pipe length. Compare the normalized velocity profile at each of these locations. N Read more

### Data Analysis using Python Habishek Umapathy · 2019-08-13 15:39:11

OBJECTIVE – We have to write the script which should take column numbers as the input and plot the respective columns as separate images. The plot labels should be extracted from the file. If there is a request for a plot between column 1(crank angle) and column 8 Read more

### Curve Fitting using Python Habishek Umapathy · 2019-08-01 06:59:25

OBJECTIVE – To write a program to perform curve fitting.   Curve Fitting is the process of constructing a curve or mathematical functions, which possess the closest proximity to the real series of data. By curve fitting, we can mathematically constr Read more

### Breaking Ice with Air cushion Vehicle - Find minimum pressure with Newton-Raphson method Habishek Umapathy · 2019-07-29 18:24:30

The Newton Raphson method is an iterative technique that is used to find out the roots of a real valued function. It uses the idea that a continuous and differentiable function can be approximated by a straight-line tangent to it. In this case Newton Raphson method is Read more

### Simulation of Transient behaviour of a Simple Pendulum Habishek Umapathy · 2019-07-15 19:12:38

OBJECTIVE – To write a program to simulate the transient behaviour of a simple pendulum and to create an animation of its motion.   PROCEDURE – In Engineering, ODE is used to describe the transient behavior of a system. A simple example is a pendulum Read more

### Otto Cycle using Python Habishek Umapathy · 2019-07-08 04:43:31

OBJECTIVE - To write a code for P_V diagram of an Otto cycle and calculate thermal efficiency

PROCEDURE –

ASSUMPTIONS

• Initially state variables p1,t1,t3 and gamma a Read more

### Genetic Algorithm Using MATLAB Habishek Umapathy · 2019-06-06 16:17:05

OBJECTIVE - Write a code in MATLAB to optimise the stalagmite function and find the global maxima of the function. PROCEDURE- The genetic algorithm is a method for solving both constrained and unconstrained optimization problems that is based on natural sele Read more

### Curve Fitting Using MATLAB Habishek Umapathy · 2019-06-04 07:59:31

OBJECTIVE – To write code to fit a linear and cubic polynomial for the Cp data and plot the linear and cubic fit curves along with the raw data points.   PROCEDURE – Curve Fitting is the process of constructing a curve or mathematical functions, whic Read more