|
OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
|
Classes | |
| struct | CoreMoments |
| Rest-frame moments of the core charge. More... | |
| struct | CoreSelection |
| Result of selectCore(), the same on every rank. More... | |
| class | IpplReducer |
| All IPPL nodes, through allreduce(). More... | |
| struct | ModeState |
| class | MomentSums |
| class | Reducer |
| class | SerialReducer |
| All particles on one process: the reductions do nothing. More... | |
Enumerations | |
| enum class | ParticleClass : short { CORE , INSIDE , MESH , FAR } |
| enum class | Mode : short { FULL = 0 , CORE = 1 } |
Functions | |
| CoreSelection | selectCore (const Vector_t *R, const double *Q, const int *bin, std::size_t localNum, double nSigma, double clip, const Reducer &reducer) |
| void | getMeshBox (const Vector_t *R, const int *bin, std::size_t localNum, const CoreSelection &selection, double nSigma, const Reducer &reducer, Vector_t &boxMin, Vector_t &boxMax) |
| bool | isInside (const Vector_t &r, const Vector_t &lower, const Vector_t &upper) |
| True if r lies in [lower, upper] in every axis. | |
| ParticleClass | classify (int bin, const Vector_t &r, const Vector_t &boundsMin, const Vector_t &boundsMax, const Vector_t &meshMin, const Vector_t &meshMax) |
| Vector_t | toRestFrame (const Vector_t &r, const Vector_t &r0, double gamma) |
| Vector_t | toLabFrame (const Vector_t &E, double gamma) |
| void | computeMultipoleField (const CoreMoments &moments, const std::vector< Vector_t > &position, std::size_t begin, std::size_t end, bool withQuadrupole, std::vector< Vector_t > &field, std::vector< double > &indicator) |
| bool | needsExactCoreField (ParticleClass c, double indicator) |
| void | addDirectField (const std::vector< Vector_t > &target, std::size_t begin, std::size_t end, const std::vector< Vector_t > &source, const std::vector< double > &charge, double eps, std::vector< Vector_t > &field) |
| std::pair< std::size_t, std::size_t > | getTableRange (std::size_t n, int rank, int numRanks) |
| std::size_t | getSampleStride (std::size_t numTargets, std::size_t numSources, double maxPairs) |
| bool | isInCoreShell (const Vector_t &r, const Vector_t &lower, const Vector_t &upper) |
| bool | isSampled (std::size_t id, std::size_t stride) |
| ModeState | decideMode (const ModeState &previous, std::size_t numCore, std::size_t numLive, double farChargeFraction, double maxFarFraction, unsigned int minDwell) |
Variables | |
| constexpr unsigned int | maxClipPasses = 8 |
| constexpr double | clipTolerance = 1e-3 |
| The clipped passes stop when |dsigma_d| < clipTolerance * sigma_d in every axis. | |
| constexpr double | haloSigma = 10.0 |
| The halo proper: live particles beyond haloSigma clipped rms widths in any axis. | |
| constexpr double | flatWidth = 1e-10 |
| constexpr double | indicatorThreshold = 0.1 |
| constexpr double | maxFarFarPairs = 1e8 |
| constexpr double | maxCorePairsPerCore = 8 |
| constexpr double | coreShellFraction = 0.25 |
| constexpr double | warnFarFraction = 0.01 |
| The solve warns when the far charge fraction exceeds this. | |
| constexpr double | minCoreParticles = 1000 |
| constexpr double | minCoreFraction = 0.5 |
| constexpr double | returnCoreFraction = 0.6 |
| constexpr double | returnFarFactor = 0.5 |
|
strong |
CORE solves on the core-fitted mesh, FULL on the box of all particles (fallback). The values are those of the stat column scMode.
| Enumerator | |
|---|---|
| FULL | |
| CORE | |
Definition at line 302 of file CoreFitSC.h.
|
strong |
How a particle takes part in the solve on the core mesh. The far table holds the MESH and FAR particles, with charge 0 for the lost ones.
Definition at line 179 of file CoreFitSC.h.
| void CoreFitSC::addDirectField | ( | const std::vector< Vector_t > & | target, |
| std::size_t | begin, | ||
| std::size_t | end, | ||
| const std::vector< Vector_t > & | source, | ||
| const std::vector< double > & | charge, | ||
| double | eps, | ||
| std::vector< Vector_t > & | field | ||
| ) |
Adds to field[i], for the targets i in [begin, end), the rest-frame field of the point charges at source, without the coupling constant, softened by eps: sum_j charge_j (t_i - s_j) / (|t_i - s_j|^2 + eps^2)^(3/2). Pairs at exactly the same position are skipped. With the far table as targets and its live entries as sources this is the far-far field (eps = the smallest rest-frame core cell); the lost entries, of charge 0, would only add cost as sources. With the local core particles as sources and eps = 0 it is this rank's part of the exact core field.
Definition at line 332 of file CoreFitSC.cpp.
References begin(), dot(), and end().
Referenced by PartBunch::computeFarField().

| CoreFitSC::ParticleClass CoreFitSC::classify | ( | int | bin, |
| const Vector_t & | r, | ||
| const Vector_t & | boundsMin, | ||
| const Vector_t & | boundsMax, | ||
| const Vector_t & | meshMin, | ||
| const Vector_t & | meshMax | ||
| ) |
Class of a particle, from the core bounds of the selection and the cell-centre range of the core mesh (the core bounds enlarged by boundp()). A live particle is CORE exactly when selectCore() put it in the core: a far particle fails the nSigma test in some axis, and the bounds in that axis are extremes of particles that pass it.
Definition at line 240 of file CoreFitSC.cpp.
References CORE, FAR, INSIDE, isInside(), and MESH.
Referenced by PartBunch::computeSelfFields_cycl().

| void CoreFitSC::computeMultipoleField | ( | const CoreMoments & | moments, |
| const std::vector< Vector_t > & | position, | ||
| std::size_t | begin, | ||
| std::size_t | end, | ||
| bool | withQuadrupole, | ||
| std::vector< Vector_t > & | field, | ||
| std::vector< double > & | indicator | ||
| ) |
Monopole plus quadrupole field of the core at the rest-frame positions of the far table entries [begin, end), without the coupling constant: E' = Q_c d / |d|^3 - Q d / |d|^5 + (5/2) (d Q d) d / |d|^7, d = s - c', minus the gradient of the potential Q_c / |d| + (1/2) d Q d / |d|^5 (the dipole about c' is zero). indicator[i] is |quadrupole term| / |monopole term| (0 without monopole). With withQuadrupole false, field[i] is the monopole term alone. field and indicator must have at least end entries; entries outside [begin, end) are not touched. Only the FAR entries use them: a FAR entry with indicator > indicatorThreshold gets the exact core field instead (needsExactCoreField()), and the MESH entries are gathered from the mesh.
Definition at line 309 of file CoreFitSC.cpp.
References begin(), CoreFitSC::CoreMoments::centroid, CoreFitSC::CoreMoments::charge, dot(), end(), euclidean_norm(), and CoreFitSC::CoreMoments::quadrupole.
Referenced by PartBunch::computeFarField().

| CoreFitSC::ModeState CoreFitSC::decideMode | ( | const ModeState & | previous, |
| std::size_t | numCore, | ||
| std::size_t | numLive, | ||
| double | farChargeFraction, | ||
| double | maxFarFraction, | ||
| unsigned int | minDwell | ||
| ) |
Mode for the next solve, from globally reduced inputs and the previous state, so every rank takes the same decision. CORE switches to FULL at once when numCore < max(minCoreParticles, minCoreFraction * numLive): the core has broken up, or it is empty and has no box. The other switches wait until dwell reaches minDwell (REPARTFREQ): CORE to FULL when farChargeFraction > maxFarFraction, and FULL back to CORE when farChargeFraction < returnFarFactor * maxFarFraction, numCore > returnCoreFraction * numLive and numCore >= minCoreParticles. The mode switched if it differs from previous.mode.
Definition at line 386 of file CoreFitSC.cpp.
References CORE, CoreFitSC::ModeState::dwell, FULL, minCoreFraction, minCoreParticles, CoreFitSC::ModeState::mode, returnCoreFraction, and returnFarFactor.
Referenced by PartBunchBase< T, Dim >::getSolverMeshBounds().
| void CoreFitSC::getMeshBox | ( | const Vector_t * | R, |
| const int * | bin, | ||
| std::size_t | localNum, | ||
| const CoreSelection & | selection, | ||
| double | nSigma, | ||
| const Reducer & | reducer, | ||
| Vector_t & | boxMin, | ||
| Vector_t & | boxMax | ||
| ) |
Box the core-fitted mesh is fitted to (before boundp() enlarges it): the core bounds of the selection, widened to the particles flagged lost (Bin < 0) in its core window, within nSigma * sigma of the clipped mean in every axis, by the test with which selectCore() takes a live particle into the core. The particles flagged lost stay in the bunch until the tracker deletes them, and the mesh of all particles holds them: with an nSigma so large that every particle lies in the window, the box is the bounds of all particles. Lost particles outside the window never widen it. classify() takes the box in place of the core bounds: a live particle lies in it exactly when it is a core particle, as the extremes of the box pass the core test in every axis. R, bin, localNum and nSigma must be those of the selection. Collective: one minimum of 6 doubles.
Definition at line 206 of file CoreFitSC.cpp.
References CoreFitSC::CoreSelection::boundsMax, CoreFitSC::CoreSelection::boundsMin, CoreFitSC::CoreSelection::mean, CoreFitSC::Reducer::min(), and CoreFitSC::CoreSelection::sigma.
Referenced by PartBunchBase< T, Dim >::getSolverMeshBounds().

| std::size_t CoreFitSC::getSampleStride | ( | std::size_t | numTargets, |
| std::size_t | numSources, | ||
| double | maxPairs | ||
| ) |
Stride of the subsample of the sources that keeps a direct sum over numTargets targets and numSources sources within maxPairs pairs: 1 (every source) up to maxPairs pairs, else ceil(numTargets * numSources / maxPairs). With global counts every rank gets the same stride.
Definition at line 364 of file CoreFitSC.cpp.
Referenced by PartBunch::computeFarField().
| std::pair< std::size_t, std::size_t > CoreFitSC::getTableRange | ( | std::size_t | n, |
| int | rank, | ||
| int | numRanks | ||
| ) |
Entries [rank * n / numRanks, (rank + 1) * n / numRanks) of a table of n entries: the far-field work of one rank, independent of which rank owns the particles.
Definition at line 356 of file CoreFitSC.cpp.
Referenced by PartBunch::computeFarField().
| bool CoreFitSC::isInCoreShell | ( | const Vector_t & | r, |
| const Vector_t & | lower, | ||
| const Vector_t & | upper | ||
| ) |
True if r lies in the outer shell of the box [lower, upper]: farther from its centre than 1 - coreShellFraction of its half-width in some axis. The exact core field sums over the core particles in the shell and over the others apart (maxCorePairsPerCore).
Definition at line 374 of file CoreFitSC.cpp.
References coreShellFraction.
Referenced by PartBunch::computeFarField().
|
inline |
True if r lies in [lower, upper] in every axis.
Definition at line 171 of file CoreFitSC.h.
Referenced by classify().
|
inline |
True if the source with this particle ID belongs to the subsample of the stride: every source for stride 1, else about one in stride, those whose hashed ID (the splitmix64 finalizer) is a multiple of the stride. The hash keeps the subsample from following the order in which the particles were created (a FROMFILE distribution numbers them in the order of the file), and a particle stays in the subsample, on whichever rank, as long as the stride does not change. The solve scales the charges of the subsample to the charge of all the sources it stands for.
Definition at line 290 of file CoreFitSC.h.
Referenced by PartBunch::computeFarField().
|
inline |
True if a far table entry gets the exact core field in place of the multipole field: a FAR entry whose indicator exceeds indicatorThreshold. A MESH entry never does: it is gathered from the mesh, whatever its indicator.
Definition at line 252 of file CoreFitSC.h.
References FAR, and indicatorThreshold.
Referenced by PartBunch::computeFarField().
| CoreFitSC::CoreSelection CoreFitSC::selectCore | ( | const Vector_t * | R, |
| const double * | Q, | ||
| const int * | bin, | ||
| std::size_t | localNum, | ||
| double | nSigma, | ||
| double | clip, | ||
| const Reducer & | reducer | ||
| ) |
Core selection over the localNum particles of this rank (local space-charge frame). Pass 0 is the plain mean and rms over the live particles (Bin >= 0). Each of the passes 1 to maxClipPasses takes the mean and rms over the live particles within clip * sigma of the mean of the previous pass in every axis. The passes stop when the count does not change or when every sigma_d changed by less than clipTolerance (an axis whose new sigma_d is at most flatWidth has settled); a pass that selects no particle is dropped and ends them. The core is the live particles within nSigma * sigma in every axis, and its bounds are the exact minima and maxima of their positions. The halo counts every live particle beyond haloSigma * sigma in any axis, core particles too if nSigma > haloSigma. No half-width of these tests is below flatWidth. Particles flagged lost count nowhere. The pointers may be null if localNum is 0. Collectives: 2 + passes sums (3 + passes if a pass is dropped) and one minimum, of at most 8 doubles.
Definition at line 89 of file CoreFitSC.cpp.
References CoreFitSC::CoreSelection::boundsMax, CoreFitSC::CoreSelection::boundsMin, CoreFitSC::CoreSelection::chargeFar, CoreFitSC::CoreSelection::chargeLive, clipTolerance, CoreFitSC::CoreSelection::converged, CoreFitSC::CoreSelection::farMaxDistance, flatWidth, haloSigma, maxClipPasses, CoreFitSC::CoreSelection::mean, CoreFitSC::Reducer::min(), CoreFitSC::CoreSelection::numCore, CoreFitSC::CoreSelection::numFar, CoreFitSC::CoreSelection::numHalo, CoreFitSC::CoreSelection::numLive, CoreFitSC::CoreSelection::passes, CoreFitSC::CoreSelection::sigma, and CoreFitSC::Reducer::sum().
Referenced by PartBunchBase< T, Dim >::getSolverMeshBounds().

Lab-frame field of a rest-frame field, (gamma E'x, E'y, gamma E'z): the factors the mesh field gets from eg_m *= (gamma, 1/gamma, gamma) after the gradient over the unscaled mesh spacing.
Definition at line 205 of file CoreFitSC.h.
Referenced by PartBunch::computeFarField().
Rest-frame position about the centre r0 (the core box centre), s = (x - x0, gamma (y - y0), z - z0): the frame of the mesh solve, whose longitudinal mesh spacing is hr[1] * gamma (PartBunch::computeSelfFields_cycl).
Definition at line 198 of file CoreFitSC.h.
Referenced by CoreFitSC::MomentSums::add(), and PartBunch::computeFarField().
|
constexpr |
The clipped passes stop when |dsigma_d| < clipTolerance * sigma_d in every axis.
Definition at line 52 of file CoreFitSC.h.
Referenced by selectCore().
|
constexpr |
The outer shell of the box: the points farther from its centre than 1 - coreShellFraction of its half-width in some axis.
Definition at line 75 of file CoreFitSC.h.
Referenced by isInCoreShell().
|
constexpr |
Smallest half-width of the clip, core and halo tests [m]. In an axis in which the bunch is flat (rms 0 up to round-off), the tests then keep the particles in its plane, whatever the round-off of the mean, and exclude the others. boundp() treats extents below the same 1e-10 m as flat; the rms of a real bunch is many orders larger.
Definition at line 59 of file CoreFitSC.h.
Referenced by selectCore().
|
constexpr |
The halo proper: live particles beyond haloSigma clipped rms widths in any axis.
Definition at line 54 of file CoreFitSC.h.
Referenced by ParallelCyclotronTracker::printMeshFit_m(), and selectCore().
|
constexpr |
FAR particles whose quadrupole term exceeds this fraction of the monopole term get the exact core field (needsExactCoreField()).
Definition at line 62 of file CoreFitSC.h.
Referenced by needsExactCoreField().
|
constexpr |
Fixed parameters of the selection and of the far-field model. At most this many clipped passes after the plain rms.
Definition at line 50 of file CoreFitSC.h.
Referenced by selectCore().
|
constexpr |
The exact core field (N_flag x N_core pairs) sums over two parts of the core apart: the core particles in the outer shell of the box (isInCoreShell()), next to the flagged far particles just outside it, and the others. Each part takes at most about this many pairs per core particle, maxCorePairsPerCore * N_core, all ranks together; above it, the part runs over a subsample of its particles (getSampleStride(), isSampled()).
Definition at line 72 of file CoreFitSC.h.
Referenced by PartBunch::computeFarField().
|
constexpr |
The far-far field (N_far x N_far pairs) takes at most about this many pairs, all ranks together (1 / P of them on each rank); above it, the sum runs over a subsample of its sources (getSampleStride(), isSampled()).
Definition at line 66 of file CoreFitSC.h.
Referenced by PartBunch::computeFarField().
|
constexpr |
Definition at line 85 of file CoreFitSC.h.
Referenced by decideMode().
|
constexpr |
Mode decision: the solve falls back to the full box (FULL) when the core holds fewer than max(minCoreParticles, minCoreFraction * live) particles or the far charge fraction exceeds its limit. It returns to the core box (CORE) only when the far charge fraction is below returnFarFactor times the limit and the core holds more than returnCoreFraction of the live particles (and at least minCoreParticles).
Definition at line 84 of file CoreFitSC.h.
Referenced by decideMode().
|
constexpr |
Definition at line 86 of file CoreFitSC.h.
Referenced by decideMode().
|
constexpr |
Definition at line 87 of file CoreFitSC.h.
Referenced by decideMode().
|
constexpr |
The solve warns when the far charge fraction exceeds this.
Definition at line 77 of file CoreFitSC.h.
Referenced by PartBunchBase< T, Dim >::getSolverMeshBounds().