Skip to content
Projects

Particle pusher

The equations of tree_d_3d.simulation, declared on the code that implements them and checked by the tests.

ElectrostaticSimulation

classsource

Isolated, nonrelativistic electrostatic N-body dynamics in a plane.

motion
miv˙i=qi(E(ri)+vi×Bzz^),r˙i=vi,E(ri)=ke Eraw(ri; j≠i)m_i \dot{\mathbf v}_i = q_i\big(\mathbf E(\mathbf r_i) + \mathbf v_i \times B_z\hat{\mathbf z}\big), \qquad \dot{\mathbf r}_i = \mathbf v_i, \qquad \mathbf E(\mathbf r_i) = k_e\, \mathbf E_\mathrm{raw}(\mathbf r_i;\, j \ne i)
energy
K=12∑imivi2,U=12∑iqiϕiK = \frac12\sum_i m_i v_i^2, \qquad U = \frac12\sum_i q_i \phi_i
momentum
P=∑imivi,Lz=∑imi(xivy,i−yivx,i)\mathbf P = \sum_i m_i \mathbf v_i, \qquad L_z = \sum_i m_i (x_i v_{y,i} - y_i v_{x,i})
absorption
removed after a drift if s (xaxis−xwall)>0, or if the chord rn→rn+1 enters an object\text{removed after a drift if } s\,(x_\mathrm{axis} - x_\mathrm{wall}) > 0, \text{ or if the chord } \mathbf r^n \to \mathbf r^{n+1} \text{ enters an object}
method
auto:direct if θ=0 or Ncharged≤Ndirect; else the FMM (log, θ<1), else the tree walk\texttt{auto}: \text{direct if } \theta = 0 \text{ or } N_\mathrm{charged} \le N_\mathrm{direct}; \text{ else the FMM (log, } \theta < 1\text{), else the tree walk}
Assumes
  • free space, nonrelativistic, a uniform static BzB_z; the self-field is excluded (j≠ij \ne i); fixed sources never move
  • finite-θ\theta forces are not pairwise symmetric (except the FMM with symmetric=True): momentum and energy are conserved to the tree error
  • absorbing walls and objects only remove particles: no image charges, no wall potential
Built from

get_potential_energy

functionsource

Pair energy for the force kernel, excluding self-energy.

field energy
U=12∑iqiϕi(the field evaluation of the forces)U = \frac12\sum_i q_i \phi_i \qquad \text{(the field evaluation of the forces)}
coulomb pairs
U=ke∑i<jqiqjrij2+ε2U = k_e \sum_{i<j} \frac{q_i q_j}{\sqrt{r_{ij}^2 + \varepsilon^2}}
log pairs
U=−ke∑i<jqiqjln⁡rij2+ε2r02U = -k_e \sum_{i<j} q_i q_j \ln\frac{r_{ij}^2 + \varepsilon^2}{r_0^2}
Assumes
  • without the self-energy; exact=True sums all pairs, O(N2)O(N^2); otherwise exact for direct sums and accurate to the tree error
  • r0r_0 = reference_radius shifts the log energy, not the forces

step

functionsource

Electric half-kick, exact cyclotron drift, electric half-kick.

half kick
v−=vn+Δt2m qEn,vn+1=v++Δt2m qEn+1\mathbf v^- = \mathbf v^n + \frac{\Delta t}{2m}\, q\mathbf E^n, \qquad \mathbf v^{n+1} = \mathbf v^+ + \frac{\Delta t}{2m}\, q\mathbf E^{n+1}
drift
rn+1=rn+Δt[sin⁡αα v−+1−cos⁡αα (vy−,−vx−)],α=qmBzΔt\mathbf r^{n+1} = \mathbf r^n + \Delta t\left[\frac{\sin\alpha}{\alpha}\, \mathbf v^- + \frac{1 - \cos\alpha}{\alpha}\, (v^-_y, -v^-_x)\right], \qquad \alpha = \frac{q}{m} B_z \Delta t
rotation
v+=R(−α) v−=(vx−cos⁡α+vy−sin⁡α, vy−cos⁡α−vx−sin⁡α)\mathbf v^+ = R(-\alpha)\, \mathbf v^- = \big(v^-_x\cos\alpha + v^-_y\sin\alpha,\ v^-_y\cos\alpha - v^-_x\sin\alpha\big)
Order
2
Assumes
  • the drift is the exact solution of v˙=(qBz/m)(vy,−vx)\dot{\mathbf v} = (qB_z/m)(v_y, -v_x) over Δt\Delta t and its time integral, written with sinc⁡α\operatorname{sinc}\alpha and α2sinc⁡2α2\frac{\alpha}{2}\operatorname{sinc}^2\frac{\alpha}{2} so the Bz→0B_z \to 0 limit is exact: velocity Verlet at Bz=0B_z = 0
  • explicit: Δt\Delta t must resolve close encounters and the plasma period; the magnetic rotation is exact for any α\alpha
  • one field evaluation per step (cached); particles are absorbed after the drift, before the end-of-step fields