Commit 16bb99c4 authored by snuverink_j's avatar snuverink_j
Browse files

add flag to check if cavity was just applied, fixes #267

parent 0b38169d
......@@ -3142,12 +3142,13 @@ void ParallelCyclotronTracker::singleMode_m(double& t, const double dt,
Vector_t Pold = itsBunch_m->P[i]; // [px,py,pz] (beta*gamma)
// integrate for one step in the lab Cartesian frame (absolute value).
/*bool flagNoDeletion = */
itsStepper_mp->advance(itsBunch_m, i, t, dt);
// If gap crossing happens, do momenta kicking
gapCrossKick_m(i, t, dt, Rold, Pold);
// If gap crossing happens, do momenta kicking (not if gap crossing just happened)
if (itsBunch_m->cavityGapCrossed[i] == true)
itsBunch_m->cavityGapCrossed[i] = false;
else
gapCrossKick_m(i, t, dt, Rold, Pold);
IpplTimings::stopTimer(IntegrationTimer_m);
......@@ -3224,8 +3225,11 @@ void ParallelCyclotronTracker::bunchMode_m(double& t, const double dt, bool& dum
// Integrate for one step in the lab Cartesian frame (absolute value).
itsStepper_mp->advance(itsBunch_m, i, t, dt);
// If gap crossing happens, do momenta kicking
gapCrossKick_m(i, t, dt, Rold, Pold);
// If gap crossing happens, do momenta kicking (not if gap crossing just happened)
if (itsBunch_m->cavityGapCrossed[i] == true)
itsBunch_m->cavityGapCrossed[i] = false;
else
gapCrossKick_m(i, t, dt, Rold, Pold);
}
IpplTimings::stopTimer(IntegrationTimer_m);
......@@ -3278,6 +3282,7 @@ void ParallelCyclotronTracker::gapCrossKick_m(size_t i, double t,
}
if ( tag_crossing ) {
itsBunch_m->cavityGapCrossed[i] = true;
double oldMomentum2 = dot(Pold, Pold);
double oldBetgam = sqrt(oldMomentum2);
......
......@@ -477,6 +477,7 @@ public:
ParticleAttrib< short > PType; // we can distinguish dark current particles from primary particle
ParticleAttrib< int > TriID; // holds the ID of triangle that the particle hit. Only for BoundaryGeometry case.
ParticleAttrib< short > cavityGapCrossed; ///< particle just crossed cavity gap (for ParallelCyclotronTracker)
Vector_t RefPartR_m;
......@@ -612,7 +613,7 @@ protected:
double qi_m;
/// counter to store the distributin dump
/// counter to store the distribution dump
int distDump_m;
///
......
......@@ -2064,6 +2064,7 @@ void PartBunchBase<T, Dim>::swap(unsigned int i, unsigned int j) {
std::swap(dt[i], dt[j]);
std::swap(PType[i], PType[j]);
std::swap(TriID[i], TriID[j]);
std::swap(cavityGapCrossed[i], cavityGapCrossed[j]);
}
......@@ -2106,17 +2107,18 @@ void PartBunchBase<T, Dim>::setup(AbstractParticle<T, Dim>* pb) {
pb->addAttribute(dt);
pb->addAttribute(PType);
pb->addAttribute(TriID);
pb->addAttribute(cavityGapCrossed);
boundpTimer_m = IpplTimings::getTimer("Boundingbox");
boundpTimer_m = IpplTimings::getTimer("Boundingbox");
boundpBoundsTimer_m = IpplTimings::getTimer("Boundingbox-bounds");
boundpUpdateTimer_m = IpplTimings::getTimer("Boundingbox-update");
statParamTimer_m = IpplTimings::getTimer("Compute Statistics");
selfFieldTimer_m = IpplTimings::getTimer("SelfField total");
statParamTimer_m = IpplTimings::getTimer("Compute Statistics");
selfFieldTimer_m = IpplTimings::getTimer("SelfField total");
histoTimer_m = IpplTimings::getTimer("Histogram");
histoTimer_m = IpplTimings::getTimer("Histogram");
distrCreate_m = IpplTimings::getTimer("Create Distr");
distrReload_m = IpplTimings::getTimer("Load Distr");
distrCreate_m = IpplTimings::getTimer("Create Distr");
distrReload_m = IpplTimings::getTimer("Load Distr");
globalPartPerNode_m = std::unique_ptr<size_t[]>(new size_t[Ippl::getNodes()]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment