The CP for many materials can be expressed by the polynomial: Cp, m = k + a T +
ID: 3697138 • Letter: T
Question
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.
Explanation / Answer
I did : Read the polynome,Model it,Pass to a function to calculate. You will need to find tune the algorithm to your needs since this question is from ¿Chemistry?. Have a good day!
#include <stdio.h>
#include <math.h>
double f1 (double x);
double f2 (double x);
double simpson_13 (double (*f) (double x), double a, double b, int n);
double buildPolynomial();
int
main (void)
{
double chegg;
chegg = buildPolynomial();
double *r = &chegg;
double a, b, n; // limits of integration and number of intervals to integrate
double res;
printf("INTEGRAL DATA");
printf (" ");
printf (" Enter T1,T2,n: ");
scanf ("%lf %lf %lf", &a, &b, &n);
/* Show integral computed with simpson's 1/3 rd rule */
res = simpson_13 (r, a, b, n);
printf (" I_Simpson_13rd (f(x), %g, %g, %g) = %g", a, b, n, res);
printf (" ");
return 0;
}
/* Takes a function pointer which should represent the single variable
* function of which the integral is to be found. The function should
* receive a double and return a double. The limits a and b and the
* number of intervals n is provided. The value returned is the integral
* of the passed function is the argument
*/
double simpson_13 (double (*f) (double x), double a, double b, int n)
{
double h;
double y = 0, x, even = 0, odd = 0, y0, yn;
int i;
h = (b - a) / n;
y0 = f (a);
yn = f (b);
for (i = 1, x = a + h; i < n; x = x + h, i++)
{
if (i % 2 == 0)
even = even + f (x);
else
odd = odd + f (x);
}
y = (h / 3) * ((y0 + yn) + 2 * even + 4 * odd);
return y;
}
double buildPolynomial(){
double k,a,b,c,t; // t will be our "x"
double m;
printf("Enter the value of the coefficient, k:");
scanf("%lf", &k);
printf("Enter the value of the coefficient, a:");
scanf("%lf", &a);
printf("Enter the value of the coefficient, b:");
scanf("%lf", &b);
printf("Enter the value of the coefficient, c:");
scanf("%lf", &c);
printf("Enter the value of the coefficient, T:");
scanf("%lf", &t);
m = c*(t*t*t) + b*(t*t) + a*t + k;
return m;
}