;PRO demo_laplace ;Show smoothing for small and large scale ;perturbations ;Aim: Solve Poisson equation in 2D ;-Laplace phi=rho ;device,decompose=0 ;Setup the grid Lx=10.0 Ly=10.0 h=0.4; grid resolution; try also h=0.2 and h=0.1 nx=long(Lx/h+1) ny=long(Ly/h+1) nx=40 &ny=nx h=Lx/(nx-1) print,'nx=',nx,' ,ny=',ny x=Lx*findgen(nx)/(nx-1) y=Ly*findgen(ny)/(ny-1) phi=fltarr(nx,ny) ; ;Some initialization rho=fltarr(nx,ny) xv=fltarr(nx,ny) yv=fltarr(nx,ny) for iy=0,ny-1 do xv[*,iy]=x for ix=0,nx-1 do yv[ix,*]=y ; ;Sources rho(x,y) x0=5.0 & y0=5.0 x1=8.0 & y1=4.0 l=1.0; How extended are the charges? ;Feel Free to add more or less electric charges rho=0.0*exp(-((xv-x0)^2+(yv-y0)^2)/l) $ -0.0*exp(-((xv-x1)^2+(yv-y1)^2)/l) phi_new=phi ; k=1 print,'Input wave number of disturbance:' read, k hu=1.0*sin(k*!pi*xv/Lx)*sin(k*!pi*yv/Ly) phi=phi+hu ; method=1 print,' ' print,'Which method to use?' print,'1=Jacobi, 2=Gauss-Seidel, 3=SOR' read,method tol=1.0e-6; Tolerance level for error w=1.0 ; for overrelextion: 1.0