The equations of beamtracer.solver.fields , declared on the code that implements them and checked by the tests.
A static axisymmetric magnetic field from its on-axis profile B_z(z).
expansion B z = ∑ k ( − 1 ) k ( r 2 ) 2 k B ( 2 k ) ( k ! ) 2 , B r = ∑ k ( − 1 ) k + 1 ( r 2 ) 2 k + 1 B ( 2 k + 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)!} B z = k ∑ ( − 1 ) k ( 2 r ) 2 k ( k ! ) 2 B ( 2 k ) , B r = k ∑ ( − 1 ) k + 1 ( 2 r ) 2 k + 1 k ! ( k + 1 )! B ( 2 k + 1 ) truncated B z = B − r 2 4 B ′ ′ + r 4 64 B ′ ′ ′ ′ − r 6 2304 B ( 6 ) , B r = − r 2 B ′ + r 3 16 B ′ ′ ′ − r 5 384 B ( 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)} B z = B − 4 r 2 B ′′ + 64 r 4 B ′′′′ − 2304 r 6 B ( 6 ) , B r = − 2 r B ′ + 16 r 3 B ′′′ − 384 r 5 B ( 5 ) stencils B i ( k ) = 1 Δ z k ∑ a = − 3 3 c a ( k ) B i + a , of orders 6 , 6 , 4 , 4 , 2 , 2 for k = 1 , … , 6 B^{(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 B i ( k ) = Δ z k 1 a = − 3 ∑ 3 c a ( k ) B i + a , of orders 6 , 6 , 4 , 4 , 2 , 2 for k = 1 , … , 6 interpolation B ( k ) ( z ) = ( 1 − t ) B i ( k ) + t B i + 1 ( k ) , t = z − z 0 Δ z − i B^{(k)}(z) = (1 - t)\, B^{(k)}_i + t\, B^{(k)}_{i+1}, \qquad t = \frac{z - z_0}{\Delta z} - i B ( k ) ( z ) = ( 1 − t ) B i ( k ) + t B i + 1 ( k ) , t = Δ z z − z 0 − i Order 2 Assumes current-free and divergence-free near the axis; B z B_z B z kept to r 2 ⌊ n / 2 ⌋ r^{2\lfloor n/2\rfloor} r 2 ⌊ n /2 ⌋ and B r B_r B r to r 2 ⌈ n / 2 ⌉ − 1 r^{2\lceil n/2\rceil - 1} r 2 ⌈ n /2 ⌉ − 1 for order n ≤ 6 n \le 6 n ≤ 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 ∇ ⋅ B = 0 to O ( Δ z 2 ) O(\Delta z^2) O ( Δ z 2 ) : B z B_z B z is interpolated linearly, B r B_r B r uses the differenced derivativesthe order is in the sample spacing Δ z \Delta z Δ z , between the samples (the linear interpolation) References Return the on-axis B_z [T] of a thin-walled solenoid scaled to peak [T].
shape B ( z ) = B 0 S ( z ) S ( c ) , S ( z ) = z − c + L / 2 ( z − c + L / 2 ) 2 + a 2 − z − c − L / 2 ( z − c − L / 2 ) 2 + a 2 B(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}} B ( z ) = B 0 S ( c ) S ( z ) , S ( z ) = ( z − c + L /2 ) 2 + a 2 z − c + L /2 − ( z − c − L /2 ) 2 + a 2 z − c − L /2 Assumes a thin-walled solenoid (a finite current sheet) of length L L L , winding radius a a a and centre c c c ; S S S is its on-axis field in units of μ 0 n I / 2 \mu_0 n I / 2 μ 0 n I /2 scaled so that B 0 B_0 B 0 is the field at the centre BeamOptics samples the solenoids at Δ z = h / 2 \Delta z = h/2 Δ z = h /2 from x m i n − 8 Δ z x_\mathrm{min} - 8\Delta z x min − 8Δ z to x m a x + 8 Δ z x_\mathrm{max} + 8\Delta z x max + 8Δ z , or adds them to a measured axial fieldThe electric field of a potential on the edges between nodes.
edges E x , i − 1 / 2 , j = ϕ i − 1 , j − ϕ i , j h , E y , i , j − 1 / 2 = ϕ i , j − 1 − ϕ i , j h E_{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} E x , i − 1/2 , j = h ϕ i − 1 , j − ϕ i , j , E y , i , j − 1/2 = h ϕ i , j − 1 − ϕ i , j surface E edge = ± ϕ near − ϕ electrode d h between a near-solid node and its electrode node E_\text{edge} = \pm\frac{\phi_\text{near} - \phi_\text{electrode}}{d\, h} \quad \text{between a near-solid node and its electrode node} E edge = ± d h ϕ near − ϕ electrode between a near-solid node and its electrode node faces E face = − E first (mirror: the axis) or E face = 2 E first − E second (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)} E face = − E first (mirror: the axis) or E face = 2 E first − E second (linear) interpolation E ( x , y ) = bilinear interpolation on each staggered grid , E x at the index x − x 0 h + 1 2 E(x, y) = \text{bilinear interpolation on each staggered grid}, \qquad E_x \text{ at the index } \frac{x - x_0}{h} + \tfrac12 E ( x , y ) = bilinear interpolation on each staggered grid , E x at the index h x − x 0 + 2 1 Order 2 Assumes d d d the bracketed distance to the surface in units of h h h ; on an edge inside an electrode the field is extrapolated from the one adjacent surface, if there is exactly onethe axis of a cylindrical mesh mirrors, so E r = 0 E_r = 0 E r = 0 there; the other faces extrapolate linearly points outside the mesh are clamped to its edges; the order is in h h h , away from electrodes and faces Return |E| [V/m] at the free nodes next to an electrode, and that electrode.
component E x , node = { E on the edge to the electrode a solid neighbour on one side the larger in magnitude solid neighbours on both sides 1 2 ( E i − 1 / 2 + E i + 1 / 2 ) none E_{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} E x , node = ⎩ ⎨ ⎧ E on the edge to the electrode the larger in magnitude 2 1 ( E i − 1/2 + E i + 1/2 ) a solid neighbour on one side solid neighbours on both sides none magnitude ∣ E ∣ = E x 2 + E y 2 at the near-solid nodes |E| = \sqrt{E_x^2 + E_y^2} \quad \text{at the near-solid nodes} ∣ E ∣ = E x 2 + E y 2 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