Hello ppl. I have wriiten a code in C to check the convergence of an iterative process. But when I run it in Turbo C without running it shows error- "nvtdm has stopped working". What could that be? And how to solve this problem?
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
int n,m,limiter,i,j,z;
float s[100][100],s0[100][100];
float dt,dx,dy,tol,dfmax1,dfabs1;
limiter=50;
printf ("Enter no of grid points:", m);
scanf ("%d", &m);
printf ("Enter tolerence:", tol);
scanf ("%f", &tol);
printf ("Enter time step:", dt);
scanf ("%f", &dt);
n=(m-1);
dx = 1.0/(n-1);
dy = 1.0/(n-1);
for (i=0;i<=n;i++)
{
for (j=0;j<=n;j++)
{
s0[i][j]=0.0;
}
}
for (z=1;z<=limiter;z++)
{
for (i=1;i<n;i++)
{
for (j=1;j<n;j++)
{
s[i][j]=(s0[i-1][j]+s0[i][j-1]+s0[i+1][j]+s0[i][j+1]+1*dx*dx)/4;
}
}
dfmax1=0.0;
for (i=1;i<n;i++)
{
for (j=1;j<n;j++)
{
dfabs1= abs(s[i][j]-s0[i][j]);
if (dfabs1>dfmax1)
dfmax1=dfabs1;
}
}
printf ("%f ", dfmax1);
for (i=1;i<n;i++)
{
for (j=1;j<n;j++)
{
s0[i][j]=s[i][j];
}
}
if (dfmax1<tol)
{
break;
}
}
printf ("no of iterations for iner loop:%d\n ", z);
for (j=n;j>=0;j--)
{
for (i=0;i<=n;i++)
{
printf ("%f ", s0[i][j]);
}
printf ("\n");
}
}



LinkBack URL
About LinkBacks



