A filtered Boris algorithm for charged-particle dynamics in a strong magnetic field

A modification of the standard Boris algorithm, called filtered Boris algorithm, is proposed for the numerical integration of the equations of motion of charged particles in a strong non-uniform magnetic field in the asymptotic scaling known as maximal ordering. With an appropriate choice of filters, second-order error bounds in the position and in the parallel velocity, and first-order error bounds in the normal velocity are obtained with respect to the scaling parameter. The proof compares the modulated Fourier expansions of the exact and the numerical solutions. Numerical experiments illustrate the error behaviour of the filtered Boris algorithm.


Introduction x(t) =ẋ(t) × B(x(t), t) + E(x(t), t)
with B(x, t) = 1 ε B 0 (εx) + B 1 (x, t) for 0 < ε 1. (1.1) This scaling is of interest in particle methods in plasma physics and is called maximal ordering in [2]; see also [12] for a careful discussion of scalings and a rigorous analysis of this model. It is assumed that |B 0 (0)| ≥ 1, that B 0 , B 1 and E are smooth functions that are bounded independently of ε on bounded domains together with all their derivatives, and that the initial data x(0) = x 0 ,ẋ(0) = v 0 are bounded independently of ε.
In (1.1), x(t) ∈ R 3 represents the position at time t of a charged particle (of unit mass and charge) that moves in the magnetic field B and the electric field E. The motion is composed of fast rotation around a guiding center (with the Larmor radius proportional to ε) and slow motion of the guiding center.
The standard integrator for charged particles in a magnetic field is the Boris algorithm [1] (see also, e.g., [6]), which in the two-step formulation with step size h is given by with the velocity approximation v n = 1 2h x n+1 − x n−1 at time t n = nh. This algorithm does, however, not behave well for (1.1) with small ε. Here we propose a modification, which we name filtered Boris algorithm. This modified integrator allows us to obtain better accuracy with considerably larger time steps, at minor additional computational cost. It is still a symmetric algorithm. We formulate and discuss this new algorithm in Sect. 2. It comes in different variants that depend on the choice of a suitable filter function and of the positions where the magnetic field is evaluated, and we identify favourable choices.
A different approach to numerical integrators for charged particles in a strong magnetic field is taken in [3], where damping linearly implicit integrators are studied. For step sizes h ≥ ε, those integrators quickly reduce that part of the kinetic energy that comes from the velocity component perpendicular to the magnetic field. As is shown in [3], the numerical solution then approximates a numerical solution of an asymptotic model for guiding-center motion. In contrast, the original Boris method and the filtered Boris method proposed here do not dampen the high oscillations, and the filtered method is shown to give approximations of second-order accuracy to both the actual position and the actual guiding center over an O(1) time scale for stepsizes h ∼ ε.
In Sect. 3 we state the main theoretical result, Theorem 3.1, which gives an error bound for the filtered Boris method that behaves favourably with respect to ε. While most filters only yield a first-order error bound in the positions, for a particular, nontrivial choice of the filter a second-order error bound is obtained. A second-order error bound is also obtained for the component of the velocity that is parallel to the magnetic field. For the normal velocity approximation, there is still a first-order error bound for any filter. The proof of Theorem 3.1 is based on comparing the modulated Fourier expansions of the exact and the numerical solutions, which are derived in Sects. 4 and 5, respectively. Combining those results, the proof of Theorem 3.1 is finally completed in Sect. 6.
We remark that the differential equations for the coefficient functions of the modulated Fourier expansions derived explicitly up to O(ε 2 ) in Sect. 4 also yield the motion of the guiding center up to O(ε 2 ). They coincide up to O(ε 2 ) with the guiding center equations of the numerical approximation given by the filtered Boris integrator for an appropriate filter and for non-resonant step sizes h ≤ Cε with a possibly large constant C. This does not hold true for the standard Boris integrator.
In Sect. 7 we describe a related, but different integrator, called two-point filtered Boris algorithm, which evaluates the magnetic field both in the current position and in the current guiding center approximation in each step, and which has similar convergence properties to the previously considered filtered Boris method.
In Sect. 8 we present the results of numerical experiments in which we compare the standard and filtered Boris algorithms.
In the Appendix we show how the filters are evaluated efficiently using a Rodrigueztype formula.

Filtered Boris algorithm
Using the velocity approximation at the mid-point, the Boris algorithm (1.2) is usually written and implemented as a one-step method To capture the high oscillations in the velocity more accurately, the second line of (2.1) needs to be modified, and one should rather work with averaged velocities v n+1/2 ≈ 1 h t n+1 t n v(t) dt and possibly averaged positions. This can be achieved with the help of filter functions like in [4,9] and [8,Section XIII.2].
For a vector B = (b 1 , b 2 , b 3 ) ∈ R 3 we denote by |B| the Euclidean norm of B and we use the common notation For real-analytic functions (ζ ) [such as exp(ζ )] we will form matrix functions (−h B), which are efficiently computed by a Rodriguez-type formula as described in the Appendix.
We denote by with B n = B(x n , t n ) the guiding center approximation at time t n (cf. [11]). For the argument of B in the algorithm we choose a point on the straight line connecting x n and x n : with θ n = θ(h|B n |) for a real function θ . It turns out that there is a unique choice of θ such that a second-order error bound will be obtained: where sinc(ξ ) = sin(ξ )/ξ . We note that with the scaling (1.1), we havex n = x n + O(ε), provided that h|B n | is bounded away from non-zero integral multiples of 2π . We consider the following modification of the Boris algorithm.
Theorem 3.1 below shows that the choice of filter functions made in Algorithm 2.1 and (2.5) is the unique choice that gives a second-order error bound.
For the choice θ n = 1, the algorithm is explicit and requires only matrix-vector multiplications that can be done efficiently with a Rodriguez-type formula (see the Appendix).
For θ n = θ(h|B n |) with θ(ζ ) from (2.5), the algorithm is implicit, becausex n then depends on v n and appears in the argument ofB n in the second line. This can be solved by a rapidly convergent fixed-point iteration forx n : We start the iteration withx n = x n , then compute v n+1/2 − from (2.6) and v n from (2.7) using This then yields x n from (2.3) and the newx n from (2.4). We note that all matrix-vector multiplications can be done with a Rodriguez-type formula.
It is readily checked that this iteration map has a Lipschitz constant of size O(ε 2 ) under the scaling (1.1) and for stepsizes h = O(ε). Since the deviation from the solution of the implicit method is therefore reduced by a factor O(ε 2 ) in each iteration, making just one iteration is sufficient to get the improved second-order accuracy of the implicit method.
We mention that Algorithm 2.1 preserves volume in phase space exactly in the case of constant B (and time-dependent B(t)), but only approximately up to O(hε) in the general case of an inhomogeneous magnetic field (1.1). For the original Boris method it is, however, known from [13] that the map (x n , v n−1/2 ) → (x n+1 , v n+1/2 ) is volume-preserving for general magnetic fields.

Two-step formulation
The filtered Boris algorithm has the symmetric two-step formulation as is readily obtained by taking two consecutive steps and using (2.8). This formulation is the basis of our theoretical analysis.
Starting value The starting value v 1/2 is chosen such that formulas (2.6)-(2.7) also hold for n = 0. We find, for arbitrary n, that where ϕ 1 (ζ ) = (e ζ − 1)/ζ . Note that, for given x 0 and v 0 , the vectors x n andx n are known, so that (2.7) provides an explicit formula for v 1/2 .
Using the last formula of (2.6) together with (2.10) for relating x n+1 and x n , and (2.10) with n and + and with n + 1 and − for relating v n+1 and v n , the filtered Boris algorithm can be written as where n ± = ϕ 1 (∓h Bn ) and n The method is symmetric in the sense that exchanging n ↔ n + 1 and h ↔ −h gives the same formulas.
The integrator in the case of a constant magnetic field For constant B, we note that ( n+1 − ) −1 n + = exp(−h B), and so (2.11) reduces to the exponential integrator (with the notation ± (ζ ) = (ζ ) ∓ 2ϕ 1 (±ζ )ϒ(ζ )) . The method is exact for a constant magnetic field B and vanishing electric field E, because Since we have chosen (ζ ) = tanch(ζ /2), the method is also exact for constant B and E. This is seen as follows: For constant B, the variation-of-constants formula for For constant E, this becomes (2.12), which yields

Statement of the main result
Our main theoretical result in this paper is the following error bound for the filtered Boris algorithm. Here we denote, for the exact velocity and similarly for the numerical velocity v n , We then have the following result.
Theorem 3. 1 We assume the following, with arbitrarily chosen positive constants c, C, M and T :

The initial velocity satisfies an ε-independent bound
The step size satisfies h ≤ Cε and is such that the following non-resonance condition is satisfied: If in the filtered Boris algorithm, -x n is given by (2.4) with the function θ of (2.5), and -the filter functions and ϒ are defined as in Algorithm 2.1, then the errors in the positions and the velocities are bounded by For a different choice of the functions θ , and ϒ, the error bounds are not better than O(ε) for general problems (1.1). The constants in the O-notation are independent of ε and h and n with 0 ≤ t n = nh ≤ T , but depend on T , on the velocity bound M and the constants c and C, and on bounds of derivatives of B 0 , B 1 and E in a neighbourhood of the set K .
We remark that in view of the error bounds, the non-resonance condition might be required along the numerical solution x n instead of the exact solution x(t) as in (3.2).
The proof of this theorem will compare the modulated Fourier expansion of the exact solution (as given in Sect. 4) with that of the numerical approximation (as given in Sect. 5). It will be given in Sect. 6.

Remark 3.1
The proof also shows that the choicex n = x n is sufficient for order 2 if the magnetic field satisfies, for all z ∈ C 3 and x ∈ K and all times t,

Remark 3.2
As a consequence of Theorem 3.1, the approximate guiding center x n of the numerical solution, given by (2.3), is an O(ε 2 ) approximation to which is an O(ε 2 ) approximation to the guiding center of the trajectory x(t) (by Theorem 4.1 below; cf. [11]).

Modulated Fourier expansion of the exact solution
We write the solution of (1.1) as a modulated Fourier expansion with coefficient functions z k (t) for which all time derivatives are bounded independently of ε, whereφ(t)/ε = B z 0 (t), t , and z 0 (t) describes the motion of the guiding center. Such a formal expansion has first been considered in [10] for proving the existence of an adiabatic invariant (essentially the magnetic moment . It has been used for a rigorous proof of the long-time nearconservation of the magnetic moment in [7], where this approach was extended to the numerical solution of a variational integrator, for which near-conservation of the magnetic moment and of the energy is rigorously proved over long times that cover arbitrary negative powers of ε. The following result is a variant of Theorem 4.1 in [7], adapted to the present case of a strong magnetic field of the form (1.1). Note that B in this paper corresponds to B/ε in [7].
(a) The coefficient functions z k (t) together with their derivatives (up to order N ) are bounded as z 0 for |k| = 1, j = k, and for the remaining ( j, k) with |k| ≤ N , The remainder term and its derivative are bounded by where we use the notationṖ j (z 0 , t) = d dt P j z 0 (t), t and similar forP j (z 0 , t). All other coefficient functions z k j are given by algebraic expressions depending given by The constants symbolised by the O-notation are independent of ε and t with 0 ≤ t ≤ T , but they depend on N , on the velocity bound M in (3.1), on bounds of derivatives of B and E, and on T .
where C is independent of ε but grows exponentially with T . This is proved by x, t) and using the variation-of-constants formula and the Gronwall inequality. The improvement of the bound (4.5) is a consequence of the fact that the derivatives of B(x, t) are bounded independently of ε.
To get solutions with derivatives bounded uniformly in ε, one has to extract the dominant terms. Multiplying (4.11) with P 0 (z 0 , t) eliminates the ε −1 -term that is present in B(z 0 , t), and the second derivativez 0 0 becomes dominant. Differentiating the relation z 0 0 = P 0 (z 0 , t)z 0 with respect to time yieldsz 0 0 = P 0 (z 0 , t)z 0 +2Ṗ 0 (z 0 , t)ż 0 + P 0 (z 0 , t)z 0 . This then gives (4.7). Note that, due to the special form of B(x, t), the time derivatives of P j (z 0 , t) are of size O(ε).

Modulated Fourier expansion of the numerical solution
We consider the two-step formulation (2.9) of the filtered Boris algorithm, and we write the numerical approximation x n as We use the same notation for the coefficient functions as in Sect. 4. Note, however, that for the numerical solution these functions are not the same and depend on the additional parameter h. We again consider the basis {v j (x, t)} and the corresponding orthogonal projections P j (x, t), and we write the coefficient functions z k as in (4.2), with the only difference that here the argument z 0 (t) is the non-oscillating part of (5.1) and not that of (4.1). where the phase function is given byφ(t) = ε|B(z 0 (t), t)|.
The constants symbolised by the O-notation are independent of ε and n with 0 ≤ nh ≤ T , but they depend on N , on the velocity bound M in

), on bounds of derivatives of B and E, and on T .
Proof (a) and (b) We do not present the details of the proof of the existence of the modulated Fourier expansion and the bounds for the coefficient functions and the remainder term, since this uses the same kind of arguments as in previous such proofs, e.g. in [5,7,8]. In particular, for |k| = 1, j = k and for |k| ≥ 2 the construction of the coefficient functions (see part (c) below) shows that z k j is multiplied by Under the non-resonance assumption (5.2) this expression is bounded from below by a positive constant, so that an algebraic relation for z k j can be extracted. By construction of the coefficient functions the truncated series of (5.3) satisfies the two-step relation (2.9) up to a defect of size O(ε N ). A standard discrete Gronwall argument then gives the bounds on the remainder.
(d) The initial values are obtained from which is a consequence of (5.1), and froṁ which follows from (2.7) and Lemma 5.1. As in the proof of Theorem 4.1 this constitutes a nonlinear system for the values z 0 (0),ż 0 Remarkably we get, up to terms of size O(ε 2 ), the same formulas for the initial values as for the exact solution.
By the uniqueness of the modulated Fourier expansion [up to O(ε N )], these relations hold not only at time 0, but for arbitrary times t ≤ T , except for a phase factor e ∓iφ(t) in the equation for z ±1 ±1 . This phase factor did not appear in (5.7) because we chose φ(0) = 0.
(c) To derive the differential equations for the coefficient functions we first expand the perturbed argument of B(x, t) in the filtered Boris algorithm as The coefficient functions ζ k (t) are obtained as follows: inserting the modulated Fourier expansion (5.1) into (2.7), using Lemma 5.1 below, and replacing 1 h Bn see also the more detailed computation in Sect. 6. Since we haveż 0 and consequently x n = z 0 (t n ) + O(ε 2 ), which shows that x n is an excellent approximation of the non-oscillating part of the numerical solution x n . Together with the definition (2.4) ofx n we find the dominating terms of the expansion (5.10) as After this preparation, we insert the expansions (5.1) for x n and (5.10) forx n into the two-step formulation (2.9) of the filtered Boris algorithm. Using Lemma 5.1 below, expanding the nonlinearities around ζ 0 and z 0 , and comparing the coefficients of e ikφ(t)/ε yields with respect to x and, similarly, t) with respect to x. These derivatives are bounded under the assumption that η = h/ε ≤ c and the non-resonance condition (3.2).
For k = 0 we obtain and for k = ±1 we get Because of (5.11), the argument ζ 0 can be replaced by z 0 in these equations. In the limit h → 0, i.e., η → 0 we have accordance with the Eqs. (4.11) and (4.12) for the exact solution, respectively. To get the differential equations for the dominant coefficient functions, we shall use the relations Multiplying the Eq. (5.12) with P 0 (z 0 , t) and applying the differentiation formula of Lemma 5.2 yields the differential equation , t), the trigonometric identity sin(2α) = 2 sin(α) cos(α), and the second relation of (5.11), this equation becomes (5.4). A multiplication of (5.12) with P ±1 (z 0 , t) permits to extract the dominant first derivativeż 0 ±1 and gives (5.5). We next consider the Eq. (5.13). The ε −2 -terms in the left and right sides are contained in After multiplication with P ±1 (z 0 , t) these terms cancel because of the above formula for P ±1 (z 0 , t)T B (z 0 , t). The remaining terms lead tȯ which simplifies to (5.6).
In the above proof we referred to the following lemmas.
Proof Expanding φ(t ± h) and z k (t ± h) into Taylor series around t yields the stated formulas. , t) , and let P j (x, t) be the orthogonal projections onto the eigenspace of B(x, t) corresponding to the eigenvalues λ 0 = 0 and λ 1 = −i|B(x, t)| = −iφ(x, t)/ε, and λ −1 = i|B(x, t)| = iφ(x, t)/ε, respectively. Omitting the argument (x, t), we then have with η = h/ε, where prime indicates the derivative with respect to x.
Proof Writing tanh as a Taylor series with coefficients γ l and differentiating term by term, we obtain This proves the statement of the lemma.
We shall show below that the numerical solution admits the same expansion with functions φ(t),ż 0 (t), z 1 1 (t), z −1 −1 (t) that correspond to the modulated Fourier expansion (5.1) of the numerical solution and not to (4.1) of the exact solution. By Theorems 4.1 and 5.1, these functions differ only by O(ε 2 ). Because of the denominator ε in the second and third terms on the right-hand side of (6.1), this yields and proves the statement of Theorem 3.1. Using Lemma 5.1 andφ(t) = O(ε), we have, with t = nh, that A consequence of the maximal ordering in (1.1) is that 1 Since ϒ(0) = 0 we have ϒ h B(z 0 (t), t) P 0 (z 0 (t), t) = 0. On the other hand which follows from (5.5) for (iy) = tanc(y/2). This proves the relation (6.1) also for the numerical solution.

A two-point filtered Boris algorithm
Algorithm 2.1 evaluates the magnetic field B atx n given by (2.4)-(2.5), which can be far from both x n and the guiding center approximation x n of (2.3) when h|B(x n )| is close to a nonzero integral multiple of 2π . In the following we propose an alternative filtered Boris algorithm with the same second-order convergence properties as in Theorem 3.1, which evaluates the magnetic field at the two points x n and x n .
For constant B, Algorithms 2.1 and 7.1 are identical and explicit. In the general case, both methods are implicit, but this time the fixed-point iteration for x n requires not only the evaluation of matrix functions by the Rodriguez formula, but in addition the solution of a linear system with the 3×3 matrix 2 . We further note that in the case of a vanishing electric field, E n = 0, Algorithm 2.1 preserves the velocity norm |v n+1/2 | = |v n−1/2 |, which is satisfied only approximately up to O(hε) by Algorithm 7.1. While these properties are unfavourable for Algorithm 7.1, our numerical experiments indicate that it yields higher accuracy than Algorithm 2.1 for stepsizes such that h|B| is large, and in particular it is less sensitive to near-resonances where h|B| is close to an integral multiple of 2π .
The two-step formulation of Algorithm 7.1 is 2) The starting value v 1/2 is chosen such that formulas (7.1) and (2.7) also hold for n = 0. With the abbreviations we find, for arbitrary n, that like in (2.10), v n±1/2 = n ± v n ± h and the one-step map (x n , v n ) → (x n+1 , v n+1 ) is then again given by (2.11) with these modified matrices n ± and n ± . For the two-point filtered Boris algorithm, the second-order convergence result of Theorem 3.1 in x and v and the first-order convergence in v ⊥ remain valid, as can be shown by an adaptation of the proof of Theorem 5.1, for which we omit the details.

Numerical experiment
As an illustrative numerical experiment, we consider the charged-particle motion in the magnetic field The initial values are chosen as x(0) = ( 1 3 , 1 4 , 1 2 ) and v(0) = ( 2 5 , 2 3 , 1) . We solve this problem for 0 ≤ t ≤ 1 with h = , 4 , 16 and compare the numerical errors of the following methods: -the standard Boris algorithm, -Exp-A: the filtered Boris method of Algorithm 2.1 with θ = 1 in (2.4) (wherē x n = x n and the method is explicit), -Imp-A: the filtered Boris method of Algorithm 2.1 with θ of (2.5), -Two P-A: the two-point filtered Boris method of Algorithm 7.1.
The errors in x and v , v ⊥ against different = 1/2 j are displayed in Fig. 1, where j = 4, . . . , 13. Then we fix = 1/2 10 and show the errors at t = 1 against h/ in Fig. 2. It is observed that all three filtered Boris methods improve considerably over the standard Boris method, and the optimally filtered methods Imp-A and Two P-A show second order, whereas method Exp-A only shows first order. Methods Imp-A and Two P-A behave very similar away from stepsize resonances, but method Two P-A appears more robust near stepsize resonances. For the implicit methods Imp-A and Two P-A, the error behaviour remains essentially unchanged after just one fixed-point iteration. Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

Appendix: Implementation
The filtered Boris algorithm requires the computation of matrix functions applied to a vector. This can be done very efficiently with a Rodriguez-like formula. Consider a vector B = (b 1 , b 2 , b 3 ) ∈ R 3 and the skew-symmetric matrix B of (2.2), and let b = |B|. Assume that the function ϕ(ζ ) can be expanded into a Taylor series at the origin with real coefficients c n , and write ϕ(iy) = ϕ(0) + iyϕ 1 (y) − y 2 ϕ 2 (y) with ϕ 1 (y) = j≥0 c 2 j+1 (−y 2 ) j and ϕ 2 (y) = j≥0 c 2 j+2 (−y 2 ) j . The fact that