Commit ec8cf7c1 authored by adelmann's avatar adelmann 🎗
Browse files

fix Issue #15

parent 02bc6fdb
......@@ -26,7 +26,7 @@
#include "AbstractObjects/Expressions.h"
#include "Attributes/Attributes.h"
#include "Utilities/Options.h"
#include "Utilities/Options.h"
#include "Utilities/OpalException.h"
#include "halton1d_sequence.hh"
#include "AbstractObjects/OpalData.h"
#include "Algorithms/PartBunch.h"
......@@ -1119,7 +1119,7 @@ void Distribution::CheckParticleNumber(size_t &numberOfParticles) {
size_t numberOfDistParticles = tOrZDist_m.size();
reduce(numberOfDistParticles, numberOfDistParticles, OpAddAssign());
if (numberOfDistParticles != numberOfParticles) {
*gmsg << "\n--------------------------------------------------" << endl
<< "Warning!! The number of particles in the initial" << endl
......@@ -1134,6 +1134,8 @@ void Distribution::CheckParticleNumber(size_t &numberOfParticles) {
<< "(" << numberOfDistParticles << ") "
<< "will take precedence." << endl
<< "---------------------------------------------------\n" << endl;
throw OpalException("Distribution::CheckParticleNumber",
"Number of macro particles and NPART on BEAM are not equal");
}
numberOfParticles = numberOfDistParticles;
}
......@@ -1576,6 +1578,9 @@ void Distribution::CreateOpalCycl(PartBunch &beam,
beam.setPBins(energyBins_m);
}
// Check number of particles in distribution.
CheckParticleNumber(numberOfParticles);
InitializeBeam(beam);
WriteOutFileHeader();
......
......@@ -596,16 +596,6 @@ void TrackRun::setupCyclotronTracker(){
*gmsg << "* Mass of simulation particle= " << macromass << " GeV/c^2" << endl;
*gmsg << "* Charge of simulation particle= " << macrocharge << " [C]" << endl;
try {
throw (beam->getNumberOfParticles() != Track::block->bunch->getTotalNum());
}
catch (bool notEqual) {
if (notEqual && !opal->inRestartRun()) {
throw OpalException("TrackRun::execute CYCLOTRON_T",
"Number of macro particles and NPART on BEAM are not equal");
}
}
Track::block->bunch->setdT(1.0 / (Track::block->stepsPerTurn * beam->getFrequency() * 1.0e6));
Track::block->bunch->setStepsPerTurn(Track::block->stepsPerTurn);
......
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