Commit f345284b authored by kraus's avatar kraus
Browse files

Merge branch 'arrayTrack'

- first step towards multiple dt in single track
parents 42fe8119 179cfc16
......@@ -36,8 +36,10 @@ otherwise a new bunch is allocated in the dictionary.
*/
Track::Track(BeamSequence *u, const PartData &ref, double dt, int maxtsteps, int stepsperturn, double zStop, int timeintegrator,
int nslices, double t0, double dtScInit, double deltaTau):
Track::Track(BeamSequence *u, const PartData &ref, const std::vector<double> & dt,
const std::vector<int> & maxtsteps, int stepsperturn,
const std::vector<double> & zStop, int timeintegrator, int nslices,
double t0, double dtScInit, double deltaTau):
reference(ref),
use(u),
parser(),
......@@ -69,4 +71,4 @@ Track::Track(BeamSequence *u, const PartData &ref, double dt, int maxtsteps, int
Track::~Track()
{}
{}
\ No newline at end of file
......@@ -35,7 +35,9 @@ class Track {
public:
Track(BeamSequence *, const PartData &, double dt, int maxtsteps, int stepsperturn, double zStop, int timeintegrator, int nslices,
Track(BeamSequence *, const PartData &, const std::vector<double> & dt,
const std::vector<int> & maxtsteps, int stepsperturn,
const std::vector<double> & zStop, int timeintegrator, int nslices,
double t0, double dtScInit, double deltaTau);
~Track();
......@@ -57,7 +59,7 @@ public:
static Track *block;
/// The initial timestep
double dT;
std::vector<double> dT;
// For AMTS integrator in OPAL-T
double dtScInit, deltaTau;
......@@ -67,13 +69,13 @@ public:
double t0_m;
/// Maximal number of timesteps
int localTimeSteps;
std::vector<int> localTimeSteps;
/// The timsteps per revolution period. ONLY available for OPAL-cycl.
int stepsPerTurn;
/// The location at which the simulation stops
double zstop;
std::vector<double> zstop;
/// The ID of time integrator
// 0 --- RK-4(default)
......@@ -90,4 +92,4 @@ private:
void operator=(const Track &);
};
#endif // OPAL_Track_HH
#endif // OPAL_Track_HH
\ No newline at end of file
......@@ -59,20 +59,20 @@ TrackCmd::TrackCmd():
("LINE", "Name of lattice to be tracked");
itsAttr[BEAM] = Attributes::makeString
("BEAM", "Name of beam to be used", "UNNAMED_BEAM");
itsAttr[DT] = Attributes::makeReal
("DT", "THE INTEGRATION TIMESTEP IN SECONDS", 1e-12);
itsAttr[DT] = Attributes::makeRealArray
("DT", "THE INTEGRATION TIMESTEP IN SECONDS");
itsAttr[DTSCINIT] = Attributes::makeReal
("DTSCINIT", "Only for adaptive integrator: Initial time step for space charge integration", 1e-12);
itsAttr[DTAU] = Attributes::makeReal
("DTAU", "Only for adaptive integrator: Alternative way to set accuracy of space integration.", -1.0);
itsAttr[T0] = Attributes::makeReal
("T0", "THE ELAPSED TIME OF THE BUNCH IN SECONDS", 0.0);
itsAttr[MAXSTEPS] = Attributes::makeReal
("MAXSTEPS", "THE MAXIMUM NUMBER OF INTEGRATION STEPS DT, should be larger ZSTOP/(beta*c average)", 10);
itsAttr[MAXSTEPS] = Attributes::makeRealArray
("MAXSTEPS", "THE MAXIMUM NUMBER OF INTEGRATION STEPS DT, should be larger ZSTOP/(beta*c average)");
itsAttr[STEPSPERTURN] = Attributes::makeReal
("STEPSPERTURN", "THE TIME STEPS PER REVOLUTION PERIOD, ONLY FOR OPAL-CYCL", 720);
itsAttr[ZSTOP] = Attributes::makeReal
("ZSTOP", "Defines a z-location [m], after which the simulation stops when the last particles passes", 1000000.0);
itsAttr[ZSTOP] = Attributes::makeRealArray
("ZSTOP", "Defines a z-location [m], after which the simulation stops when the last particles passes");
itsAttr[TIMEINTEGRATOR] = Attributes::makeString
("TIMEINTEGRATOR", "Name of time integrator to be used", "RK-4");
itsAttr[NNB] = Attributes::makeReal
......@@ -92,8 +92,12 @@ TrackCmd *TrackCmd::clone(const std::string &name) {
return new TrackCmd(name, this);
}
double TrackCmd::getDT() const {
return Attributes::getReal(itsAttr[DT]);
std::vector<double> TrackCmd::getDT() const {
std::vector<double> dt = Attributes::getRealArray(itsAttr[DT]);
if (dt.size() == 0) {
dt.push_back(1e-12);
}
return dt;
}
double TrackCmd::getDTSCINIT() const {
......@@ -108,12 +112,25 @@ double TrackCmd::getT0() const {
return Attributes::getReal(itsAttr[T0]);
}
double TrackCmd::getZSTOP() const {
return Attributes::getReal(itsAttr[ZSTOP]);
std::vector<double> TrackCmd::getZSTOP() const {
std::vector<double> zstop = Attributes::getRealArray(itsAttr[ZSTOP]);
if (zstop.size() == 0) {
zstop.push_back(1000000.0);
}
return zstop;
}
int TrackCmd::getMAXSTEPS() const {
return (int) Attributes::getReal(itsAttr[MAXSTEPS]);
std::vector<int> TrackCmd::getMAXSTEPS() const {
std::vector<double> maxsteps_d = Attributes::getRealArray(itsAttr[MAXSTEPS]);
std::vector<int> maxsteps_i;
if (maxsteps_d.size() == 0) {
maxsteps_i.push_back(10);
}
for (auto it = maxsteps_d.begin(); it != maxsteps_d.end(); ++ it) {
maxsteps_i.push_back(*it);
}
return maxsteps_i;
}
int TrackCmd::getSTEPSPERTURN() const {
......@@ -147,19 +164,32 @@ void TrackCmd::execute() {
BeamSequence *use = BeamSequence::find(Attributes::getString(itsAttr[LINE]));
Beam *beam = Beam::find(Attributes::getString(itsAttr[BEAM]));
double dt = getDT();
std::vector<double> dt = getDT();
double t0 = getT0();
int maxsteps = getMAXSTEPS();
std::vector<int> maxsteps = getMAXSTEPS();
int stepsperturn = getSTEPSPERTURN();
double zstop = getZSTOP();
std::vector<double> zstop = getZSTOP();
int timeintegrator = getTIMEINTEGRATOR();
int nslices = beam->getNumberOfSlices();
// Execute track block.
size_t numTracks = dt.size();
numTracks = std::max(numTracks, maxsteps.size());
numTracks = std::max(numTracks, zstop.size());
for (size_t i = dt.size(); i < numTracks; ++ i) {
dt.push_back(dt.back());
}
for (size_t i = maxsteps.size(); i < numTracks; ++ i) {
maxsteps.push_back(maxsteps.back());
}
for (size_t i = zstop.size(); i < numTracks; ++ i) {
zstop.push_back(zstop.back());
}
// Execute track block.
Track::block = new Track(use, beam->getReference(), dt, maxsteps, stepsperturn, zstop, timeintegrator, nslices, t0, getDTSCINIT(), getDTAU());
Track::block->parser.run();
// Clean up.
delete Track::block;
Track::block = 0;
}
}
\ No newline at end of file
......@@ -41,7 +41,7 @@ public:
virtual void execute();
/// Return the timestep in seconds
double getDT() const;
std::vector<double> getDT() const;
double getDTSCINIT() const;
......@@ -51,14 +51,14 @@ public:
double getT0() const;
/// Return the maximum timsteps we integrate the system
int getMAXSTEPS() const;
std::vector<int> getMAXSTEPS() const;
/// Return the timsteps per revolution period. ONLY available for OPAL-cycl.
/// In OPAL-cycl, timestep is calculated by STEPSPERTURN, rather than given in TRACK command.
int getSTEPSPERTURN() const;
/// location at which the simulation stops
double getZSTOP() const;
std::vector<double> getZSTOP() const;
/// return the name of time integrator
int getTIMEINTEGRATOR() const;
......@@ -77,4 +77,4 @@ private:
TrackCmd(const std::string &name, TrackCmd *parent);
};
#endif // OPAL_TrackCmd_HH
#endif // OPAL_TrackCmd_HH
\ No newline at end of file
......@@ -207,7 +207,7 @@ void TrackRun::execute() {
charge = 1.0;
}
Track::block->slbunch->setdT(Track::block->dT);
Track::block->slbunch->setdT(Track::block->dT.front());
// set the total charge
charge = beam->getCharge() * beam->getCurrent() / beam->getFrequency();
Track::block->slbunch->setCharge(charge);
......@@ -239,8 +239,8 @@ void TrackRun::execute() {
*ds,
Track::block->reference,
false, false,
Track::block->localTimeSteps,
Track::block->zstop,
Track::block->localTimeSteps.front(),
Track::block->zstop.front(),
*mySlApTracker);
} else if(method == "PARALLEL-T") {
OpalData::getInstance()->setInOPALTMode();
......@@ -289,7 +289,7 @@ void TrackRun::execute() {
double charge = SetDistributionParallelT(beam);
Track::block->bunch->setdT(Track::block->dT);
Track::block->bunch->setdT(Track::block->dT.front());
Track::block->bunch->dtScInit_m = Track::block->dtScInit;
Track::block->bunch->deltaTau_m = Track::block->deltaTau;
......@@ -500,14 +500,14 @@ void TrackRun::execute() {
#ifdef HAVE_AMR_SOLVER
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->reference, false, false, Track::block->localTimeSteps.front(),
Track::block->zstop.front(), Track::block->timeIntegrator,
beam->getNumberOfParticles(),amrptr);
#else
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->reference, false, false, Track::block->localTimeSteps.front(),
Track::block->zstop.front(), Track::block->timeIntegrator,
beam->getNumberOfParticles());
#endif
itsTracker->setMpacflg(mpacflg); // set multipacting flag in ParallelTTracker
......@@ -641,15 +641,15 @@ void TrackRun::execute() {
*gmsg << "* ********************************************************************************** " << endl;
}
*gmsg << "* Number of neighbour bunches= " << specifiedNumBunch << endl;
*gmsg << "* DT = " << Track::block->dT << endl;
*gmsg << "* MAXSTEPS = " << Track::block->localTimeSteps << endl;
*gmsg << "* DT = " << Track::block->dT.front() << endl;
*gmsg << "* MAXSTEPS = " << Track::block->localTimeSteps.front() << endl;
*gmsg << "* Phase space dump frequency = " << Options::psDumpFreq << endl;
*gmsg << "* Statistics dump frequency = " << Options::statDumpFreq << " w.r.t. the time step." << endl;
*gmsg << "* ********************************************************************************** " << endl;
itsTracker = new ParallelCyclotronTracker(*Track::block->use->fetchLine(),
dynamic_cast<PartBunch &>(*Track::block->bunch), *ds, Track::block->reference,
false, false, Track::block->localTimeSteps, Track::block->timeIntegrator);
false, false, Track::block->localTimeSteps.front(), Track::block->timeIntegrator);
itsTracker->setNumBunch(specifiedNumBunch);
......@@ -920,7 +920,7 @@ ParallelTTracker *TrackRun::setupForAutophase() {
charge /= beam->getNumberOfParticles();
Track::block->bunch->setdT(Track::block->dT);
Track::block->bunch->setdT(Track::block->dT.front());
Track::block->bunch->resetIfScan();
......@@ -937,14 +937,14 @@ ParallelTTracker *TrackRun::setupForAutophase() {
Amr* null_amrptr = 0;
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->reference, false, false, Track::block->localTimeSteps.front(),
Track::block->zstop.front(), Track::block->timeIntegrator,
N,null_amrptr);
#else
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->reference, false, false, Track::block->localTimeSteps.front(),
Track::block->zstop.front(), Track::block->timeIntegrator,
N);
#endif
}
......
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