Skip to content

Commit

Permalink
add tests of output resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed May 10, 2024
1 parent e551f23 commit 7877298
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/BasicForParticleSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,41 @@

end

@testitem "ParticleSystem - resize output" begin
using StaticArrays
using CellListMap
function force(x, y, i, j, d2, f)
fxy = (x - y) / d2
f[i] -= fxy
f[j] += fxy
return f
end
x = rand(SVector{3,Float64}, 100)
sides = [1,1,1]
cutoff = 0.1
sys = ParticleSystem(
positions=x,
unitcell=sides,
cutoff=cutoff,
output=zero(x),
output_name = :force
)
naive = CellListMap.map_naive!(force, zero(x), x, Box(sides, cutoff))
map_pairwise!(force, sys)
@test sys.force naive
resize!(x, 120)
x[101:end] .= rand(SVector{3,Float64}, 20)
naive = CellListMap.map_naive!(force, zero(x), x, Box(sides, cutoff))
resize_output!(sys, 120)
map_pairwise!(force, sys)
@test sys.force naive
resize!(x, 90)
naive = CellListMap.map_naive!(force, zero(x), x, Box(sides, cutoff))
resize_output!(sys, 90)
map_pairwise!(force, sys)
@test sys.force naive
end

@testitem "ParticleSystem - update_lists" begin
using StaticArrays
using CellListMap
Expand Down

0 comments on commit 7877298

Please sign in to comment.