Placement 2025 Scholarship: Your Future Starts Here | 6 Guaranteed Job Interviews | Limited to 100 seats. Apply Now

08D 07H 44M 35S

Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Placements

Student Reviews


For Business


More

Academic Training

Informative Articles

Find Jobs

We are Hiring!


All Courses

Choose a category

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

All Courses

All Courses

logo

CHOOSE A CATEGORY

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

Top Job Leading Courses

Automotive

CFD

FEA

Design

MBD

Med Tech

Courses by Software

Design

Solver

Automation

Vehicle Dynamics

CFD Solver

Preprocessor

Courses by Semester

First Year

Second Year

Third Year

Fourth Year

Courses by Domain

Automotive

CFD

Design

FEA

Tool-focused Courses

Design

Solver

Automation

Preprocessor

CFD Solver

Vehicle Dynamics

Machine learning

Machine Learning and AI

POPULAR COURSES

coursePost Graduate Program in Hybrid Electric Vehicle Design and Analysis
coursePost Graduate Program in Computational Fluid Dynamics
coursePost Graduate Program in CAD
coursePost Graduate Program in CAE
coursePost Graduate Program in Manufacturing Design
coursePost Graduate Program in Computational Design and Pre-processing
coursePost Graduate Program in Complete Passenger Car Design & Product Development
Executive Programs
Workshops
For Business

Success Stories

Placements

Student Reviews

More

Projects

Blogs

Academic Training

Find Jobs

Informative Articles

We're Hiring!

phone+91 9342691281Log in
  1. Home/
  2. Shlok Dixit/
  3. Project 1 - Parsing NASA thermodynamic data

Project 1 - Parsing NASA thermodynamic data

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.…

  • BIM
  • CAE
  • CFD
  • CSS
  • DEM
  • 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-

clear all close all clc
%R=molar gas constant R=8.314;
%syntax to open the file THERMO.dat f1=fopen('THERMO.dat','r')
%To read lines l1=fgetl(f1); l2=fgetl(f1);
value=strsplit(l2,' ');
%To get global temperatures from file in number form global_lowtemp=str2num(value{2})
global_midtemp=str2num(value{3}) global_hightemp=str2num(value{4})
%temperature range
T=linspace(global_lowtemp,global_hightemp,1000);
%skipping these 3 lines l3=fgetl(f1);
l4=fgetl(f1); l5=fgetl(f1);
%Reading species ,calcuating cp,h,s and plotting for i=1:53
tline=fgetl(f1);
A=strsplit(tline,' '); name_of_species=(A{1});
lowtemp= str2num(A{end-3}); midtemp=str2num(A{end-2}); hightemp=str2num(A{end-1});
%Finding 7 higher coefficients and 7 lower coefficients tline1=fgetl(f1);
a=findstr(tline1,'E');
a1=tline1(1:a(1)+3); a1=str2num(a1);
a2=tline1(a(1)+4:a(2)+3); a2=str2num(a2);
a3=tline1(a(2)+4:a(3)+3); a3=str2num(a3);
a4=tline1(a(3)+4:a(4)+3); a4=str2num(a4);
a5=tline1(a(4)+4:a(5)+3); a5=str2num(a5);
tline2=fgetl(f1);
a=findstr(tline2,'E');
a6=tline2(1:a(1)+3); a6=str2num(a6);
a7=tline2(a(1)+4:a(2)+3); a7=str2num(a7);
a8=tline2(a(2)+4:a(3)+3); a8=str2num(a8);
a9=tline2(a(3)+4:a(4)+3); a9=str2num(a9);
a10=tline2(a(4)+4:a(5)+3); a10=str2num(a10);
tline3=fgetl(f1);
a=findstr(tline3,'E');
a11=tline3(1:a(1)+3); a11=str2num(a11);
a12=tline3(a(1)+4:a(2)+3); a12=str2num(a12);
a13=tline3(a(2)+4:a(3)+3); a13=str2num(a13);
a14=tline3(a(3)+4:a(4)+3); a14=str2num(a14);
%calculate specific heat(cp),Enthalpy(H),Entropy(S)
Cp=Specific_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,global_midtemp); H=Enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,global_midtemp); S=Entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,global_midtemp);
%calculating molecular weight and printing it. Molecular_weight=wt(name_of_species);
fprintf('molecular weight of %s= %fn',name_of_species,Molecular_weight);
%PLOTTING CP,H,T
cd('C:UsershhhDesktopmatlabNASA FILES')
%creating the folder
mkdir(name_of_species); cd(name_of_species);
%plotting T vs cp figure(1)
plot(T,Cp,'linewidth',5,'color','r') xlabel('Temperature(T)')
ylabel('Specific heat(cp)') grid on
title(name_of_species)
saveas(figure(1),'specific heat.jpg');
%Plotting T vs H figure(2)
plot(T,H,'linewidth',5,'color','b') xlabel('Temperature(T)')
ylabel('Enthalpy(H)') grid on
title(name_of_species)
saveas(figure(2),'Enthalpy.jpg');
%Plotting T vs S figure(3)
plot(T,S,'linewidth',5,'color','y') xlabel('Temperature(T)')
ylabel('Entropy(S)') grid on
title(name_of_species)
saveas(figure(3),'Entropy.jpg');
cd('C:UsershhhDocumentsMATLABnasa files')
end
 
 

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.

Please  login to add a comment

Other comments...

No comments yet!
Be the first to add a comment

Read more Projects by Shlok Dixit (16)

Week 3 - External flow simulation over an Ahmed body.

Objective:

Hello this is Shlok here in this we are going to discuss about the Ahmed bodyCimulation in CFD Ansys Fluent So beofre going furthur lets get a few details about Ahmed Body Ahmed body is a simplified vehicle body used for capturing basic yet charecteristic features seen in objects used in the automobile industry. It is…

calendar

01 Aug 2023 12:27 PM IST

  • CFD
  • HTML
Read more

Week 3.5 - Deriving 4th order approximation of a 2nd order derivative using Taylor Table method

Objective:

AIM:                To derive the fourth order approximations of a second order derivative using central differencing scheme, skewed right sided difference and skewed left sided difference with the help of taylor table method and to compare the analytical…

calendar

18 Jul 2023 09:03 AM IST

  • HTML
Read more

Week 2 - Flow over a Cylinder.

Objective:

Aim: To Simulate the flow over a cylinder and explain the phenomenon of Karman vortex street Objective: 1.To Calculate the coefficient of drag and lift over a cylinder by setting the Reynolds number to 10,100,1000,10000 & 100000. (Run with steady solver) 2.Simulate the flow with the steady and unsteady case…

calendar

11 Jul 2023 05:55 PM IST

  • BIM
  • CAE
  • CFD
  • CSS
  • DEM
  • FEA
  • GIS
  • HEV
  • MBD
Read more

Project 1 : CFD Meshing for Tesla Cyber Truck

Objective:

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 :…

calendar

26 Feb 2023 04:02 PM IST

  • ANSA
  • CAE
  • CFD
  • RADIOSS
Read more

Schedule a counselling session

Please enter your name
Please enter a valid email
Please enter a valid number

Related Courses

coursecard

Linear Algebra

Recently launched

20 Hours of Content

coursecardcoursetype

Post Graduate Program in Infrastructure - Engineering Design and Project Management

4.5

127 Hours of Content

coursecardcoursetype

Post Graduate Program in CFD Solver Development

4.8

119 Hours of Content

coursecard

Introduction to OpenFOAM Development

4.9

18 Hours of Content

coursecard

FEA using SOLIDWORKS

4.8

4 Hours of Content

Schedule a counselling session

Please enter your name
Please enter a valid email
Please enter a valid number

logo

Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.

https://d27yxarlh48w6q.cloudfront.net/web/v1/images/facebook.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/insta.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/twitter.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/youtube.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/linkedin.svg

Our Company

News & EventsBlogCareersGrievance RedressalSkill-Lync ReviewsTermsPrivacy PolicyBecome an Affiliate
map
EpowerX Learning Technologies Pvt Ltd.
4th Floor, BLOCK-B, Velachery - Tambaram Main Rd, Ram Nagar South, Madipakkam, Chennai, Tamil Nadu 600042.
mail
info@skill-lync.com
mail
ITgrievance@skill-lync.com

Top Individual Courses

Computational Combustion Using Python and CanteraIntroduction to Physical Modeling using SimscapeIntroduction to Structural Analysis using ANSYS WorkbenchIntroduction to Structural Analysis using ANSYS Workbench

Top PG Programs

Post Graduate Program in Hybrid Electric Vehicle Design and AnalysisPost Graduate Program in Computational Fluid DynamicsPost Graduate Program in CADPost Graduate Program in Electric Vehicle Design & Development

Skill-Lync Plus

Executive Program in Electric Vehicle Embedded SoftwareExecutive Program in Electric Vehicle DesignExecutive Program in Cybersecurity

Trending Blogs

Heat Transfer Principles in Energy-Efficient Refrigerators and Air Conditioners Advanced Modeling and Result Visualization in Simscape Exploring Simulink and Library Browser in Simscape Advanced Simulink Tools and Libraries in SimscapeExploring Simulink Basics in Simscape

© 2025 Skill-Lync Inc. All Rights Reserved.

              Do You Want To Showcase Your Technical Skills?
              Sign-Up for our projects.