22#ifndef OPALX_ParallelTracker_HH
23#define OPALX_ParallelTracker_HH
62class ParticleMatterInteractionHandler;
83 std::vector<std::vector<std::shared_ptr<SamplingBase>>>
118 const std::vector<unsigned long long>& maxSTEPS,
double zstart,
119 const std::vector<double>& zstop,
const std::vector<double>& dt,
120 const std::vector<std::vector<std::shared_ptr<SamplingBase>>>& emittingSamplers = {});
240 void writePhaseSpace(
const long long step,
bool psDump,
bool statDump);
248 void dumpStats(
long long step,
bool psDump,
bool statDump);
ippl::Vector< T, Dim > Vector_t
An abstract sequence of beam line components.
Component applying a constant accelerating electric field (Ex,Ey,Ez).
Interface for drift space.
Passive OPALX laser element.
Interface for general multipole.
void visit(const T &, BeamlineVisitor &, PartBunch_t &)
Implements the main time-based simulation loop for parallel tracking.
void activateEmittingContainers(double t)
Force-activate containers whose emitting samplers have not yet finished.
void saveCavityPhases()
Persist cavity phases to the data sink.
void updateRFElement(std::string elName, double maxPhi)
Set stored RF phase on the named cavity or traveling-wave element.
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
double dtCurrentTrack_m
Global for the current track segment.
IpplTimings::TimerRef BinRepartTimer_m
void printInitialContainerRefs(Inform &m) const
Log reference state for each container at track start.
void restoreCavityPhases()
Restore cavity phases from a prior track or restart.
void evolveSpinTBMT()
Thomas-BMT spin precession across all active containers that store Pol. Must be called after external...
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a solenoid.
size_t deleteInvalidParticles(bool activeOnly, Inform &m, const std::string &reason)
Delete particles marked invalid by the central per-container mask.
void prepareSections()
Accept beamline visitor, prepare sections, compute and save 3D lattice.
DataSink * itsDataSink_m
Borrowed beam statistics and phase-space output sink.
void resetFields()
Zero E and B on all active particle containers.
virtual void visitMonitor(const Monitor &)
Apply the algorithm to a monitor.
void doBinaryRepartition()
Trigger binary repartition for the field solver if configured.
void updateRefToLabCSTrafo()
Refresh each container's reference-to-lab transform from current state.
void kickParticles(const BorisPusher &pusher, PartBunch_t::ParticleContainer_t &pc)
Boris half-kick using E, B and per-particle dt on one container.
void autophaseCavities(const BorisPusher &pusher)
Autophase TRAVELINGWAVE and RFCAVITY elements along the reference orbit.
void printRFPhases()
Print RF phases (debug/diagnostic hook).
IpplTimings::TimerRef WakeFieldTimer_m
IpplTimings::TimerRef OrbThreader_m
void emitFromEmissionSources(double t, double dt)
Emit macroparticles from configured samplers per container.
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a multipole.
void setTime()
Reset per-particle dt views to the current global bunch dt.
virtual void visitDrift(const Drift &)
Apply the algorithm to a drift.
virtual void execute()
Run the main tracking loop until all step-size segments complete.
std::vector< std::vector< std::shared_ptr< SamplingBase > > > emittingSamplers_m
Per-container emitters.
virtual void visitMultipoleT(const MultipoleT &)
Apply the algorithm to a multipole (templated type).
void setOptionalVariables()
Load REPARTFREQ and related options from input.
unsigned long long repartFreq_m
Space-charge repartition period (steps); 0 disables it.
void updateReferenceParticles(const BorisPusher &pusher)
Advance reference positions/momenta through the beamline for one step.
virtual void visitSBend(const SBend &)
Apply the algorithm to a sector bend.
void writePhaseSpace(const long long step, bool psDump, bool statDump)
Write phase space and/or statistics when flags request it.
void timeIntegration2(BorisPusher &pusher)
Second half: kick then push all active containers.
size_t applyGlobalProcesses(double dt)
Apply global processes and return the global number of particles marked invalid.
virtual void visitBeamline(const Beamline &)
Visit the full beamline (iterates elements into OpalBeamline). Overrides DefaultVisitor.
virtual void visitLaser(const Laser &)
Reject laser tracking until dedicated laser tracking is implemented.
void selectDT()
Set global bunch dt to dtCurrentTrack_m.
double zstart_m
Path-length start position for the track (m).
void changeDT()
Set bunch dt from StepSizeConfig and copy to all container dt views.
size_t markBackwardParticlesAtSourcePlane()
Mark particles moving backward behind an active source/cathode plane.
void updateReference(const BorisPusher &pusher)
Update reference trajectories and lab/reference coordinate transforms.
IpplTimings::TimerRef timeIntegrationTimer2_m
void computeExternalFields(OrbitThreader &oth)
Apply external fields from elements intersecting each active container.
virtual void visitTravelingWave(const TravelingWave &)
Apply the algorithm to a traveling wave cavity.
void computeSpaceChargeFields(unsigned long long step)
Self-fields in beam frame (primary container); optional binary repartition.
bool hasEndOfLineReached(const BoundingBox &globalBoundingBox)
Whether tracking should stop at end-of-line (global reduction).
void findStartPositions(const BorisPusher &pusher)
Integrate references in time until path length reaches zstart_m.
bool globalEOL_m
End-of-line flag (e.g. orbit threader out of bounds).
void dumpStats(long long step, bool psDump, bool statDump)
Log per-container stats and trigger dumps according to dump flags.
virtual void visitComponent(const Component &)
Visit a generic component using the base tracker behavior.
IpplTimings::TimerRef timeIntegrationTimer1_m
IpplTimings::TimerRef PluginElemTimer_m
virtual void visitMarker(const Marker &)
Apply the algorithm to a marker.
void computeInitialBounds(Vector_t< double, 3 > &rmin, Vector_t< double, 3 > &rmax)
Union of per-container spatial bounds over MPI.
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to an RF cavity.
virtual void visitConstantEFieldCavity(const ConstantEFieldCavity &)
Apply the algorithm to a constant E-field cavity.
IpplTimings::TimerRef fieldEvaluationTimer_m
void pushParticles(const BorisPusher &pusher, PartBunch_t::ParticleContainer_t &pc)
Boris position push (unitless positions) on one container.
void timeIntegration1(BorisPusher &pusher)
First half of the leapfrog step: push all active containers.
StepSizeConfig stepSizes_m
virtual ~ParallelTracker()
Destructor; releases tracker resources.
OpalBeamline itsOpalBeamline_m
Cloned field elements and coordinate transforms.
Container for all per-particle (and per-simulation) fields tracked during OPALX tracking.
Abstract rectangular bend with straight body and curved reference path.
Interface for standing wave cavities.
Abstract sector bend with planar-arc body geometry.
Abstract class for a solenoid magnet.
PartBunch_t * itsBunch_m
The bunch of particles to be tracked. Borrowed; lifetime is managed by TrackRun.
Interface for traveling wave cavities.