朱莉娅3d晶格上随时间变化的薛定inger方程 [英] Time-dependent Schrodinger equation on 3d lattice in Julia
本文介绍了朱莉娅3d晶格上随时间变化的薛定inger方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 DifferentialEquations.jl来解决3d晶格上矩阵形式的时间相关Schrodinger方程,
即(∂/∂t)ψ= -i H ψ,其中ψ是一个向量,H是一个(与时间无关的)矩阵。 br />
我试图编写这样的代码。
I want to solve the matrix-form time-dependent Schrodinger equation on 3d lattice with DifferentialEquations.jl,
i.e., (∂/∂t)ψ = -iHψ ,where ψ is a vector and H is a (time-independent) matrix.
I tried to write the code like this.
#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来参数化。 />
但是此代码有错误。
Here,H(Lx,Ly,Lz) is a N×N matrix parameterized by systemsize Lx,Ly,Lz and N = Lx×Ly×Lz.
But this code has an error.
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
您可能不希望方程式为非具体类型,因此您可能想这样做
You probably don't want your equation to be non-concretely typed, so you likely want to do
ψ0 = Float64[] # Initial conditions
这篇关于朱莉娅3d晶格上随时间变化的薛定inger方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文