Download Canvas

Potential(x,y) Using Laplace's Equation Div(gradV)=0 with Mixed BCs

Here I will use a more complicated mix of Neumann (normal gradient=0) and Dirichlet (value) Boundary Conditions and the boundary potentials will be variable in time and position. We have rectangular bounds. The potential at the top is V=1 (exceptin the center gap where the normal gradient is zero) and the potential at the bottom is is a square wave (plotted in black) with time dependent amplitude. At the left and right sides of the rectangle the normal gradient is again zero. When the charge density, rho, is zero, the differential equation for the potential, V, is Div(grad(V))=0 where I will assume that the dielectric constant is constant=1 here. For the finite difference method that I used to refine the guess, I very strongly recommend the following link: http://www.iosrjournals.org/iosr-jm/papers/Vol6-issue4/K0646675.pdf. This solution uses the "5 point stencil" where V[i][j]=1/4(V[i-1][j]+V[i+1][j]+V[i][j-1]+V[i][j+1]). This equation for the second derivative yields 2nd order accuracy. I also include an option for 4th order accuracy which seems to converge with less iterations. To get the equilibrium values at all V[i][j] this equation is iterated for all internal (free) points many, many times. For this equation i is the y (row) variable and j is the x (column) variable and space between points is 1. In the animation, the potential on the bottom square wave is oscillated in order to see how the potential contours move within the rectangle. At the top of the rectangle, the normal gradient is set to zero within the central gap so the potential contours are normal to the gap there. Before each iteration this and the sides normal gradient is set to zero by an equation like V[0][j]=1/4*(2V[1][j]+V[0][j+1]+V[0][j-1]]). Since the calculation can require several minutes, the frames are saved to an array which can be played back at any time. To avoid confusion, it is better to press the "Stop" button before playing back the movie. As always, the learner is welcome to press the F12 button on Windows to view the Javascript code.
imageCanvas