diff --git a/contents/split-operator_method/code/julia/split_op.jl b/contents/split-operator_method/code/julia/split_op.jl index 7fd771601..fcdaeddcc 100644 --- a/contents/split-operator_method/code/julia/split_op.jl +++ b/contents/split-operator_method/code/julia/split_op.jl @@ -33,8 +33,8 @@ end mutable struct Operators V::Vector{Complex{Float64}} - PE::Vector{Complex{Float64}} - KE::Vector{Complex{Float64}} + R::Vector{Complex{Float64}} + K::Vector{Complex{Float64}} wfc::Vector{Complex{Float64}} Operators(res) = new(Vector{Complex{Float64}}(res), @@ -49,11 +49,11 @@ function init(par::Param, voffset::Float64, wfcoffset::Float64) opr.V = 0.5 * (par.x - voffset).^2 opr.wfc = exp.(-(par.x - wfcoffset).^2/2) if (par.im_time) - opr. = exp.(-0.5*par.k.^2*par.dt) - opr.PE = exp.(-0.5*opr.V*par.dt) + opr.K = exp.(-0.5*par.k.^2*par.dt) + opr.R = exp.(-0.5*opr.V*par.dt) else - opr. = exp.(-im*0.5*par.k.^2*par.dt) - opr.PE = exp.(-im*0.5*opr.V*par.dt) + opr.K = exp.(-im*0.5*par.k.^2*par.dt) + opr.R = exp.(-im*0.5*opr.V*par.dt) end return opr @@ -64,19 +64,19 @@ function split_op(par::Param, opr::Operators) for i = 1:par.timesteps # Half-step in real space - opr.wfc = opr.wfc .* opr.PE + opr.wfc = opr.wfc .* opr.R # fft to momentum space opr.wfc = fft(opr.wfc) # Full step in momentum space - opr.wfc = opr.wfc .* opr. + opr.wfc = opr.wfc .* opr.K # ifft back opr.wfc = ifft(opr.wfc) # final half-step in real space - opr.wfc = opr.wfc .* opr.PE + opr.wfc = opr.wfc .* opr.R # density for plotting and potential density = abs2.(opr.wfc) diff --git a/contents/split-operator_method/split-operator_method.md b/contents/split-operator_method/split-operator_method.md index 429218866..4152dc760 100644 --- a/contents/split-operator_method/split-operator_method.md +++ b/contents/split-operator_method/split-operator_method.md @@ -103,7 +103,7 @@ Regardless, we first need to set all the initial parameters, including the initi As a note, when we generate our grid in momentum space `k`, we need to split the grid into two lines, one that is going from `0` to `-kmax` and is then discontinuous and goes from `kmax` to `0`. This is simply because the FFT will naturally assume that the `0` in our grid is at the left side of the simulation, so we shift k-space to match this expectation. -Also, for this code we will be using the notation from above: `opr.R` will be the real space operators and `opr.M` will be the momentum space operators. +Also, for this code we will be using notation to what we used above: `opr.R` will be the real space operators and `opr.K` will be the momentum space operators. There is another boolean value here called `im_time`, which is for imaginary time evolution. Afterwards, we turn them into operators: