- #1
nazmulislam
- 21
- 0
Hi,
I have written some codes for the finite difference solution of diffusion equation (\frac{\partial c}{\partial t}= D {\nabla^2 c}, where c is the species concentration and D is the diffusion coefficient) as follows:
DO k= 1, tsteps+1
DO i = 2, zsteps
DO j = 2, rsteps
cnew(i,j) = c(i,j) + D*dt*((c(i+1,j) - 2.D0*c(i,j) + c(i-1,j))/dz**2 + (c(i,j+1)-2.D0*c(i,j) + c(i,j-1))/dr**2 +
(c(i,j+1) - c(i,j-1))/(r(j)*2.D0*dr))
END DO
END DO
END DO
where 'dt' is the step size in time, 'dz' is the z-step size, 'dr' is the r-step size, 'tsteps' is the number of time steps, 'zsteps' is the number of steps in the z-direction and 'rsteps' is the number of steps in the r-direction.
The code is working only for the square grid (dz=dr), but not working for the non-square grid space.
Can anybody help me in this matter.
Cheers
I have written some codes for the finite difference solution of diffusion equation (\frac{\partial c}{\partial t}= D {\nabla^2 c}, where c is the species concentration and D is the diffusion coefficient) as follows:
DO k= 1, tsteps+1
DO i = 2, zsteps
DO j = 2, rsteps
cnew(i,j) = c(i,j) + D*dt*((c(i+1,j) - 2.D0*c(i,j) + c(i-1,j))/dz**2 + (c(i,j+1)-2.D0*c(i,j) + c(i,j-1))/dr**2 +
(c(i,j+1) - c(i,j-1))/(r(j)*2.D0*dr))
END DO
END DO
END DO
where 'dt' is the step size in time, 'dz' is the z-step size, 'dr' is the r-step size, 'tsteps' is the number of time steps, 'zsteps' is the number of steps in the z-direction and 'rsteps' is the number of steps in the r-direction.
The code is working only for the square grid (dz=dr), but not working for the non-square grid space.
Can anybody help me in this matter.
Cheers