All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM: To write a program in matlab to parse the NASA thermodynamic data file and then calculate t various gas species. OBJECTIVE: To write a function that extracts the 14 co-efficient and calculates the enthalpy ,entropy and s data file. Calculating the molecular weight of each species and displaying it in command window.…
Shlok Dixit
updated on 05 Jun 2022
AIM: To write a program in matlab to parse the NASA thermodynamic data file and then calculate t various gas species.
OBJECTIVE:
To write a function that extracts the 14 co-efficient and calculates the enthalpy ,entropy and s data file.
Calculating the molecular weight of each species and displaying it in command window. Plotting cp, enthalpy and entropy for local temperature range specific for each species.
Save the plot as images with appropriate names and dump them in separate folders for each
INTRODUCTION:
PARSING DATA:
Parsing means to make something understandable. For programming this means to convert i form into another form that's easier to work with. This is done by partially analysing the data, u structure (by making some assumptions based on what you're expecting to see), and then ex in the code.
Parsing a file means reading in a data stream of some sort and building an in memory model data. This aims at facilitating perfoming some kind of transformation on the data.
EQUATIONS:
The equations that we are going to use in the Functions to calculate cp, H,S are:
cp 2 3 4
= a1 + a2T + a3T + a4T + a5T
R
H a2T T 2 T 3 T 4 a6
= a1 + + a3 + a4 + a5 + RT 2 3 4 5 T
S T 2 T 3 T 4
= a1 ln T + a2T + a3 + a4 + a5 + a7 R 2 3 4
Where, Cp=specific heat
R =molar gas constant
T=temperature S=Entropy H=Enthalpy a=coefficients
BODY OF THE CONTENT:
Code for calling function Specific_heat( ):
function Cp = Specific_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,global_midtemp)
%calculating specific_heat for higher and lower temperature respectively if(T>= global_midtemp)
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 end
Code for calling function Enthalpy( ):
function H = Enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,global_midtemp)
%calculating enthalpy for higher and lower temperature respectively if(T>=global_midtemp)
H=R*((a1*T)+((a2*(T).^2)/2)+((a3*(T).^3)/3)+((a4*(T).^4)/4)+((a5*(T).^5)/5)+a6);
else
H=R*((a8*T)+((a9*(T).^2)/2)+((a10*(T).^3)/3)+((a11*(T).^4)/4)+((a12*(T).^5)/5)+a13);
end end
Code for calling function Entropy( ):
function S=Entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,global_midtemp)
%calculating entropy for higher and lower temperature respectively if(T>= global_midtemp)
S=R*(a1.*log(T)+(a2*T)+((a3*(T).^2)/2)+((a4*(T).^3)/3)+((a5*(T).^4)/5)+a7);
else
S=R*(a8.*log(T)+(a9*T)+((a10*(T).^2)/2)+((a11*(T).^3)/3)+((a12*(T).^4)/4));
end end
function Molecular_weight=wt(species_name)
Elements=['H' 'C' 'O' 'N' 'A' 'S'];
Atomic_weight =[1 12 16 14 40 32]; species=upper(species_name)
Molecular_weight=0;
for i=1:length(species)
for j=1:length(Elements)
if strcmp(species(i),Elements(j))
Molecular_weight=Molecular_weight+Atomic_weight(j); k=j;
else
n=str2double(species(i)); if (n>1)
Molecular_weight=Molecular_weight+Atomic_weight(k)*(n-1); break
end
end end
end
end
MainCode-
Explanation for code:
Initially the value of ‘R’ is being defined.
Then we use a command to open the file ‘THERMO.dat’strings to numbers and assigning global (low,mid and high) temperatures.
Then we have written a command to get the temperature range for calculation and plotting purpose. Then again using the fgetl command to go to thel next 3 lines and skipping it.
Then we use a for loop to get 53 species and their temperatures (low, mid, high) and the 14 coefficients.
In the for loop we again use the fgetl command and then the next line is read and from that line the species name, the three local temperatures are read and stored.
Then we use fgetl command to go to further line and get the first 7 coefficients and store them. Similarly using the fgetl command we move to the next two lines and get the remaining coefficients.
Then after getting the 14 coefficients, we use these coefficients and by calling the functions we calculate cp,H,S. Further we use the Molecular weight function and calculate molecular weight for that species.
Further I have used a command to change the directory so that I can save the files at a particular location.After changing the directory I have used ‘mkdir' to create a new folder with the name of the current species and then a ‘cd’ command to make mkdir as the current directory.
Then further we use plot command to plot temperature vs (cp,enthalpy,entropy) .
In this plotting we use the figure command to get the three different plots and saveas command to save the figures in the Then again we change our directory to again start the loop. So the loop continues to function till we get all the 53 species and then gets terminated.
ERRORS:
In this there was a typing error in the function name. I changed the function name (i.e. ‘s’ to ‘S’ ) and the problem was solved
OUTPUTS:
Plots for oxygen(o2) :
Plots for carbon dioxide(co2) :
Molecular weights:
CONCLUSION:
So here we were able to parse the data from the THERMO.dat file. Then using this data we were able properties and also make plots for these properties with respect to the temperature.
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 : CFD Meshing for Tesla Cyber Truck
Objective : To Identifying & cleanup all the topological errors in the given Tesla Cyber Truck Car model. To create a surface mesh. To Create a wind tunnel around Tesla Cyber Truck Car . To create a volumetric mesh to perform an external flow CFD analysis simulation. Introduction : ANSA :…
26 Feb 2023 04:02 PM IST
Week 4 Challenge : CFD Meshing for BMW car
CFD MESHING FOR BMW CAR:- Objective- Do topo cleanup for BMW car Do 2D meshing, check quality criterias Use hidden mode to check failed meshes on quality criteria Use reconstruct option to view and clear failed meshes Do 3D Meshing for car Create a wind tunnel , either in 2D or 3D mesh depending on capacity…
26 Feb 2023 12:50 PM IST
Week 5 Challenge : Surface wrap on Automotive Assembly
Aim/Objective : To do surface wrap over assembled parts (engine,transmission and gear box) Target length for Wrap = 3mm Procedure : First the model is loaded on to ANSA Unwanted surface are deleted without damaging the outer shape of the geometries. Single cons are resolved mainly here as it would affect negetively on…
26 Feb 2023 12:09 PM IST
Week 3 Challenge : CFD meshing on Turbocharger
AIM: For the given model, to check for the geometrical errors to make appropriate volumes, create and assign PIDs. To perform surface mesh with the given target lengths as per PIDs. Blade stage-1 = 1 mm Blade stage-2 = 1 mm Impeller = 2 mm Shaft rotor = 1 mm Turbo casing = 5 mm Compressor casing = 5 mm Inlet casing cover…
26 Feb 2023 11:25 AM IST
Related Courses
100 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.