朱莉娅3d晶格上随时间变化的薛定inger方程

问题描述

我想用DifferentialEquations.jl来求解3d晶格上与时间有关的矩阵形式的薛定inger方程,
即(∂/∂t)ψ= -i H ψ,其中ψ是向量,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参数化。
但是此代码有错误。

StackOverflowError:
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

您可能不希望方程式是非具体输入的,所以您可能想要这样做

ψ0 = Float64[] #  Initial conditions

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...