Skip to content

Commit

Permalink
add distributed for long direct
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrogantGao committed Apr 3, 2024
1 parent 5dc4204 commit 6097617
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "1.0.0-DEV"

[deps]
ChebParticleMesh = "1983ef0c-217d-4026-99b0-9163e7750d85"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
ExTinyMD = "fec76197-d59f-46dd-a0ed-76a83c21f7aa"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
FastChebInterp = "cf66c380-9a80-432c-aff8-4f9c79c0bdde"
Expand Down
1 change: 1 addition & 0 deletions src/FastSpecSoG.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module FastSpecSoG

using Distributed
using ExTinyMD, LinearAlgebra, SpecialFunctions, ChebParticleMesh, SumOfExpVPMR, LoopVectorization, OMEinsum, FastChebInterp, Polynomials, FFTW

import FastChebInterp: ChebPoly
Expand Down
12 changes: 4 additions & 8 deletions src/energy/energy_long_naive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,13 @@ function long_energy_us_k(qs::Vector{T}, poses::Vector{NTuple{3, T}}, accuracy::
@assert M_min 1
@assert M_max length(uspara.sw)

Ek = zero(T)

for l in M_min:M_max
Ek = @distributed (+) for l in M_min:M_max
s, w = uspara.sw[l]
# accuracy = exp(-k^2 * s^2 / 4)
km = sqrt(-4 * log(accuracy) / s^2)
# km = π * n / max{L_x, L_y, L_z}
cutoff = ceil(Int, km * maximum(L) / 2π) + 1
Ek += long_energy_sw_k(qs, poses, cutoff, L, s, w)
long_energy_sw_k(qs, poses, cutoff, L, s, w)
end
@debug "long range energy, direct su, k" Ek

Expand All @@ -121,11 +119,9 @@ function long_energy_us_0(qs::Vector{T}, poses::Vector{NTuple{3, T}}, L::NTuple{
@assert M_min 1
@assert M_max length(uspara.sw)

E0 = zero(T)

for l in M_min:M_max
E0 = @distributed (+) for l in M_min:M_max
s, w = uspara.sw[l]
E0 += long_energy_sw_0(qs, poses, L, s, w)
long_energy_sw_0(qs, poses, L, s, w)
end
@debug "long range energy, direct sum, zeroth mode" E0

Expand Down

0 comments on commit 6097617

Please sign in to comment.