ChargedParticles Example Seems Too Boring as an Example of NBodySimulator - Am I doing something wrong?

I am using the NBodySimulator.jl package and trying to understand it to model “blue-noise sampling” (see here if interested: Blue noise sampling using an N-body simulation-based method | SpringerLink).

I am swimming out of my depths a bit, but feel that if I see a “charged particles” example that does something, that would aid my understanding. Running the documented example from the documentation (link here) reproduced below with my choice for coulomb’s constant, k:

using NBodySimulator
using StaticArrays
using Plots

## I supplied k - is it wrong
k = 8.987551787368177e9
r = 100.0 # m
q1 = 1e-3 # C
q2 = -1e-3 # C
m1 = 100.0 # kg
m2 = 0.1 # kg
v2 = sqrt(abs(k * q1 * q2 / m2 / r)) # m/s - using the centrifugal acceleration
t = 2 * pi * r / v2 # s  - for one rotation
p1 = ChargedParticle(SVector(0.0, 0.0, 0.0), SVector(0.0, 0, 0.0), m1, q1)
p2 = ChargedParticle(SVector(100.0, 0.0, 0.0), SVector(0.0, v2, 0.0), m2, q2)
system = ChargedParticles([p1, p2], k)
simulation = NBodySimulation(system, (0.0, t))
sim_result = run_simulation(simulation)

plot(sim_result)  ## plot seems too boring

the plot does not show anything happening. The points/particles just sit there being all boring-like without any path trace shown:

Is there something I am doing wrong or something I can adjust to at least see a movement path of some kind? I would think the particles might move towards one another since they are oppositely charged.

I got some kind help suggesting using animate instead of plot. Now I can see the dynamics much better.

animate(sim_result, "path_to_animated_particles.gif", fps = 120,xlims=(-150,150),ylims=(-150,150))


I guess plot does not show the trace path as it does for some other examples. Thx for the help!!

1 Like