Possible bug fixes

This commit is contained in:
ysyapa 2023-08-29 22:11:02 +00:00
parent 543e9c7714
commit e7fa5c3b3c
1 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ which_index(s::system, dim::Int, coord::Int)::Int = (dim - 1) * (s.n - 1) + coor
function nearest(s::system, Δk::Int)::Int function nearest(s::system, Δk::Int)::Int
# TODO: Optimize # TODO: Optimize
while true while true
if Δk > s.N ÷ 2 if Δk > (s.N ÷ 2 - 1)
Δk -= s.N Δk -= s.N
elseif Δk < -s.N ÷ 2 elseif Δk < -s.N ÷ 2
Δk += s.N Δk += s.N
@ -63,7 +63,7 @@ function calculate_Vs(s::system{T}, V_twobody::Function, ϕ::T, n_image::Int)::A
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))...)
Threads.@threads for i in CartesianIndices(Vs) Threads.@threads for i in CartesianIndices(Vs)
xs = reshape(collect(Tuple(i)), s.n - 1, s.d) .- (s.N ÷ 2 - 1) xs = reshape(collect(Tuple(i)), s.n - 1, s.d) .- (s.N ÷ 2 + 1)
rs = s.invU * xs rs = s.invU * xs
for p1 in 1:s.n for p1 in 1:s.n
for p2 in 1:(p1 - 1) for p2 in 1:(p1 - 1)