|
OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
|
#include <PartBunch.h>


Public Types | |
| enum | { Dim = Dimension } |
| typedef IpplParticleBase< Layout_t > | pbase_t |
| typedef std::function< bool(size_t)> | ParticleMask_t |
| Per-particle predicate on the local index, for scatterMasked() and gatherMasked(). | |
Public Types inherited from PartBunchBase< double, 3 > | |
| enum | UnitState_t |
| typedef AbstractParticle< double, Dim >::ParticlePos_t | ParticlePos_t |
| typedef AbstractParticle< double, Dim >::ParticleIndex_t | ParticleIndex_t |
| typedef AbstractParticle< double, Dim >::UpdateFlags | UpdateFlags_t |
| typedef AbstractParticle< double, Dim >::Position_t | Position_t |
| typedef std::pair< Vector_t, Vector_t > | VectorPair_t |
Public Member Functions | |
| PartBunch (const PartData *ref) | |
| Default constructor. | |
| PartBunch ()=delete | |
| PartBunch (const PartBunch &)=delete | |
| PartBunch & | operator= (const PartBunch &)=delete |
| ~PartBunch () | |
| void | initialize (FieldLayout_t *fLayout) |
| void | do_binaryRepart () |
| double | getRho (int x, int y, int z) |
| const Mesh_t & | getMesh () const |
| Mesh_t & | getMesh () |
| FieldLayout_t & | getFieldLayout () |
| void | setBCAllPeriodic () |
| void | setBCAllOpen () |
| void | setBCForDCBeam () |
| VectorPair_t | getEExtrema () |
| void | computeSelfFields () |
| void | computeSelfFields (int b) |
| void | computeSelfFields_cycl (double gamma) |
| Calculates the self electric field from the charge density distribution for use in cyclotrons. | |
| void | computeSelfFields_cycl (int b) |
| Calculates the self electric field from the charge density distribution for use in cyclotrons. | |
| void | scatterMasked (const ParticleMask_t &accept) |
| CIC scatter of Q onto rho_m, of the particles with Bin >= 0 and accept(i) true. | |
| void | gatherMasked (const ParticleMask_t &accept) |
| CIC gather of eg_m into Ef, at the particles with accept(i) true. | |
| void | resetInterpolationCache (bool clearCache=false) |
| void | swap (unsigned int i, unsigned int j) |
| Inform & | print (Inform &os) |
Public Member Functions inherited from PartBunchBase< double, 3 > | |
| virtual | ~PartBunchBase () |
| PartBunchBase (AbstractParticle< double, Dim > *pb, const PartData *ref) | |
| PartBunchBase (const PartBunchBase &rhs)=delete | |
| bool | getIfBeamEmitting () |
| int | getLastEmittedEnergyBin () |
| size_t | getNumberOfEmissionSteps () |
| int | getNumberOfEnergyBins () |
| void | Rebin () |
| void | setEnergyBins (int numberOfEnergyBins) |
| bool | weHaveEnergyBins () |
| void | switchToUnitlessPositions (bool use_dt_per_particle=false) |
| void | switchOffUnitlessPositions (bool use_dt_per_particle=false) |
| void | setDistribution (Distribution *d, std::vector< Distribution * > addedDistributions, size_t &np) |
| void | setDistribution (Distribution *d, size_t numberOfParticles, double current, const Beamline &bl) |
| bool | isGridFixed () const |
| bool | hasBinning () const |
| void | setTEmission (double t) |
| double | getTEmission () |
| bool | doEmission () |
| bool | weHaveBins () const |
| void | setPBins (PartBins *pbin) |
| void | setPBins (PartBinsCyc *pbin) |
| size_t | emitParticles (double eZ) |
| Emit particles in the given bin i.e. copy the particles from the bin structure into the particle container. | |
| void | updateNumTotal () |
| void | rebin () |
| int | getLastemittedBin () |
| void | setLocalBinCount (size_t num, int bin) |
| void | calcGammas () |
| Compute the gammas of all bins. | |
| void | calcGammas_cycl () |
| void | calcDebyeLength () |
| Compute the (global) Debye length for the beam. | |
| void | setComputeSCDiagnostics (bool compute) |
| double | getBinGamma (int bin) |
| Get gamma of one bin. | |
| virtual void | setBinCharge (int bin, double q) |
| Set the charge of one bin to the value of q and all other to zero. | |
| virtual void | setBinCharge (int bin) |
| Set the charge of all other the ones in bin to zero. | |
| size_t | calcNumPartsOutside (Vector_t x) |
| returns the number of particles outside of a box defined by x | |
| void | calcLineDensity (unsigned int nBins, std::vector< double > &lineDensity, std::pair< double, double > &meshInfo) |
| calculates the 1d line density (not normalized) and append it to a file. | |
| void | setBeamFrequency (double v) |
| virtual void | boundp () |
| void | boundp_destroyCycl () |
| size_t | boundp_destroyT () |
| size_t | destroyT () |
| virtual double | getPx (int i) |
| virtual double | getPy (int i) |
| virtual double | getPz (int i) |
| virtual double | getPx0 (int i) |
| virtual double | getPy0 (int i) |
| virtual double | getX (int i) |
| virtual double | getY (int i) |
| virtual double | getZ (int i) |
| virtual double | getX0 (int i) |
| virtual double | getY0 (int i) |
| virtual void | setZ (int i, double zcoo) |
| void | get_bounds (Vector_t &rmin, Vector_t &rmax) const |
| void | getLocalBounds (Vector_t &rmin, Vector_t &rmax) const |
| std::pair< Vector_t, double > | getBoundingSphere () |
| std::pair< Vector_t, double > | getLocalBoundingSphere () |
| void | push_back (OpalParticle const &p) |
| void | setParticle (FVector< double, 6 > z, int ii) |
| void | setParticle (OpalParticle const &p, int ii) |
| OpalParticle | getParticle (int ii) |
| ConstIterator | begin () const |
| ConstIterator | end () const |
| void | maximumAmplitudes (const FMatrix< double, 6, 6 > &D, double &axmax, double &aymax) |
| Return maximum amplitudes. | |
| void | setdT (double dt) |
| double | getdT () const |
| void | setT (double t) |
| void | incrementT () |
| double | getT () const |
| double | get_sPos () const |
| void | set_sPos (double s) |
| double | get_gamma () const |
| double | get_meanKineticEnergy () const |
| double | get_temperature () const |
| double | get_debyeLength () const |
| double | get_plasmaParameter () const |
| double | get_rmsDensity () const |
| Vector_t | get_origin () const |
| Vector_t | get_maxExtent () const |
| Vector_t | get_centroid () const |
| Vector_t | get_rrms () const |
| Vector_t | get_rprms () const |
| Vector_t | get_rmean () const |
| Vector_t | get_prms () const |
| Vector_t | get_pmean () const |
| Vector_t | get_pmean_Distribution () const |
| Vector_t | get_emit () const |
| Vector_t | get_norm_emit () const |
| Vector_t | get_halo () const |
| Vector_t | get_68Percentile () const |
| Vector_t | get_95Percentile () const |
| Vector_t | get_99Percentile () const |
| Vector_t | get_99_99Percentile () const |
| Vector_t | get_normalizedEps_68Percentile () const |
| Vector_t | get_normalizedEps_95Percentile () const |
| Vector_t | get_normalizedEps_99Percentile () const |
| Vector_t | get_normalizedEps_99_99Percentile () const |
| virtual Vector_t | get_hr () const |
| double | get_Dx () const |
| double | get_Dy () const |
| double | get_DDx () const |
| double | get_DDy () const |
| virtual void | set_meshEnlargement (double dh) |
| void | setMeshFit (const MeshFitParameters &meshFit) |
| FIELDSOLVER, MESHFIT: the particles the space-charge mesh is fitted to. | |
| const MeshFitParameters & | getMeshFit () const |
| void | setMeshFitSolveStep (bool solveStep) |
| const CoreFitSC::CoreSelection & | getMeshFitCore () const |
| void | getMeshFitFullBounds (Vector_t &rmin, Vector_t &rmax) const |
| MESHFIT=CORE: the bounds of all particles of the same fit. | |
| Vector_t | getMeshSpacing (const Vector_t &rmin, const Vector_t &rmax) const |
| Mesh spacing that boundp() gives to particles within [rmin, rmax]. | |
| const CoreFitSC::ModeState & | getMeshFitMode () const |
| void | setMeshFitMode (const CoreFitSC::ModeState &mode) |
| MESHFIT=CORE: restores the mode, from the step attributes of an H5 restart. | |
| bool | isMeshFitToCore () const |
| bool | isMeshFitRepartitionDue () const |
| const MeshFitStatistics & | getMeshFitStatistics () const |
| void | resetMeshFitTurn () |
| void | gatherLoadBalanceStatistics () |
| size_t | getLoadBalance (int p) const |
| void | get_PBounds (Vector_t &min, Vector_t &max) const |
| void | calcBeamParameters () |
| void | calcBeamParametersInitial () |
| double | getCouplingConstant () const |
| void | setCouplingConstant (double c) |
| void | setCharge (double q) |
| void | setChargeZeroPart (double q) |
| void | setMass (double mass) |
| void | setMassZeroPart (double mass) |
| double | getCharge () const |
| get the total charge per simulation particle | |
| double | getChargePerParticle () const |
| get the macro particle charge | |
| double | getMassPerParticle () const |
| virtual void | setSolver (FieldSolver *fs) |
| bool | hasFieldSolver () |
| FieldSolverType | getFieldSolverType () const |
| Return the fieldsolver type if we have a fieldsolver. | |
| void | setStepsPerTurn (int n) |
| int | getStepsPerTurn () const |
| void | setGlobalTrackStep (long long n) |
| step in multiple TRACK commands | |
| long long | getGlobalTrackStep () const |
| void | setLocalTrackStep (long long n) |
| step in a TRACK command | |
| void | incTrackSteps () |
| long long | getLocalTrackStep () const |
| void | setNumBunch (short n) |
| short | getNumBunch () const |
| void | setTotalNumPerBunch (size_t numpart, short n) |
| size_t | getTotalNumPerBunch (short n) const |
| void | setLocalNumPerBunch (size_t numpart, short n) |
| size_t | getLocalNumPerBunch (short n) const |
| void | countTotalNumPerBunch () |
| void | setGlobalMeanR (Vector_t globalMeanR) |
| Vector_t | getGlobalMeanR () |
| void | setGlobalToLocalQuaternion (Quaternion_t globalToLocalQuaternion) |
| Quaternion_t | getGlobalToLocalQuaternion () |
| void | setSteptoLastInj (int n) |
| int | getSteptoLastInj () const |
| double | calcMeanPhi () |
| calculate average angle of longitudinal direction of bins | |
| bool | resetPartBinID2 (const double eta) |
| reset Bin[] for each particle according to the method given in paper PAST-AB(064402) by G. Fubiani et al. | |
| bool | resetPartBinBunch () |
| double | getdE () const |
| virtual double | getGamma (int i) |
| virtual double | getBeta (int i) |
| virtual void | actT () |
| const PartData * | getReference () const |
| double | getEmissionDeltaT () |
| DistributionType | getDistType () const |
| double | getMomentumTolerance () const |
| Quaternion_t | getQKs3D () |
| void | setQKs3D (Quaternion_t q) |
| Vector_t | getKs3DRefr () |
| void | setKs3DRefr (Vector_t r) |
| Vector_t | getKs3DRefp () |
| void | setKs3DRefp (Vector_t p) |
| void | iterateEmittedBin (int binNumber) |
| void | calcEMean () |
| Inform & | print (Inform &os) |
| virtual void | runTests () |
| size_t | getTotalNum () const |
| void | setTotalNum (size_t n) |
| void | setLocalNum (size_t n) |
| size_t | getLocalNum () const |
| size_t | getDestroyNum () const |
| size_t | getGhostNum () const |
| ParticleLayout< double, Dim > & | getLayout () |
| const ParticleLayout< double, Dim > & | getLayout () const |
| bool | getUpdateFlag (UpdateFlags_t f) const |
| void | setUpdateFlag (UpdateFlags_t f, bool val) |
| ParticleBConds< Position_t, Dimension > & | getBConds () |
| void | setBConds (const ParticleBConds< Position_t, Dimension > &bc) |
| bool | singleInitNode () const |
| void | resetID () |
| void | update () |
| void | update (const ParticleAttrib< char > &canSwap) |
| void | createWithID (unsigned id) |
| void | create (size_t M) |
| void | globalCreate (size_t np) |
| void | destroy (size_t M, size_t I, bool doNow=false) |
| void | performDestroy (bool updateLocalNum=false) |
| void | ghostDestroy (size_t M, size_t I) |
| FMatrix< double, 2 *Dim, 2 *Dim > | getSigmaMatrix () const |
| double | getQ () const |
| Access to reference data. | |
| double | getM () const |
| double | getP () const |
| double | getE () const |
| ParticleOrigin | getPOrigin () const |
| ParticleType | getPType () const |
| double | getInitialBeta () const |
| double | getInitialGamma () const |
| void | resetQ (double q) |
| void | resetM (double m) |
| void | setPOrigin (ParticleOrigin) |
| void | setPType (const std::string &type) |
Public Attributes | |
| Field_t | rho_m |
| scalar potential | |
| VField_t | eg_m |
| vector field on the grid | |
Public Attributes inherited from PartBunchBase< double, 3 > | |
| ParticlePos_t & | R |
| ParticleIndex_t & | ID |
| ParticleAttrib< Vector_t > | P |
| ParticleAttrib< double > | Q |
| ParticleAttrib< double > | M |
| ParticleAttrib< double > | Phi |
| ParticleAttrib< Vector_t > | Ef |
| ParticleAttrib< Vector_t > | Eftmp |
| ParticleAttrib< Vector_t > | Bf |
| ParticleAttrib< int > | Bin |
| ParticleAttrib< double > | dt |
| ParticleAttrib< ParticleType > | PType |
| ParticleAttrib< ParticleOrigin > | POrigin |
| ParticleAttrib< int > | TriID |
| ParticleAttrib< short > | cavityGapCrossed |
| ParticleAttrib< short > | bunchNum |
| Vector_t | RefPartR_m |
| Vector_t | RefPartP_m |
| CoordinateSystemTrafo | toLabTrafo_m |
| ParticleOrigin | refPOrigin_m |
| ParticleType | refPType_m |
| PartBins * | pbin_m |
| IpplTimings::TimerRef | distrReload_m |
| timer for IC, can not be in Distribution.h | |
| IpplTimings::TimerRef | distrCreate_m |
| double | dtScInit_m |
| double | deltaTau_m |
Private Member Functions | |
| void | updateDomainLength (Vektor< int, 3 > &grid) |
| void | updateFields (const Vector_t &hr, const Vector_t &origin) |
| void | resizeMesh () |
| resize mesh to geometry specified | |
| void | computeFarField (double gamma, const std::vector< CoreFitSC::ParticleClass > &particleClass) |
| MESHFIT=CORE: field of the particles outside the core bounds. | |
| void | checkUnmaskedInterpolation (const std::string &where) const |
| ParticleLayout< double, 3 > & | getLayout () |
| const ParticleLayout< double, 3 > & | getLayout () const |
Private Attributes | |
| BConds< double, 3, Mesh_t, Center_t > | bc_m |
| for defining the boundary conditions | |
| BConds< Vector_t, 3, Mesh_t, Center_t > | vbc_m |
| bool | interpolationCacheSet_m |
| ParticleAttrib< CacheDataCIC< double, 3U > > | interpolationCache_m |
| ParticleAttrib< double > | maskedQ_m |
| scatterMasked(): the charges and positions of the particles that a predicate accepts | |
| ParticleAttrib< Vector_t > | maskedR_m |
Additional Inherited Members | |
Static Public Attributes inherited from PartBunchBase< double, 3 > | |
| static const unsigned | Dimension |
Protected Types inherited from PartBunchBase< double, 3 > | |
| enum | MeshFitWarning |
| MESHFIT=CORE: the warnings of the solve, each given at most once per turn. More... | |
Protected Member Functions inherited from PartBunchBase< double, 3 > | |
| size_t | calcMoments () |
| void | calcMomentsInitial () |
| double | calculateAngle (double x, double y) |
| angle range [0~2PI) degree | |
| void | warnMeshFitOnce (MeshFitWarning warning, const std::string &message) |
Protected Attributes inherited from PartBunchBase< double, 3 > | |
| IpplTimings::TimerRef | boundpTimer_m |
| IpplTimings::TimerRef | boundpBoundsTimer_m |
| IpplTimings::TimerRef | boundpUpdateTimer_m |
| IpplTimings::TimerRef | statParamTimer_m |
| IpplTimings::TimerRef | histoTimer_m |
| IpplTimings::TimerRef | selfFieldTimer_m |
| timer for selfField calculation | |
| IpplTimings::TimerRef | meshFitTimer_m |
| IpplTimings::TimerRef | farFieldTimer_m |
| IpplTimings::TimerRef | exactCoreTimer_m |
| const PartData * | reference |
| UnitState_t | unit_state_ |
| UnitState_t | stateOfLastBoundP_ |
| double | centroid_m [2 *Dim] |
| holds the centroid of the beam | |
| double | dt_m |
| holds the timestep in seconds | |
| double | t_m |
| holds the actual time of the integration | |
| double | spos_m |
| the position along design trajectory | |
| Vector_t | globalMeanR_m |
| Quaternion_t | globalToLocalQuaternion_m |
| Vector_t | rmax_m |
| maximal extend of particles | |
| Vector_t | rmin_m |
| minimal extend of particles | |
| double | rmsDensity_m |
| bool | computeSCDiagnostics_m |
| See setComputeSCDiagnostics(). | |
| Vector_t | hr_m |
| meshspacing of cartesian mesh | |
| Vektor< int, 3 > | nr_m |
| meshsize of cartesian mesh | |
| FieldSolver * | fs_m |
| stores the used field solver | |
| double | couplingConstant_m |
| double | qi_m |
| double | massPerParticle_m |
| int | distDump_m |
| counter to store the distribution dump | |
| double | dh_m |
| Mesh enlargement. | |
| MeshFitParameters | meshFit_m |
| relative enlargement of the mesh | |
| bool | meshFitSolveStep_m |
| See setMeshFitSolveStep(). | |
| CoreFitSC::CoreSelection | scCore_m |
| MESHFIT=CORE: see getMeshFitCore() and getMeshFitFullBounds() | |
| Vector_t | scFullMin_m |
| Vector_t | scFullMax_m |
| CoreFitSC::ModeState | scMode_m |
| bool | scRepartitionDue_m |
| bool | scHasSolved_m |
| MeshFitStatistics | scStatistics_m |
| unsigned int | scWarned_m |
| bool | scCoreMesh_m |
| Vector_t | scBoxMin_m |
| Vector_t | scBoxMax_m |
| Vector_t | scMeshMin_m |
| Vector_t | scMeshMax_m |
| size_t | scNumCore_m |
| bool | scFitted_m |
| double | tEmission_m |
| if larger than 0, emitt particles for tEmission_m [s] | |
| std::unique_ptr< double[]> | bingamma_m |
| holds the gamma of the bin | |
| std::unique_ptr< size_t[]> | binemitted_m |
| int | stepsPerTurn_m |
| steps per turn for OPAL-cycl | |
| long long | localTrackStep_m |
| step in a TRACK command | |
| long long | globalTrackStep_m |
| if multiple TRACK commands | |
| short | numBunch_m |
| current bunch number | |
| std::vector< size_t > | bunchTotalNum_m |
| number of particles per bunch | |
| std::vector< size_t > | bunchLocalNum_m |
| int | SteptoLastInj_m |
| std::unique_ptr< size_t[]> | globalPartPerNode_m |
| Distribution * | dist_m |
| DistributionMoments | momentsComputer_m |
| bool | dcBeam_m |
| double | periodLength_m |
| std::shared_ptr< AbstractParticle< double, Dim > > | pbase_m |
Definition at line 30 of file PartBunch.h.
| typedef std::function<bool(size_t)> PartBunch::ParticleMask_t |
Per-particle predicate on the local index, for scatterMasked() and gatherMasked().
Definition at line 96 of file PartBunch.h.
| typedef IpplParticleBase<Layout_t> PartBunch::pbase_t |
Definition at line 33 of file PartBunch.h.
| anonymous enum |
| Enumerator | |
|---|---|
| Dim | |
Definition at line 34 of file PartBunch.h.
|
explicit |
Default constructor.
Definition at line 47 of file PartBunch.cpp.
|
delete |
|
delete |
| PartBunch::~PartBunch | ( | ) |
Definition at line 55 of file PartBunch.cpp.
|
private |
MESHFIT=CORE: throws if particles were outside the mesh at the last update(). IPPL's unmasked CIC scatter and gather visit every particle, and such a particle aborts there, or writes past the local brick or loses its charge (see scatterMasked()).
Definition at line 1148 of file PartBunch.cpp.
References CORE, PartBunchBase< double, 3 >::meshFit_m, PartBunchBase< double, 3 >::scStatistics_m, MeshFitParameters::type, and where().
Referenced by computeSelfFields(), computeSelfFields(), computeSelfFields_cycl(), and computeSelfFields_cycl().

|
private |
MESHFIT=CORE: field of the particles outside the core bounds.
The MESH particles (inside the range of cell centres) have their mesh field in Ef already, the FAR particles get theirs here. Every rank adds its particles outside the core bounds to a far table of rest-frame positions, charges (0 for particles flagged lost), classes and IDs, in rank order, and evaluates an even share of it by index: the monopole and quadrupole of the core charge and the validity indicator, and for the live entries the far-far field, whose sources they are. The live FAR entries whose indicator exceeds CoreFitSC::indicatorThreshold get the exact field of the core particles instead of the multipole field, summed on every rank over its own. Above CoreFitSC::maxFarFarPairs pairs, the far-far field runs over a subsample of its sources; above CoreFitSC::maxCorePairsPerCore pairs per core particle, the exact core field sums over the core particles in the outer shell of the box and over the others apart, each over a subsample if its pairs exceed that budget. A subsample is picked by particle ID (CoreFitSC::isSampled()), its charge scaled to that of the sources it stands for. The entries flagged lost get the multipole field (FAR) or keep their mesh field (MESH). MESHFITFARFIELD="QUADRUPOLE" leaves out the far-far field and the exact core field, "MONOPOLE" also the quadrupole.
Definition at line 877 of file PartBunch.cpp.
References CoreFitSC::MomentSums::add(), CoreFitSC::addDirectField(), allreduce(), PartBunchBase< double, 3 >::Bin, CoreFitSC::computeMultipoleField(), PartBunchBase< double, 3 >::Ef, PartBunchBase< double, 3 >::exactCoreTimer_m, PartBunchBase< double, 3 >::FarFarWarning, MeshFitParameters::farField, PartBunchBase< double, 3 >::farFieldTimer_m, FULL, IpplInfo::getComm(), PartBunchBase< double, 3 >::getCouplingConstant(), PartBunchBase< double, 3 >::getLocalNum(), IpplInfo::getNodes(), CoreFitSC::getSampleStride(), CoreFitSC::getTableRange(), PartBunchBase< double, 3 >::hr_m, PartBunchBase< double, 3 >::ID, CoreFitSC::isInCoreShell(), CoreFitSC::isSampled(), CoreFitSC::maxCorePairsPerCore, CoreFitSC::maxFarFarPairs, PartBunchBase< double, 3 >::meshFit_m, MONOPOLE, IpplInfo::myNode(), CoreFitSC::needsExactCoreField(), PartBunchBase< double, 3 >::Q, PartBunchBase< double, 3 >::R, CoreFitSC::MomentSums::reduce(), PartBunchBase< double, 3 >::scBoxMax_m, PartBunchBase< double, 3 >::scBoxMin_m, PartBunchBase< double, 3 >::scNumCore_m, PartBunchBase< double, 3 >::scStatistics_m, IpplTimings::startTimer(), IpplTimings::stopTimer(), CoreFitSC::toLabFrame(), CoreFitSC::toRestFrame(), and PartBunchBase< double, 3 >::warnMeshFitOnce().
Referenced by computeSelfFields_cycl().

|
virtual |
Magnetic field in x and y direction induced by the electric field
\[ B_x = \gamma(B_x^{'} - \frac{beta}{c}E_y^{'}) = -\gamma \frac{beta}{c}E_y^{'} = -\frac{beta}{c}E_y \]
\[ B_y = \gamma(B_y^{'} - \frac{beta}{c}E_x^{'}) = +\gamma \frac{beta}{c}E_x^{'} = +\frac{beta}{c}E_x \]
\[ B_z = B_z^{'} = 0 \]
Implements PartBunchBase< double, 3 >.
Definition at line 357 of file PartBunch.cpp.
References PartBunchBase< double, 3 >::Bf, Physics::c, PartBunchBase< double, 3 >::calcDebyeLength(), PoissonSolver::calculatePairForces(), checkUnmaskedInterpolation(), PoissonSolver::computePotential(), PartBunchBase< double, 3 >::dt, FieldWriter::dumpField(), PartBunchBase< double, 3 >::Ef, eg_m, endl(), FFT, FFTBOX, PartBunchBase< double, 3 >::fs_m, PartBunchBase< double, 3 >::getCouplingConstant(), PartBunchBase< double, 3 >::getdT(), FieldSolver::getFieldSolverType(), PartBunchBase< double, 3 >::getTotalNum(), gmsg, Grad(), FieldSolver::hasValidSolver(), PartBunchBase< double, 3 >::hr_m, PartBunchBase< double, 3 >::localTrackStep_m, PartBunchBase< double, 3 >::nr_m, PartBunchBase< double, 3 >::P, P3M, PartBunchBase< double, 3 >::Q, Physics::q_e, PartBunchBase< double, 3 >::R, resizeMesh(), rho_m, PartBunchBase< double, 3 >::rmsDensity_m, ParticleAttrib< T >::scatter(), PartBunchBase< double, 3 >::selfFieldTimer_m, FieldSolver::solver_m, IpplTimings::startTimer(), IpplTimings::stopTimer(), and sum().

|
virtual |
/brief used for self fields with binned distribution
Set initial charge density to zero. Create image charge potential field.
Set initial E field to zero.
Mesh the whole domain
Scatter charge onto space charge grid.
Calculate mesh-scale factor and get gamma for this specific slice (bin).
Scale charge density to get charge density in real units. Account for Lorentz transformation in longitudinal direction.
Scale mesh spacing to real units (meters). Lorentz transform the longitudinal direction.
Find potential from charge in this bin (no image yet) using Poisson's equation (without coefficient: -1/(eps)).
Scale mesh back (to same units as particle locations.)
The scalar potential is given back in rho_m and must be converted to the right units.
IPPL Grad numerical computes gradient to find the electric field (in bin rest frame).
Scale field. Combine Lorentz transform with conversion to proper field units.
Interpolate electric field at particle positions. We reuse the cached information about where the particles are relative to the field, since the particles have not moved since this the most recent scatter operation.
Magnetic field in x and y direction induced by the electric field.
\[ B_x = \gamma(B_x^{'} - \frac{beta}{c}E_y^{'}) = -\gamma \frac{beta}{c}E_y^{'} = -\frac{beta}{c}E_y \]
\[ B_y = \gamma(B_y^{'} - \frac{beta}{c}E_x^{'}) = +\gamma \frac{beta}{c}E_x^{'} = +\frac{beta}{c}E_x \]
\[ B_z = B_z^{'} = 0 \]
Now compute field due to image charge. This is done separately as the image charge is moving to -infinity (instead of +infinity) so the Lorentz transform is different.
Find z shift for shifted Green's function.
Find potential from image charge in this bin using Poisson's equation (without coefficient: -1/(eps)).
Scale mesh back (to same units as particle locations.)
The scalar potential is given back in rho_m and must be converted to the right units.
IPPL Grad numerical computes gradient to find the electric field (in rest frame of this bin's image charge).
Scale field. Combine Lorentz transform with conversion to proper field units.
Interpolate electric field at particle positions. We reuse the cached information about where the particles are relative to the field, since the particles have not moved since this the most recent scatter operation.
Magnetic field in x and y direction induced by the image charge electric field. Note that beta will have the opposite sign from the bunch charge field, as the image charge is moving in the opposite direction.
\[ B_x = \gamma(B_x^{'} - \frac{beta}{c}E_y^{'}) = -\gamma \frac{beta}{c}E_y^{'} = -\frac{beta}{c}E_y \]
\[ B_y = \gamma(B_y^{'} - \frac{beta}{c}E_x^{'}) = +\gamma \frac{beta}{c}E_x^{'} = +\frac{beta}{c}E_x \]
\[ B_z = B_z^{'} = 0 \]
Implements PartBunchBase< double, 3 >.
Definition at line 83 of file PartBunch.cpp.
References PartBunchBase< double, 3 >::Bf, Physics::c, checkUnmaskedInterpolation(), PoissonSolver::computePotential(), ParticleAttrib< T >::create(), ParticleAttrib< T >::destroy(), PartBunchBase< double, 3 >::dt, FieldWriter::dumpField(), PartBunchBase< double, 3 >::Ef, PartBunchBase< double, 3 >::Eftmp, eg_m, endl(), PartBunchBase< double, 3 >::fs_m, Field< T, Dim, M, C >::get_mesh(), PartBunchBase< double, 3 >::getBinGamma(), PartBunchBase< double, 3 >::getCouplingConstant(), FieldLayout< Dim >::getDomain(), PartBunchBase< double, 3 >::getdT(), getFieldLayout(), FieldSolver::getFieldSolverType(), PartBunchBase< double, 3 >::getLocalNum(), gmsg, Grad(), FieldSolver::hasValidSolver(), PartBunchBase< double, 3 >::hr_m, interpolationCache_m, interpolationCacheSet_m, PartBunchBase< double, 3 >::localTrackStep_m, PartBunchBase< double, 3 >::nr_m, P3M, PartBunchBase< double, 3 >::Q, PartBunchBase< double, 3 >::R, resizeMesh(), rho_m, ParticleAttrib< T >::scatter(), PartBunchBase< double, 3 >::selfFieldTimer_m, ParticleAttrib< T >::size(), FieldSolver::solver_m, IpplTimings::startTimer(), and IpplTimings::stopTimer().

|
virtual |
Calculates the self electric field from the charge density distribution for use in cyclotrons.
\method computeSelfFields_cycl()
Comments -DW: I have made some changes in here: -) Some refacturing to make more similar to computeSelfFields() -) Added meanR and quaternion to be handed to the function so that SAAMG solver knows how to rotate the boundary geometry correctly. -) Fixed an error where gamma was not taken into account correctly in direction of movement (y in cyclotron) -) Comment: There is no account for image charges in the cyclotron tracker (yet?)!
set initial charge density to zero.
set initial E field to zero
mesh the whole domain
FIELDSOLVER, MESHFIT=CORE: the mesh of this solve, as the stat file and the log report it. A repartition after the fit of the solve step fits the mesh again.
FIELDSOLVER, MESHFIT=CORE: on a mesh fitted to the core only the core particles are deposited, and only the particles within the range of cell centres gathered (CoreFitSC::ParticleClass); the others may lie outside the mesh.
scatter particles charge onto grid, on a mesh fitted to the core that of the core particles. One call serves both meshes (see scatterMasked()).
Lorentz transformation In particle rest frame, the longitudinal length (y for cyclotron) enlarged
from charge (C) to charge density (C/m^3).
now charge density is in rho_m calculate Possion equation (without coefficient: -1/(eps))
retrive coefficient: -1/(eps)
calculate electric field vectors from field potential
Back Lorentz transformation CAVE: y coordinate needs 1/gamma factor because IPPL function Grad() divides by hr_m which is not scaled appropriately with Lorentz contraction in y direction only hr_scaled is! -DW
interpolate electric field at the particles within the range of cell centres, then the field of the particles outside the core bounds.
interpolate electric field at particle positions.
Calculate coefficient
calculate B field from E field
Implements PartBunchBase< double, 3 >.
Definition at line 490 of file PartBunch.cpp.
References PartBunchBase< double, 3 >::Bf, PartBunchBase< double, 3 >::Bin, Physics::c, PartBunchBase< double, 3 >::calcDebyeLength(), checkUnmaskedInterpolation(), CoreFitSC::classify(), computeFarField(), PoissonSolver::computePotential(), PartBunchBase< double, 3 >::computeSCDiagnostics_m, CoreFitSC::CORE, CORE, FieldWriter::dumpField(), PartBunchBase< double, 3 >::Ef, eg_m, endl(), CoreFitSC::FAR, FFT, FFTBOX, PartBunchBase< double, 3 >::fs_m, gatherMasked(), PartBunchBase< double, 3 >::getCouplingConstant(), FieldSolver::getFieldSolverType(), PartBunchBase< double, 3 >::getLocalNum(), PartBunchBase< double, 3 >::getTotalNum(), gmsg, Grad(), FieldSolver::hasValidSolver(), PartBunchBase< double, 3 >::hr_m, PartBunchBase< double, 3 >::isMeshFitToCore(), PartBunchBase< double, 3 >::localTrackStep_m, PartBunchBase< double, 3 >::meshFit_m, PartBunchBase< double, 3 >::nr_m, P3M, Physics::q_e, PartBunchBase< double, 3 >::R, resizeMesh(), rho_m, PartBunchBase< double, 3 >::rmsDensity_m, SAAMG, scatterMasked(), PartBunchBase< double, 3 >::scBoxMax_m, PartBunchBase< double, 3 >::scBoxMin_m, PartBunchBase< double, 3 >::scMeshMax_m, PartBunchBase< double, 3 >::scMeshMin_m, PartBunchBase< double, 3 >::scStatistics_m, PartBunchBase< double, 3 >::selfFieldTimer_m, FieldSolver::solver_m, IpplTimings::startTimer(), IpplTimings::stopTimer(), sum(), MeshFitParameters::type, and WARNMSG.

|
virtual |
Calculates the self electric field from the charge density distribution for use in cyclotrons.
\method computeSelfFields_cycl()
Overloaded version for having multiple bins with separate gamma for each bin. This is necessary For multi-bunch mode.
Comments -DW: I have made some changes in here: -) Some refacturing to make more similar to computeSelfFields() -) Added meanR and quaternion to be handed to the function (TODO: fall back to meanR = 0 and unit quaternion if not specified) so that SAAMG solver knows how to rotate the boundary geometry correctly. -) Fixed an error where gamma was not taken into account correctly in direction of movement (y in cyclotron) -) Comment: There is no account for image charges in the cyclotron tracker (yet?)!
set initial charge dentsity to zero.
set initial E field to zero
get gamma of this bin
mesh the whole domain
scatter particles charge onto grid.
Lorentz transformation In particle rest frame, the longitudinal length (y for cyclotron) enlarged
from charge (C) to charge density (C/m^3).
now charge density is in rho_m calculate Possion equation (without coefficient: -1/(eps))
retrive coefficient: -1/(eps)
calculate electric field vectors from field potential
Back Lorentz transformation CAVE: y coordinate needs 1/gamma factor because IPPL function Grad() divides by hr_m which is not scaled appropriately with Lorentz contraction in y direction only hr_scaled is! -DW
Interpolate electric field at particle positions.
Calculate coefficient
Calculate B_bin field from E_bin field accumulate B and E field
Implements PartBunchBase< double, 3 >.
Definition at line 684 of file PartBunch.cpp.
References PartBunchBase< double, 3 >::Bf, Physics::c, checkUnmaskedInterpolation(), PoissonSolver::computePotential(), FieldWriter::dumpField(), PartBunchBase< double, 3 >::Ef, PartBunchBase< double, 3 >::Eftmp, eg_m, endl(), FFT, FFTBOX, PartBunchBase< double, 3 >::fs_m, PartBunchBase< double, 3 >::getBinGamma(), PartBunchBase< double, 3 >::getCouplingConstant(), FieldSolver::getFieldSolverType(), gmsg, Grad(), FieldSolver::hasValidSolver(), PartBunchBase< double, 3 >::hr_m, PartBunchBase< double, 3 >::localTrackStep_m, PartBunchBase< double, 3 >::nr_m, P3M, PartBunchBase< double, 3 >::Q, PartBunchBase< double, 3 >::R, resizeMesh(), rho_m, ParticleAttrib< T >::scatter(), PartBunchBase< double, 3 >::selfFieldTimer_m, FieldSolver::solver_m, IpplTimings::startTimer(), and IpplTimings::stopTimer().

|
virtual |
Reimplemented from PartBunchBase< double, 3 >.
Definition at line 70 of file PartBunch.cpp.
References BinaryRepartition(), PartBunchBase< double, 3 >::boundp(), PartBunchBase< double, 3 >::get_bounds(), PartBunchBase< double, 3 >::pbase_m, PartBunchBase< double, 3 >::rmax_m, PartBunchBase< double, 3 >::rmin_m, and PartBunchBase< double, 3 >::update().

| void PartBunch::gatherMasked | ( | const ParticleMask_t & | accept | ) |
CIC gather of eg_m into Ef, at the particles with accept(i) true.
Ef of the others is left as it is, for the caller to set; they may lie outside the mesh. A predicate that is true for every particle gives the Ef of Ef.gather(eg_m, R, IntrplCIC_t()), bit for bit.
The loop of ParticleAttrib::gather, restricted to the accepted particles.
Definition at line 859 of file PartBunch.cpp.
References BareField< T, Dim >::Compress(), PartBunchBase< double, 3 >::Ef, eg_m, Field< T, Dim, M, C >::fillGuardCells(), IntCIC::gather(), Field< T, Dim, M, C >::get_mesh(), PartBunchBase< double, 3 >::getLocalNum(), BareField< T, Dim >::isDirty(), PartBunchBase< double, 3 >::R, and BareField< T, Dim >::Uncompress().
Referenced by computeSelfFields_cycl().

|
inlinevirtual |
Implements PartBunchBase< double, 3 >.
Definition at line 1252 of file PartBunch.cpp.
References eg_m, max(), and min().

|
virtual |
Implements PartBunchBase< double, 3 >.
Definition at line 1174 of file PartBunch.cpp.
References ParticleSpatialLayout< T, Dim, Mesh, CachingPolicy >::getLayout(), and getLayout().
Referenced by computeSelfFields(), resizeMesh(), updateDomainLength(), and updateFields().

|
inlineprivate |
Definition at line 176 of file PartBunch.h.
References PartBunchBase< double, 3 >::pbase_m.
Referenced by getFieldLayout(), getMesh(), getMesh(), and initialize().
|
inlineprivate |
Definition at line 181 of file PartBunch.h.
References PartBunchBase< double, 3 >::pbase_m.
|
inline |
Definition at line 200 of file PartBunch.h.
References ParticleSpatialLayout< T, Dim, Mesh, CachingPolicy >::getLayout(), and getLayout().

|
inline |
Definition at line 194 of file PartBunch.h.
References ParticleSpatialLayout< T, Dim, Mesh, CachingPolicy >::getLayout(), and getLayout().
Referenced by resizeMesh(), and updateFields().

|
inlinevirtual |
Implements PartBunchBase< double, 3 >.
Definition at line 189 of file PartBunch.h.
References rho_m.
|
virtual |
Implements PartBunchBase< double, 3 >.
Definition at line 64 of file PartBunch.cpp.
References ParticleSpatialLayout< T, Dim, Mesh, CachingPolicy >::getLayout(), and getLayout().

Definition at line 1279 of file PartBunch.cpp.
References PartBunchBase< T, Dim >::print().
Referenced by operator<<().

|
inlinevirtual |
Reimplemented from PartBunchBase< double, 3 >.
Definition at line 1262 of file PartBunch.cpp.
References ParticleAttrib< T >::destroy(), interpolationCache_m, interpolationCacheSet_m, and ParticleAttrib< T >::size().

|
privatevirtual |
resize mesh to geometry specified
Reimplemented from PartBunchBase< double, 3 >.
Definition at line 305 of file PartBunch.cpp.
References bc_m, PartBunchBase< double, 3 >::boundp(), PartBunchBase< double, 3 >::destroy(), PartBunchBase< double, 3 >::dh_m, eg_m, endl(), PartBunchBase< double, 3 >::fs_m, PartBunchBase< double, 3 >::get_bounds(), getFieldLayout(), FieldSolver::getFieldSolverType(), PartBunchBase< double, 3 >::getLocalNum(), getMesh(), PoissonSolver::getXRangeMax(), PoissonSolver::getXRangeMin(), PoissonSolver::getYRangeMax(), PoissonSolver::getYRangeMin(), PartBunchBase< double, 3 >::hr_m, PartBunchBase< double, 3 >::ID, INFOMSG, Field< T, Dim, M, C >::initialize(), level2(), PartBunchBase< double, 3 >::R, PoissonSolver::resizeMesh(), rho_m, PartBunchBase< double, 3 >::rmax_m, PartBunchBase< double, 3 >::rmin_m, SAAMG, UniformCartesian< Dim, MFLOAT >::set_meshSpacing(), UniformCartesian< Dim, MFLOAT >::set_origin(), FieldSolver::solver_m, PartBunchBase< double, 3 >::update(), and vbc_m.
Referenced by computeSelfFields(), computeSelfFields(), computeSelfFields_cycl(), and computeSelfFields_cycl().

| void PartBunch::scatterMasked | ( | const ParticleMask_t & | accept | ) |
CIC scatter of Q onto rho_m, of the particles with Bin >= 0 and accept(i) true.
Without a predicate (an empty accept) it is Q.scatter(rho_m, R, IntrplCIC_t()) with Q of the particles flagged lost (Bin < 0) set to zero for the call, which visits every particle. With one, the others are not read, so they may lie outside the mesh, and a predicate that is true for every particle gives the same rho_m, bit for bit.
Particles flagged lost (Bin < 0) stay in the bunch until the tracker deletes them, every DELPARTFREQ steps. Leave their charge off the mesh, as setBinCharge() does in the multi-bunch solve. Without a predicate their Q is set to zero for the scatter and restored after it: the integrator, ScatteringPhysics and the loss records still read it. With a predicate the accepted particles that are not flagged lost are copied, in order, into maskedQ_m and maskedR_m; a flagged particle adds only zero to the scatter of Q, so an all-true predicate gives the same rho_m, bit for bit. Both cases share one call of IPPL's scatter: with a second call, or with a loop of its own over IPPL's CIC kernel, the production build no longer inlines the kernel into computeSelfFields_cycl(double) and computeSelfFields().
Definition at line 810 of file PartBunch.cpp.
References PartBunchBase< double, 3 >::Bin, ParticleAttrib< T >::create(), ParticleAttrib< T >::destroy(), PartBunchBase< double, 3 >::getLocalNum(), maskedQ_m, maskedR_m, PartBunchBase< double, 3 >::Q, PartBunchBase< double, 3 >::R, rho_m, ParticleAttrib< T >::scatter(), and ParticleAttrib< T >::size().
Referenced by computeSelfFields_cycl().

|
virtual |
Reimplemented from PartBunchBase< double, 3 >.
Definition at line 1198 of file PartBunch.cpp.
References bc_m, PartBunchBase< double, 3 >::dcBeam_m, endl(), PartBunchBase< double, 3 >::getBConds(), INFOMSG, level3(), ParticleNoBCond(), and vbc_m.

|
virtual |
Reimplemented from PartBunchBase< double, 3 >.
Definition at line 1179 of file PartBunch.cpp.
References bc_m, PartBunchBase< double, 3 >::dcBeam_m, endl(), PartBunchBase< double, 3 >::getBConds(), IpplInfo::getNodes(), INFOMSG, level3(), ParticlePeriodicBCond(), and vbc_m.

|
virtual |
Reimplemented from PartBunchBase< double, 3 >.
Definition at line 1208 of file PartBunch.cpp.
References bc_m, PartBunchBase< double, 3 >::dcBeam_m, endl(), PartBunchBase< double, 3 >::getBConds(), IpplInfo::getNodes(), INFOMSG, level3(), ParticleNoBCond(), ParticlePeriodicBCond(), and vbc_m.

|
virtual |
Reimplemented from PartBunchBase< double, 3 >.
Definition at line 1269 of file PartBunch.cpp.
References interpolationCache_m, interpolationCacheSet_m, and PartBunchBase< T, Dim >::swap().

|
privatevirtual |
Implements PartBunchBase< double, 3 >.
Definition at line 1231 of file PartBunch.cpp.
References PartBunchBase< double, 3 >::Dimension, FieldLayout< Dim >::getDomain(), and getFieldLayout().

Reimplemented from PartBunchBase< double, 3 >.
Definition at line 1238 of file PartBunch.cpp.
References bc_m, eg_m, getFieldLayout(), getMesh(), PartBunchBase< double, 3 >::hr_m, Field< T, Dim, M, C >::initialize(), rho_m, UniformCartesian< Dim, MFLOAT >::set_meshSpacing(), UniformCartesian< Dim, MFLOAT >::set_origin(), and vbc_m.

for defining the boundary conditions
Definition at line 163 of file PartBunch.h.
Referenced by resizeMesh(), setBCAllOpen(), setBCAllPeriodic(), setBCForDCBeam(), and updateFields().
| VField_t PartBunch::eg_m |
vector field on the grid
Definition at line 123 of file PartBunch.h.
Referenced by computeSelfFields(), computeSelfFields(), computeSelfFields_cycl(), computeSelfFields_cycl(), gatherMasked(), getEExtrema(), resizeMesh(), and updateFields().
|
private |
Definition at line 169 of file PartBunch.h.
Referenced by computeSelfFields(), resetInterpolationCache(), and swap().
|
private |
Definition at line 167 of file PartBunch.h.
Referenced by computeSelfFields(), resetInterpolationCache(), and swap().
|
private |
scatterMasked(): the charges and positions of the particles that a predicate accepts
Definition at line 172 of file PartBunch.h.
Referenced by scatterMasked().
|
private |
Definition at line 173 of file PartBunch.h.
Referenced by scatterMasked().
| Field_t PartBunch::rho_m |
scalar potential
Definition at line 120 of file PartBunch.h.
Referenced by computeSelfFields(), computeSelfFields(), computeSelfFields_cycl(), computeSelfFields_cycl(), getRho(), resizeMesh(), scatterMasked(), and updateFields().
Definition at line 164 of file PartBunch.h.
Referenced by resizeMesh(), setBCAllOpen(), setBCAllPeriodic(), setBCForDCBeam(), and updateFields().