Minor refactoring
This commit is contained in:
parent
37e01c254b
commit
17d729f007
|
|
@ -16,7 +16,7 @@ struct Hamiltonian{T}
|
||||||
function Hamiltonian{T}(s::system{T}, V_twobody::Function, ϕ::Real, n_image::Int, mode::Hamiltonian_backend) where {T<:Float}
|
function Hamiltonian{T}(s::system{T}, V_twobody::Function, ϕ::Real, n_image::Int, mode::Hamiltonian_backend) where {T<:Float}
|
||||||
@assert mode != gpu_cutensor || CUDA.functional() && CUDA.has_cuda() && CUDA.has_cuda_gpu() "CUDA not available"
|
@assert mode != gpu_cutensor || CUDA.functional() && CUDA.has_cuda() && CUDA.has_cuda_gpu() "CUDA not available"
|
||||||
k = -s.N÷2:s.N÷2-1
|
k = -s.N÷2:s.N÷2-1
|
||||||
Vs = calculate_Vs(V_twobody, s, convert(T, ϕ), n_image)
|
Vs = calculate_Vs(s, V_twobody, convert(T, ϕ), n_image)
|
||||||
hermitian = ϕ == 0.0
|
hermitian = ϕ == 0.0
|
||||||
K_partial = (exp(-im * convert(T, ϕ)) * im / sqrt(2 * s.μ)) .* ∂_1DOF.(Ref(s), k, k')
|
K_partial = (exp(-im * convert(T, ϕ)) * im / sqrt(2 * s.μ)) .* ∂_1DOF.(Ref(s), k, k')
|
||||||
K_diag = nothing
|
K_diag = nothing
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ function get_Δk(s::system, i::CartesianIndex, dim::Int, p1::Int, p2::Int)::Int
|
||||||
end
|
end
|
||||||
|
|
||||||
"Calculate diagonal elements of the V matrix"
|
"Calculate diagonal elements of the V matrix"
|
||||||
function calculate_Vs(V_twobody::Function, s::system{T}, ϕ::T, n_image::Int)::Array{Complex{T}} where {T<:Float}
|
function calculate_Vs(s::system{T}, V_twobody::Function, ϕ::T, n_image::Int)::Array{Complex{T}} where {T<:Float}
|
||||||
coeff² = (exp(im * ϕ) * s.L / s.N)^2
|
coeff² = (exp(im * ϕ) * s.L / s.N)^2
|
||||||
images = collect.(Iterators.product(fill(-n_image:n_image, s.d)...)) # TODO: Learn how to use tuples instead of vectors
|
images = collect.(Iterators.product(fill(-n_image:n_image, s.d)...)) # TODO: Learn how to use tuples instead of vectors
|
||||||
Vs = zeros(Complex{T}, fill(s.N, s.d * (s.n - 1))...)
|
Vs = zeros(Complex{T}, fill(s.N, s.d * (s.n - 1))...)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue