I want to solve the time-dependent Schrodinger Equation using the Crank-Nicolson scheme. I end up with the following matrix equation
A_fixed = ... # the matrix that does the finite difference method
B_fixed = ... # the matrix that does the finite difference method
A = A_fixed - diags(V) # Add the potential term V to the diagonal of A_fixed
B = B_fixed + diags(V) # Add the potential term V to the diagonal of A_fixed
# solve for psi_new at each time step:
A.dot(psi_new) = B.dot(psi_old) # psi_old is the solution at the previous time-step
And $A$ and $B$ are sparse matrices with all the terms along the main/off-diagonals (is this called 'banded'?). What are the best ways to solve for the above matrix equation?
I am using the scipy library sp.sparse.linalg
, where it provides a solve
method which uses LU decomposition. If the potential term $V$ is time-independent, then both $A$ and $B$ are actually fixed throughout the whole computation, so I can use sp.sparse.linalg.factorized
to pre-factorize $A$. This gives me like a 2x speed up.
But what if $V$ is time-varying, so $A$ and $B$ changes at each time step? Are there are algorithms which work for this specific problem (where both $A$ and $B$ consist of fixed terms and some time-varying terms which are only added to the main diagonal)?