Skip to content
Projects

Trajectories

The equations of beamtracer.solver.tracer, declared on the code that implements them and checked by the tests.

beam_with_energy

functionsource

Seed a beam emitted from a line with a given energy; return it and J / v.

positions
xk=a+k+1/2N(b−a),k=0,…,N−1\mathbf x_k = \mathbf a + \frac{k + 1/2}{N} (\mathbf b - \mathbf a), \qquad k = 0, \dots, N - 1
velocities
v=v0n^+σ⊥g1t^+σ∥g2n^ (+σ⊥g3z^ cylindrical),n^=(ty,−tx)\mathbf v = v_0 \hat{\mathbf n} + \sigma_\perp g_1 \hat{\mathbf t} + \sigma_\parallel g_2 \hat{\mathbf n} \ (+ \sigma_\perp g_3 \hat{\mathbf z} \text{ cylindrical}), \qquad \hat{\mathbf n} = (t_y, -t_x)
speed
v0=2Eem,σ∥,⊥=T∥,⊥ em,ρ0=Jv0v_0 = \sqrt{\frac{2 E e}{m}}, \qquad \sigma_{\parallel,\perp} = \sqrt{\frac{T_{\parallel,\perp}\, e}{m}}, \qquad \rho_0 = \frac{J}{v_0}
ring
Ik=2πJs rkN (cylindrical, a ring),Ik=JsN [A/m] (planar)I_k = \frac{2\pi J s\, r_k}{N} \text{ (cylindrical, a ring)}, \qquad I_k = \frac{J s}{N} \text{ [A/m] (planar)}
Assumes
  • ss the length of the emission line from a\mathbf a to b\mathbf b, t^\hat{\mathbf t} its direction; the beam moves to its right
  • g1,2,3g_{1,2,3} standard normal: an unscrambled 3D Sobol sequence (origin skipped) through the inverse normal, the same beam on every call, so the Vlasov iteration has a fixed point
  • the ring currents sum to JπR2J \pi R^2 up to the midpoint rule's O(N−2)O(N^{-2}) for a line along rr

BeamTracer

classsource

Trace particles through a static electric (and magnetic) field.

rk4
yn+1=yn+Δt6(k1+2k2+2k3+k4),y=(x,v),y˙=(v,a(x,v))\mathbf y^{n+1} = \mathbf y^n + \frac{\Delta t}{6}(\mathbf k_1 + 2\mathbf k_2 + 2\mathbf k_3 + \mathbf k_4), \qquad \mathbf y = (\mathbf x, \mathbf v), \quad \dot{\mathbf y} = (\mathbf v, \mathbf a(\mathbf x, \mathbf v))
step
Δt=fmin⁡(h∣v∣,2h∣a∣),0<f≤1\Delta t = f \min\left(\frac{h}{|\mathbf v|}, \sqrt{\frac{2h}{|\mathbf a|}}\right), \qquad 0 < f \le 1
Order
4
Assumes
  • ff = step_fraction (0.5 by default); a non-finite estimate (a particle at rest without force) falls back to fhf h
  • each particle has its own step; the field at the stage points
  • the order is that of the integrator in Δt\Delta t; the plane crossings are interpolated linearly along a step
Built from

acceleration

functionsource

Return the acceleration (3, N) at positions x and velocities v.

motion
dxdt=v,dvdt=qm(E+v×B)\frac{d\mathbf x}{dt} = \mathbf v, \qquad \frac{d\mathbf v}{dt} = \frac{q}{m}\left(\mathbf E + \mathbf v \times \mathbf B\right)
planar
E=(Ex,Ey,0)(x,y)+Eimp(x,y),B=B(x,y)\mathbf E = (E_x, E_y, 0)(x, y) + \mathbf E_\mathrm{imp}(x, y), \qquad \mathbf B = \mathbf B(x, y)
cylindrical
r=y2+z2,E=Exx^+Err^+Eimp,B=Bxx^+Brr^+Bθθ^,θ^=x^×r^r = \sqrt{y^2 + z^2}, \qquad \mathbf E = E_x \hat{\mathbf x} + E_r \hat{\mathbf r} + \mathbf E_\mathrm{imp}, \qquad \mathbf B = B_x \hat{\mathbf x} + B_r \hat{\mathbf r} + B_\theta \hat{\boldsymbol\theta}, \qquad \hat{\boldsymbol\theta} = \hat{\mathbf x} \times \hat{\mathbf r}
mean charge
q=qˉ=e∑szsFs(charge changes in fractions mode)q = \bar q = e \sum_s z_s F_s \quad \text{(charge changes in fractions mode)}
Assumes
  • non-relativistic; 3D Cartesian motion in fields of (x,y)(x, y) or (x,r)(x, r), so a trajectory crossing the axis continues at negative yy
  • cylindrical: a trajectory stands for a ring of charge; on the axis r^=0\hat{\mathbf r} = 0, so ErE_r and BrB_r do not act there
  • the imposed Eimp\mathbf E_\mathrm{imp} and B\mathbf B (solenoids, a field map) are static and given in the plane: (x, y) or (x, r), the cylindrical ones axial, radial (and azimuthal)

trace

functionsource

Trace particles until they leave the mesh or hit an electrode.

charge
ΔQ=sign⁡(q) I Δtor, with charge changes,ΔQ=Nk e∑szsFˉs Δt\Delta Q = \operatorname{sign}(q)\, I\, \Delta t \quad \text{or, with charge changes,} \quad \Delta Q = N_k\, e \sum_s z_s \bar F_s\, \Delta t
midpoint
x1/2=12(x+x′)+Δt8(v−v′)\mathbf x_{1/2} = \tfrac12 (\mathbf x + \mathbf x') + \frac{\Delta t}{8} (\mathbf v - \mathbf v')
weights
wx=x−xih,wr=r2−rj2rj+12−rj2 (cylindrical),wy=y−yjh (planar)w_x = \frac{x - x_i}{h}, \qquad w_r = \frac{r^2 - r_j^2}{r_{j+1}^2 - r_j^2} \ \text{(cylindrical)}, \quad w_y = \frac{y - y_j}{h} \ \text{(planar)}
volumes
ρij=QijVj,Vj=h2 (planar),Vj=πh(rj+1/22−rj−1/22)=2πrjh2,V0=πh3\rho_{ij} = \frac{Q_{ij}}{V_j}, \qquad V_j = h^2 \ \text{(planar)}, \quad V_j = \pi h (r_{j+1/2}^2 - r_{j-1/2}^2) = 2\pi r_j h^2, \quad V_0 = \pi h^3
path
Δs=12Δt (∣v∣+∣v′∣)×the share of the step inside the mesh\Delta s = \tfrac12 \Delta t\, (|\mathbf v| + |\mathbf v'|) \times \text{the share of the step inside the mesh}
Assumes
  • a steady trajectory of current II is a line charge I/vI / v, so a step holds IΔtI \Delta t; currents are magnitudes, the sign is the charge's
  • x1/2\mathbf x_{1/2} the cubic Hermite interpolant at the half step; charge outside the mesh goes to the boundary nodes, whose densities are doubled (half cells)
  • a trajectory ends transmitted (x≥xmaxx \ge x_\mathrm{max}), backward (x<xminx < x_\mathrm{min}), on the wall, on an electrode (tested in the cells touching one) or after max_steps, tested at the end of each step
  • Fˉ\bar F the mean of the fractions before and after the step; with MPI the node charges are summed over the ranks
Built from