Schrödinger equation
Go back to Examples.
2D infinite square well
We are solving a Schrödinger equation for a quantum particle that is confined to a 2-dimensional square box, 0<x<L and 0<y<L. Within this square the particle behaves as a free particle, but the walls are impenetrable, so the wave function is zero at the walls. This is described by the infinite potential
V(x)= \begin{cases} 0, &0<x<L,\: 0<y<L, \\ \infty, &{\text{otherwise.}} \end{cases}
With this potential Schrodinger equation simplifies to -{\hbar^2 \over 2m} \nabla^2 \Psi(x,y,t) = i\hbar {\partial \over \partial t}\Psi(x,y,t),
The solution \Psi(x,y,t) must therefore satisfy \nabla^2 \Psi = -i{\partial \over \partial t}\Psi \quad \text{in} \quad \Omega,
Once we prepare the domain and operators, we can turn the Schrodinger equation into code. As we are solving the time propagation implicitly, we will have to solve a matrix equation for every step. For this reason a space matrix M is constructed. Next the equations are implemented, psi denotes the matrix solution for each step and rhs the right-hand side of the matrix equation which is in our case equivalent to the previous state psi .
1 Eigen::SparseMatrix<std::complex<double>, Eigen::RowMajor> M(N, N);
2 // set initial state
3 for(int i : domain.interior()) {
4 double x = domain.pos(i, 0);
5 double y = domain.pos(i, 1);
6 rhs(i) = sin(PI * x) * sin(PI * y);
7 }
8
9 // set equation on interior
10 for(int i : domain.interior()) {
11 op.value(i) + (-1.0i) * dt * op.lap(i) = rhs(i);
12 }
13
14 // set equation on boundary
15 for (int i: domain.boundary()){
16 op.value(i) = 0;
17 }
At each time step the matrix equation is solved using an Eigen linear equation solver, in this case, the BICGStab algorithm, and rhs is updated.
1 // solve matrix system
2 psi = solver.solve(rhs);
3
4 // update rhs
5 rhs = psi;
The animation of the real part of solution \Re \Psi(x,y) is presented below.
Go back to Examples.