All Courses
All Courses
AIM : 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. You will be reading this file NASA thermodynamic data(Tip: use fopen and fgetl). The formulae are shown below. Here R is the universal gas constant,…
Shaik Faraz
updated on 13 Jun 2022
AIM :
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. You will be reading this file NASA thermodynamic data(Tip: use fopen and fgetl). The formulae are shown below.
Here R is the universal gas constant, T is the temeprature
The FIRST 7 coefficients are HIGH-temperature coefficients and the SECOND 7 coefficients are LOW-temperature coefficients.
Also use the LOCAL TEMPERATURE RANGES which is unique for each individual species, not the GLOBAL TEMPERATURE RANGE.
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.
4. 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.
THEORY :
Parsing: Parsing a file means reading in a data stream and building a memory model of the content of that data. This aims at facilitating perfoming some kind of transformation on the data. Parsing splits a file or other input into pieces of data that can be easily stored or manipulated.
DATA SOURCE :
Link to thermodynamic data file,
FORMULAE USED :
MAIN code :
clear all
close all
clc
F1=fopen('THERMO.dat','r')
first_line=fgetl(F1);
R=8.314;
temp=fgetl(F1);
A=strsplit(temp,' ');
globel_low_tempreture=str2num(A{2});
globel_middle_tempreture=str2num(A{3});
globel_high_tempreture=str2num(A{4});
tempreture=linspace(globel_low_tempreture,globel_high_tempreture,globel_middle_tempreture);
third_line=fgetl(F1);
fourth_line=fgetl(F1);
fifth_line=fgetl(F1);
for i=1:53
sixth_line=fgetl(F1);
M=strsplit(sixth_line,' ');
species_name=M{1};
sixth_line_one=fgetl(F1);
a=findstr(sixth_line_one,'E');
a1=sixth_line_one(1:a(1)+3);
a1=str2num(a1);
a2=sixth_line_one(a(1)+4:a(2)+3);
a2=str2num(a2);
a3=sixth_line_one(a(2)+4:a(3)+3);
a3=str2num(a3)
a4=sixth_line_one(a(3)+4:a(4)+3);
a4=str2num(a4);
a5=sixth_line_one(a(4)+4:a(5)+3);
a5=str2num(a5);
sixth_line_sec=fgetl(F1)
a=findstr(sixth_line_sec,'E')
a6=sixth_line_sec(1:a(1)+3);
a6=str2num(a6);
a7=sixth_line_sec(a(1)+4:a(2)+3);
a7=str2num(a7);
a8=sixth_line_sec(a(2)+4:a(3)+3);
a8=str2num(a8)
a9=sixth_line_sec(a(3)+4:a(4)+3);
a9=str2num(a9);
a10=sixth_line_sec(a(4)+4:a(5)+3);
a10=str2num(a10);
sixth_line_third=fgetl(F1)
a=findstr(sixth_line_sec,'E')
a11=sixth_line_sec(1:a(1)+3);
a11=str2num(a11);
a12=sixth_line_sec(a(1)+4:a(2)+3);
a12=str2num(a12);
a13=sixth_line_sec(a(2)+4:a(3)+3);
a13=str2num(a13)
a14=sixth_line_sec(a(3)+4:a(4)+3);
a14=str2num(a14);
A=entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,tempreture,globel_middle_tempreture,R);
B=enthalphy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,tempreture,globel_middle_tempreture,R)
C=speciofic_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,tempreture,globel_middle_tempreture,R)
molecular_w(i) = molecular_weight(species_name)
molecular_weight_of_the_species=fopen('molecular_weight.txt','w');
fprintf(molecular_weight_of_the_species,'molecular weight of the %s is %f \n',species_name,molecular_w);
fclose( molecular_weight_of_the_species)
derectory_curr=pwd;
mkdir(species_name);
cd(species_name);
figure(1)
plot(tempreture,A,'color','r',LineWidth=2)
xlabel('tempreturess')
ylabel('entropys')
grid on
title(sprintf('variation in entropy wrt tempreture in %s',species_name))
saveas(figure(1),'entrogy.jpg')
figure(2)
plot(tempreture,B,'color','b',LineWidth=2)
xlabel('tempreture')
ylabel('enthalpy')
grid on
title(sprintf('variation in enthalpy wrt tempreture in %s',species_name))
saveas(figure(2),'enthalpy.jpg')
figure(3)
plot(tempreture,C,'color','k',LineWidth=2)
xlabel('tempreture')
ylabel('specific_heat')
grid on
title(sprintf('variation in specific heat wrt tempreture in %s',species_name))
saveas(figure(3),'specificheat.jpg')
cd(derectory_curr)
end
function molecular_w = molecular_weight(species_name)
key_possion=['O','H','C','N','A']
compounds_value= [15.999,1.008,12.011,14.007,39.948];
molecular_w= 0;
for i = 1:length(species_name)
for j = 1:length(key_possion)
if strcmp(species_name(i),key_possion(j))
molecular_w= molecular_w+compounds_value(j);
poss = j;
end
end
K= str2num(species_name(i));
if (K>1)
molecular_w = molecular_w+compounds_value(j)*(K-1);
end
fprintf('molecular weight of the species %s',species_name)
fprintf('%f',molecular_w)
disp(' ')
end
function [A]=entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,tempreture,globel_middel_temp,R)
if (tempreture>=globel_middel_temp)
A=R*(a1.*log(tempretur)+a2.*(tempreture)+(a3.*(tempreture).^2/2)+(a4.*(tempreture.^3)/3)+(a5.*(tempreture).^4/4)+a7);
else
A=R.*(a8.*log(tempreture)+a9.*(tempreture)+(a10.*(tempreture).^2/2)+(a11.*(tempreture.^3)/3)+(a12.*(tempreture).^4/4)+a14);
end
end
function [B]=enthalphy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,tempreture,globel_middel_temp,R)
if (tempreture>=globel_middel_temp)
B=R.*tempreture.*(a1+(a2.*tempreture/2)+(a3.*(tempreture).^2/3)+(a4.*(tempreture).^3/4)+(a5.*(tempreture).^4/5)+(a6.*(tempreture).^5/6));
else
B=R.*tempreture.*(a8+(a9.*tempreture/2)+(a10.*(tempreture).^2/3)+(a11.*(tempreture).^3/4)+(a12.*(tempreture).^4/5)+(a13.*(tempreture).^5/6));
end
end
function [C]=speciofic_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,tempreture,globel_middel_temp,R)
if (tempreture>=globel_middel_temp)
C=R.*(a1+(a2.*(tempreture))+(a3.*(tempreture).^2)+(a4.*(tempreture).^3)+(a5.*(tempreture).^4));
else
C=R.*(a8+(a9.*(tempreture))+(a10.*(tempreture).^2)+(a11.*(tempreture).^3)+(a12.*(tempreture).^4));
end
end
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
Aim: Performing topological cleanup and surface mesh on tesla cyber truck and on a wind tunnel based on selected target length values of its different components using element type as Tria, as well as appropriate selection of the volume that contains the vehicle and its surroundings with the wind tunnel for volumetric…
15 Nov 2022 04:17 AM IST
Week 5 Challenge : Surface wrap on Automotive Assembly
Aim: Perforform Topo cleanup and delete unwanted surfaces for Surface wrap. After Topo cleanup, Merge all 3 models and perform surface wrap. Target length for Wrap = 3 mm 1. Engine: 2. Gear box: 3. Transmission: Procedure: 1. Topo Cleanup : (Engine, Transmission & Gear Box)…
10 Nov 2022 08:22 AM IST
Week 4 Challenge : CFD Meshing for BMW car
Aim: To perform topological clean-up, and carry out the surface meshing of a BMW M6 car model and create a wind tunnel surrounding the same. Objectives: For the given model, check and solve all geometrical errors on half portion and Assign appropriate PIDs. Perform meshing with the given Target length and element Quality…
07 Nov 2022 11:33 AM IST
Week 3 Challenge : CFD meshing on Turbocharger
Aim: Performing CFD meshing on Turbocharger using ANSA Objective: For the given model, check for the geometrical errors to make appropriate volumes. Create and assign PIDs as shown in the video. Perform surface mesh with the given target lengths as per PIDs. Blade stage-1 = 1 mm Blade stage-2 = 1 mm Impeller = 2 mm…
03 Nov 2022 08:06 AM IST
Related Courses
0 Hours of Content