Commit dbdee57e authored by adelmann's avatar adelmann 🎗

pass initial number of particles

parent 33e7f1ec
......@@ -72,10 +72,12 @@ using namespace OPALTimer;
ParallelTTracker::ParallelTTracker(const Beamline &beamline,
const PartData &reference,
bool revBeam,
bool revTrack):
bool revTrack,
size_t N):
Tracker(beamline, reference, revBeam, revTrack),
itsBunch(NULL),
itsDataSink_m(NULL),
specifiedNPart_m(N),
bgf_m(NULL),
itsOpalBeamline_m(),
lineDensity_m(),
......@@ -128,9 +130,11 @@ ParallelTTracker::ParallelTTracker(const Beamline &beamline,
bool revTrack,
int maxSTEPS,
double zstop,
int timeIntegrator):
int timeIntegrator,
size_t N):
Tracker(beamline, reference, revBeam, revTrack),
itsBunch(&bunch),
specifiedNPart_m(N),
itsDataSink_m(&ds),
bgf_m(NULL),
itsOpalBeamline_m(),
......@@ -1932,6 +1936,10 @@ void ParallelTTracker::emitParticles(long long step) {
if(step > minStepforReBin_m) {
itsBunch->Rebin();
itsBunch->resetInterpolationCache(true);
// if (itsBunch->getTotalNum() < specifiedNPart_m) {
// WARNMSG("Rebinning, but less particles emitted than specifyed. Either increase MINSTEPFORREBIN or you have particle losses!"<< endl);
//}
}
}
......
......@@ -113,7 +113,7 @@ public:
// If [b]revBeam[/b] is true, the beam runs from s = C to s = 0.
// If [b]revTrack[/b] is true, we track against the beam.
explicit ParallelTTracker(const Beamline &bl, const PartData &data,
bool revBeam, bool revTrack);
bool revBeam, bool revTrack, size_t N);
/// Constructor.
// The beam line to be tracked is "bl".
......@@ -122,7 +122,7 @@ public:
// If [b]revBeam[/b] is true, the beam runs from s = C to s = 0.
// If [b]revTrack[/b] is true, we track against the beam.
explicit ParallelTTracker(const Beamline &bl, PartBunch &bunch, DataSink &ds,
const PartData &data, bool revBeam, bool revTrack, int maxSTEPS, double zstop, int timeIntegrator);
const PartData &data, bool revBeam, bool revTrack, int maxSTEPS, double zstop, int timeIntegrator, size_t N);
virtual ~ParallelTTracker();
......@@ -280,6 +280,9 @@ private:
double surfaceEmissionStop_m;
size_t specifiedNPart_m;
// This variable controls the minimal number of steps of emission (using bins)
// before we can merge the bins
int minStepforReBin_m;
......
......@@ -322,7 +322,8 @@ void TrackRun::execute() {
itsTracker = new ParallelTTracker(*Track::block->use->fetchLine(),
dynamic_cast<PartBunch &>(*Track::block->bunch), *ds,
Track::block->reference, false, false, Track::block->localTimeSteps,
Track::block->zstop, Track::block->timeIntegrator);
Track::block->zstop, Track::block->timeIntegrator,
beam->getNumberOfParticles());
itsTracker->setMpacflg(mpacflg); // set multipacting flag in ParallelTTracker
} else if(method == "PARALLEL-Z") {
......@@ -362,7 +363,7 @@ void TrackRun::execute() {
getFrequency() gets RF frequency [MHz], NOT isochronous revolution frequency of particle!
getCurrent() gets beamcurrent [A]
*/
*/
macrocharge = beam->getCurrent() / (beam->getFrequency() * 1.0e6); // [MHz]-->[Hz]
if(!OPAL->hasBunchAllocated()) {
......@@ -372,8 +373,8 @@ void TrackRun::execute() {
dist->CreateOpalCycl(*Track::block->bunch, beam->getNumberOfParticles(), Options::scan);
} else {
dist->DoRestartOpalCycl(*Track::block->bunch, beam->getNumberOfParticles(),
OPAL->getRestartStep(), specifiedNumBunch);
dist->DoRestartOpalCycl(*Track::block->bunch, beam->getNumberOfParticles(),
OPAL->getRestartStep(), specifiedNumBunch);
macrocharge /= beam->getNumberOfParticles();
macromass = beam->getMass() * macrocharge / (beam->getCharge() * q_e);
}
......@@ -703,10 +704,11 @@ ParallelTTracker *TrackRun::setupForAutophase() {
double coefE = 1.0 / (4 * pi * epsilon_0);
Track::block->bunch->setCouplingConstant(coefE);
size_t N = 1;
return new ParallelTTracker(*Track::block->use->fetchLine(),
dynamic_cast<PartBunch &>(*Track::block->bunch), *ds,
Track::block->reference, false, false, Track::block->localTimeSteps,
Track::block->zstop, Track::block->timeIntegrator);
Track::block->zstop, Track::block->timeIntegrator,
N);
}
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