Write a C code to compute the thermodynamic functions molar

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.

Solution

I have attached two separate codes for the enthalpy and entrophy calculation. I have taken the polynomial function Cpm = K + a*T + b*T*T where K-69.62, a-0.00753, b--1406000 (assumed, you may change the value as you know)

Code1: ENTHALPY


#include<stdio.h>
#include<conio.h>
#include<math.h>
float f(float T);

{
      return(69.6 + (0.00753*T) + (-1.406000*T*T));
}   
int main()
{
int n,i;
float s1=0,s2=0,sum,a,b,h;
printf(\"Enter the value of upper limit = \");
scanf(\"%f\",&b);
printf(\"Enter the value of lower limit = \");
scanf(\"%f\",&a);
printf(\"Enter the number of intervals = \");
scanf(\"%d\",&n);
h=(b-a)/n;
if(n%2==0)
{
for(i=1;i<=n-1;i++)
{
     if(i%2==0)
       {
            s1=s1+f(a+i*h);
        }
        else
        {
            s2=s2+f(a+i*h);
         }
}
sum=h/3*(f(a)+f(b)+4*s2+2*s1);
printf(\"the Enthalpy value is = %f\",sum);
}
else
{
printf(\"the rule is not appliciable\");
}
getch();
}

Code2: Entrophy

#include<stdio.h>
#include<conio.h>
#include<math.h>
float f(float T);

{
      return((69.6 + (0.00753*T) + (-1.406000*T*T))/T);
}   
int main()
{
int n,i;
float s1=0,s2=0,sum,a,b,h;
printf(\"Enter the value of upper limit = \");
scanf(\"%f\",&b);
printf(\"Enter the value of lower limit = \");
scanf(\"%f\",&a);
printf(\"Enter the number of intervals = \");
scanf(\"%d\",&n);
h=(b-a)/n;
if(n%2==0)
{
for(i=1;i<=n-1;i++)
{
     if(i%2==0)
       {
            s1=s1+f(a+i*h);
        }
        else
        {
            s2=s2+f(a+i*h);
         }
}
sum=h/3*(f(a)+f(b)+4*s2+2*s1);
printf(\"the Entrophy value is = %f\",sum);
}
else
{
printf(\"the rule is not appliciable\");
}
getch();
}

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site