Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C language In a heat transfer course the following description of the temperatur

ID: 3828352 • Letter: C

Question

C language

In a heat transfer course the following description of the temperature distribution in a fat rectangular metal plate is derived. The temperature is held constant at T_1 on three sides and at T_2 on the fourth side. The temperature T at a location with coordinates x and y is given by the formula: T = (T_2 - T_1) * wsum + T_1 where wsum = 2/n sigma^infinite n add 2/n sin(n pi x/L)sinh(n pi y/L)/sinh(n pi W/L) In function main declare and initialize temperatures T_1 = 70 degrees F, T_2 = 200 degrees F and plate dimensions W = 2 and L = 2. Also declare a dimensional array of temperatures with 11 rows and 11 columns. Call a function to calculate the temperatures from x = 0 to 2.0 and y from 0 to 2.0, at intervals of o.2 feet in both x and y directions. Function parameters should be the temperatures T_1 and T_2 W, L and the two dimensional array of temperatures. This is a triple nested loop problem. Allow the value of n to start at 1 and at intervals of 2, for computing wsum at each grid point. (The values will not converge exactly at the 200-degree edge, but come closer and closer to converging as the number of terms in wsum increases) Place the temperatures in the two dimensional array with 11 rows and 11 columns. Note that the temperature array subscripts must be integers, so x and y must be related to the array subscripts. in a second function, print the array of temperatures showing the temperature distribution on the plate. Print each temperature with one decimal digit.

Explanation / Answer

#include <stdio.h>
#include <math.h>
/*This function used to calculate temperature
using the given parameters.
The formula for calculating temp is
T(x,y)=(T2 – T1) * wsum + T1
wsum=2/pi((summation(n is odd, to infinity)((2/n) * sin((n*pi*x)/L)) * (sinh((n*pi*y/L)) / (sinh((n*pi*W)/L))) */

double calctemp(int t1,int t2,int w,int L,double t[11][11])
{
  
float x,y;
double s1,s2,s3,wsum,sum,pi;
pi=3.14159;
int n,i=0,j=0;
sum=0;
for(x=0;x<=2;x=x+0.2)
{
for(y=0;y<=2;y=y+0.2)
{
for(n=1;n<=201;n=n+2)
{
s1=(n*pi*x)/L;
s2=(n*pi*y)/L;
s3=(n*pi*w)/L;
sum=sum+((2/n) * (sin(s1)*(sinh(s2)/sinh(s3))));
}
wsum = (2/pi)*sum;
j++;

}
t[i][j]=((t2-t1) * wsum)+t1;
i++;
  
  
}
return t;
}
/* function for prints outpur*/
void printres(double Temp[11][11])
{
int i,j;
double x=0,y=0;
for(i=0;i<11;i++)
{
for(j=0;j<11;j++)
{
  
printf("Temp(%d,%d) is %d",x,y,Temp[i][j]);
y=y+0.2;
}
x=x+0.2;
}
}
int main()
{
int T1=70,T2=200,W=2,L=2;
double T[11][11];
  
  
calctemp(T1,T2,W,L,T);
printres(T);
  

return 0;
}