Skip to content
Projects

Fields

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

AxisymmetricMagneticField

classsource

A static axisymmetric magnetic field from its on-axis profile B_z(z).

expansion
Bz=∑k(−1)k(r2)2kB(2k)(k!)2,Br=∑k(−1)k+1(r2)2k+1B(2k+1)k! (k+1)!B_z = \sum_k (-1)^k \left(\frac{r}{2}\right)^{2k} \frac{B^{(2k)}}{(k!)^2}, \qquad B_r = \sum_k (-1)^{k+1} \left(\frac{r}{2}\right)^{2k+1} \frac{B^{(2k+1)}}{k!\,(k+1)!}
truncated
Bz=B−r24B′′+r464B′′′′−r62304B(6),Br=−r2B′+r316B′′′−r5384B(5)B_z = B - \frac{r^2}{4} B'' + \frac{r^4}{64} B'''' - \frac{r^6}{2304} B^{(6)}, \qquad B_r = -\frac{r}{2} B' + \frac{r^3}{16} B''' - \frac{r^5}{384} B^{(5)}
stencils
Bi(k)=1Δzk∑a=−33ca(k)Bi+a,of orders 6,6,4,4,2,2 for k=1,…,6B^{(k)}_i = \frac{1}{\Delta z^k} \sum_{a=-3}^{3} c^{(k)}_a B_{i+a}, \quad \text{of orders } 6, 6, 4, 4, 2, 2 \text{ for } k = 1, \dots, 6
interpolation
B(k)(z)=(1−t) Bi(k)+t Bi+1(k),t=z−z0Δz−iB^{(k)}(z) = (1 - t)\, B^{(k)}_i + t\, B^{(k)}_{i+1}, \qquad t = \frac{z - z_0}{\Delta z} - i
Order
2
Assumes
  • current-free and divergence-free near the axis; BzB_z kept to r2⌊n/2⌋r^{2\lfloor n/2\rfloor} and BrB_r to r2⌈n/2⌉−1r^{2\lceil n/2\rceil - 1} for order n≤6n \le 6
  • at least 8 samples; the three end samples have no derivatives, and beyond the valid cells the derivatives are extrapolated linearly
  • ∇⋅B=0\nabla \cdot \mathbf B = 0 to O(Δz2)O(\Delta z^2): BzB_z is interpolated linearly, BrB_r uses the differenced derivatives
  • the order is in the sample spacing Δz\Delta z, between the samples (the linear interpolation)
References

solenoid_on_axis

functionsource

Return the on-axis B_z [T] of a thin-walled solenoid scaled to peak [T].

shape
B(z)=B0S(z)S(c),S(z)=z−c+L/2(z−c+L/2)2+a2−z−c−L/2(z−c−L/2)2+a2B(z) = B_0 \frac{S(z)}{S(c)}, \qquad S(z) = \frac{z - c + L/2}{\sqrt{(z - c + L/2)^2 + a^2}} - \frac{z - c - L/2}{\sqrt{(z - c - L/2)^2 + a^2}}
Assumes
  • a thin-walled solenoid (a finite current sheet) of length LL, winding radius aa and centre cc; SS is its on-axis field in units of μ0nI/2\mu_0 n I / 2
  • scaled so that B0B_0 is the field at the centre
  • BeamOptics samples the solenoids at Δz=h/2\Delta z = h/2 from xmin−8Δzx_\mathrm{min} - 8\Delta z to xmax+8Δzx_\mathrm{max} + 8\Delta z, or adds them to a measured axial field

StaggeredElectricField

classsource

The electric field of a potential on the edges between nodes.

edges
Ex, i−1/2, j=ϕi−1,j−ϕi,jh,Ey, i, j−1/2=ϕi,j−1−ϕi,jhE_{x,\, i-1/2,\, j} = \frac{\phi_{i-1,j} - \phi_{i,j}}{h}, \qquad E_{y,\, i,\, j-1/2} = \frac{\phi_{i,j-1} - \phi_{i,j}}{h}
surface
Eedge=±ϕnear−ϕelectroded hbetween a near-solid node and its electrode nodeE_\text{edge} = \pm\frac{\phi_\text{near} - \phi_\text{electrode}}{d\, h} \quad \text{between a near-solid node and its electrode node}
faces
Eface=−Efirst (mirror: the axis)orEface=2Efirst−Esecond (linear)E_\text{face} = -E_\text{first} \ \text{(mirror: the axis)} \quad \text{or} \quad E_\text{face} = 2 E_\text{first} - E_\text{second} \ \text{(linear)}
interpolation
E(x,y)=bilinear interpolation on each staggered grid,Ex at the index x−x0h+12E(x, y) = \text{bilinear interpolation on each staggered grid}, \qquad E_x \text{ at the index } \frac{x - x_0}{h} + \tfrac12
Order
2
Assumes
  • dd the bracketed distance to the surface in units of hh; on an edge inside an electrode the field is extrapolated from the one adjacent surface, if there is exactly one
  • the axis of a cylindrical mesh mirrors, so Er=0E_r = 0 there; the other faces extrapolate linearly
  • points outside the mesh are clamped to its edges; the order is in hh, away from electrodes and faces

surface_field

functionsource

Return |E| [V/m] at the free nodes next to an electrode, and that electrode.

component
Ex,node={E on the edge to the electrodea solid neighbour on one sidethe larger in magnitudesolid neighbours on both sides12(Ei−1/2+Ei+1/2)noneE_{x,\text{node}} = \begin{cases} E \text{ on the edge to the electrode} & \text{a solid neighbour on one side} \\ \text{the larger in magnitude} & \text{solid neighbours on both sides} \\ \tfrac12 (E_{i-1/2} + E_{i+1/2}) & \text{none} \end{cases}
magnitude
∣E∣=Ex2+Ey2at the near-solid nodes|E| = \sqrt{E_x^2 + E_y^2} \quad \text{at the near-solid nodes}
Assumes
  • the edge to an electrode is taken over the bracketed distance to its surface, so it is the field at the surface
  • at a sharp corner the field is singular and this value grows as the mesh is refined: round the electrode edges whose field matters
Built from