Julia 中 3d 晶格上的时间相关薛定谔方程

Time-dependent Schrodinger equation on 3d lattice in Julia

我想用 DifferentialEquations.jl,
求解 3d 晶格上的矩阵形式的时间相关薛定谔方程 即,(∂/∂t)ψ = -iHψ ,其中 ψ 是向量,H 是(时间无关的)矩阵。
我试过这样写代码。

#Define the underlying equation
function time_evolution(ψdot,ψ,p,t)
  ψdot.=-im.*H(Lx,Ly,Lz)*ψ
end

Lx = Ly = Lz = 10
ψ0 = [] #  Initial conditions
σ = sqrt(5/2)

for iz = 1:Lz
    for ix = 1:Lx
        for iy = 1:Ly                  
           gauss = (1/(sqrt(2*π)*σ)^3)*exp(-((ix)^2 + (iy)^2 + (iz)^2)/(2*(σ)^2))
           push!(ψ0,gauss)                           
        end
    end
end

tspan = (0.,1.0) #  Simulation time span


#Pass to Solvers
prob = ODEProblem(time_evolution,ψ0,tspan)
sol = solve(prob)

这里,H(Lx,Ly,Lz)是一个N×N矩阵,由系统大小Lx,Ly,Lz参数化,N = Lx×Ly×Lz。
但是这段代码有错误。

WhosebugError:
Stacktrace:
 [1] recursive_unitless_bottom_eltype(::Type{Any}) at 
/Users/username/.julia/packages/RecursiveArrayTools/OAIEc/src/utils.jl:86 (repeats 
80000 times)

代码哪里错了?

ψ0 = [] #  Initial conditions

您可能不希望 non-concretely 键入方程式,因此您可能想要

ψ0 = Float64[] #  Initial conditions