Skip to content

Commit 88dc18c

Browse files
committed
bug in SHAKE constructor when no dist constraints passed
1 parent a37df91 commit 88dc18c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/constraints/shake.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ of the linear system solved to satisfy the RATTLE algorithm.
3434
distance constraints to be applied. If `nothing`, no distance constraints are applied.
3535
- `angle_constraints`: A vector of [`AngleConstraint`](@ref) objects that define the
3636
angle constraints to be applied. If `nothing`, no angle constraints are applied.
37-
- `gpu_block_size`: The number of threads per block to use for GPU calculations.
37+
- `gpu_block_size`: The number of threads per block to use for GPU calculations. Defaults to 128.
3838
- `max_iters`: The maximum number of iterations to perform when doing SHAKE. Defaults to 25.
3939
"""
4040
struct SHAKE_RATTLE{A, B, C, D, E, F, I <: Integer}
@@ -53,19 +53,25 @@ function SHAKE_RATTLE(n_atoms,
5353
vel_tolerance;
5454
dist_constraints = nothing,
5555
angle_constraints = nothing,
56-
gpu_block_size = 64, max_iters = 25)
56+
gpu_block_size = 128, max_iters = 25)
57+
58+
dc_isnothing = isnothing(dist_constraints)
59+
ac_isnothing = isnothing(angle_constraints)
60+
61+
dc_length = dc_isnothing ? 0 : length(dist_constraints)
62+
ac_length = ac_isnothing ? 0 : length(angle_constraints)
5763

5864
ustrip(dist_tolerance) <= 0.0 && throw(ArgumentError("dist_tolerance must be greater than zero"))
5965
ustrip(vel_tolerance) <= 0.0 && throw(ArgumentError("vel_tolerance must be greater than zero"))
60-
(isnothing(dist_constraints) && isnothing(angle_constraints)) && throw(ArgumentError("At least one of dist_constraints or angle_constraints must be provided"))
61-
(length(dist_constraints) < 0 && length(angle_constraints) < 0) && throw(ArgumentError("At least one of dist_constraints or angle_constraints must be non-empty"))
66+
(dc_isnothing && ac_isnothing) && throw(ArgumentError("At least one of dist_constraints or angle_constraints must be provided"))
67+
(dc_length == 0 && ac_length == 0) && throw(ArgumentError("At least one of dist_constraints or angle_constraints must be non-empty"))
6268

63-
if !isnothing(dist_constraints) && length(dist_constraints) == 0
69+
if !dc_isnothing && dc_length == 0
6470
@warn "You passed an empty vector for `dist_constraints`, no distance constraints will be applied."
6571
dist_constraints = nothing
6672
end
6773

68-
if !isnothing(angle_constraints) && length(angle_constraints) == 0
74+
if !ac_isnothing && ac_length == 0
6975
@warn "You passed an empty vector for `angle_constraints`, no angle constraints will be applied."
7076
angle_constraints = nothing
7177
end

0 commit comments

Comments
 (0)