Monday, April 18, 2016

quantum mechanics - Turning a finite difference equation into code (2d Schrodinger equation)


I am trying to convert the following finite difference equations into code (taken from the bottom of page 12 of this thesis by Maike Schulte Numerical Solution of the Schrodinger Equation on Unbounded Domains (2007)) (NB: it's a PDF). Please be aware I don't know a lot about this sort of thing. iD+tψnj,k=22m(D2xψn+1/2j,k+D2yψn+1/2j,k)+Vn+1/2j,kψn+1/2j,k

where D+tψnj,k=ψn+1j,kψnj,kΔtD2xψnj,k=ψnj1,k2ψnj,k+ψnj+1,kΔx2D2yψnj,k=ψnj,k12ψnj,k+ψnj,k+1Δy2
denote the standard finite difference operators and Vn+1/2j=V(xj,tn+1/2)ψn+1/2j,k=12(ψn+1j,k+ψnj,k)



I would like to make a simulation of the general behaviour of the Schrodinger equation in 2d, and scales are unimportant so I figure I can ignore , m, Δt, Δx and Δy, setting them all =1. I am also dropping the potential term setting V=0 for now.


Presumably from the definition of D+t the direction of time is positive thus the aim is to calculate ψn+1. So, the confusing thing, ψn+12 is used on the RHS hence ψn+1 appears in what I'm trying to compute. How can the formula for ψn+1 be expressed purely in terms of $\psi^{0


Answer



The issue is with short-hand notation. The term ψn+1/2j,k being operated on by D2x really means D2xψn+1/2j,k=D2x[12(ψn+1j,k+ψnj,k)]=12D2xψn+1j,k+12D2xψnj,k=12Δx2[ψn+1j1,k+ψn+1j+1,k2ψn+1j,k]+12Δx2[ψnj1,k+ψnj+1,k2ψnj,k]

and similarly for D2yψn+1/2j,k. The definition of ψn+1/2j,k is given in that document. Using this, you'll find something along the lines of αψn+1j+1,k+βψn+1j,k+1+γψn+1j1,k+δψn+1j,k1+ϵψn+1j,k=f(ψn)
where the term on the right side is all the t=n terms and α,β,γ,δ,ϵ are constants of parameters dt,dx2,dy2,m, and i. This is a band-diagonal matrix and can be computed in a number of manners (e.g., sparse matrix solvers or iterative methods).


It was also pointed out in this CompSci post that it might be easier to solve the Schrodinger equation in two pieces, one real and one imaginary (ψ=R+iI) and solve them at alternate half-time steps. Though it might be a little more complex, the method should be extensible to 2D.


In one dimension, you can solve the Crank-Nicolson method with a tri-diagonal matrix algorithm. In 2D, you get a penta-diagonal matrix that is a bit more complicated to solve (cf. this FORTRAN routine by Dr Kevin Kreider at the University of Akron). If you sweep along the dimensions individually (i.e.g, solve x for each y cell and vice versa), you can the aforementioned tri-diagonal solver to solve 2D problems (though it's typically referred to as "alternating direction implicit" when done this way).


Alternatively, you can use some sparse solvers in BLAS routines or try an iterative solver like the Gauss-Seidel method.


No comments:

Post a Comment

classical mechanics - Moment of a force about a given axis (Torque) - Scalar or vectorial?

I am studying Statics and saw that: The moment of a force about a given axis (or Torque) is defined by the equation: $M_X = (\vec r \times \...