ImpactX
Loading...
Searching...
No Matches
impactx Namespace Reference

Namespaces

namespace  detail
namespace  diagnostics
namespace  distribution
namespace  elements
namespace  envelope
namespace  initialization
namespace  integrators
namespace  particles
namespace  transformation

Classes

struct  Config
struct  CopyAndMarkNegative
struct  Envelope
class  ImpactX
class  ImpactXParticleContainer
struct  IntSoA
class  ParConstIterSoA
class  ParIterSoA
struct  ParticleChunk
struct  RealSoA
struct  RefPart
struct  TrackingState

Typedefs

using Map6x6 = amrex::SmallMatrix<amrex::ParticleReal, 6, 6, amrex::Order::F, 1>
using CovarianceMatrix = Map6x6

Enumerations

enum class  CoordSystem { s , t }
enum class  TrackingDirection { Forward , Backward }

Functions

template<typename T_Element, bool UseSimd = true, typename F>
void ParallelFor (int n, F &&f)
SpaceChargeAlgo get_space_charge_algo ()
std::string to_string (SpaceChargeAlgo sca)
 AMREX_ENUM (SpaceChargeAlgo, False, True_3D, Gauss3D, Gauss2p5D, True_2D, True_2p5D)
void read_element (std::string const &element_name, std::list< elements::KnownElements > &m_lattice, int nslice_default)
std::unordered_map< int, std::pair< amrex::MultiFab, amrex::MultiFab > > flatten_charge_to_2D (std::unordered_map< int, amrex::MultiFab > const &rho, amrex::Box domain_3d)
std::unordered_map< int, amrex::MultiFabproject_charge_to_2D (std::unordered_map< int, amrex::MultiFab > const &rho, amrex::Box domain_3d)
void collect_lost_particles (ImpactXParticleContainer &source)
Map6x6 symplectic_form ()
void push (ImpactXParticleContainer &pc, elements::KnownElements &element_variant, int step, int period)
void push (RefPart &ref, elements::KnownElements &element_variant)
template<typename T_Element>
void push_all (ImpactXParticleContainer &pc, T_Element &element, int step, int period, bool omp_parallel=true)
ParticleChunk split_equally (amrex::Long npart, amrex::Long index, amrex::Long size)
template<typename HookFn, typename CollectiveKicks, typename ElementPush>
void track_lattice_particles (std::list< elements::KnownElements > &lattice, ImpactXParticleContainer &pc, TrackingState &tracking_state, HookFn const &call_hook, CollectiveKicks &&collective_kicks, ElementPush &&element_push)

Typedef Documentation

◆ CovarianceMatrix

this is the 6x6 covariance matrix

◆ Map6x6

using impactx::Map6x6 = amrex::SmallMatrix<amrex::ParticleReal, 6, 6, amrex::Order::F, 1>

this is a 6x6 matrix

Enumeration Type Documentation

◆ CoordSystem

enum class impactx::CoordSystem
strong
Enumerator

fixed s as the independent variable

fixed t as the independent variable

◆ TrackingDirection

enum class impactx::TrackingDirection
strong

Direction in which the lattice is traversed.

Forward is ordinary tracking (entrance to exit). Backward traverses the periods, elements and space-charge slices in reverse, inverts each element's map, and applies the per-slice operations in mirrored order, i.e. time-symmetric back-tracking.

Enumerator
Forward 
Backward 

Function Documentation

◆ AMREX_ENUM()

impactx::AMREX_ENUM ( SpaceChargeAlgo ,
False ,
True_3D ,
Gauss3D ,
Gauss2p5D ,
True_2D ,
True_2p5D  )

Space Charge: Implemented algorithms

Parameters
-Disabled: no space charge calculation
-3D beam distribution
-Assume a 3D Gaussian beam distribution
-Assume a transverse 2D Gaussian beam distribution
-Averaged 2D transverse beam distribution
-Averaged 2D transverse beam distribution with a current along s

◆ collect_lost_particles()

void impactx::collect_lost_particles ( ImpactXParticleContainer & source)

Move lost particles into a separate container

If particles are marked as lost, by setting their id to negative, we will move them to another particle container, store their position when lost and stop pushing them in the beamline.

Parameters
sourcethe beam particle container that might loose particles

◆ flatten_charge_to_2D()

std::unordered_map< int, std::pair< amrex::MultiFab, amrex::MultiFab > > impactx::flatten_charge_to_2D ( std::unordered_map< int, amrex::MultiFab > const & rho,
amrex::Box domain_3d )

◆ get_space_charge_algo()

SpaceChargeAlgo impactx::get_space_charge_algo ( )

Return the currently active space charge algorithm

◆ ParallelFor()

template<typename T_Element, bool UseSimd = true, typename F>
void impactx::ParallelFor ( int n,
F && f )

A generalized ParallelFor that dispatches to amrex::ParallelFor or amrex::ParallelForSIMD depending on whether the element type T_Element is vectorized.

Template Parameters
T_Elementthe element type
UseSimddefault-on if AMREX_USE_SIMD is set, allows disabling SIMD for performance corner cases
Fthe functor type
Parameters
nthe number of items to iterate over
fthe functor to execute

◆ project_charge_to_2D()

std::unordered_map< int, amrex::MultiFab > impactx::project_charge_to_2D ( std::unordered_map< int, amrex::MultiFab > const & rho,
amrex::Box domain_3d )

Project a deposited 3D charge density to 2D (x-y).

Convenience wrapper around flatten_charge_to_2D that keeps only the unique (charge-conserving) projection per level.

Parameters
rhothe deposited (raw, un-summed) 3D charge per level
domain_3dthe level-0 simulation domain (cell-centered)
Returns
the 2D-projected charge per level

◆ push() [1/2]

void impactx::push ( ImpactXParticleContainer & pc,
elements::KnownElements & element_variant,
int step,
int period )

Push a whole particle beam (incl. reference particle) through an element

Parameters
[in,out]pccontainer of the particles to push
[in,out]element_varianta single element to push the particles through
[in]stepglobal step for diagnostics
[in]periodfor periodic lattices, this is the current period (turn or cycle)

◆ push() [2/2]

void impactx::push ( RefPart & ref,
elements::KnownElements & element_variant )

Push the reference particle through an element

Parameters
[in,out]refthe reference particle
[in,out]element_varianta single element to push the particles through

◆ push_all()

template<typename T_Element>
void impactx::push_all ( ImpactXParticleContainer & pc,
T_Element & element,
int step,
int period,
bool omp_parallel = true )

Push all particles in a particle container.

This element pushes first the reference particle, then all other particles. All particles are pushed independently with the same logic. Particles are relative to the reference particle.

Parameters
[in,out]pcparticle container to push
[in,out]elementthe beamline element
[in]stepglobal step for diagnostics
[in]periodfor periodic lattices, this is the current period (turn or cycle)
[in]omp_parallelallow threading via OpenMP for the particle iterator loop (note: if OMP backend is active)

◆ read_element()

void impactx::read_element ( std::string const & element_name,
std::list< elements::KnownElements > & m_lattice,
int nslice_default )

Read a lattice element

Read a lattice element from amrex::ParmParse, initialize it and append it to m_lattice.

Parameters
[in]element_nameelement name
[in,out]m_latticethe accelerator lattice
[in]nslice_default

◆ split_equally()

ParticleChunk impactx::split_equally ( amrex::Long npart,
amrex::Long index,
amrex::Long size )

Split an array of contiguous elements into well-balanched chunks.

This function contains the auxiliary math to split npart contiguous particles into contiguous chunks of size, returning the individual starting offset and chunk size. It also deals with distributing remainders well.

This can be used for distributed logic for MPI and OpenMP parallelism alike.

Parameters
nparttotal number of elements/particles
indexmy index in parallelization, e.g., MPI rank or OpenMP thread id
sizethe parallelization space, e.g., MPI size or OpenMP max threads
Returns
offset and size of the chunk for a specific index

◆ symplectic_form()

Map6x6 impactx::symplectic_form ( )
inline

Return the 6x6 skew-symmetric symplectic form

diag([[0,1],[-1,0]], [[0,1],[-1,0]], [[0,1],[-1,0]]) for the phase space ordering (x, px, y, py, t, pt).

Note: commonly referred to as J (especially in accelerator physics), but sometimes called Omega to avoid confusion with complex structures.

See also
https://en.wikipedia.org/wiki/Symplectic_matrix Refs.:
  • K. R. Meyer and D. C. Offin, Introduction to Hamiltonian Dynamical Systems and the N-Body Problem, Springer-Verlag NY, 2009.
  • A. J. Dragt, Lie Methods for Nonlinear Dynamics with Applications to Accelerator Physics, University of Maryland, 2020, http://www.physics.umd.edu/dsat/

◆ to_string()

std::string impactx::to_string ( SpaceChargeAlgo sca)

A user-friendly string

Returns a string that is similar to the spelling in user input options.

◆ track_lattice_particles()

template<typename HookFn, typename CollectiveKicks, typename ElementPush>
void impactx::track_lattice_particles ( std::list< elements::KnownElements > & lattice,
ImpactXParticleContainer & pc,
TrackingState & tracking_state,
HookFn const & call_hook,
CollectiveKicks && collective_kicks,
ElementPush && element_push )

Traverse the lattice for particle (beam + reference) tracking, applying the per-slice physics as two composable operations.

This function performs the nested lattice traversal (looping over periods, then over the beamline elements in each period, then over the collective-effect slices within each element). It also maintains the user-defined hooks, the reference-particle edge update and the global step counter. The caller supplies the per-slice physics as a collective_kicks (space charge, CSR, ISR, ...) and an element_push (the external-field of an element). Keeping the kick and the transport as separate, composable operations isolates the collective-effect composition: forward, this applies K then M per slice (first order). Planned: second-order Strang split K(1/2) [M K]^(n-1) M K(1/2).

Hooks, the reference-particle edge update, the step counter and the tracking-state element pointer are maintained on Forward tracking only.

The number of periods (lattice.periods) and verbosity (impactx.verbose) are read from the inputs. The step counter is advanced from its current value, so the caller is expected to reset it (to 0) before a forward run.

Template Parameters
HookFncallable void (std::string const & name) invoking a named hook
CollectiveKickscallable, see ElementPush for the signature
ElementPushcallable void (elements::KnownElements & element, int element_index, int slice_step, int nslice, amrex::ParticleReal slice_ds, int step, int period)
Parameters
[in,out]latticethe beamline elements to traverse
[in,out]pcbeam particle container (reference particle / edge update)
[in,out]tracking_statetracking state shared with hooks (element, step, period); its m_direction selects the traversal direction
[in]call_hookregistry for user-specified callback hooks
[in]collective_kicksapplied collective effect kicks (SC, CSR, ISR, etc.), per-slice
[in]element_pushapplied the external-field of an element, per-slice