Skip to content

Commit b5c5a3a

Browse files
committed
More minor cleanup
1 parent 247261b commit b5c5a3a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/nbody_simulation_result.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,24 +199,25 @@ function lennard_jones_potential(p::LennardJonesParameters, indxs::Vector{<:Inte
199199
end
200200

201201
function electrostatic_potential(p::ElectrostaticParameters, indxs::Vector{<:Integer}, exclude::Dict{Int,Vector{Int}}, qs, rs, pbc::BoundaryConditions)
202-
e_el = 0
202+
e_el = 0.0
203203

204204
n = length(indxs)
205205
for ind_i = 1:n
206206
i = indxs[ind_i]
207207
ri = @SVector [rs[1, i], rs[2, i], rs[3, i]]
208-
e_el_i = 0
208+
e_el_i = 0.0
209209
for ind_j = ind_i + 1:n
210210
j = indxs[ind_j]
211211
if !in(j, exclude[i])
212212
rj = @SVector [rs[1, j], rs[2, j], rs[3, j]]
213213

214214
(rij, r, r2) = get_interparticle_distance(ri, rj, pbc)
215-
if !(r2 < p.R2)
216-
rij = p.R # NOTE: hmm?
217-
end
218215

219-
e_el_i += qs[j] / norm(rij)
216+
if r2 < p.R2
217+
e_el_i += qs[j] / r
218+
else
219+
e_el_i += qs[j] / p.R
220+
end
220221
end
221222
end
222223
e_el += e_el_i * qs[i]

0 commit comments

Comments
 (0)