Sie sind auf Seite 1von 1

#include <stdio.

h>
#include <math.h>
#define td 0.000000143
#define tk 0.591
int main()
{
double t[200], pt[200], maxer, e[200], a, b, c, dx=0.5, A, B, h, l;
int i, it, n, z;
do
{
it=0;
maxer=1;
printf("\nEnter the value of convection heat transfer coefficient: ");
scanf("%lf", &h);
A=(0.06*0.00001)/td;
B=(0.06*h)/tk;
a=(1/(dx*dx))-(A/(2*dx));
b=(2/(dx*dx))+B;
c=(1/(dx*dx))+(A/(2*dx));
t[0]=1;
for(i=1;i<200;i++)
t[i]=0;
do
{
if(it>0)
{
for(i=1;i<n;i++)
pt[i]=t[i];
}
i=1;
do
{
t[i]=((t[i+1]*a)+(t[i-1]*c))/b;
i++;
}while(t[i-1]>0.0001);
l=(i-1)*dx*0.06;
printf("\nIteration %d\tNumber of nodes = %d\tLength of the channel =
%0.2fm", it+1, i, l);
n=i;
if(it>0)
{
for(i=1;i<n;i++)
e[i]=fabs(pt[i]-t[i]);
maxer=e[1];
for(i=2;i<n;i++)
{
if(e[i]>maxer)
maxer=e[i];
}
}
it++;
}while(maxer>0.001);
printf("\n\nPress 1 for a different heat transfer coefficient: ");
scanf("%d", &z);
}while(z==1);
}

Das könnte Ihnen auch gefallen