Download Canvas

Potential(x,y) Using Laplace's Equation Div(gradV)=0 with Variable Boundary Geometry

Potentials are interesting because of their gradients. If the potential refers to a temperature, the rate of heat flow is proportional to its gradient. If it refers to an electrical voltage, the force on a small charged particle is proportional to its gradient. Potentials can be defined by their values at the boundaries of the domain. The normal gradient of the potential on some of the boundary segments can be set to a constant which means that the heat flow or force at these boundaries is proportional to that constant. The task here is to find the potential inside the boundaries. Here I will use a more complicated outer boundary and the boundary potentials will be variable in value and position. We generally have rectangular bounds. The potential at the top is V=Vt (except in the center gap where the potential is zero) and the potential in the bottom block is V=Vb (plotted in black) The height of the bottom block is modulated with a 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 and the dielectric constant is the same everywhere, the differential equation for the potential, V, is Div(grad(V))=0. We start by makeing a crude guess, V, for the potential at all points inside the rectangle. 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]). For this equation i is the y (row) variable and j is the x (column) variable and space between points is 1.This equation for the second derivative yields 2nd order accuracy. To get the equilibrium values at all V[i][j] this equation is iterated for all internal (free) points many, many times. In the animation, the height of the indent of the bottom square wave is oscillated in order to see how the potential contours move within the rectangle. Before each iteration normal gradients of the sides are 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