Skip to content

Menu

WorksPhysics and Astronomy

OPALX: A performance-portable framework for particle accelerator simulations

Download PDFView on arXiv

Ask your agent about this work

Your agent reads this work through Valency, with its citations and similar works. Paste this at the start of a chat.

Use the Valency MCP. Work: W_ew7yf5uv. Fetch it with get_paper_by_id, then find its nearest works with find_similar_papers and tell me what it adds.

Works with any MCP client. Not connected yet? Connect your agent

Abstract

Accurate charged-particle beam simulations require self-consistent collective fields and realistic accelerator models, while their computational cost motivates efficient use of heterogeneous computing systems. We present OPALX, a performance-portable accelerator simulation framework that builds on the beam-dynamics capabilities of OPAL. Its modular architecture uses the Independent Parallel Particle Layer (IPPL) and Kokkos to support distributed-memory execution on multicore CPUs and GPUs from a common codebase. The framework combines relativistic particle tracking with prescribed accelerator fields, particle-in-cell space charge calculations, and spin tracking. We describe the physical and numerical models and their integration into the simulation workflow. The implementation is assessed using disorder-induced heating and frozen-spin test cases, together with comparisons of spin evolution with G4Beamline and beam transport with TraceWin. A three-dimensional space charge benchmark evaluates throughput on CPU and GPU systems, reaching approximately 10910^9 macroparticles per second on a single NVIDIA A100 GPU for this benchmark. These results provide initial verification of the implemented models and demonstrate CPU and GPU execution of self-consistent space charge calculations. OPALX provides a common foundation for extending accelerator models and numerical methods across heterogeneous computing platforms.

Introduction

Numerical simulations are essential to the design and operation of particle accelerators. For high-intensity and high-brightness beams, accurate predictions require realistic accelerator fields and a self-consistent treatment of collective effects. Space charge can modify beam sizes, emittances, halo formation, and particle losses, particularly in low-energy accelerators and injectors [1, 2]. In dense beams, discrete Coulomb interactions can introduce additional evolution beyond the smooth space charge field [3, 4]. The interplay between space charge and intrabeam scattering (IBS) can further affect beam evolution in regimes where both collective and collisional effects are significant [5, 6]. Resolving these processes can require large particle ensembles, fine meshes, and many integration steps, making efficient parallel computation an integral part of accelerator modeling [7, 8].

The Object Oriented Parallel Accelerator Library (OPAL) provides an established foundation for these calculations [9]. Its OPAL-t mode models beam lines, linacs, and radio-frequency (RF) photo-injectors, while OPAL-cycl addresses cyclotrons and fixed-field alternating-gradient (FFA) accelerators. Applications include high-charge electron-beamline optimization at the Argonne Wakefield Accelerator [10] and cyclotron injection and high-current cyclotron design [11, 12]. These applications combine accelerator-component models with parallel particle tracking and self-consistent space charge calculations. The resulting algorithms, physical models, and operational experience form the basis for the development of OPALX.

The increasing use of heterogeneous computing systems creates a need to execute these calculations efficiently on both multicore CPUs and GPUs. Maintaining separate implementations for each architecture would complicate the development and verification of accelerator-physics models. OPALX addresses this challenge through a modular computational framework based on the Independent Parallel Particle Layer (IPPL) [13] and Kokkos [14]. IPPL supplies distributed particle and field data structures, particle–mesh operations, and field solvers; Kokkos provides abstractions for parallel execution and memory management within each process. Together with communication through the Message Passing Interface (MPI) [15], these dependencies allow accelerator models to use a common source implementation across CPU and GPU platforms.

The contribution of OPALX is the integration of accelerator modeling and tracking within this computational framework. The program organizes particle advancement, accelerator components, external-field evaluation, collective-field calculations, and diagnostics through common interfaces. Established OPAL capabilities can therefore be migrated and verified incrementally, while additional models can be introduced within the same workflow. The framework is intended for both hadron and lepton accelerators. The models discussed here include relativistic orbital dynamics, spin tracking, and space charge calculations using three-dimensional and 2.5D particle–mesh methods and a particle–particle particle–mesh (P3M) method for short-range interactions. Beam generation, emission, and accelerator-element placement connect these models to the specification of an accelerator simulation. The source code and documentation are publicly available [16, 17].

This paper presents the computational framework, the physical and numerical models, and their integration into the simulation workflow. Its assessment focuses on the results available in the present version. Disorder-induced heating and frozen-spin test cases examine short-range interactions and spin dynamics, respectively. Comparisons with G4Beamline [18] and TraceWin [19] provide independent checks of spin evolution and beam transport. A three-dimensional space charge benchmark [20] measures throughput on CPU and GPU systems. These studies establish the behavior of selected models and their execution on different architectures; broader verification and accelerator applications remain part of the ongoing development.

This paper is organized as follows. § 1.1 introduces the design principles and computational framework of OPALX. Section III presents the physical and numerical models, including particle and spin dynamics, time integration, the self-field formulation, particle–field coupling, and space charge solvers. Section IV describes the program structure and simulation workflow, including input processing, tracking, diagnostics, and reproducibility. § 1.4 discusses beam generation, accelerator-element placement, and external-field evaluation. § 2 presents numerical verification cases and comparisons with independent simulation codes. Section VII describes the performance benchmark methodology and CPU and GPU results. Section VIII discusses current limitations and planned developments, and § 3.5 summarizes the main conclusions.

Design principles and computational framework

Design objectives

High-fidelity accelerator simulations can require large particle ensembles, fine computational meshes, and tracking over many integration steps. Distributed-memory particle-in-cell (PIC) methods have long enabled such simulations to use large-scale computing resources [7]. More recently, the increasing use of heterogeneous systems combining multicore CPUs and GPUs has created a need for accelerator codes that can use different hardware architectures without maintaining separate implementations of their physical models [8].

A central design objective of OPALX is therefore performance portability. In this context, performance portability denotes the ability to express computationally intensive algorithms through a common source implementation and execute them efficiently on different CPU and GPU systems. It does not imply identical performance on every architecture: particle tracking, particle–mesh operations, field solvers, and communication may place different demands on the available hardware. Instead, the objective is to retain a common implementation of the physical and numerical models while delegating architecture-specific execution and memory management to the underlying parallel framework.

A second objective is distributed-memory scalability. Simulations should be able to use multiple processes and compute nodes when the particle number or mesh resolution required for a calculation exceeds the capacity of a single device. The computational framework must therefore combine interprocess communication with the node-level parallelism available from multicore CPUs or GPUs. The resulting execution model is intended to support simulations ranging from local development and verification cases to large accelerator applications on high-performance computing systems.

OPALX builds on the accelerator-physics experience accumulated in OPAL [9]. Established physical models, accelerator descriptions, and simulation concepts are retained or migrated where appropriate. However, OPALX is not intended as a line-by-line port of the legacy code. Its computational structure has been redesigned to separate accelerator-physics functionality from parallel particle and field operations. This approach permits established OPAL capabilities to be migrated and verified incrementally while providing a foundation for new physical models, accelerator components, and numerical methods.

Layered computational framework

The OPALX computational framework is organized in layers with distinct responsibilities. At the application level, OPALX provides the accelerator-specific functionality. This includes the description of the beam and accelerator lattice, the representation of accelerator components, the evaluation of external and collective fields, particle tracking, particle-loss treatment, and diagnostics. This layer defines the physical problem and coordinates the overall simulation.

IPPL [13] provides the distributed particle and field abstractions needed in OPALX. It supplies the infrastructure required to represent particle ensembles and mesh-based fields across multiple processes, together with mechanisms for domain decomposition, particle redistribution, communication between subdomains, particle–field operations, and field solvers. Accelerator-physics models can therefore operate on particles and fields without directly implementing the associated distributed-memory data management and numerical methods.

Kokkos provides abstractions for node-level parallel execution and memory management [14]. Computational kernels can therefore be executed using the selected CPU or GPU backend without embedding hardware-specific code in the accelerator-physics models. MPI [15] provides communication between processes on the same or different compute nodes. Kokkos and MPI consequently address complementary levels of parallelism: Kokkos exposes parallelism within a process, whereas MPI distributes the simulation across processes and nodes.

In a distributed simulation, the computational domain and its associated field data are partitioned among MPI processes. Each process operates primarily on its local particles and field data. Particles are redistributed as they move between subdomains, while field operations exchange information between neighboring subdomains where required. Global quantities needed by numerical algorithms or diagnostics are obtained using collective communication.

Together, IPPL, Kokkos, and MPI isolate much of the numerical, hardware-dependent and communication-related functionality from the accelerator-physics layer. The physical models implemented in OPALX can consequently operate in terms of particles, fields and accelerator elements rather than numerical approaches related to particle–field couplings and field solvers or high-performance computing (HPC) strategies such as device memory, thread scheduling, and explicit message-passing operations.

This separation allows novel numerical methods and HPC strategies to be implemented, tested, and optimized before they are used in complete accelerator simulations. Mini-applications in IPPL [13] support this workflow. It also enables alternative solver implementations to be selected without changing the general tracking workflow. Similarly, new accelerator components can be introduced through the common mechanisms for element placement and external-field evaluation.

Physical and numerical models

OPALX combines relativistic particle tracking with external accelerator fields, self-consistent collective effects, and optional spin and particle-decay processes. This section presents the physical equations, numerical approximations, and field solvers implemented in the framework.

Particle equations of motion

The beam is represented by an ensemble of macroparticles. Each macroparticle represents a group of physical particles of a given species. Its statistical weight determines its contribution to the collective charge distribution, while its motion in an electromagnetic field is governed by the charge-to-mass ratio of the corresponding particle species.

For macroparticle ii of species ss, the orbital state is described by its position ri=(xi,yi,zi)\mathbf{r}_i = (x_i, y_i, z_i) in the Cartesian laboratory frame and its normalized mechanical momentum

ui=pimsc=γiβi,γi=1+∥ui∥2,(1)\mathbf{u}_i = \frac{\mathbf{p}_i}{m_s c} = \gamma_i \boldsymbol{\beta}_i,\qquad\gamma_i = \sqrt{1 + \lVert\mathbf{u}_i\rVert^2}, \tag*{(1)}

where msm_s and qsq_s are the rest mass and charge of the species, pi=γimsvi\mathbf{p}_i = \gamma_i m_s \mathbf{v}_i is the physical momentum, vi\mathbf{v}_i is the particle velocity, βi=vi/c\boldsymbol{\beta}_i = \mathbf{v}_i/c, and cc is the speed of light. Positions are expressed in meters, and the normalized momentum components are dimensionless, following the convention used in OPAL [9].

The relativistic equations of motion are

dridt=cuiγi,(2)\frac{\mathrm{d}\mathbf{r}_i}{\mathrm{d}t} = c\frac{\mathbf{u}_i}{\gamma_i}, \tag*{(2)}
duidt=qsmsc(Ei+cuiγi×Bi),(3)\frac{\mathrm{d}\mathbf{u}_i}{\mathrm{d}t} = \frac{q_s}{m_s c}\left(\mathbf{E}_i + c\frac{\mathbf{u}_i}{\gamma_i} \times\mathbf{B}_i\right), \tag*{(3)}

which correspond to the Lorentz-force equations written in terms of normalized mechanical momentum [1]. Here tt is the laboratory time, and Ei\mathbf{E}_i and Bi\mathbf{B}_i are the total laboratory-frame fields evaluated at the particle position ri\mathbf{r}_i and time tt. They contain prescribed accelerator fields and self-fields determined from the evolving particle distribution. Their calculation and combination are described in Secs. III D and III E.

In addition to the macroparticle ensemble, OPALX advances a reference particle using the external accelerator fields. The reference particle does not contribute to the collective charge distribution; its trajectory defines the reference path through the lattice and supports the identification of active elements. Reference-path construction and element activation are described in Sec. IV, while element placement and external-field evaluation are discussed in Sec. V.

Time integration and operator splitting

OPALX advances the particle ensemble in laboratory time using a drift–kick–drift scheme with a relativistic Boris momentum update [17, 21]. For a particle present at the beginning of a step of duration Δt=tn+1−tn\Delta t = t^{n+1} - t^n, the first half drift is

rin+1/2=rin+cΔt2uinγin,γin=1+∥uin∥2.(4)\mathbf{r}_i^{n+1/2} = \mathbf{r}_i^n + \frac{c\Delta t}{2}\frac{\mathbf{u}_i^n}{\gamma_i^n},\qquad\gamma_i^n = \sqrt{1 + \lVert\mathbf{u}_i^n\rVert^2}. \tag*{(4)}

The momentum remains unchanged during this drift. In the default MIDPOINT ordering, the self-fields are then recalculated from the half-step particle positions. External fields are evaluated at the half-step particle positions. RF-cavity fields use midpoint time, whereas time-dependent MultipoleT scaling currently uses the step-start time. The total fields supplied to the momentum update are denoted by Ei∗\mathbf{E}_i^* and Bi∗\mathbf{B}_i^*; their calculation and transformation are described in Secs. III D and III E.

The Boris update splits the momentum advance into two half electric impulses separated by a magnetic rotation. The first electric impulse gives

ui−=uin+qsΔt2mscEi∗.(5)\mathbf{u}_i^- = \mathbf{u}_i^n + \frac{q_s\Delta t}{2m_s c}\mathbf{E}_i^*. \tag*{(5)}

The rotation parameters are

γi−=1+∥ui−∥2,(6)\gamma_i^- = \sqrt{1 + \lVert\mathbf{u}_i^-\rVert^2}, \tag*{(6)}
τi=qsΔt2msγi−Bi∗,ηi=2τi1+∥τi∥2.(7)\boldsymbol{\tau}_i = \frac{q_s\Delta t}{2m_s\gamma_i^-}\mathbf{B}_i^*,\qquad\boldsymbol{\eta}_i = \frac{2\boldsymbol{\tau}_i}{1 + \lVert\boldsymbol{\tau}_i\rVert^2}. \tag*{(7)}

Using an intermediate vector u~i\widetilde{\mathbf{u}}_i, the rotation and second electric impulse are

u~i=ui−+ui−×τi,(8)\widetilde{\mathbf{u}}_i = \mathbf{u}_i^- + \mathbf{u}_i^- \times\boldsymbol{\tau}_i, \tag*{(8)}
ui+=ui−+u~i×ηi,(9)\mathbf{u}_i^+ = \mathbf{u}_i^- + \widetilde{\mathbf{u}}_i \times\boldsymbol{\eta}_i, \tag*{(9)}
uin+1=ui++qsΔt2mscEi∗.(10)\mathbf{u}_i^{n+1} = \mathbf{u}_i^+ + \frac{q_s\Delta t}{2m_sc}\mathbf{E}_i^*. \tag*{(10)}

The magnetic substep preserves the momentum magnitude, ∥ui+∥=∥ui−∥\lVert\mathbf{u}_i^+\rVert= \lVert\mathbf{u}_i^-\rVert, up to roundoff. The step is completed by the second half drift,

rin+1=rin+1/2+cΔt2uin+1γin+1,(11)\mathbf{r}_i^{n+1} = \mathbf{r}_i^{n+1/2} + \frac{c\Delta t}{2}\frac{\mathbf{u}_i^{n+1}}{\gamma_i^{n+1}}, \tag*{(11)}

where γin+1=1+∥uin+1∥2\gamma_i^{n+1} = \sqrt{1+\lVert\mathbf{u}_i^{n+1}\rVert^2}.

The PRESTEP option changes the sampling of the collective fields: the self-field solve precedes the first half drift and uses the particle positions rin\mathbf{r}_i^n. The gathered fields are carried with the particles to the momentum update and combined with external fields evaluated at the half-step particle positions, using the element-dependent time sampling described above. This option retains the historical OPAL space charge sampling point; the Boris update and position drifts are unchanged [17].

Time-dependent emission is inserted after the self-field solve. Newly created particles use the fraction of the step following their birth time, as described by Eq. (47); they first contribute to the subsequent collective-field update. The placement of spin tracking and additional processes within the complete step is described in Sec. IV.

For sufficiently smooth prescribed fields evaluated consistently at the midpoint, the centered drift–Boris-kick–drift scheme is second-order accurate. The current step-start sampling of time-dependent MultipoleT scaling does not satisfy this temporal-centering condition, so second-order accuracy should not be assumed for such configurations. The temporal accuracy of a self-consistent calculation also depends on the sampling of the source distribution and the source-frame quantities used to construct the self-fields. Midpoint particle positions alone do not ensure that source velocities and Lorentz factors are centered in time. The accuracy of the coupled calculation must therefore be established through time-step refinement. The configured time-step schedule must resolve the relevant field variations, particle motion, emission, and collective dynamics.

Spin dynamics and tracking

The spin state of a spin-1/2 particle is described by a density matrix ρ\rho: a 2×22 \times2 Hermitian, positive semidefinite matrix with unit trace [22]. It can always be written as

ρ=∑ipiχiχi†,pi≥0,∑ipi=1,(12)\rho= \sum_i p_i \chi_i \chi_i^\dagger,\qquad p_i \ge0,\qquad\sum_i p_i = 1, \tag*{(12)}

where each

χi=(αiβi)∈C2,∣αi∣2+∣βi∣2=1,(13)\chi_i = \begin{pmatrix} \alpha_i \\ \beta_i \end{pmatrix} \in\mathbb{C}^2,\qquad|\alpha_i|^2 + |\beta_i|^2 = 1, \tag*{(13)}

is a normalized pure spin state with statistical weight pip_i. All observable quantities depend only on ρ\rho.

The identity matrix II and the three Pauli matrices σx\sigma_x, σy\sigma_y, and σz\sigma_z form a basis of the real vector space of 2×22 \times2 Hermitian matrices [22, 23]. Introducing the dimensionless spin-polarization vector P\mathbf{P} and writing σ=(σx,σy,σz)\boldsymbol{\sigma} = (\sigma_x,\sigma_y,\sigma_z), the density matrix can therefore be written as

ρ=12(I+P⋅σ),P∈R3,∣P∣≤1,(14)\rho= \frac{1}{2}(I+\mathbf{P}\cdot\boldsymbol{\sigma}),\qquad\mathbf{P}\in\mathbb{R}^3,\qquad|\mathbf{P}|\le1, \tag*{(14)}

where the coefficient of II is fixed by the condition Tr⁡(ρ)=1\operatorname{Tr}(\rho)=1, and the bound ∣P∣≤1|\mathbf{P}|\le1 follows from the positivity of ρ\rho.

For i∈{x,y,z}i\in\{x,y,z\}, the expectation value of the Pauli operator σi\sigma_i is

⟨σi⟩=Tr⁡(ρσi)=Pi.(15)\langle\sigma_i\rangle=\operatorname{Tr}(\rho\sigma_i)=P_i. \tag*{(15)}

The physical spin operator is S=(ℏ/2)σS=(\hbar/2)\sigma, so that ⟨S⟩=(ℏ/2)P\langle S\rangle=(\hbar/2)\mathbf{P}. More generally, for a unit vector n\mathbf{n}, the observable n⋅σ\mathbf{n}\cdot\boldsymbol{\sigma} yields the outcome ±1\pm1 with probability 12(1±n⋅P)\frac{1}{2}(1\pm\mathbf{n}\cdot\mathbf{P}), so that ⟨n⋅σ⟩=n⋅P\langle\mathbf{n}\cdot\boldsymbol{\sigma}\rangle=\mathbf{n}\cdot\mathbf{P}. Since ρ\rho is fully determined by P\mathbf{P}, it suffices to track the evolution of P\mathbf{P} to statistically simulate the outcomes of spin measurements.

The evolution of the spin polarization is given by

d⟨σj⟩dt=iℏ⟨[H,σj]⟩.(16)\frac{\mathrm{d}\langle\sigma_j\rangle}{\mathrm{d}t}=\frac{i}{\hbar}\langle[H,\sigma_j]\rangle. \tag*{(16)}

Since the Hamiltonian HH is also a 2×22 \times2 Hermitian matrix, it admits the decomposition

H=h0I+h⋅σ.(17)H=h_0I+\mathbf{h}\cdot\boldsymbol{\sigma}. \tag*{(17)}

The term h0Ih_0I commutes with every matrix and therefore drops out of the commutator in Eq. (16) and has no effect on the spin dynamics. We write the remaining vector as h=ℏ2Ω\mathbf{h}=\frac{\hbar}{2}\boldsymbol{\Omega}, where the factor ℏ/2\hbar/2 is chosen so that Ω\boldsymbol{\Omega} is the angular velocity of the precession derived below:

H=h0I+ℏ2Ω⋅σ.(18)H=h_0I+\frac{\hbar}{2}\boldsymbol{\Omega}\cdot\boldsymbol{\sigma}. \tag*{(18)}

The Pauli matrices satisfy the commutation relation

[σk,σl]=2iϵklmσm,(19)[\sigma_k,\sigma_l]=2i\epsilon_{klm}\sigma_m, \tag*{(19)}

where ϵklm\epsilon_{klm} is the Levi-Civita symbol and summation over repeated indices is implied. The commutator of the Hamiltonian with σj\sigma_j is therefore

[H,σj]=ℏ2Ωk[σk,σj]=iℏϵkjlΩkσl.(20)[H,\sigma_j]=\frac{\hbar}{2}\Omega_k[\sigma_k,\sigma_j]=i\hbar\epsilon_{kjl}\Omega_k\sigma_l. \tag*{(20)}

Substituting this into Eq. (16), using Pj=⟨σj⟩P_j=\langle\sigma_j\rangle, and treating Ω\boldsymbol{\Omega} as a classical quantity so that ⟨Ωkσl⟩=Ωk⟨σl⟩\langle\Omega_k\sigma_l\rangle=\Omega_k\langle\sigma_l\rangle, gives

dPjdt=iℏiℏϵkjlΩkPl=−ϵkjlΩkPl=ϵjklΩkPl,(21)\frac{\mathrm{d}P_j}{\mathrm{d}t}=\frac{i}{\hbar}i\hbar\epsilon_{kjl}\Omega_kP_l=-\epsilon_{kjl}\Omega_kP_l=\epsilon_{jkl}\Omega_kP_l, \tag*{(21)}

where the last step uses the antisymmetry ϵkjl=−ϵjkl\epsilon_{kjl}=-\epsilon_{jkl}. The right-hand side is the jj-th component of Ω×P\boldsymbol{\Omega}\times\mathbf{P}, so

dPdt=Ω×P.(22)\frac{\mathrm{d}\mathbf{P}}{\mathrm{d}t}=\boldsymbol{\Omega}\times\mathbf{P}. \tag*{(22)}

This describes a rotation of P\mathbf{P} about Ω\boldsymbol{\Omega} with angular frequency ∣Ω∣|\boldsymbol{\Omega}|, where ∣P∣|\mathbf{P}| is conserved.

The evolution of the spin polarization of a particle with a classical orbit and no electric dipole moment is given by the Thomas–BMT equation [24, 25, 26]

dPdt=ΩBMT×P,(23)\frac{\mathrm{d}\mathbf{P}}{\mathrm{d}t}=\boldsymbol{\Omega}_{\mathrm{BMT}}\times\mathbf{P}, \tag*{(23)}
ΩBMT=−qm[(G+1γ)B−Gγγ+1(β⋅B)β−(G+1γ+1)β×Ec],(24)\boldsymbol{\Omega}_{\mathrm{BMT}}=-\frac{q}{m}\left[\left(G+\frac{1}{\gamma}\right)\mathbf{B}-\frac{G\gamma}{\gamma+1}(\boldsymbol{\beta}\cdot\mathbf{B})\boldsymbol{\beta}-\left(G+\frac{1}{\gamma+1}\right)\frac{\boldsymbol{\beta}\times\mathbf{E}}{c}\right], \tag*{(24)}

where qq and mm are the charge and mass of the particle, G=(g−2)/2G=(g-2)/2 is its magnetic anomaly, γ\gamma is the Lorentz factor, β=v/c\boldsymbol{\beta}=\mathbf{v}/c, and E\mathbf{E} and B\mathbf{B} are the lab-frame fields at the position of the particle. The polarization P\mathbf{P} is defined in the particle rest frame, and tt is the lab time.

Rodrigues’ Rotation

Conventional explicit Runge–Kutta methods do not, in general, preserve the polarization magnitude exactly when integrating Eq. (23) [27 Chap. IV]. For a pure rotation, the commonly used Boris update (the Boris-B variant) preserves the vector norm but introduces a finite-step phase error [21].

Rodrigues’ rotation formula [28, 29] gives the exact rotation of P\mathbf{P} about a unit vector n\mathbf{n} through an angle θ\theta.

To derive it, decompose P\mathbf{P} into components parallel and perpendicular to the rotation axis,

P∥=(n⋅P)n,P⊥=P−(n⋅P)n.(25)\mathbf{P}_{\parallel}=(\mathbf{n}\cdot\mathbf{P})\mathbf{n},\qquad\mathbf{P}_{\perp}=\mathbf{P}-(\mathbf{n}\cdot\mathbf{P})\mathbf{n}. \tag*{(25)}

The parallel component is unchanged by the rotation. The perpendicular component rotates in the plane orthogonal to n\mathbf{n}, which is spanned by the orthogonal vectors P⊥\mathbf{P}_{\perp} and n×P⊥=n×P\mathbf{n}\times\mathbf{P}_{\perp}=\mathbf{n}\times\mathbf{P}. The rotated vector P′\mathbf{P}' is given by

P′=P∥+P⊥cos⁡θ+(n×P)sin⁡θ=Pcos⁡θ+(n×P)sin⁡θ+(n⋅P)n(1−cos⁡θ).(26)\begin{aligned} \mathbf{P}'&=\mathbf{P}_{\parallel}+\mathbf{P}_{\perp}\cos\theta+(\mathbf{n}\times\mathbf{P})\sin\theta\\ &=\mathbf{P}\cos\theta+(\mathbf{n}\times\mathbf{P})\sin\theta\\ &\quad+(\mathbf{n}\cdot\mathbf{P})\mathbf{n}(1-\cos\theta). \tag*{(26)} \end{aligned}

Because the three terms P∥\mathbf{P}_{\parallel}, P⊥\mathbf{P}_{\perp} and n×P\mathbf{n}\times\mathbf{P} are mutually orthogonal,

∣P′∣2=∣P∥∣2+∣P⊥∣2(cos⁡2θ+sin⁡2θ)=∣P∣2,(27)|\mathbf{P}'|^2=|\mathbf{P}_{\parallel}|^2+|\mathbf{P}_{\perp}|^2\left(\cos^2\theta+\sin^2\theta\right)=|\mathbf{P}|^2, \tag*{(27)}

so the norm is conserved for any θ\theta. For a nonzero precession vector ΩBMT\boldsymbol{\Omega}_{\mathrm{BMT}} that is constant over a time step Δt\Delta t, Eq. (26) with

n=ΩBMT∣ΩBMT∣,θ=∣ΩBMT∣Δt(28)\mathbf{n}=\frac{\boldsymbol{\Omega}_{\mathrm{BMT}}}{|\boldsymbol{\Omega}_{\mathrm{BMT}}|},\qquad\theta=|\boldsymbol{\Omega}_{\mathrm{BMT}}|\Delta t \tag*{(28)}

is the exact solution of Eq. (23) over that step. When ∣ΩBMT∣=0|\boldsymbol{\Omega}_{\mathrm{BMT}}|=0, the polarization is unchanged, P′=P\mathbf{P}'=\mathbf{P}.

Self-field formulation

The space charge model uses an electrostatic approximation in a frame moving with the beam, following the formulation used in OPAL [9]. A relativistic beam can have a substantial magnetic self-field in the laboratory while its internal motion is nonrelativistic in this co-moving frame. Primes denote co-moving quantities, and vb=cβb\mathbf{v}_b=c\boldsymbol{\beta}_b and γb=(1−∣βb∣2)−1/2\gamma_b=(1-|\boldsymbol{\beta}_b|^2)^{-1/2} denote the frame velocity relative to the laboratory and its associated Lorentz factor, respectively. The self-fields obey Maxwell’s equations,

∇′⋅Eself′=ρ′ϵ0,∇′⋅Bself′=0,(29)\nabla'\cdot\mathbf{E}'_{\mathrm{self}}=\frac{\rho'}{\epsilon_0},\qquad\nabla'\cdot\mathbf{B}'_{\mathrm{self}}=0, \tag*{(29)}
∇′×Eself′=−∂Bself′∂t′,∇′×Bself′=μ0J′+1c2∂Eself′∂t′,(30)\nabla'\times\mathbf{E}'_{\mathrm{self}}=-\frac{\partial\mathbf{B}'_{\mathrm{self}}}{\partial t'},\qquad\nabla'\times\mathbf{B}'_{\mathrm{self}}=\mu_0\mathbf{J}'+\frac{1}{c^2}\frac{\partial\mathbf{E}'_{\mathrm{self}}}{\partial t'}, \tag*{(30)}

where ρ′\rho' and J′\mathbf{J}' are the charge and current densities, ϵ0\epsilon_0 and μ0\mu_0 are the vacuum permittivity and permeability, and μ0ϵ0=c−2\mu_0\epsilon_0=c^{-2}. If internal currents are sufficiently weak and the fields vary on timescales long compared with the light-crossing time of the bunch, magnetic and retardation effects can be neglected in this frame. Thus Bself′≃0\mathbf{B}'_{\mathrm{self}}\simeq0 and ∇′×Eself′≃0\nabla'\times\mathbf{E}'_{\mathrm{self}}\simeq0, giving

Eself′=−∇′ϕ′,∇′2ϕ′=−ρ′ϵ0.(31)\mathbf{E}'_{\mathrm{self}}=-\nabla'\phi',\qquad\nabla'^2\phi'=-\frac{\rho'}{\epsilon_0}. \tag*{(31)}

Here ρ′\rho' is measured in C m−3\mathrm{C\,m^{-3}}, ϕ′\phi' in volts, and Eself′\mathbf{E}'_{\mathrm{self}} in V m−1\mathrm{V\,m^{-1}}. Boundary conditions are selected according to the solver and geometry; the free-space case is discussed in Sec. III F.

For a boost along the local beam direction zz, the Lorentz transformation of space-time coordinates is

z′=γb(z−vbt),x′=x,z'=\gamma_b(z-v_b t),\qquad x'=x,
t′=γb(t−vbzc2),y′=y.(32)t'=\gamma_b\left(t-\frac{v_b z}{c^2}\right),\qquad y'=y. \tag*{(32)}

The charge density transforms as ρ′=γb(ρ−vb⋅J/c2)\rho'=\gamma_b(\rho-\mathbf{v}_b\cdot\mathbf{J}/c^2). For a distribution convected with the mean beam velocity, J≃ρvb\mathbf{J}\simeq\rho\mathbf{v}_b, this reduces to ρ′≃ρ/γb\rho'\simeq\rho/\gamma_b. In the quasi-static approximation, a frozen azimuthal snapshot is represented by stretching longitudinal separations by γb\gamma_b, with this density rescaling preserving total charge. This treatment neglects evolution between the different co-moving times associated with simultaneous laboratory particle positions.

The inverse Lorentz transformation, with Bself′≃0\mathbf{B}'_{\mathrm{self}}\simeq0, gives [26]

Eself,∥=Eself,∥′,Eself,⊥=γbEself,⊥′,(33)\mathbf{E}_{\mathrm{self},\parallel}=\mathbf{E}'_{\mathrm{self},\parallel},\qquad\mathbf{E}_{\mathrm{self},\perp}=\gamma_b\mathbf{E}'_{\mathrm{self},\perp}, \tag*{(33)}
Bself=1c2vb×Eself,(34)\mathbf{B}_{\mathrm{self}}=\frac{1}{c^2}\mathbf{v}_b\times\mathbf{E}_{\mathrm{self}}, \tag*{(34)}

where parallel and perpendicular refer to vb\mathbf{v}_b, and Bself\mathbf{B}_{\mathrm{self}} is measured in tesla. Thus the laboratory magnetic self-field is retained even though it is neglected in the co-moving electrostatic solve.

If the longitudinal energy spread of a beam is large enough that the nonrelativistic approximation in the co-moving frame no longer holds, OPALX can group particles into energy bins with their own mean velocity and Lorentz factor. Each bin contributes a quasi-static Poisson solve with longitudinal mesh stretching and charge-density normalization. Its fields are transformed back and summed. The approximation requires small internal velocities within each source group and slowly varying sources. Within each bin, the electrostatic approximation of Eq. (31) is applied, with internal currents neglected. OPALX selects the histogram used to assign particles to energy bins using a cost function that balances field accuracy against computational cost and modeling error [30]. The co-moving frame is treated as instantaneously inertial; acceleration and curvature must be small enough on the bunch scale for this local self-field approximation to apply.

Particle-field coupling

The PIC method closes the self-consistent coupling between beam motion and collective fields through the loop illustrated in Figure 1. At each collective update, the current particle positions define the charge deposited on the mesh. The Poisson solver selected by the user computes the mesh field, which is gathered to the particles and combined with the prescribed accelerator fields. Particle advancement changes the distribution that supplies the next field calculation. The field solve is therefore one stage of a repeated particle–mesh–particle cycle, rather than a calculation with a fixed source [9, 13].

Electrostatic particle-in-cell loop in OPALX

Figure 1. Electrostatic particle-in-cell loop in OPALX. Charge deposition, the Poisson solve, and field gathering connect particles to the computational mesh; particle advancement closes the loop. For relativistic source bins, each bin is solved in its co-moving frame, and its electric and magnetic fields are transformed and accumulated before gathering. Prescribed external fields enter after the self-field calculation. The diagram shows the numerical data flow; the actual half-drift, emission, and optional-process ordering is shown in Figure 4.

In the continuous formulation, the total laboratory fields at each particle position are

Ei=Eext(ri,t)+Eself(ri,t),(35)\mathbf{E}_i = \mathbf{E}_{\mathrm{ext}}(\mathbf{r}_i,t) + \mathbf{E}_{\mathrm{self}}(\mathbf{r}_i,t), \tag*{(35)}
Bi=Bext(ri,t)+Bself(ri,t).(36)\mathbf{B}_i = \mathbf{B}_{\mathrm{ext}}(\mathbf{r}_i,t) + \mathbf{B}_{\mathrm{self}}(\mathbf{r}_i,t). \tag*{(36)}

The sampling positions and times used in the discrete integration are specified in Sec. III B. The external fields are supplied by magnets, RF cavities, and other accelerator components, using analytical models or prescribed field maps. Particle coordinates are transformed to each active element’s local frame for field evaluation, and the resulting vectors are rotated back to a common frame and added. Overlapping elements therefore contribute to the same external-field sum. Unlike the self-consistent fields, these prescribed fields do not depend on the deposited beam charge.

For the three-dimensional Cartesian PIC calculation, the self-fields are obtained on a computational mesh and interpolated to the particles through IPPL [13]. The computational domain is a rectangular box in beam-aligned coordinates. In the bunch-fitted configuration, its bounds follow the global particle-position extrema, enlarged by a configurable margin; the chosen mesh dimensions determine the uniform spacing in each direction. A fixed box can instead be prescribed for the open-boundary solver. This spatial translation and rotation into beam-aligned coordinates is distinct from the Lorentz transformation used for a source bin.

Charge deposition uses cloud-in-cell (CIC) weights: a particle contributes to each of the eight neighboring mesh points, with weights given by products of linear weights in each coordinate. The deposited charge is normalized by the cell volume and, where applicable, by the Lorentz factor of the source bin. The selected solver then computes the co-moving electric field described in Sec. III D. For relativistic source bins, the laboratory electric and magnetic fields are formed and accumulated on the mesh before gathering to the particles.

Writing WiaW_{ia} for the CIC weight linking particle ii to mesh point aa, the gather operation is

Eself,i=∑aWiaEself,a,Bself,i=∑aWiaBself,a.(37)\mathbf{E}_{\mathrm{self},i} = \sum_a W_{ia}\mathbf{E}_{\mathrm{self},a}, \qquad\mathbf{B}_{\mathrm{self},i} = \sum_a W_{ia}\mathbf{B}_{\mathrm{self},a}. \tag*{(37)}

The weights satisfy ∑aWia=1\sum_a W_{ia}=1 and use the same interpolation shape as charge deposition, giving trilinear field interpolation in three dimensions. Both self-fields are expressed in the same frame as the external fields before their sum is applied in the Lorentz-force update. The collective Lorentz force includes both qsEself,iq_s\mathbf{E}_{\mathrm{self},i} and qsvi×Bself,iq_s\mathbf{v}_i \times\mathbf{B}_{\mathrm{self},i}; the integration scheme and ordering of kicks are discussed in Sec. III B. The resulting particle state closes the PIC loop: before the next charge deposition, the beam-aligned coordinates, domain bounds, and particle ownership are updated as required. IPPL handles mesh-data communication and particle migration between MPI subdomains so that deposition and gathering use a consistent distributed mesh. The density and self-fields are recomputed from the evolving source distribution at each collective update. For the default MIDPOINT ordering, these source positions follow the first half drift; emission takes place after this solve, so newly emitted particles contribute to the following collective update. Section IV gives the full tracking sequence, including external-field evaluation, optional processes, and diagnostics.

Grid-based and hybrid solvers

The space charge solvers in OPALX are built on IPPL, which provides common distributed field data structures and performance-portable numerical kernels [13]. The following subsections describe the three-dimensional open-boundary and 2.5D particle–mesh Poisson solvers, followed by the P3M method, which combines a mesh-based long-range calculation with direct short-range particle–particle interactions. The supported boundary conditions are also discussed.

Open-boundary Poisson solver

The OPEN solver evaluates the electrostatic field of a spatially localized charge distribution in free space. It solves Eq. (31) with the boundary condition ϕ′(r′)→0\phi'(\mathbf{r}') \to0 as ∣r′∣→∞|\mathbf{r}'| \to\infty. The solution in the co-moving frame is the convolution

ϕ′(r′)=1ϵ0∫R3G(r′−s′)ρ′(s′) d3s′,(38)\phi'(\mathbf{r}') = \frac{1}{\epsilon_0}\int_{\mathbb{R}^3} G(\mathbf{r}'-\mathbf{s}')\rho'(\mathbf{s}')\,\mathrm{d}^3\mathbf{s}', \tag*{(38)}

with G(r′)=1/(4π∣r′∣)G(\mathbf{r}') = 1/(4\pi|\mathbf{r}'|).

OPALX uses the Hockney–Eastwood algorithm implemented in IPPL [31, 32]. On a uniform Cartesian mesh with Nx×Ny×NzN_x \times N_y \times N_z points and spacings hx,hy,hzh_x,h_y,h_z, the charge density is zero-padded onto a 2Nx×2Ny×2Nz2N_x \times2N_y \times2N_z mesh. The Green function is extended by reflection to represent all signed source–observer separations. Fast Fourier transforms (FFTs) then evaluate the resulting cyclic convolution, and the solution is restricted to the original mesh. This embedding reproduces the discrete free-space convolution without introducing periodic images into the physical domain. The convolution includes the cell-volume factor hxhyhzh_x h_y h_z.

Two Green-function discretizations are available. The STANDARD option samples GG at mesh separations and regularizes its singular value at the origin. The default INTEGRATED option instead uses the cell average of GG, assuming uniform charge density within each source cell [33]. This gives a finite contribution from the source cell itself and is particularly useful for beams with large aspect ratios. The co-moving field Eself′=−∇′ϕ′\mathbf{E}'_{\mathrm{self}} = -\nabla'\phi' is calculated by Fourier differentiation, followed by an inverse transform for each component.

The FFTs are provided through IPPL by heFFTe [34]; MPI provides the communication required by the distributed transforms and field redistribution, while Kokkos executes the local mesh kernels on CPUs or GPUs [32]. For Ng=NxNyNzN_g = N_xN_yN_z, the solve has O(Nglog⁡Ng)O(N_g \log N_g) computational complexity, with additional storage for the enlarged mesh. Accuracy remains limited by mesh resolution, charge deposition, field interpolation, and particle statistics; using FFTs does not by itself imply spectral convergence.

The method can also use a comparatively coarse longitudinal resolution when the longitudinal charge distribution varies slowly. It assumes that the beam is much longer than its transverse dimensions and is resolved by a sufficient number of longitudinal slices.

A reference path defines the Frenet–Serret coordinate system. In the current implementation, the path is assumed to lie in a horizontal plane. The coordinate ss measures distance along the path, yy is vertical, and xx is the horizontal transverse coordinate. The parameters PxP_x and PyP_y specify the transverse extent of the computational domain, as illustrated in Figure 2. The slice width is Δs\Delta s, and each slice is discretized using transverse cell sizes Δx\Delta x and Δy\Delta y. The reference path can be supplied by the OPALX orbitThr3ader or read from an external file.

Figure 2. The Frenet–Serret reference path is divided into longitudinal slices, each discretized on a two-dimensional transverse grid. The mesh covers the region around the reference path.

A 2.5D Poisson Solver (FFT2D5)

The 2.5D solver calculates space charge fields through a sequence of two-dimensional transverse Poisson solves coupled to an approximate longitudinal-field model [17]. The mesh follows a reference path expressed in Frenet–Serret coordinates, restricting the computational domain to the region around the beam. This can reduce mesh storage for extended or curved beam trajectories. For NsN_s longitudinal slices with Nx×NyN_x \times N_y transverse mesh points per slice, the transverse FFT work scales as O(NsNxNylog⁡(NxNy))O(N_sN_xN_y \log(N_xN_y)), compared with O(NsNxNylog⁡(NsNxNy))O(N_sN_xN_y \log(N_sN_xN_y)) for a three-dimensional FFT calculation with the same mesh-point counts.

Particle positions and momenta are first transformed into Frenet–Serret coordinates and then boosted into the beam’s co-moving frame. Charge deposition uses CIC weights, with a trilinear scheme distributing each particle’s charge among four transverse grid cells in each of the two adjacent slices, as illustrated in Figure 3. These operations are parallelized over particles and can execute on a GPU.

Figure 3. CIC deposition distributes the particle charge, represented by the blue cloud, among four transverse grid cells in each of two adjacent slices. The corresponding interpolation weights are used to gather fields to the particle position.

The transverse electric-field components ExE_x and EyE_y are calculated independently in each slice. The current implementation supports open transverse boundary conditions and uses a two-dimensional FFT Poisson solve with the Hockney–Eastwood doubled-domain construction [31]. The transverse fields are obtained from the potential gradients. The local mesh operations are parallelized over grid cells and can execute on a GPU.

The longitudinal electric field is estimated from the derivative of the charge line density with respect to zz, the longitudinal coordinate relative to the bunch. This coordinate is distinct from the path coordinate ss along the machine. The line density is calculated from the charge density in each slice, and its longitudinal derivative is approximated using central differences. The field is given by

Ez(z)=−g4πε0γ2dλ(z)dz(39)E_z(z)=-\frac{g}{4\pi\varepsilon_0\gamma^2}\frac{\mathrm{d}\lambda(z)}{\mathrm{d}z} \tag*{(39)}

where λ(z)\lambda(z) is the charge line density and gg is a constant determined by the boundary conditions. This calculation is parallelized over slices, so the available parallelism depends on the number of longitudinal slices.

The fields at each particle position are obtained using CIC interpolation from the adjacent grid cells and slices. The inverse Lorentz transformation and the transformation from Frenet–Serret to Cartesian coordinates return the electric and magnetic fields to the laboratory frame for use in particle tracking. These operations are parallelized over particles and can execute on a GPU.

Particle–Particle Particle–Mesh (P3M)

CIC deposition and field interpolation smooth the charge distribution, limiting the accuracy of mesh-based forces at separations comparable to or smaller than mesh spacing hh. Conceptually, the field can be separated into a smooth mean field and a fluctuating contribution:

Ei=⟨E⟩(ri)⏟mean field, smoothed ρ+δEi⏟discreteness, correlations.(40)\mathbf{E}_i=\underbrace{\langle\mathbf{E}\rangle(\mathbf{r}_i)}_{\text{mean field, smoothed }\rho}+\underbrace{\delta\mathbf{E}_i}_{\text{discreteness, correlations}}. \tag*{(40)}

Conventional grid-based FFT solvers do not accurately resolve the short-range fluctuations, δEi\delta\mathbf{E}_i, associated with discrete Coulomb interactions because of mesh smoothing and the macroparticle representation [4]. These interactions give rise to IBS [35, 36], which can significantly affect beam quality in dense, cold, high-brightness beams. In storage rings, IBS can limit the equilibrium emittance and energy spread [5, 37]. In linacs and high-brightness photoinjectors, it can increase the energy spread beyond predictions from space charge models that omit collisional effects [3, 38, 39]. OPALX provides a GPU-enabled P3M implementation to include direct short-range particle interactions alongside the mesh-based field calculation.

The method separates the Coulomb Green function into long-range and short-range contributions [31]:

G(r)=erf⁡(αr)4πr⏟GL(r)+erfc⁡(αr)4πr⏟GS(r)(41)G(r)=\underbrace{\frac{\operatorname{erf}(\alpha r)}{4\pi r}}_{G_{\mathrm{L}}(r)}+\underbrace{\frac{\operatorname{erfc}(\alpha r)}{4\pi r}}_{G_{\mathrm{S}}(r)} \tag*{(41)}

where r>0r>0 is the particle separation and α>0\alpha>0 is an inverse-length splitting parameter. The long-range contribution reuses the open-boundary FFT solver described in Sec. III F 1, replacing its Green function with the long-range kernel and the regularization used by the implementation. This retains the distributed FFT infrastructure supplied by IPPL.

The total field is E=Emesh+EPP\mathbf{E}=\mathbf{E}_{\mathrm{mesh}}+\mathbf{E}_{\mathrm{PP}}, with the short-range contribution calculated directly as

EPP,i=14πε0∑j≠irij<rcqjr^ijf(αrij)rij2,\mathbf{E}_{\mathrm{PP},i}=\frac{1}{4\pi\varepsilon_0}\sum_{\substack{j\ne i\\r_{ij}<r_c}}q_j\hat{\mathbf{r}}_{ij}\frac{f(\alpha r_{ij})}{r_{ij}^2},

where f(x)=erfc⁡(x)+2xπe−x2f(x)=\operatorname{erfc}(x)+\frac{2x}{\sqrt{\pi}}e^{-x^2}, rij=ri−rj\mathbf{r}_{ij}=\mathbf{r}_i-\mathbf{r}_j, rij=∣rij∣r_{ij}=|\mathbf{r}_{ij}|, and r^ij=rij/rij\hat{\mathbf{r}}_{ij}=\mathbf{r}_{ij}/r_{ij}. Here qjq_j is the charge carried by source particle jj, and rcr_c is the short-range cutoff radius. For an approximately uniform numerical particle density n=N/Vn=N/V, each particle has about 4π3rc3n\frac{4\pi}{3}r_c^3n neighbors. The total pair work therefore scales as N2rc3/VN^2r_c^3/V, where NN is the number of numerical particles and VV is the volume they occupy. OPALX provides the LOADBALANCINGPAIRWEIGHT option to account for pair-interaction work when balancing the load across MPI ranks through orthogonal recursive bisection (ORB) [17].

The pair summation can be parallelized once candidate neighbors have been identified. Efficient neighbor search and communication are therefore important parts of the implementation. Each MPI rank stores ghost copies of nearby particles needed for interactions within rcr_c. Particles are sorted into search cells with widths of at least rcr_c, allowing each particle to search its own cell and the 26 adjacent cells. Pair contributions are accumulated using atomic operations. The domain decomposition constrains rcr_c to at most half the local subdomain extent in every direction.

In addition to open boundaries, OPALX supports periodic P3M calculations. In this case, the periodic mesh solver uses the long-range kernel, while periodic image ghosts provide short-range interactions across the domain boundaries.

The split is characterized by the dimensionless parameters αhmax⁡\alpha h_{\max} and αrc\alpha r_c, which control mesh-resolution and cutoff-truncation effects, respectively. With α=2/rc\alpha=2/r_c, the ratio κ=rc/h\kappa=r_c/h expresses the cutoff in units of the mesh spacing hh. The cutoff can be specified as an absolute length through RCUT or relative to the mesh spacing through RCUT_CELLS. In the latter case, it is updated as the bunch-fitted mesh evolves. The cutoff must also satisfy the local-subdomain restriction stated above.

An image-field correction for a source plane at a prescribed zz coordinate uses a shifted Green function for the long-range contribution. The boundary treatment and its applicability conditions are discussed in Sec. III F 4.

The physical interpretation of the short-range dynamics depends on the macroparticle weights. Direct pair forces between macroparticles representing many physical particles generally do not reproduce the physical beam’s binary-collision dynamics and can alter the evolution of second-order moments. For electron-beam calculations intended to resolve individual electron collisions, each numerical particle must represent one electron. This distinction is essential when interpreting collisional heating and emittance or energy-spread growth.

Boundary conditions supported by OPALX

For the three-dimensional mesh and P3M solvers, the boundary conditions of the field problem must be distinguished from the handling of the numerical particle domain. By default, the mesh bounds are updated to follow the extent of the bunch. This adaptation does not determine the physical boundary conditions, which are selected through the field solver. The TYPE=FFT backend solves a periodic Poisson problem, whereas TYPE=OPEN uses the free-space solver described in Sec. III F 1, with the potential tending to zero at infinity. For the periodic FFT solve, the mean charge density is subtracted, corresponding to a uniform neutralizing background [17].

In periodic P3M calculations, the mesh solve uses the long-range kernel GLG_L defined in Sec. III F 3. Periodic copies of particles are included in the short-range sum through ghost particles exchanged across domain boundaries. For open P3M calculations, the long-range contribution is calculated with the open-boundary FFT solver using GLG_L, and no periodic particle copies are included. These periodic copies are distinct from the opposite-sign image charges used to represent a conducting boundary.

A grounded planar cathode is represented by an image-charge construction. In the frame in which the electrostatic problem is solved, let the plane be z=zpz=z_p. All quantities in the following expressions refer to this frame. For a real charge qq at (x,y,z)(x,y,z), an image charge −q-q is placed at (x,y,2zp−z)(x,y,2z_p-z). The corresponding image potential is

ϕimage(x,y,z)=−ϕreal(x,y,2zp−z),(42)\phi_{\mathrm{image}}(x,y,z)=-\phi_{\mathrm{real}}(x,y,2z_p-z), \tag*{(42)}

so that ϕreal+ϕimage=0\phi_{\mathrm{real}}+\phi_{\mathrm{image}}=0 on the plane. This construction describes an infinite grounded plane.

For the open-boundary mesh solver, the image contribution can be obtained either by depositing the mirrored, opposite-sign charge distribution explicitly or by using a shifted Green function [17]. The explicit construction requires the mesh to contain both the bunch and its image. The shifted-Green method avoids resolving the empty region between them [33]. A convolution with a kernel shifted by a displacement ss defines a potential,

ϕshifted(r)=1ϵ0∫R3G(r−s−ξ)ρ(ξ) d3ξ,(43)\phi_{\mathrm{shifted}}(\mathbf{r})=\frac{1}{\epsilon_0}\int_{\mathbb{R}^3}G(\mathbf{r}-\mathbf{s}-\boldsymbol{\xi})\rho(\boldsymbol{\xi})\,\mathrm{d}^3\xi, \tag*{(43)}

where G(r)=1/(4π∣r∣)G(\mathbf{r})=1/(4\pi|\mathbf{r}|) and ξ\boldsymbol{\xi} is the source integration coordinate. The associated field is Eshifted=−∇ϕshifted\mathbf{E}_{\mathrm{shifted}}=-\nabla\phi_{\mathrm{shifted}}. The shift is set by the relative positions of the mesh and the cathode plane. Reflection and the image-charge sign are then applied to obtain the image contribution, consistently with the potential relation above.

For open P3M calculations, the cathode correction uses the shifted long-range kernel GLG_L and adds the resulting image field to the mesh and direct-pair fields of the real bunch. Short-range interactions with the image charges are omitted. Within the cutoff approximation, these omitted interactions vanish at the real-particle positions if all real-particle–image separations exceed rcr_c. A sufficient condition is that the entire bunch lie more than rcr_c from the plane. The error associated with omitting short-range boundary contributions has been analyzed by Wyssling and Adelmann [40]. Near the cathode, particularly during emission, this separation condition can fail, and the error from omitting short-range image interactions must be assessed.

Program structure and simulation workflow

Figure 4 summarizes the input organization and tracking cycle. The following subsections describe how these stages connect the accelerator model, particle ensemble, field calculations, and output.

Input organization and tracking workflow of OPALX

Figure 4. Input organization and tracking workflow of OPALX. (a) Named input objects define the model and bind it to a tracking run; the branches group configuration responsibilities rather than prescribing a universal declaration order. (b) The default collective update uses positions after the first half drift. Emission follows this solve, so new particles enter the next collective update. The PRESTEP alternative moves the self-field calculation before the first half drift. Optional processes and diagnostics are shown in their place in the cycle.

Input and lattice construction

A simulation is specified through a MAD-inspired, statement-oriented input language retained from OPAL. Named objects describe the beam, particle distributions and emission sources, accelerator elements, lattice, and collective-field configuration. Expressions and nested LINE definitions allow parameters and lattice segments to be reused. A RING defines an ordered ring sequence; its declaration alone does not place the elements or enforce geometric closure. Element poses and field maps determine the spatial accelerator model, as discussed in § 1.4. The available commands and their current compatibility with OPAL are documented in the OPALX manual [17].

The parser resolves these objects through a common registry. A TRACK block selects the lattice and beam definitions and supplies the time-step, step-count, and stopping-position schedules. Within this block, RUN selects the parallel tracker and field solver; ENDTRACK returns to ordinary input processing. Setup constructs the runtime beamline, particle containers, sources, and a validated space charge configuration. Each selected beam has its own particle container and reference state. The solver and bunch persist for the run, while the tracker coordinates their use at each step.

Tracking workflow

Before ensemble tracking, the OrbitThreader advances a reference particle through the external fields and records the encountered element supports in an index map. Queries along this reference path provide candidate active elements during tracking. Element-local field bounds then determine which contributions apply to each particle; overlapping supports can contribute simultaneously. Supported analytic ring configurations also use spatial field selection. The reference orbit therefore organizes lattice access without replacing particle-level field evaluation or including the collective force.

Normal parallel bunch tracking uses a Boris drift–kick–drift cycle. In the default MIDPOINT ordering, particles first undergo a half drift, after which their self-fields are recalculated. Emission sources are then evaluated, and external fields are evaluated at the half-step particle positions, with the element-dependent time sampling described in Sec. III B. Newly emitted particles receive an individual time increment for the fraction of the step during which they exist. Enabled spin tracking uses the assembled fields, and the momentum kick and second half drift complete the orbital step. Configured global processes, such as decay and daughter creation, are applied subsequently; invalid and lost particles are removed, reference and beam state are updated, and diagnostics are written at their requested intervals. The PRESTEP option instead evaluates space charge before the first half drift and carries the gathered fields with the particles to the kick, reproducing the historical OPAL sampling point. The configured step schedule and stopping conditions determine progression through the run. Numerical properties of the integration and collective models belong to Sec. III; their ordering is explicit here because it affects the interpretation and reproduction of a calculation.

Coupling of external and collective fields

The tracker combines two field-evaluation paths. Active accelerator elements evaluate prescribed fields in their local coordinates and add the transformed contributions to the particle field arrays. The space charge module obtains the collective contribution from the current particle distribution and returns it in the tracker coordinates. Both paths feed the same particle push, using the electric and magnetic field sums defined in Sec. III E.

At each collective update, the tracker supplies particle-container activity, time-step information, and coordinate transformations through a common solve context. The selected space charge algorithm manages its domain, deposition, field solution, and gathering. Poisson adapters connect its field storage to the corresponding IPPL backend. This separation allows the collective method to be configured independently of element-field evaluation, with TYPE=NONE selecting tracking without collective fields. The supported source containers and boundary conditions are properties of the selected algorithm. The formulation, interpolation, and solver equations remain in Sec. III.

Diagnostics and data analysis

Diagnostics combine beam-wide observables with localized measurements. Statistics record quantities such as particle number, energy, beam centroids, rms sizes, and emittances. Monitors collect bunch crossings at selected lattice locations, while probes record crossings through specified spans. Aperture and loss handling remove particles from the tracked ensemble and provide loss records where supported by the corresponding element. Output frequencies are configurable independently for statistics, phase-space snapshots, and checkpoints.

Particle phase space is written in Hierarchical Data Format version 5 (HDF5), and beam statistics are provided in Self-Describing Data Sets (SDDS) files. Optional particle-field and rank output, together with external-field sampling through DUMPEMFIELDS, supports inspection of field evaluation and parallel particle ownership. Beam moments and selected diagnostics are evaluated in situ during tracking, reducing the need to reconstruct them from full particle dumps. Exported particle and field data, together with geometry output in Visualization Toolkit (VTK) format, support visualization and subsequent analysis.

HDF5 checkpoints preserve particle and optional spin data, reference states and coordinate transforms, RF phases, and the current time and step-schedule position. Restart redistributes the saved particles over the participating MPI ranks and resumes compatible output streams. Checkpointing is independent of diagnostic phase-space dumping. Current restart support excludes time-dependent emission and stochastic decay, whose sampler or random-pool states are not saved. Changes of MPI rank count or rebuilt iterative-solver state can also change the final floating-point bits of a continuation [17].

Extensibility and reproducibility

New accelerator components extend the common element representation, including field support, coordinate handling, and field evaluation. Parser-visible objects are registered with their attributes so that they can be constructed from input statements. New collective methods implement the space charge algorithm interface; Poisson backends are connected through adapters to IPPL. These interfaces separate model implementation from the overall tracking cycle. Extensions require appropriate unit and regression tests, documentation of assumptions and units, and verification on the intended execution backends.

OPALX is distributed as open-source software under the GNU General Public License, version 3, through its public Git repository [16]. The maintained manual provides complete worked inputs and links to the regression configurations [17]. A reproducible calculation specifies the code revision, input and supporting field-map or distribution files, random seeds, particle number, mesh, solver and field-update settings, time-step schedule, and output configuration. Compiler and dependency versions, build options, numerical precision, hardware, execution backend, and MPI and thread counts are also relevant, particularly for performance comparisons. Reproducibility is assessed through physical observables and stated numerical tolerances, since changes in parallel reduction order can prevent bitwise identity across architectures.

Beam generation and accelerator components

Initial distributions and emission

The macroparticle ensemble of Sec. III is created from three input objects. A BEAM defines the particle species, the reference energy, the bunch charge, and the macroparticle allocation. A DISTRIBUTION describes the shape of the phase-space density to be sampled, or names a file from which particle coordinates are read. An EMISSION­SOURCE binds a distribution to a position and momentum offset, a start time, and an emission model. One or more sources are collected in an EMISSIONSOURCELIST and attached to the beam. This separation allows the same distribution shape to be injected at different positions or times, and several sources with different shapes to feed the same particle container. The complete attribute lists are given in the OPALX manual [17]; this section summarizes the underlying models and conventions.

Particle species and reference particle

The species ss is selected by name (electron, positron, muon, pion, proton, antiproton, deuteron, H−^{-}, H2+_{2}^{+}, alpha, carbon, xenon, and uranium) or specified through an explicit rest mass msm_s and charge qsq_s. The input charge is specified as qs/eq_s/e, where ee is the elementary charge. The named species also carry the magnetic anomaly GG used by the spin tracking and, for muons and pions, the mean lifetime used by the decay processes. For generated distributions, the reference state is specified through one of the equivalent quantities γ0\gamma_0, total energy γ0msc2\gamma_0m_sc^2, or momentum γ0β0msc\gamma_0\beta_0m_sc, from which the reference normalized momentum u0=γ0β0u_0=\gamma_0\beta_0 follows. File-based distributions instead derive the reference momentum from the loaded coordinates. The reference particle follows a tracked trajectory and is distinct from the co-moving frame of Sec. III D, whose velocity βs\beta_s is derived from the ensemble at each collective update.

The bunch-charge magnitude QbQ_b and the number of allocated macroparticles NallocN_{\mathrm{alloc}} fix the statistical weight

w=QbNalloc∣qs∣,qi=wqs,mi=wms,(44)w = \frac{Q_b}{N_{\mathrm{alloc}\lvert q_s\rvert}}, \qquad q_i = wq_s, \qquad m_i = wm_s, \tag*{(44)}

so that every macroparticle of a beam carries the charge qiq_i and mass mim_i while preserving the charge-to-mass ratio qs/msq_s/m_s that enters the equations of motion. Since ww is determined by NallocN_{\mathrm{alloc}} rather than by the number of particles actually created, creating all allocated macroparticles gives a total charge magnitude QbQ_b, with its sign determined by qsq_s. OPALX warns when the requested particle numbers are inconsistent with the allocation. Charge and mass are stored as a single value per container by default, or as per-particle attributes when individual weights are required. Several beams, each with its own species and container, can be tracked simultaneously. A beam may name a daughter beam that receives the secondary particles produced by a decay process. Decay processes require one physical particle per macroparticle, w=1w = 1. A muon beam may carry an initial polarization vector P\mathbf{P} that enables the spin attribute of Sec. III.

Supported distributions

Table I lists the distribution types available in OPALX [17]. The generated spatial distributions use scale parameters σx,σy,σz\sigma_x,\sigma_y,\sigma_z in meters. The Gaussian types also use dimensionless normalized-momentum widths σux,σuy,σuz\sigma_{u_x},\sigma_{u_y},\sigma_{u_z}, following the convention of Sec. III. For Gaussian sampling, these parameters specify the widths of the underlying normal distributions; truncation and sample-mean subtraction affect the realized rms widths. For UNIFORM, the spatial parameters are the ellipsoid semi-axes; for the flat-top types, σx\sigma_x and σy\sigma_y are the transverse semi-axes, while the longitudinal profile is specified in time. Sampling is performed in local source coordinates. For generated injected distributions, the reference momentum is added, uz→uz+u0u_z \to u_z + u_0, followed by the source offsets r0\mathbf{r}_0 and u0\mathbf{u}_0. For generated emitted distributions, the momentum is set by the emission model described below. The number of macroparticles NN is specified per distribution. To represent the full specified bunch-charge magnitude, the requested particle numbers summed over all sources of a beam must equal NallocN_{\mathrm{alloc}}.

Table I: Distribution types in OPALX. Injected distributions create all particles at the start of the simulation, or at the source start time t0t_0. Emitted distributions release particles over a finite time interval from the plane z=z0z = z_0.

TypeModePhase-space model
UNIFORMinjectedcold, uniform within an ellipsoid
GAUSSinjecteduncorrelated truncated Gaussian
MULTIVARIATEGAUSSinjectedcorrelated truncated 6D Gaussian
FLATTOPemitteduniform disk, flat-top in time
OPALFLATTOPemittedas above, OPAL birth-time ordering
FROMFILEinjected(x,ux,y,uy,z,uz)(x,u_x,y,u_y,z,u_z) from ASCII file
EMITTEDFROMFILEemittedOPAL emission dump with birth times

Table I. Distribution types in OPALX.

The UNIFORM distribution fills the ellipsoid with semi-axes (σx,σy,σz)(\sigma_x,\sigma_y,\sigma_z) uniformly by volume and assigns the common momentum (0,0,u0)(0,0,u_0); it is intended for cold-beam test problems. The GAUSS distribution draws each position coordinate independently from a normal distribution truncated at ±3σ\pm3\sigma by inverse-transform sampling, and each momentum coordinate from an untruncated normal distribution. The MULTIVARIATEGAUSS distribution accepts the upper triangle of a symmetric positive-definite correlation matrix CC in the coordinate order (x,ux,y,uy,z,uz)(x,u_x,y,u_y,z,u_z). The nominal covariance matrix Σkl=Cklσkσl\Sigma_{kl}=C_{kl}\sigma_k\sigma_l is factorized as Σ=LLT\Sigma=LL^{\mathsf{T}}, and samples are formed as x=Lξ\mathbf{x}=L\boldsymbol{\xi} from standard normal variates ξ\boldsymbol{\xi} truncated at ±3\pm3. Thus Σ\Sigma describes the covariance before truncation rather than the exact covariance of the generated ensemble. For both Gaussian types, the global mean of the sampled positions is subtracted, using a reduction over all MPI ranks, before the reference momentum and offsets are added; MULTIVARIATEGAUSS also centers the momenta. The position centroid therefore coincides with the specified source position, up to floating-point roundoff, independently of the finite particle number.

Sampling and parallel generation

Random particle sampling is performed by Kokkos kernels on the selected backend using a Kokkos XorShift64 random-number pool [14]. Each MPI rank generates its share of the NN requested macroparticles using streams seeded from the global seed option and the rank index. The local random draws require no communication, whereas the Gaussian centering operations described above require global reductions. The resulting ensemble can depend on the number of ranks and the parallel execution schedule.

For the OPALFLATTOP and EMITTEDFROMFILE emitters, a global, sorted inventory of birth times is constructed identically on every rank, and contiguous portions are assigned to individual ranks. The birth-time sequence is therefore independent of the rank count, facilitating comparisons with OPAL and between parallel configurations. This property concerns the birth times and does not, by itself, establish reproducibility of the full phase-space ensemble.

Loading distributions from files

The FROMFILE type reads an ASCII table whose first non-comment line gives the number of records and whose next non-comment line names the columns. The required column names are x, y, z, px, py, and pz, in arbitrary order. Positions are given in meters, and the momentum columns contain the dimensionless normalized components ux,uy,uzu_x,u_y,u_z. Additional columns are ignored, and no unit conversion is performed. Every MPI rank reads the file and extracts a contiguous slice whose offset is obtained from an exclusive scan of the per-rank particle counts. Changing the rank count therefore changes the partition of the selected records rather than the loaded phase-space ensemble. The source offsets r0\mathbf{r}_0 and u0\mathbf{u}_0 are added after loading. With a positive start time t0t_0, the distribution is injected in the first step whose interval contains t0t_0, and the new particles receive the remaining fraction of that step, as described by Eq. (47).

The EMITTEDFROMFILE type reads the legacy positional format (x,ux,y,uy,z,uz)(x,u_x,y,u_y,z,u_z) of OPAL emission dumps and releases the particles through time-dependent emission. Here tt is a pre-emission time in seconds rather than a longitudinal position. These file times are converted to tracker birth times using the legacy emission-time convention; the supported file formats and time conversions are documented in the OPALX manual [17].

Time-dependent emission

Photo-injector simulations start from a cathode where the bunch does not yet exist as a spatial distribution. The emitted distribution types therefore describe the beam by a temporal current profile f(t)f(t) and a transverse density on the source plane z=z0z=z_0, and particles are created step by step while the simulation time advances. Let tat_a denote the pulse-start time on the tracker clock and τ=t−ta\tau=t-t_a the time measured from the beginning of the pulse. Transverse positions are sampled uniformly on the elliptical disk with semi-axes σx\sigma_x and σy\sigma_y. The longitudinal profile is a flat top of duration tflatt_{\mathrm{flat}} with Gaussian rise and fall,

f(τ)={exp⁡[−(τ−tr)22σr2],0≤τ<tr,1,tr≤τ<tr+tflat,exp⁡[−(τ−tr−tflat)22σf2],tr+tflat≤τ≤Te,0,otherwise.(45)f(\tau)= \begin{cases} \exp\left[-\dfrac{(\tau-t_r)^2}{2\sigma_r^2}\right], & 0\leq\tau<t_r,\\ 1, & t_r\leq\tau<t_r+t_{\mathrm{flat}},\\ \exp\left[-\dfrac{(\tau-t_r-t_{\mathrm{flat}})^2}{2\sigma_f^2}\right], & t_r+t_{\mathrm{flat}}\leq\tau\leq T_e,\\ 0, & \text{otherwise}. \end{cases} \tag*{(45)}

where the rise and fall durations are tr=ctσrt_r=c_t\sigma_r and tf=ctσft_f=c_t\sigma_f, respectively, for longitudinal cutoff ctc_t, and the total emission time is Te=tr+tflat+tfT_e=t_r+t_{\mathrm{flat}}+t_f. The flat-top duration follows from the specified full width at half maximum, tflat=max⁡{0,TFWHM−2ln⁡2 (σr+σf)}t_{\mathrm{flat}}=\max\{0,T_{\mathrm{FWHM}}-\sqrt{2\ln2}\,(\sigma_r+\sigma_f)\}. The flank widths are given either directly or through 10%–90% rise and fall times, σ=T10−90/(2ln⁡10−2ln⁡(10/9))\sigma=T_{10-90}/(\sqrt{2\ln10}-\sqrt{2\ln(10/9)}). For the unmodulated profile, the normalization integral is

A=∫0Tef(τ) dτ=tflat+π2 (σr+σf)erf⁡(ct2).(46)A=\int_0^{T_e}f(\tau)\,\mathrm{d}\tau=t_{\mathrm{flat}}+\sqrt{\frac{\pi}{2}}\,(\sigma_r+\sigma_f)\operatorname{erf}\left(\frac{c_t}{\sqrt{2}}\right). \tag*{(46)}

The OPALFLATTOP type additionally supports a sinusoidal modulation of the flat top with prescribed relative amplitude and number of periods.

Emission is advanced over tracker intervals [t,t+Δt][t,t+\Delta t]. For emitter types that support EMISSIONSTEPS, the user-defined number of emission steps specifies a preferred resolution Te/NstepsT_e/N_{\mathrm{steps}} over the emission interval [17]. The FLATTOP sampler releases ⌊(N/A)∫tt+Δtf(t′−ta) dt′⌋\lfloor(N/A)\int_t^{t+\Delta t}f(t'-t_a)\,\mathrm{d}t'\rfloor new particles per step and assigns each a birth time uniformly distributed in [t,t+Δt)[t,t+\Delta t). The OPALFLATTOP sampler instead draws all NN birth times tbt_b from ff in advance, sorts them, and releases in each step the particles with tb≤t+Δtt_b\leq t+\Delta t; the pulse is centered on the source start time t0t_0, and the simulation clock starts at the earliest birth time. In both cases a newly created particle ii receives the individual time increment

Δti=t+Δt−tb,i∈[0,Δt],ri→ri+c Δti2uiγi,(47)\Delta t_i=t+\Delta t-t_{b,i}\in[0,\Delta t],\qquad\mathbf{r}_i\to\mathbf{r}_i+\frac{c\,\Delta t_i}{2}\frac{\mathbf{u}_i}{\gamma_i}, \tag*{(47)}

which is used by the Boris integrator for the remainder of the step and compensates the half drift already performed by the existing particles (Sec. IV). During charge deposition, the contribution of particle ii is weighted by qiΔti/Δtq_i\Delta t_i/\Delta t, so that particles born late in a step deposit a correspondingly smaller charge.

Emission occurs after the space charge update of the current step, and the self-field solve is skipped entirely until the number of particles exceeds a configurable minimum; the longitudinal mesh extent is stretched in proportion to the emitted fraction while emission is active.

Two emission models define the momentum of a particle leaving the cathode. The kinetic emission energy EkinE_{\mathrm{kin}} is converted to the thermal normalized momentum uth=(1+Ekin/msc2)2−1u_{\mathrm{th}}=\sqrt{(1+E_{\mathrm{kin}}/m_sc^2)^2-1}. In the NONE model, uthu_{\mathrm{th}} is added to the longitudinal component of the source momentum offset, reproducing the cathode energy increment of OPAL. In the ASTRA model, following the treatment in the ASTRA code [41], the momentum is distributed isotropically over the forward hemisphere,

ui=u0+uth(sin⁡φcos⁡θ,sin⁡φsin⁡θ,∣cos⁡φ∣),(48)\mathbf{u}_i=\mathbf{u}_0+u_{\mathrm{th}}(\sin\varphi\cos\theta,\sin\varphi\sin\theta,|\cos\varphi|), \tag*{(48)}

with φ=2arccos⁡ξ1\varphi=2\arccos\sqrt{\xi_1} and θ=2πξ2\theta=2\pi\xi_2 for uniform variates ξ1,ξ2∈[0,1)\xi_1,\xi_2\in[0,1), which gives a uniform distribution of cos⁡φ\cos\varphi and determines the thermal emittance of the emitted beam. The non-equilibrium emission model of OPAL has not been migrated. Injected distributions accept only the NONE model.

The source plane can also represent a conducting cathode. An emission source can request Dirichlet conditions at z=z0z=z_0, which is the cathode plane zpz_p of Sec. III F 4, either through explicit image charges mirrored at the plane or through the shifted Green function of the open-boundary solver. Particles that move backward through the source plane are removed from the ensemble before the external fields are evaluated, which models their absorption by the cathode.

Reference-particle initialization

At the start of tracking, the reference particle of a container that already holds particles is set to the ensemble means ⟨ri⟩\langle\mathbf{r}_i\rangle and ⟨ui⟩\langle\mathbf{u}_i\rangle. For an emitting source whose container is still empty, the reference particle is placed at the source position r0\mathbf{r}_0 with the source momentum u0\mathbf{u}_0, augmented by 12z^\frac{1}{2}\hat{\mathbf{z}} in the ASTRA model, and for EMITTEDFROMFILE with the mean momentum of the file records. The reference state is then transformed from the beamline frame to the laboratory frame and propagated to the requested start position along the lattice before the OrbitThreader of Sec. IV constructs the reference path. Emission itself takes place in the source frame, which is aligned with the local beamline direction at r0\mathbf{r}_0. The restrictions on checkpoint restart during emission are stated in Sec. IV.

Element placement

OPALX provides accelerator components representing magnetic elements, radio-frequency structures, apertures, diagnostics, and analytical or field-map-based external fields. This section focuses on the common procedures used to place these components in the accelerator lattice and evaluate their fields. A complete list of the available elements, their parameters, and the corresponding input syntax is provided in the OPALX user manual [17].

Beamline elements can be placed either by specifying their entrance coordinates ss along a nominal design path through ELEMEDGE, or by specifying explicit positions and orientations. With path-based placement, the lattice geometry determines the element orientations; PSI can additionally specify a roll about the local longitudinal axis. Explicit placement uses three position coordinates and three orientation angles.

These two placement syntaxes are demonstrated below using the same three-element lattice, consisting of a quadrupole of length 30 cm, a sector bend of length 1 m with a bending angle of 30°, and a second quadrupole of length 30 cm. The elements are denoted QUAD1, BEND, and QUAD2, respectively. The nominal geometry is shown in Figure 5. For both examples, s=0s = 0 is at the laboratory origin and the initial design direction is along the positive zz axis.

Figure 5. Top view of the QUAD1–BEND–QUAD2 line. The nominal design path (black) is shown to s=2.8s = 2.8 m. The gray lines mark the entrance faces and give their ELEMEDGE path length ss. The magnet widths are not to scale.

Placement Along Path Length

The ELEMEDGE attribute specifies the entrance coordinate ss, and L specifies the nominal element length. For the sector bend SBEND, L is the arc length of the nominal design path.

QUAD1: QUADRUPOLE,
    ELEMEDGE = 0.5,
    L = 0.3,
    K1 = 1.0;

BEND: SBEND,
    ELEMEDGE = 1.0,
    L = 1.0,
    ANGLE = PI / 6,
    HGAP = 0.0;

QUAD2: QUADRUPOLE,
    ELEMEDGE = 2.2,
    L = 0.3,
    K1 = -1.0;

QBQ: LINE = (QUAD1, BEND, QUAD2);
Absolute Placement

For the quadrupoles and sector bend in this example, X, Y, and Z specify the entrance-frame origin in laboratory coordinates. The orientation angles THETA, PHI, and PSI correspond to rotations about the yy, xx, and zz axes, respectively, and are specified in radians.

REAL X_QUAD2 = -(6 / PI) * (1 - COS(PI / 6))
             - 0.2 * SIN(PI / 6);
REAL Z_QUAD2 = 1.0 + (6 / PI) * SIN(PI / 6)
             + 0.2 * COS(PI / 6);

QUAD1: QUADRUPOLE,
    X = 0.0, Y = 0.0, Z = 0.5,
    THETA = 0.0, PHI = 0.0, PSI = 0.0,
    L = 0.3,
    K1 = 1.0;

BEND: SBEND,
    X = 0.0, Y = 0.0, Z = 1.0,
    THETA = 0.0, PHI = 0.0, PSI = 0.0,
    L = 1.0,
    ANGLE = PI / 6,
    HGAP = 0.0;

QUAD2: QUADRUPOLE,
    X = X_QUAD2, Y = 0.0, Z = Z_QUAD2,
    THETA = -PI / 6, PHI = 0.0, PSI = 0.0,
    L = 0.3,
    K1 = -1.0;

QBQ: LINE = (QUAD1, BEND, QUAD2);

The bend radius is ρ=LB/θ=(6/π)\rho= L_B / \theta= (6 / \pi) m, where LB=1L_B = 1 m and θ=π/6\theta= \pi/ 6. The 0.2 m drift from the bend exit to the second quadrupole gives the expressions for X_QUAD2 and Z_QUAD2 above. Setting THETA=-PI/6 aligns the second quadrupole with the nominal bend-exit direction. The two inputs therefore describe the same nominal geometry.

Element Field Evaluation

The element-selection procedures described in Sec. IV identify candidate contributions to the external fields. For tracking based on a reference path, the OrbitThreader constructs an IndexMap that associates path-length intervals with candidate elements according to their field-support extents [17]. For each particle, its position is transformed into the relevant element-local coordinates, and the electric and magnetic fields are evaluated using the local field model or field map. The local field-support checks determine whether a candidate element contributes to that particle. The field vectors are transformed back to the tracker coordinates before summation. The assembled external fields are combined with the self-fields as described in Sec. III E and used in the Boris momentum update. The element-dependent time sampling is specified in Sec. III B.

Figure 6 illustrates overlapping external-field supports in the first SwissFEL linac section. At the marked path coordinate s∗s^*, the IndexMap identifies the traveling-wave structure TW1 and the solenoids S1 and S2. Their field contributions are summed for particles within the corresponding local field supports.

Overlapping field supports in the first SwissFEL linac section

Figure 6. Illustration of overlapping field supports in the first SwissFEL linac section along the reference-path coordinate ss. TW1 is a traveling-wave structure, and S1–S4 are solenoids. The curves schematically indicate the on-axis RF electric field EzE_z at a fixed time and the solenoid magnetic fields BzB_z. The dashed lines mark the intervals of the IndexMap constructed by the OrbitThreader. At s∗s^*, the candidate elements are TW1, S1, and S2; their contributions are summed wherever the particle lies within their local field supports.

Numerical verification and cross-code benchmarking

Numerical verification

Disorder-Induced Heating

The disorder-induced heating (DIH) test follows the confined spherical-bunch benchmark of Mitchell and Qiang [4]. The initial distribution is cold and uniform within a sphere of radius R=1.774R = 1.774 mm, with bunch-charge magnitude Qb=25Q_b = 25 nC. The CONSTANTFOCUSING element supplies a linear focusing field whose strength is initialized from the initial mean space-charge field and then held fixed to suppress bulk expansion. The initial rms size is σx=R/5=0.793\sigma_x = R/\sqrt{5} = 0.793 mm.

For the electron macroparticle weight w=106w = 10^6, the numerical particles have charge magnitude ∣qi∣=we\lvert q_i \rvert= we and mass M=wmeM = wm_e, consistently with Eq. (44). Let NN denote the number of numerical particles and n=3N/(4πR3)n = 3N/(4\pi R^3) their initial number density. For the stationary confined system, the corresponding plasma period is

Tp=2πϵ0Mnqi2≃43.1 ps.(49)T_p = 2\pi\sqrt{\frac{\epsilon_0 M}{nq_i^2}} \simeq43.1\ \mathrm{ps}. \tag*{(49)}

As correlations develop, the correlation potential energy decreases and thermal kinetic energy increases. For an initially cold, confined one-component plasma, the equilibrium coupling parameter is approximately Γeq=2.23\Gamma_{\mathrm{eq}} = 2.23 [4, 42]. Defining the Wigner–Seitz radius aWS=[3/(4πn)]1/3a_{\mathrm{WS}} = [3/(4\pi n)]^{1/3}, the equilibrium-temperature estimate is

kBTeq≃qi24πϵ0aWSΓeq,(50)k_B T_{\mathrm{eq}} \simeq\frac{q_i^2}{4\pi\epsilon_0 a_{\mathrm{WS}}\Gamma_{\mathrm{eq}}}, \tag*{(50)}

where kBk_B is the Boltzmann constant. For an isotropic, nonrelativistic thermal distribution without position–momentum correlations, using the initial rms size gives the equilibrium-emittance estimate

εn,xeq≃σxkBTeqMc2=R5kBTeqMc2≃4.91 μm.(51)\varepsilon_{n,x}^{\mathrm{eq}} \simeq\sigma_x\sqrt{\frac{k_B T_{\mathrm{eq}}}{Mc^2}} = \frac{R}{\sqrt{5}}\sqrt{\frac{k_B T_{\mathrm{eq}}}{Mc^2}} \simeq4.91\ \mu\mathrm{m}. \tag*{(51)}

This estimate describes the simulated macroparticle system. Its interpretation is subject to the macroparticle-weight limitation discussed in Sec. III F 3.

Figure 7. Disorder-induced heating of an initially cold, uniformly populated sphere with radius R=1.774R = 1.774 mm and macroparticle weight w=106w = 10^6. All runs use open field boundaries and a 1283128^3 mesh. The P3M curves correspond to rc/h=1r_c/h = 1, 1.5, 2, and 3, where hh is the mesh spacing; the open FFT result is shown for comparison. The normalized emittance εn,x\varepsilon_{n,x} is plotted against t/Tpt/T_p. The dashed line indicates the equilibrium estimate.

Figure 7 compares the P3M results for rc/h=1r_c/h = 1, 1.5, 2, and 3 against the open-boundary mesh solver of Sec. III F 1. The P3M results show rapid initial emittance growth followed by oscillations, with peaks near the equilibrium estimate. The open FFT result remains below the P3M curves over the displayed five plasma periods. The tested P3M cutoffs produce similar oscillatory evolution, illustrating the role of the short-range interactions. This comparison is specific to the stated configuration and does not establish a general cutoff criterion.

Frozen Spin Setup

For planar motion in a transverse magnetic field, the muon’s magnetic anomaly produces spin precession relative to the momomentum, known as anomalous or gg–2 precession [43]. An appropriately chosen radial electric field cancels this relative precession. The resulting frozen-spin technique is the basis of the muEDM search at PSI [44, 45].

Let θ\theta denote the orbital azimuth and α\alpha the signed spin phase relative to the momentum in the orbital plane, with both angles using the same azimuthal orientation. For circular motion with constant speed and fields perpendicular to the velocity, the phase advance per unit orbital angle is

dαdθ=γGB−(1β2γ2−G)βE/cB+E/(βc).(52)\frac{d\alpha}{d\theta}=\gamma\frac{GB-\left(\frac{1}{\beta^{2}\gamma^{2}}-G\right)\beta E/c}{B+E/(\beta c)}. \tag*{(52)}

Here G=(g−2)/2G=(g-2)/2 is the magnetic anomaly, β=v/c\beta=v/c, and γ=(1−β2)−1/2\gamma=(1-\beta^{2})^{-1/2}. The quantities BB and EE are the magnetic-field magnitude and the radial electric-field magnitude, respectively, evaluated on the orbit. The signs in Eq. (52) correspond to an inward radial electric field, with the electric and magnetic Lorentz forces both directed toward the orbit center. Setting the numerator to zero gives

Ef=GBcβγ21−Gβ2γ2.(53)E_f=\frac{GBc\beta\gamma^{2}}{1-G\beta^{2}\gamma^{2}}. \tag*{(53)}

At E=EfE=E_f, the magnetic-moment contribution to the spin precession relative to the momentum vanishes in this ideal configuration.

The numerical test uses a μ+\mu^{+} with momentum p=125 MeV/cp=125\ \mathrm{MeV}/c (γ=1.5491\gamma=1.5491) and initial polarization aligned with its momentum. A three-dimensional field map represents a uniform vertical magnetic field of B=3 TB=3\ \mathrm{T} and the radial electric field of a cylindrical capacitor. The particle is tracked with a time step Δt=0.1 ps\Delta t=0.1\ \mathrm{ps}, and its polarization and momentum are recorded after an orbital arc of approximately 30∘30^{\circ}. Figure 8 compares the numerical phase-advance estimates with Eq. (52) as the electric-field scale k=E/Efk=E/E_f is varied. The phase advance changes sign near k=1k=1, where the frozen-spin condition is satisfied.

Spin phase advance per unit orbital angle as a function of the electric-field scale

Figure 8. Spin phase advance per unit orbital angle, dα/dθd\alpha/d\theta, as a function of the electric-field scale k=E/Efk=E/E_f (left axis). The black curve is the analytical reference from Eq. (52), and blue circles show the OPALX estimates. Orange squares show the absolute differences from the analytical prediction using the right-axis scale. The phase advance vanishes at the frozen-spin setting k=1k=1.

Cross-code benchmarking

OPALX–TraceWin beam-dynamics comparison

We compare the beam-dynamics predictions of OPALX with those of TraceWin [19] for a low-energy ion beam transported through a quadrupole triplet followed by an interdigital H-mode drift-tube linac (IH-DTL) cavity. The cavity electromagnetic fields are represented by a three-dimensional field map. This configuration tests beam transport through magnetic focusing elements and an RF accelerating structure.

Figure 9 compares the horizontal and vertical rms beam sizes, the mean kinetic energy, and the rms energy spread as functions of the longitudinal coordinate ss. The two codes predict closely matching transverse beam envelopes, including the focusing and defocusing through the quadrupole triplet and the subsequent evolution through the cavity. The mean kinetic-energy profiles agree during both the initial transport and RF acceleration. The energy-spread profiles also show consistent evolution, including the increase within the accelerating section.

Figure 9. Comparison of OPALX and TraceWin for an ion beam transported through a quadrupole triplet followed by an IH-DTL cavity. Panels show (a) the horizontal rms beam size, (b) the vertical rms beam size, (c) the mean kinetic energy, and (d) the rms energy spread as functions of the longitudinal coordinate ss. Gray dash-dotted curves show TraceWin results, and green solid curves show OPALX results. Orange and blue shaded regions indicate the quadrupoles and the IH-DTL cavity, respectively.

The mean absolute difference between the predicted mean kinetic energies is 0.0155 MeV. At the end of the line, the relative differences in the horizontal and vertical rms beam sizes are each below 2%. These endpoint differences are small compared with the variations in beam size along the line. The comparison provides an independent cross-check of the predicted magnetic focusing and RF acceleration for this configuration and these beam observables.

G4Beamline Wien Filter

A Wien filter combines a transverse magnetic field ByB_y and an orthogonal electric field ExE_x [46, 47]. For a particle traveling along the positive zz axis in ideal uniform fields, the condition Ex=vByE_x=vB_y cancels the transverse Lorentz force. The spin polarization can nevertheless rotate in the combined fields [48]. This configuration therefore provides a test of spin transport in simultaneous electric and magnetic fields. We compare OPALX with G4Beamline [18], a Geant4-based particle-tracking code with spin-tracking and decay capabilities [49].

The test uses the separator field map from the G4Beamline model of the μ\muH2 beamline at PSI. The fields are scaled to central values By=22.1B_y = 22.1 mT and Ex=1.60E_x = 1.60 MV ⋅\cdot m−1^{-1}, and the input muon momentum is p=26.825p = 26.825 MeV/cc. Both codes use the same field map and the same set of 1000 initial μ+\mu^+ particles. Positions, momenta, and spin vectors are recorded at eight monitor planes.

Figure 10 compares the mean spin rotation about the yy axis along the separator and summarizes the spin-vector differences between the two codes using the median and 99th percentile. Both codes predict a downstream mean rotation of approximately −0.25-0.25 rad.

Mean spin rotation and spin-vector differences

Figure 10. Mean spin rotation about the yy axis as a function of position zz (left axis). Blue filled circles show OPALX results, and orange open circles show G4Beamline results. The shaded region indicates the longitudinal extent of the field map. Green diamonds and purple triangles show the median and 99th percentile, respectively, of the spin-vector differences (right axis, logarithmic scale). The initial difference is zero to machine precision and is omitted from the logarithmic axis.

G4Beamline μ\muE4 Beamline

The μ\muE4 beamline at PSI transports surface muons [50]. These μ+\mu^+ originate from the decay at rest of π+\pi^+ that stop near the surface of a graphite target irradiated by the 590 MeV proton beam. The comparison presented here uses an input muon momentum of 28 MeV/cc.

The modeled beamline segment is 19.25 m long and contains one solenoid (WSX), three dipoles (one ASR61 and two ASR62), twelve quadrupoles (QSM600) arranged in four triplets, and three sets of collimator slits (FS61, FS62, and FS63). The magnetic fields are specified by field maps. Material interactions are not simulated: particles entering the collimators or magnet housings are removed. Twenty-three monitor planes record the transverse phase space and spin polarization along the beamline. The initial spin polarization is aligned with the beam axis.

For the comparison, OPALX and G4Beamline track the same set of 2×1042 \times10^4 initial muons. OPALX uses a time step of 10−1210^{-12} s, corresponding at 28 MeV/cc to the 0.0768 mm step length used in G4Beamline. Two cases are considered, both with spin tracking: one with muon decay disabled and one with muon decay enabled. Particle data are recorded at all 23 monitor planes.

With decay disabled, the histogram bin populations at the monitors agree to within one particle. For 95 % of the muons, the position differences are within 12 μ\mum and the spin-vector differences are within 10−410^{-4}. Figure 12 compares the magnitude of the mean spin polarization and the particlewise spin differences along the beamline.

Spin-polarization comparison along the $\mu$E4 beamline

Figure 12. Spin-polarization comparison along the μ\muE4 beamline. Upper panel: magnitude of the mean spin-polarization vector from OPALX and G4Beamline. Lower panel: median and 95th percentile of the magnitudes of the particlewise differences between the spin-polarization vectors recorded by the two codes.

With decay enabled, the independently sampled decays require a statistical comparison of the two ensembles. Approximately 11 % of the muons decay before the end of the line. The final monitor records 9262 muons in OPALX and 9283 in G4Beamline; particles can also be lost at the collimators and magnet housings. Figure 11 compares the transverse phase-space distributions at three monitor locations for this case.

Transverse phase-space distributions in the $\mu$E4 comparison

Figure 11. Transverse phase-space distributions in the μ\muE4 comparison with spin tracking and muon decay enabled, using 2×1042 \times10^{4} initial muons. The monitor locations are (a) z=4.3z = 4.3 m, after the first dipole and collimator, (b) z=9.8z = 9.8 m, and (c) z=19.25z = 19.25 m, at the end of the modeled segment. The upper and lower panels show the horizontal and vertical phase spaces, respectively. Blue shading shows the OPALX particle counts per bin; red contours enclose 50 %, 90 %, and 99 % of the G4Beamline particles. The marginal histograms show the projections onto each axis.

Performance portability and scalability

Three-Dimensional Space Charge Benchmark

We assess the particle throughput of OPALX using the three-dimensional space charge benchmark of Ref. [20]. The reference configuration is a 1 nC, 250 MeV electron bunch transported through a 6 m drift with one space charge kick, using a 64364^{3} mesh, open boundaries, and an integrated Green function. The calculations use double precision (FP64). The benchmark is formulated for codes that advance particles along a longitudinal coordinate ss; the OPALX input adapts this configuration to laboratory-time tracking. All reported OPALX points pass the benchmark’s physics checks.

Figure 14 compares throughput as a function of the number of macroparticles NN, and Figure 13 summarizes the results. Throughput is defined as N/τN/\tau, where τ\tau is the time per step. For OPALX, this time is estimated from the difference between the wall times of 11-step and 1-step runs, divided by the ten additional steps. The reported timings use the fastest of three to five repeats. This metric measures the benchmark step, including the space charge calculation, rather than the particle momentum update alone.

Figure 13. Throughput summary for the three-dimensional space charge benchmark of Fig. 14. GPU entries use the particle count with the highest measured throughput for each code; CPU entries use N=106N = 10^{6}. Orange markers identify OPALX: filled markers denote the A100-40GB GPU and EPYC 7742 CPU results, and open markers denote the GH200 GPU and Grace CPU results. Reference CPU results use the EPYC 7763. The ordering therefore includes different hardware configurations and, for GPUs, potentially different particle counts.

Figure 14. Throughput as a function of macroparticle count NN for the three-dimensional space charge benchmark [20]: (a) one GPU and (b) one CPU socket. The reference configuration uses a 1 nC, 250 MeV electron bunch, a 64364^3 mesh, an integrated Green function, open boundaries, and FP64 arithmetic. Gray curves show reference results obtained with the benchmark harness on Perlmutter using an A100-SXM4-40GB GPU or a 64-core AMD EPYC 7763 socket, with the fastest FP64 build and CPU MPI-rank/thread layout selected for each code and particle count. Orange solid curves with filled markers show OPALX on an A100-SXM4-40GB GPU and a 64-core AMD EPYC 7742 socket; dashed curves with open markers show OPALX on a GH200 GPU and 64 Grace CPU cores. The EPYC 7742 and EPYC 7763 are different processor generations. The OPALX CPU runs use one MPI rank per core. Light lines indicate constant time per step, with throughput N/τN/\tau.

The reference results were obtained with the benchmark harness on Perlmutter, using an NVIDIA A100-SXM4-40GB GPU or a 64-core AMD EPYC 7763 CPU socket. The reference CPU runs use the fastest MPI-rank and thread layout selected for each code and particle count, and the reference results use the fastest FP64 build of each code. The OPALX GPU runs use an A100-SXM4-40GB and an NVIDIA GH200. Its CPU runs use a 64-core AMD EPYC 7742 socket and 64 of the 72 cores of a Grace CPU, with one MPI rank per core. The A100 comparison uses the same GPU model as the reference results. The CPU comparisons involve different processor models, and the GH200 results use different GPU hardware.

On a single GPU, the OPALX throughput approaches 1.0×1091.0 \times10^{9} macroparticles/s on the A100 and 2.3×1092.3 \times10^{9} macroparticles/s on the GH200. The A100 throughput is approximately 62 % of the Synergia result and 72 % of the ImpactX result on the 40 GB A100, approximately 2.5 times the Xsuite throughput, and approximately 11 times the Cheetah and HELIX throughputs. For N≲106N \lesssim10^{6}, the A100 step time changes little with particle count: 11.0 ms at N=105N = 10^{5} and 11.1 ms at N=106N = 10^{6}. This behavior is consistent with a substantial contribution from mesh operations and other costs that depend weakly on particle count. Above approximately N=107N = 10^{7}, the throughput approaches a plateau, consistent with an increasing contribution from particle-dependent work.

At N=106N = 10^{6}, OPALX reaches 3.2×1073.2 \times10^{7} macroparticles/s on 64 Grace cores. This is approximately 2.7, 2.2, and 1.3 times the reference throughputs of Xsuite, PyORBIT, and ImpactX, respectively, and 85% of the Synergia throughput on the EPYC 7763. On the EPYC 7742, OPALX reaches 1.7×1071.7 \times10^{7} macroparticles/s, approximately 72% of the ImpactX throughput, 46% of the Synergia throughput, and 1.2 and 1.5 times the PyORBIT and Xsuite throughputs, respectively. These ratios describe the measured code–hardware combinations.

In a CPU rank-scaling test, increasing the number of MPI ranks from 8 to 64 reduces the field-solve time from 145 to 23 ms and the total step time from 179 to 31 ms. The particle-related contribution decreases from 28 to 6 ms. These runs use orthogonal recursive bisection (ORB) load balancing, with the load-balancing condition checked at every step. Without ORB, the particle-related contribution remains between 50 and 58 ms, with the ranks covering the bunch center holding most of the particles.

μ\muE4 Beamline Performance and Strong Scaling

We measure run times for the μ\muE4 beamline model described in Sec. VII B.3, using larger particle ensembles with spin tracking and muon decay enabled and space charge disabled. These runs use a 28 MeV/cc beam, a time step of 10−1110^{-11} s in OPALX, and the corresponding step length of 0.768 mm in G4Beamline. Recording monitors are placed near the start (z=10z = 10 mm) and at the end (z=19.25z = 19.25 m) of the modeled segment. Three hardware configurations are used. On the CSCS Daint supercomputer, OPALX tracks 10810^{8} muons sampled from the same initial distribution as the smaller comparison case, using 1–16 NVIDIA GH200 GPUs with one MPI rank per GPU. On a MacBook Pro with an Apple M4 processor, each code uses one CPU core to track the same 10510^{5} muons read from a file. On the PSI Merlin6 cluster, G4Beamline tracks 10610^{6} muons on 60 CPU cores of one node.

Figure 15a shows the measured wall times. On one Apple M4 core, the wall time per initial muon is 5.2 ms for OPALX and 27 ms for G4Beamline, giving a run-time ratio of approximately 5.2. The dotted lines extrapolate these measurements assuming that wall time is proportional to the initial particle count. Under this assumption, tracking 10810^8 muons on one core would require approximately 6 days with OPALX and 32 days with G4Beamline. In comparison, the measured OPALX wall time for 10810^8 muons is approximately 3.5 h on one GH200 GPU and 17 min on 16 GPUs. The one-GPU time is about 41 times shorter than the extrapolated single-core OPALX time. The G4Beamline run on 60 Merlin6 cores requires 0.98 ms per initial muon, approximately 7.8 times the wall time per initial muon of the one-GPU OPALX run. These latter comparisons involve different hardware and, for the Merlin6 run, different particle counts.

Current limitations and outlook

The results presented here assess selected physical models and numerical operations within OPALX. The verification cases and cross-code comparisons in § 2 examine short-range interactions, orbital and spin dynamics, and RF acceleration for specific configurations. Extending this assessment requires systematic studies of time-step, mesh, and particle-number dependence, together with uncertainty estimates for stochastic processes. Agreement between independent codes provides a useful consistency check, while comparisons with measurements are needed to assess predictive accuracy for experimental systems.

The applicability of the collective models is governed by the assumptions described in Sec. III. The self-field calculation uses a quasi-static electrostatic approximation in a co-moving frame, requiring sufficiently small internal currents and sufficiently slow source evolution. The local treatment of accelerating or curved beams also requires the frame approximation to remain appropriate on the bunch scale. The 2.5D method introduces additional assumptions about beam elongation and longitudinal variation and currently uses a planar reference path. For P3M, the interpretation of short-range dynamics depends on the numerical particle weights, as discussed in Sec. III F.3. Resolving pair interactions between macroparticles does not by itself establish the physical binary-collision dynamics of the represented beam. The disorder-

Figure 15b shows the strong scaling of OPALX for a fixed initial ensemble of 10810^8 muons. Increasing the GPU count from 1 to 16 reduces the wall time from 12 520 s to 1047 s, corresponding to a speedup of 12.0 and a parallel efficiency of approximately 75 %. The accumulated step timers show a speedup of 11.7. Time outside these timers, attributed primarily to initialization, monitor output, muon decay, and removal of lost particles, accounts for 23 % of the total wall time on one GPU and 21 % on 16 GPUs. This contribution therefore also decreases in absolute time. The reduction in wall time from one to two GPUs exceeds a factor of two; the cause of this superlinear speedup has not been established. induced-heating case therefore tests the specified numerical particle system.

Run-time measurements for the $\mu$E4 model: wall time as a function of the initial number of muons and strong scaling on NVIDIA GH200 GPUs

Figure 15. (a) Wall time as a function of the initial number of muons. Each point represents one run. Dotted lines show linear extrapolations through the single-core measurements. (b) Strong scaling of OPALX on NVIDIA GH200 GPUs for 10810^{8} initial muons. Solid line: total wall time. Dashed line: accumulated step timers covering particle motion, field evaluation, aperture checks, and beam statistics. Dotted line: ideal scaling normalized to the one-GPU step-timer measurement. Figure 15: Run-time measurements for the μ\muE4 model with spin tracking and muon decay enabled and space charge disabled.

The performance results in Sec. VII demonstrate CPU and GPU execution for the reported workloads. Their interpretation depends on the particle count, numerical model, timing interval, and hardware configuration. In particular, the multi-GPU μ\muE4 calculation has space charge disabled, so its strong-scaling result does not establish the scaling of a distributed self-consistent field calculation. Further performance assessment should include integrated accelerator workloads with collective effects, communication and load-balancing costs, and the sensitivity of time to solution to the required numerical accuracy.

Priorities for further assessment include comparisons with legacy OPAL calculations and experimental measurements, together with integrated accelerator studies. Studies combining accelerator fields, collective dynamics, and, where relevant, emission or spin tracking will help establish the range of practical applications supported by the framework. Reproducible assessment requires benchmark inputs, supporting field maps and distributions, analysis scripts, and numerical results, together with the code and build information needed to reproduce both the physical observables and the performance measurements.

Conclusions

We have presented OPALX, an accelerator simulation framework that integrates relativistic particle tracking, spin dynamics, accelerator-component models, and collective-field calculations within a common computational architecture. Built on IPPL and Kokkos, the framework combines distributed-memory parallelism with CPU and GPU execution. Its interfaces connect beam generation and emission, external-field evaluation, space charge solvers, and diagnostics within a shared tracking workflow.

The cases presented in this paper assess selected parts of this implementation. The disorder-induced-heating case examines correlation-driven heating in the specified numerical particle system, while the frozen-spin case compares spin evolution with an analytical reference. Comparisons with TraceWin assess magnetic focusing and RF acceleration, and comparisons with G4Beamline examine orbital and spin transport through a Wien filter and the μ\muE4 beamline. These studies provide cross-checks for the configurations and observables considered.

The performance benchmarks demonstrate CPU and GPU execution for both a three-dimensional space charge calculation and beamline tracking. In the space charge benchmark, OPALX reaches approximately 1.0×1091.0 \times10^{9} macroparticles/s on an NVIDIA A100 GPU and 2.3×1092.3 \times10^{9} macroparticles/s on an NVIDIA GH200 GPU. For the μ\muE4 model with spin tracking and muon decay enabled and space charge disabled, tracking 10810^{8} initial muons on 16 GH200 GPUs gives a speedup of approximately 12 relative to one GPU, corresponding to a parallel efficiency of 75 %. These results establish performance for the reported workloads and hardware configurations. The broader convergence, validation, and application studies outlined in Sec. VIII will extend this assessment.

Acknowledgments

This work was supported in part by the Platform for Advanced Scientific Computing (PASC) through the OPAL-X: Object oriented Parallel Accelerator Library for eXascale project and by the Swiss National Science Foundation (SNSF).

References

References

  1. [1]M. Reiser, Theory and Design of Charged Particle Beams, 2nd ed. (Wiley-VCH, Weinheim, Germany, 2008).
  2. [2]I. Hofmann, Space Charge Physics for Particle Accelerators, Particle Acceleration and Detection (Springer International Publishing, Cham, Switzerland, 2017).DOI
  3. [3]E. Prat, P. Craievich, P. Dijkstal, S. Di Mitri, E. Ferrari, T. G. Lucas, A. Malyzhenkov, G. Perosa, S. Reiche, and T. Schietinger, Energy spread blowup by intrabeam scattering and microbunching at the SwissFEL injector, Phys. Rev. Accel. Beams 25, 104401 (2022).
  4. [4]C. Mitchell and J. Qiang, A Parallel Particle-Particle, Particle-Mesh Solver for Studying Coulomb Collisions in the Code IMPACT-T, in Proc. 6th International Particle Accelerator Conference (IPAC’15) (JACoW, Geneva, Switzerland, 2015) pp. 593–595.
  5. [5]M. Zampetakis, F. Antoniou, F. Asvesta, H. Bartosik, and Y. Papaphilippou, Interplay of space charge, intrabeam scattering, and synchrotron radiation in the Compact Linear Collider damping rings, Phys. Rev. Accel. Beams 27, 064403 (2024).
  6. [6]M. Zampetakis, F. Antoniou, F. Asvesta, H. Bartosik, Y. Papaphilippou, and A. Saá Hernández, Interplay of space charge and intrabeam scattering in the lhc ion injector chain (2023), arXiv:2310.03504 [physics.acc-ph].
  7. [7]J. Qiang, R. D. Ryne, S. Habib, and V. Decyk, An Object-Oriented Parallel Particle-in-Cell Code for Beam Dynamics Simulation in Linear Accelerators, Journal of Computational Physics 163, 434 (2000).
  8. [8]A. Huebl, R. Lehè, C. E. Mitchell, J. Qiang, R. Ryne, R. Sandberg, and J.-L. Vay, Next Generation Computational Tools for the Modeling and Design of Particle Accelerators at Exascale, in Proc. 5th Int. Particle Accel. Conf. (NAPAC’22) (JACoW Publishing, 2022) pp. 302–306.DOI
  9. [9]A. Adelmann, P. Calvo, M. Frey, A. Gsell, U. Locans, C. Metzger-Kraus, N. Neveu, C. Rogers, S. Russell, S. Sheehy, et al., OPAL a versatile tool for charged particle accelerator simulations (2019), arXiv:1905.06654 [physics.acc-ph].arxiv.org/abs/1905.06654
  10. [10]N. Neveu, L. Spentzouris, A. Adelmann, Y. Neichen, A. Kolano, C. Metzger-Kraus, C. Bekas, A. Curioni, and P. Arbenz, Parallel general purpose multiobjective optimization framework with application to electron beam dynamics, Phys. Rev. Accel. Beams 22, 054602 (2019).
  11. [11]D. Winklnehrer, A. Adelmann, A. Gsell, T. Kaman, and D. Campo, Realistic simulations of a cyclotron spiral inflector within a particle-in-cell framework, Phys. Rev. Accel. Beams 20, 124201 (2017).
  12. [12]D. Winklnehrer, J. M. Conrad, D. Schoen, M. Yampolskaya, A. Adelmann, S. Mayani, and S. Muralikrishnan, Order-of
  13. [13]S. Muralikrishnan, M. Frey, A. Vinciguerra, M. Logitino, A. J. Cerfon, M. Stoyanov, R. Gayatri, and A. Adelmann, Scaling and performance portability of the particle-in-cell scheme for plasma physics applications through mini-apps targeting exascale architectures, in Proceedings of the 2024 SIAM Conference on Parallel Processing for Scientific Computing (PP) (Society for Industrial and Applied Mathematics, 2024) pp. 26–38.
  14. [14]C. R. Trott, D. Lebrun-Grandie, D. Arndt, J. Ciesko, V. Dang, N. Ellingwood, R. Gayatri, E. Harvey, D. S. Hollman, D. Ibanez, et al., Kokkos 3: Programming model extensions for the exascale era, IEEE Transactions on Parallel and Distributed Systems 33, 805 (2022).
  15. [15]Message Passing Interface Forum, MPI: A Message-Passing Interface Standard, Version 5.0 (2025).
  16. [16]OPALX Project, OPALX: Object-oriented particle accelerator library for exascale, https://github.com/OPALX-project/OPALX (2026).
  17. [17]OPALX Project, The OPALX Universe: User Guide, Physics Manual, Reference, and Developer Handbook (2026), source: https://github.com/OPALX-project/opalx-manual.
  18. [18]T. J. Roberts and D. M. Kaplan, G4beamline simulation program for matter-dominated beamlines, in 2007 IEEE Particle Accelerator Conference (PAC) (IEEE, 2007) pp. 3468–3470.
  19. [19]D. Uriot and N. Pichoff, Status of TraceWin Code, in Proc. 6th International Particle Accelerator Conference (IPAC’15) (JACoW, 2015) pp. 92–94.DOI
  20. [20]A. Huebl, ImpactX Benchmarks, https://github.com/BLAST-ImpactX/impactx-benchmarks (2026), Accessed: 16 October 2026.
  21. [21]S. Zenitani and T. Umeda, On the Boris solver in particle-in-cell simulation, Physics of Plasmas 25, 112110 (2018).DOI
  22. [22]U. Fano, Description of States in Quantum Mechanics by Density Matrix and Operator Techniques, Reviews of Modern Physics 29, 74 (1957).DOI
  23. [23]K. Blum, Density Matrix Theory and Applications, 3rd ed., Springer Series on Atomic, Optical, and Plasma Physics, Vol. 64 (Springer, Berlin, Heidelberg, 2012).
  24. [24]V. Bargmann, L. Michel, and V. L. Telegdi, Precession of the polarization of particles moving in a homogeneous electromagnetic field, Phys. Rev. Lett. 2, 435 (1959).
  25. [25]L. H. Thomas, The Motion of the Spinning Electron, Nature 117, 514 (1926).DOI
  26. [26]J. D. Jackson, Classical Electrodynamics, 3rd ed. (Wiley, New York, 1999).
  27. [27]E. Hairer, C. Lubich, and G. Wanner, Geometric Numerical Integration: Structure-Preserving Algorithms for Ordinary Differential Equations, 2nd ed., Springer Series in Computational Mathematics, Vol. 31 (Springer, Berlin, Heidelberg, 2006).
  28. [28]O. Rodrigues, Des lois géométriques qui régissent les déplacements d’un système solide dans l’espace, et de la variation des coordonnées provenant de ces déplacements considérés indépendamment des causes qui peuvent les produire, Journal de Mathématiques Pures et Appliquées 5, 380 (1840).
  29. [29]J. S. Dai, Euler–Rodrigues formula variations, quaternion conjugation and intrinsic connections, Mechanism and Machine Theory 92, 144 (2015).DOI
  30. [30]A. Lieman, Adaptive Energy Binning in OPALX, Master’s thesis, ETH Zurich (2025).
  31. [31]R. W. Hockney and J. W. Eastwood, Computer Simulation Using Particles (CRC Press, Boca Raton, 2021).
  32. [32]S. Mayani, V. Montanaro, A. J. Cerfon, M. Frey, S. Muralikrishnan, and A. Adelmann, A massively parallel performance portable free-space spectral poisson solver, ACM Transactions on Mathematical Software 51, 15 (2025).
  33. [33]J. Qiang, S. M. Lidia, R. D. Ryne, and C. Limborg-Deprey, Three-dimensional quasistatic model for high brightness beam dynamics simulation, Phys. Rev. ST Accel. Beams 9, 044204 (2006).DOI
  34. [34]A. Ayala, S. Tomov, A. Haidar, and J. Dongarra, heFFTe: Highly Efficient FFT for Exascale, in Computational Science - ICCS 2020, Lecture Notes in Computer Science, Vol. 12137 (Springer International Publishing, 2020) pp. 262–275.DOI
  35. [35]A. Piwinski, Intra-beam-Scattering, in 9th International Conference on High-Energy Accelerators (1974) pp. 405–409.
  36. [36]J. D. Bjorken and S. K. Mtingwa, Intrabeam scattering, Part. I, Phys. Rev. Lett. 51, 115 (1983).
  37. [37]K. L. F. Bane, H. Hayano, K. Kubo, T. Naito, T. Okugi, and J. Urakawa, Intrabeam scattering analysis of measurements at KEK’s Accelerator Test Facility damping ring, Physical Review Special Topics - Accelerators and Beams 5, 10.1103/physrevstab.5.084403 (2002).DOI
  38. [38]T. G. Lucas, P. Craievich, E. Prat, S. Reiche, and E. Gjonaj, Accurate modelling of intrabeam scattering and its impact on photoinjectors for free-electron lasers, Scientific Reports 16, 2629 (2026).DOI
  39. [39]S. Di Mitri, G. Perosa, A. Brynes, I. Setija, S. Spampinati, P. H. Williams, A. Wolski, E. Allaria, S. Brussaard, L. Giannessi, et al., Experimental evidence of intrabeam scattering in a free-electron laser driver, New Journal of Physics 22, 083053 (2020).
  40. [40]T. Wyssling and A. Adelmann, On Boundary Conditions in the sub-mesh interaction of the Particle-Particle-Particle-Mesh Algorithm (2021), arXiv:2103.02046 [physics.comp-ph].arxiv.org/abs/2103.02046
  41. [41]K. Flöttmann, A Space Charge Tracking Algorithm, DESY, Hamburg, Germany (2017), user manual, version 3.2.
  42. [42]J. M. Maxson, I. V. Bazarov, W. Wan, H. A. Padmore, and C. E. Coleman-Smith, Fundamental photoemission brightness limit from disorder induced heating, New Journal of Physics 15, 103024 (2013).DOI
  43. [43]F. Jegerlehner and A. Nyffeler, The muon g-2, Physics Reports 477, 1 (2009).DOI
  44. [44]A. Adelmann, A. R. Bainbridge, I. Bailey, A. Baldini, S. Basnet, N. Berger, L. Bianco, C. Calzolaio, L. Caminada, G. Cavoto, et al., A compact frozen-spin trap for the search for the electric dipole moment of the muon, The European Physical Journal C 85, 622 (2025).
  45. [45]F. J. M. Farley, K. Jungmann, J. P. Miller, W. M. Morse, Y. F. Orlov, B. L. Roberts, Y. K. Semertzidis, A. Silenko, and E. J. Stephenson, New Method of Measuring Electric Dipole Moments in Storage Rings, Physical Review Letters 93, 052001 (2004).pubmed.ncbi.nlm.nih.gov/15323687
  46. [46]W. Wien, Untersuchungen über die elektrische Entladung in verdünnten Gasen, Annalen der Physik 301, 440 (1898).
  47. [47]E. Plies, K. Marianowski, and T. Ohnweiler, The Wien filter: History, fundamentals and modern applications, Nuclear Instruments and Methods in Physics Research Section A 645, 7 (2011).DOI
  48. [48]K. Tsuno and D. Ioanoviciu, Application of Wien Filters to Electrons, in Advances in Imaging and Electron Physics, Vol. 176 (Elsevier, 2013) pp. 177–212.DOI
  49. [49]S. Agostinelli et al., GEANT4 - A Simulation Toolkit, Nucl. Instrum. Meth. A 506, 250 (2003).DOI
  50. [50]T. Prokscha, E. Morenzoni, K. Deiters, F. Foroughi, D. George, R. Kobler, A. Suter, and V. Vrankovic, The new μE4 beam at PSI: A hybrid-type large acceptance channel for the generation of a high intensity surface-muon beam, Nucl. Instrum. Methods Phys. Res. A 595, 317 (2008).DOI

AI tools statement

No AI-use declaration is available for this version in Valency.

The available record does not establish whether AI systems or models contributed to this work.

How AI tools are recorded

Paper details

Cite this paper

Publication

Published
Version
Latest

Data & code

No code, data or supplementary files were declared for this version.

Pick where to look, or just type