Commit 6f22df2f authored by kraus's avatar kraus

Resolve "Source elements should delete particles that are pushed back into it"

parent 5c83e306
......@@ -75,8 +75,7 @@ ParallelTTracker::ParallelTTracker(const Beamline &beamline,
fieldEvaluationTimer_m(IpplTimings::getTimer("External field eval")),
BinRepartTimer_m(IpplTimings::getTimer("Binaryrepart")),
WakeFieldTimer_m(IpplTimings::getTimer("WakeField")),
particleMatterStatus_m(false),
totalParticlesInSimulation_m(0)
particleMatterStatus_m(false)
{}
ParallelTTracker::ParallelTTracker(const Beamline &beamline,
......@@ -108,8 +107,7 @@ ParallelTTracker::ParallelTTracker(const Beamline &beamline,
fieldEvaluationTimer_m(IpplTimings::getTimer("External field eval")),
BinRepartTimer_m(IpplTimings::getTimer("Binaryrepart")),
WakeFieldTimer_m(IpplTimings::getTimer("WakeField")),
particleMatterStatus_m(false),
totalParticlesInSimulation_m(0)
particleMatterStatus_m(false)
{
for (unsigned int i = 0; i < zstop.size(); ++ i) {
stepSizes_m.push_back(dt[i], zstop[i], maxSteps[i]);
......@@ -257,7 +255,6 @@ void ParallelTTracker::execute() {
saveCavityPhases();
numParticlesInSimulation_m = itsBunch_m->getTotalNum();
totalParticlesInSimulation_m = itsBunch_m->getTotalNum();
setTime();
......@@ -588,7 +585,6 @@ void ParallelTTracker::computeExternalFields(OrbitThreader &oth) {
ne = itsBunch_m->destroyT();
}
numParticlesInSimulation_m = itsBunch_m->getTotalNum();
totalParticlesInSimulation_m -= ne;
deletedParticles_m = true;
}
......@@ -599,7 +595,7 @@ void ParallelTTracker::computeExternalFields(OrbitThreader &oth) {
if (ne > 0) {
msg << level1 << "* Deleted " << ne << " particles, "
<< "remaining " << totalParticlesInSimulation_m << " particles" << endl;
<< "remaining " << numParticlesInSimulation_m << " particles" << endl;
}
}
......@@ -1390,4 +1386,4 @@ void ParallelTTracker::evenlyDistributeParticles() {
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End:
// End:
\ No newline at end of file
......@@ -244,8 +244,6 @@ private:
std::set<ParticleMatterInteractionHandler*> activeParticleMatterInteractionHandlers_m;
bool particleMatterStatus_m;
unsigned long totalParticlesInSimulation_m;
/********************** END VARIABLES ***********************************/
void kickParticles(const BorisPusher &pusher);
......
......@@ -45,17 +45,13 @@ bool Source::apply(const size_t &i, const double &t, Vector_t &/*E*/, Vector_t &
const Vector_t &P = RefPartBunch_m->P[i];
const double &dt = RefPartBunch_m->dt[i];
const double recpgamma = Physics::c * dt / Util::getGamma(P);
const double end = getElementLength();
if (online_m && dt < 0.0) {
if (R(2) > end &&
(R(2) + P(2) * recpgamma) < end) {
double frac = (end - R(2)) / (P(2) * recpgamma);
if (online_m && R(2) <= 0.0 && P(2) < 0.0) {
double frac = -R(2) / (P(2) * recpgamma);
lossDs_m->addParticle(R + frac * recpgamma * P,
P, RefPartBunch_m->ID[i], t + frac * dt, 0);
lossDs_m->addParticle(R + frac * recpgamma * P,
P, RefPartBunch_m->ID[i], t + frac * dt, 0);
return true;
}
return true;
}
return false;
......@@ -98,5 +94,4 @@ void Source::getDimensions(double &zBegin, double &zEnd) const {
ElementBase::ElementType Source::getType() const {
return SOURCE;
}
}
\ No newline at end of file
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