The equations of tree_d_3d.simulation , declared on the code that implements them and checked by the tests.
Isolated, nonrelativistic electrostatic N-body dynamics in a plane.
motion m i v ˙ i = q i ( E ( r i ) + v i × B z z ^ ) , r ˙ i = v i , E ( r i ) = k e E r a w ( r i ; 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) m i v ˙ i = q i ( E ( r i ) + v i × B z z ^ ) , r ˙ i = v i , E ( r i ) = k e E raw ( r i ; j = i ) energy K = 1 2 ∑ i m i v i 2 , U = 1 2 ∑ i q i ϕ i K = \frac12\sum_i m_i v_i^2, \qquad U = \frac12\sum_i q_i \phi_i K = 2 1 i ∑ m i v i 2 , U = 2 1 i ∑ q i ϕ i momentum P = ∑ i m i v i , L z = ∑ i m i ( x i v y , i − y i v x , 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}) P = i ∑ m i v i , L z = i ∑ m i ( x i v y , i − y i v x , i ) absorption removed after a drift if s ( x a x i s − x w a l l ) > 0 , or if the chord r n → r n + 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} removed after a drift if s ( x axis − x wall ) > 0 , or if the chord r n → r n + 1 enters an object method auto : direct if θ = 0 or N c h a r g e d ≤ N d i r e c t ; 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} auto : direct if θ = 0 or N charged ≤ N direct ; else the FMM (log, θ < 1 ), else the tree walk Assumes free space, nonrelativistic, a uniform static B z B_z B z ; the self-field is excluded (j ≠ i j \ne i j = 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 Pair energy for the force kernel, excluding self-energy.
field energy U = 1 2 ∑ i q i ϕ i (the field evaluation of the forces) U = \frac12\sum_i q_i \phi_i \qquad \text{(the field evaluation of the forces)} U = 2 1 i ∑ q i ϕ i (the field evaluation of the forces) coulomb pairs U = k e ∑ i < j q i q j r i j 2 + ε 2 U = k_e \sum_{i<j} \frac{q_i q_j}{\sqrt{r_{ij}^2 + \varepsilon^2}} U = k e i < j ∑ r ij 2 + ε 2 q i q j log pairs U = − k e ∑ i < j q i q j ln r i j 2 + ε 2 r 0 2 U = -k_e \sum_{i<j} q_i q_j \ln\frac{r_{ij}^2 + \varepsilon^2}{r_0^2} U = − k e i < j ∑ q i q j ln r 0 2 r ij 2 + ε 2 Assumes without the self-energy; exact=True sums all pairs, O ( N 2 ) O(N^2) O ( N 2 ) ; otherwise exact for direct sums and accurate to the tree error r 0 r_0 r 0 = reference_radius shifts the log energy, not the forcesElectric half-kick, exact cyclotron drift, electric half-kick.
half kick v − = v n + Δ t 2 m q E n , v n + 1 = v + + Δ t 2 m q E n + 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} v − = v n + 2 m Δ t q E n , v n + 1 = v + + 2 m Δ t q E n + 1 drift r n + 1 = r n + Δ t [ sin α α v − + 1 − cos α α ( v y − , − v x − ) ] , α = q m B z Δ 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 r n + 1 = r n + Δ t [ α sin α v − + α 1 − cos α ( v y − , − v x − ) ] , α = m q B z Δ t rotation v + = R ( − α ) v − = ( v x − cos α + v y − sin α , v y − cos α − v x − 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) v + = R ( − α ) v − = ( v x − cos α + v y − sin α , v y − cos α − v x − sin α ) Order 2 Assumes the drift is the exact solution of v ˙ = ( q B z / m ) ( v y , − v x ) \dot{\mathbf v} = (qB_z/m)(v_y, -v_x) v ˙ = ( q B z / m ) ( v y , − v x ) over Δ t \Delta t Δ t and its time integral, written with sinc α \operatorname{sinc}\alpha sinc α and α 2 sinc 2 α 2 \frac{\alpha}{2}\operatorname{sinc}^2\frac{\alpha}{2} 2 α sinc 2 2 α so the B z → 0 B_z \to 0 B z → 0 limit is exact: velocity Verlet at B z = 0 B_z = 0 B z = 0 explicit: Δ t \Delta t Δ 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