Question: finite difference schemes with continuous boundaries

hello, first post here.

i'm attempting to solve the 1 d heat equation using a finite difference scheme, with continous boundaries eg.

for j from 2 to m-1 do
       for i from 1 to n do
 if i=1 then
       f[i,j+1]:=f[i,j]+d*(f[i+1,j]-2*f[i,j]+f[n,j])
 elif i=n then
       f[i,j+1]:=f[i,j]+d*(f[1,j]-2*f[i,j]+f[i-1,j])
 else
       f[i,j+1]:=f[i,j]+d*(f[i+1,j]-2*f[i,j]+f[i-1,j]);
 end if;
 end do; end do:

a matrix f[n,m] has already been set up, n and i corespond to the spatial profile/steps,  j and m to the temporal.

the if and elif statement take care of the boundaries i = 1 and i= n, making sure it is continuous, whilst the else part fills up the rest of the spatial line. then the whole thing steps forward one time step j.

the problem is, it does not work at all.

i

Please Wait...