Skip to content

Commit

Permalink
update CellListMap usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiq committed May 2, 2024
1 parent c6f3f34 commit 65657c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Packmol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using TestItems
using Parameters
using StaticArrays
import CellListMap
using CellListMap.PeriodicSystems
using CellListMap
using SPGBox
import LinearAlgebra: norm
import Statistics: mean
Expand Down
10 changes: 5 additions & 5 deletions src/mono_atomic.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CellListMap.PeriodicSystems
using CellListMap
using StaticArrays
using SPGBox

Expand All @@ -11,7 +11,7 @@ mutable struct MonoAtomicFG{N,T}
end

# Custom copy, reset and reducer functions
import CellListMap.PeriodicSystems: copy_output, reset_output!, reducer
import CellListMap: copy_output, reset_output!, reducer
copy_output(x::MonoAtomicFG) = MonoAtomicFG(x.f, copy(x.g), x.dmin)
function reset_output!(output::MonoAtomicFG{N,T}) where {N,T}
output.f = zero(T)
Expand Down Expand Up @@ -127,7 +127,7 @@ function pack_monoatomic!(
cutoff = (volume / ncells)^(1/N)
println("Using cell list cutoff: ", cutoff)
println("Using packing tolerance: ", packing_tol)
system = PeriodicSystem(
system = ParticleSystem(
xpositions=positions,
unitcell=unitcell,
cutoff=cutoff,
Expand Down Expand Up @@ -160,14 +160,14 @@ end
@testitem "gradient" begin
using StaticArrays
using FiniteDifferences
using CellListMap.PeriodicSystems
using CellListMap
import Packmol: MonoAtomicFG, fg!

# Testing function that computes the function value with the definition
# of fg! above, to use finite-differences to check the gradient
function f(x; dimension=2, unitcell=[1, 1], tol=0.1, parallel=false, return_grad=false)
positions = [SVector{dimension}(x[i:i+dimension-1]) for i in 1:dimension:length(x)]
system = PeriodicSystem(
system = ParticleSystem(
xpositions=positions,
unitcell=unitcell,
cutoff=tol,
Expand Down
8 changes: 4 additions & 4 deletions src/rigid_body.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function random_move!(
scale = 100.0

# Generate random coordinates for the center of mass
cmin, cmax = PeriodicSystems.get_computing_box(system)
cmin, cmax = CellListMap.get_computing_box(system)
newcm = SVector{3}(scale * (cmin[i] + rand(RNG, Float64) * (cmax[i] - cmin[i])) for i in 1:3)

# Generate random rotation angles
Expand All @@ -132,7 +132,7 @@ end
using Packmol
using StaticArrays
using LinearAlgebra: norm
using CellListMap.PeriodicSystems
using CellListMap
import Random

function check_internal_distances(x, y)
Expand All @@ -151,7 +151,7 @@ end
RNG = Random.Xoshiro()
# Orthorhombic cell
x = [-1.0 .+ 2 * rand(SVector{3,Float64}) for _ = 1:5]
system = PeriodicSystem(positions=x, cutoff=0.1, unitcell=SVector(10.0, 10.0, 10.0), output=0.0)
system = ParticleSystem(positions=x, cutoff=0.1, unitcell=SVector(10.0, 10.0, 10.0), output=0.0)
@test check_internal_distances(x, Packmol.random_move!(copy(x), 1, system, RNG))
system.xpositions .= [-9.0 .+ 2 * rand(SVector{3,Float64}) for _ = 1:5]
@test check_internal_distances(x, Packmol.random_move!(copy(x), 1, system, RNG))
Expand All @@ -160,7 +160,7 @@ end

# Triclinic cell
x = [-1.0 .+ 2 * rand(SVector{3,Float64}) for _ = 1:5]
system = PeriodicSystem(positions=x, cutoff=0.1, unitcell=@SMatrix[10.0 5.0 0.0; 0.0 10.0 0.0; 0.0 0.0 10.0], output=0.0)
system = ParticleSystem(positions=x, cutoff=0.1, unitcell=@SMatrix[10.0 5.0 0.0; 0.0 10.0 0.0; 0.0 0.0 10.0], output=0.0)
@test check_internal_distances(x, Packmol.random_move!(copy(x), 1, system, RNG))
system.xpositions .= [-9.0 .+ 2 * rand(SVector{3,Float64}) for _ = 1:5]
@test check_internal_distances(x, Packmol.random_move!(copy(x), 1, system, RNG))
Expand Down

0 comments on commit 65657c7

Please sign in to comment.