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 codes of a function that extracts the 14 co-efficients of a tharmodynamic data,to calculate the entropy,enthalphy and specific heat by using the matlab. EXPLANATION: 1.parsing:parsing a file means reading in a data stream of som sort and building a memory model of the content of that data.this aims…
Mohmmed Riyaz
updated on 24 Mar 2022
AIM:To write a codes of a function that extracts the 14 co-efficients of a tharmodynamic data,to calculate the entropy,enthalphy and specific heat by using the matlab.
EXPLANATION:
1.parsing:parsing a file means reading in a data stream of som sort and building a memory model of the content of that data.this aims at facilitating performing some kind of transformation on the data.parsing splits a file or other input into peices of data that can be easily stored or manipulated.
2.specific heat:the quantity of heat required to raise the temperature of one gram of a substance by one celsius degree.here the specific heat is represented as Cp and universal gas constant is represented as R.
3.enthalphy:it is a property of a thermodynamic system,it is the sum of the system's internal energy,E and the products of its pressure,p and volume,V.H=E+PV.according to the law of energy conservation,the cgange in internal energy is equal to the heat transferred,the change in internal energy is equal to the heat transferred to, less the work done by the system.
4.entropy:entropy is the measure of a system's thermal energy per unit temperature that is unavailable for doing useful work.it also defined as the measure of randomness or disorderness of a system.
EXPLANATION OF CODES:1.The fopen command is used to open the file and reading the file by r command.
2.fgetl(fileID) command is used for returns the next line of the specified file,removing the newline characters.
3.string split command is used which is used to split the given global temperature which was in the form of combined data.
4.string is converted into number which the str2num is used to extract the the temperature and other variables should be stored.
5.for loop command is used to repeating the structure of each species .
6.strfind function command is used to find the searches the string for occurance of a shorter string,pattern,and returns the starting index of each occurence.here strfind is used to seperate between constants and combined a part.
7.if-else command is used find the temperatures.
8.plot command ois used to create the plots.
MAIN PROGRAM:
codes of entropy:
function s=entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,lmt)
if T<lmt
s=(a8*log*T+a9*T+a10*(T.^2)/2+a11*(T.^3)./3+a12*(T.^4)./4+a14)*R;
else
s=(a1*log(T)+a2*T+a3*(T.^2)./2+a4*(T.^3)./3+a5*(T.^4)/4+a7)*R;
end
end
codes of specific heat:
function cp=Specific_heats(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,lmt)
if T<lmt
cp=(a8+a9*T+a10*T.^2+a11*T.^3+a12*T.^4).*R;
else
cp=(a1+a2*T+a3*T.^2+a4*T.^3+a5*T.^4).*R;
end
end
codes of enthalpy:
function H=enthalphy_H(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,lmt)
if T<lmt
H=(a8+(a9.*T)/2+(a10*T.^2)/3+(a11*T.^2)/4+(a12*T.^3)/5+a13./T).*R.*T;
else
H=(a1+(a2.*T)/2+(a3*T.^2)/3+(a4*T.^3)/4+(a5*T.^4)/5+a6./T).*R.*T;
end
end
codes of molecular mass:
function M=molecular_mass(C)
species = upper (C)
constituents = ['H','C','N','O','A'];
atomic_weight = [1.00749 12.0107 14.0067 15.9994 39.948];
M=0;
for i=1:length(species)
for j=1:length(constituents)
if strcmp(species(i),constituents(j))
M=M+atomic_weight(j);
u=j;
end
n=str2double(species(i));
if n>1
M=M +atomic_weight(u)*(n-1);
end
end
end
codes of all species:
clear all
close all
clc
%reading
f1=fopen('THERMO.dat','r')
%skip header
for i=1:5
A=fgetl(f1)
end
%read the header
for i=1:53
header=fgetl(f1)
B=strsplit(header,' ')
d=length(B)
C=B{1}
llt=str2double(B{d-3})
lmt=str2double(B{d-1})
lht=str2double(B{d-2})
%reading 1st line
line1=fgetl(f1);
e=strfind(line1,'E')
a1= str2double(line1(1:e(1)+3))
a2=str2double(line1(e(1)+4:e(2)+3))
a3=str2double(line1(e(2)+4:e(3)+3))
a4=str2double(line1(e(3)+4:e(4)+3))
a5=str2double(line1(e(4)+4:e(5)+3))
% reading 2nd line
line2=fgetl(f1)
e1=strfind(line2,'E')
a6=str2double(line2(1:e1(1)+3))
a7=str2double(line2(e1(1)+4:e1(2)+3))
a8=str2double(line2(e1(2)+4:e1(3)+3))
a9=str2double(line2(e1(3)+4:e1(4)+3))
a10=str2double(line2(e1(4)+4:e1(5)+3))
%reading of 3rd line
line3=fgetl(f1)
e2=strfind(line3,'E')
a11=str2double(line3(1:e2(1)+3))
a12=str2double(line3(e2(1)+4:e2(2)+3))
a13=str2double(line3(e2(2)+4:e2(3)+3))
a14=str2double(line3(e2(3)+4:e2(4)+3))
%assume a array for temperature and universal constant'R'
R= 8.314;
T=linspace (llt,lht,200);
%functions for entrophy
cp=Specific_heats(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,lmt);
H=enthalphy_H(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,lmt);
s=entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,lmt);
%plotting the point
figure(1)
plot(T,cp,'LineWidth',4,'Color','r')
title(C)
xlabel('temperature')
ylabel('specificheat')
figure(2)
plot(T,H,'linewidth',4,'Color','g')
title(C)
xlabel('temperature')
ylabel('enthalphy')
figure(3)
plot(T,s,'LineWidth',4,'Color','b')
title(C)
xlabel('temperature')
ylabel('entropy')
C=B{1}
mkdir(C)
cd(C)
saveas(1,'specific heat','jpg')
saveas(2,'enthalpy','jpg')
saveas(3,'entropy','jpg')
cd ..
M= molecular_mass(C)
end
fclose(f1)
PLOTS:
The plot of Element o2(in order of Enthalpy,Entropy,Specific heat)
The plot of Element N2(in order of Enthalpy,Entropy,Specific heat)
The plot of Element CO2(in order of Enthalpy,Entropy,Specific heat)
Screenshot of the different folders created:
Screenshot of molecular mass(from command window):
ERRORS:I got a error from all the species folder creation that should be overcome with the help of supportive person.The screenshot is uploaded below.
CONCLUSION:The codes has been created successfully and the folder has been created seperately by using the matlab.
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 2
AIM: To develop the forward energy-based fuel Consumption model of a P1 hybrid vehicle by using the matlab and simulink. Overview: 1. Hybrid Electric vehicle: Using the Two or more energy sources to propulsion system in driving is called the Hybrid Electric Vehicle. Conventionally,petroleum fuel based energy source (Petrol,deisel,etc..)via…
30 Jun 2022 03:17 PM IST
Project 2 Adaptive Cruise Control
EV BATCH17 AIM: To develop a model of adaptive cruise control by using the matlab. Objective: Development of a MATLAB Simulink Model for Adaptive Cruise Control feature as per the requirement document following Model Based Development(MBD) related process.SLDD creation,configuration parameter changes,Model advisor check…
27 Jun 2022 07:56 AM IST
Project 1 (Mini Project on Vehicle Direction Detection
AIM: To develop the model of vehicle direction by using the matlab. OBJECTIVE: The objective of this project is to create a MBD complaint MATLAB Simulink model for a vehicle direction dectection as per the requirement specified. Tag the requirements to the simulink model;Requirement 1 & Requirement 2 are tagged…
26 Jun 2022 06:30 AM IST
Project 2 Thermal modeling of battery pack
EV BATCH17 AIM: To design a 10 series lithium ion battery model,simulate the thermal effects by using the matlab. abstract: Lithium ion (Li-ion) battery pack is a complex system consisting of numerous cells connected in parallel and series. The performance of the pack is highly dependent on the health of each individual…
18 Jun 2022 09:46 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.