The CP for many materials can be expressed by the polynomial
The CP for many materials can be expressed by the polynomial: Cp, m = k + a T + b T 2 + c T 3 (1) Write a C code to compute the thermodynamic functions molar Enthalpy (H) and Entropy (S), with an option for user to input the temperature range, the number of intervals (n) to compute the area under the curve using the Simpson’s 1/3 rule, the coefficients a, b, c and constant k in the polynomial approximation of Cp. (2) Using the code developed in the previous task compute molar H and S for -ZrO2. Based on experimental observations the Cp of -ZrO2. can be written as: Cp, m = 69.62 + 7.53 10-3 T - 14.06 105 T -2 . Calculate the Enthalpy (H) and Entropy (S) for the above material using the following values: T1= 293K T2=500K n = 500.
Solution
I\'m not the best programming in C, anyways, the entalpy of a substance is equal to the integral from T=T1 to T=T2 of Cp*dT, and the entropy for a non-compressible fluid is given by S = Integral from T0 to Tn of Cp/T*dT.
I give you two codes, one for entalpy and one for entropy:
For the entalpy:
#include<stdio.h>
int main (int argc, char *argv[])
{
int i,500;
float x0=293,xn=500,h,y[501],so,se,ans,x[501];
h=(xn-x0)/n;
for(i=0; i<=n; i++)
{
x[i]=x0+i*h;
y[i]=69.62+7.53*x[i]/1000-14.06*x[i]*x[i]/100000;
}
so=0;
se=0;
for(i=1; i<n; i++)
{
if(i%2==1)
{
so=so+y[i];
}
else
{
se=se+y[i];
}
}
ans=h/3*(y[0]+y[n]+4*so+2*se);
printf(\"\ Final integration for H =\" %f,ans);
}
For the entropy:
#include<stdio.h>
int main ()
{
int i,500;
float x0=293,xn=500,h,y[501],so,se,ans,x[501];
h=(xn-x0)/n;
for(i=0; i<=n; i++)
{
x[i]=x0+i*h;
y[i]=69.62/x[i]+7.53/1000-14.06*x[i]/100000;
}
so=0;
se=0;
for(i=1; i<n; i++)
{
if(i%2==1)
{
so=so+y[i];
}
else
{
se=se+y[i];
}
}
ans=h/3*(y[0]+y[n]+4*so+2*se);
printf(\"\ Final integration for H =\" %f,ans);
}
good luck

