So for we have chosen simulations that never reach the edge or the boundary. We have either limited the time or, as with the particle in a box, setup a potential that forces the wave function to zero at the boundary. For many examples, this is sufficient. However, in general, we have to deal with the wave function at the boundary of our simulation. This example shows a wave packet that interacts with the boundary almost immediately.
Clearly the behavior at the boundary does not reflect physical reality. We can find the cause if we look at the update equations, and consider their evaluation at the ends of the grid.
To update the real part of the wave function
and to update the imaginary part we have
Remember that the terms like on the right side correspond to texture reads.
For simplicity focus on the right side of the grid. On the right edge, the problematic term is , which reads beyond the edge of the grid.
Remember that when we setup the textures, we set
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
So that when we read beyond the edge of the grid, we get the value at the edge. Clearly we need to do better for a realistic physical simulation.
This issue of what to do at the boundary of a simulation is one that recurs again and again in scientific computing. Indeed, the solution we will put forward borrows directly from the methods developed for electromagnetic fields.
We impose a wave equation at the boundary 1, and numerically only treat the part that propagates from the interior region outward to the boundary. This is referred to as a one way wave equation.
Of course the wave equation is not an exact match for the Schrödinger equation. However, the errors introduced by using the wave equation along the boundary are small compare to the errors introduced without this treatment of the boundary. We will see an obvious improvement.
The one way wave equation is a close kin to the standard wave equation. We start with a standard wave equation, then factor it into operators.
Now, we can look at each of these differential operators separately. which has solutions of the form , representing a leftward propagating wave. Impose this condition on the left edge of the grid, allowing only outward bound waves.
has solutions of the form , representing a rightward propagating wave. Impose this condition at the right edge of the grid restricting the solution to rightward, outward, propagating waves.
Work through the application along the right edge in detail then carry what we learn over to the left edge.
Write out expressions for the space and time derivatives at the edge of the grid as finite differences.
We might be tempted substitute these expressions directly into the one way wave equation, but we can't quite do that yet. Something a little bit subtle has happened here. These expressions are defined at different locations, and we need to do a little more work before we have an optimal solution.
Luckily there is a simple process to shift the derivatives onto a common location. Average the x derivative at t with a similar derivative at t+Δt. This shifts the derivative from to .
Similarly, evaluate the derivative at . Averaging this with the derivative at shifts the derivative from to .
This gives us new expressions for the derivatives. .
Put these expressions into the one way wave equation for the right edge, giving a slightly long, but luckily not very complicated, expression.
Rearrange terms to get an expression for at the right edge of the grid at the most advanced time in the simulation.
A similar process gives us an expression for at the left ( ) edge.
These update equations are significantly different from those we have seen before. In the next section we will see that they can be expressed elegantly with OpenGL geometry and shaders.