40 bool revBeam,
bool revTrack)
41 :
Tracker(beamline, reference, revBeam, revTrack)
45 , itsDataSink_m(nullptr)
46 , itsOpalBeamline_m(beamline.getOrigin3D(), beamline.getInitialDirection())
51 , mapCreation_m(
IpplTimings::getTimer(
"mapCreation"))
52 , mapCombination_m(
IpplTimings::getTimer(
"mapCombination"))
53 , mapTracking_m(
IpplTimings::getTimer(
"mapTracking"))
66 bool revBeam,
bool revTrack,
67 const std::vector<unsigned long long> &maxSteps,
69 const std::vector<double> &zstop,
70 const std::vector<double> &dt,
71 const int& truncOrder)
72 :
Tracker(beamline, bunch, reference, revBeam, revTrack)
73 , hamiltonian_m(truncOrder)
77 , itsOpalBeamline_m(beamline.getOrigin3D(), beamline.getInitialDirection())
81 , truncOrder_m(truncOrder)
82 , mapCreation_m(
IpplTimings::getTimer(
"mapCreation"))
83 , mapCombination_m(
IpplTimings::getTimer(
"mapCombination"))
84 , mapTracking_m(
IpplTimings::getTimer(
"mapTracking"))
86 if ( zstop.size() > 1 )
88 "Multiple tracks not yet supported.");
238 beamline_t::const_iterator el =
elements_m.cbegin();
242 double pos = it->getElement()->getElementPosition();
247 std::string(
"Elements are not in ascending order or overlap.") +
248 " Element Name: " + it->getElement()->getName() +
249 " ELEMEDGE position: " + std::to_string(pos) +
250 " Beamline end " + std::to_string(currentEnd) +
251 " element length " + std::to_string(std::get<2>(*el))) ;
253 currentEnd = pos + std::get<2>(*el);
255 while (std::get<2>(*el) == 0) ++el;
269 beamline_t::const_iterator el =
elements_m.cbegin();
274 tmp.push_back( *el );
276 double pos = it->getElement()->getElementPosition();
278 double length =
std::abs(pos - currentEnd);
285 currentEnd = pos + std::get<2>(*el);
305 for (
int i=0; i<6; i++){
310 for (
int i=2; i<4; i++){
311 dispInitialVal[0][i]=0;
325 std::size_t step = 0;
333 const series_t& H = std::get<0>(*it);
334 const std::size_t& nSlices = std::get<1>(*it);
335 const double& length = std::get<2>(*it);
337 const double ds = length / double(nSlices);
344 for (std::size_t slice = 0; slice < nSlices; ++slice) {
378 for (
int d = 0; d < 3; ++d) {
379 particle[2 * d] =
R(d);
380 particle[2 *d + 1] = P(d);
390 for (
int d = 0; d < 3; ++d) {
391 R(d) = particle[2 * d];
392 P(d) = particle[2 *d + 1];
401 static bool first =
true;
409 out.open(fn, std::ios::out);
411 out.open(fn, std::ios::app);
414 out << std::setprecision(16)
454 double pParticle=
std::sqrt( particle[1] * particle[1] +
455 particle[3] * particle[3] +
456 particle[5] * particle[5]);
458 particle[1] /= betagamma;
459 particle[3] /= betagamma;
461 particle[5] =
std::sqrt( 1.0 + pParticle * pParticle ) / betagamma
465 particle = map * particle;
468 particle[1] *= betagamma;
469 particle[3] *= betagamma;
474 pParticle =
std::sqrt( tempGamma * tempGamma -1.0);
476 particle[5] =
std::sqrt(pParticle * pParticle -
477 particle[1] * particle[1] -
478 particle[3] * particle[3] );
504 static bool first =
true;
511 out.open(fn, std::ios::out);
513 out.open(fn, std::ios::app);
516 out << std::setprecision(16);
523 for (
int i=0; i<2; i++){
524 dxi[i][0]= initialVal[0][i];
525 dyi[i][0]= initialVal[0][i+2];
530 for (
int j=0; j<2; j++){
532 subx[i][j]=tempMatrix[i][j];
533 suby[i][j]=tempMatrix[i+2][j+2];
538 dx= subx*dxi + subdx;
539 dy= suby*dyi + subdy;
543 out <<pos<<
"\t" << dx[0][0] <<
"\t" << dx[0][1] <<
"\t" << dy[0][0] <<
"\t" << dy[0][1] <<
std::endl;
568 if (psDump || statDump) {
592 std::vector<std::pair<std::string, unsigned int> > collimatorLosses;
599 const std::size_t& step)
604 double beta =
std::sqrt(1.0 - 1.0 / (gamma * gamma) );
610 for (
unsigned int i = 0; i < localNum; ++i) {
void checkElementOrder_m()
ParticleAttrib< Vector_t > P
FVps truncate(int trunc)
Truncate.
void write_m(const map_t &map)
CoordinateSystemTrafo referenceToLabCSTrafo_m
void advanceParticles_m(const map_t &map)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
constexpr double e
The value of .
void setOpenMode(OPENMODE openMode)
bool getRelativeFlag() const
OpalBeamline itsOpalBeamline_m
Vector_t rotateTo(const Vector_t &r) const
const Beamline & itsBeamline_m
The base class for all OPAL exceptions.
IpplTimings::TimerRef mapTracking_m
track particles trough maps of elements_m
std::list< ClassicField > FieldList
void advanceDispersion_m(fMatrix_t tempMatrix, FMatrix< double, 1, 4 > initialVal, double pos)
Writes Dispersion in X and Y plane.
void updateParticle_m(particle_t &particle, const map_t &map)
Vector_t transformTo(const Vector_t &r) const
Vector_t get_pmean_Distribution() const
virtual Quaternion getInitialDirection() const
unsigned long getFieldAt(const unsigned int &, const Vector_t &, const long &, const double &, Vector_t &, Vector_t &)
Vector_t getOrigin3D() const
FMatrix< double, 2 *Dim, 2 *Dim > getSigmaMatrix()
size_t getTotalNum() const
Hamiltonian::series_t drift(const double &gamma0)
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
double getInitialBeta() const
static OpalData * getInstance()
double zstart_m
Start of beam line.
beamline_t elements_m
elements in beam line
void calcBeamParameters()
Template class for beam lines.
IpplTimings::TimerRef mapCombination_m
map accumulation along elements_m -> Transfermap
void fillGaps_m()
Fills undefined beam path with a Drift Space.
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
constexpr double c
The velocity of light in m/s.
Hamiltonian hamiltonian_m
static void startTimer(TimerRef t)
particle_t particleToVector_m(const Vector_t &R, const Vector_t &P) const
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
void vectorToParticle_m(const particle_t &particle, Vector_t &R, Vector_t &P) const
virtual void iterate(BeamlineVisitor &, bool r2l) const
Apply visitor to all elements of the line.
void dumpH5(PartBunchBase< double, 3 > *beam, Vector_t FDext[]) const
FieldList getElementByType(ElementBase::ElementType)
FVps< T, N > ExpMap(const FTps< T, N > &H, int trunc=FTps< T, N >::EXACT)
Build the exponential series.
double getInitialGamma() const
Vektor< double, 3 > Vector_t
void swap(OpalBeamline &rhs)
double zstop_m
End of beam line.
An abstract sequence of beam line components.
const PartData itsReference
The reference information.
size_t getLocalNum() const
FMatrix< T, N, N > linearTerms() const
Extract the linear part of the map.
Tps< T > sqrt(const Tps< T > &x)
Square root.
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
ParticleAttrib< double > dt
double getGamma() const
The relativistic gamma per particle.
void setGlobalPhaseShift(double shift)
units: (sec)
T euclidean_norm(const Vector< T > &)
Euclidean norm.
Vector_t rotateFrom(const Vector_t &r) const
double threshold_m
Threshold for element overlaps and gaps.
void update_m(const double &spos, const std::size_t &step)
CoordinateSystemTrafo inverted() const
void dumpSDDS(PartBunchBase< double, 3 > *beam, Vector_t FDext[], const double &azimuth=-1) const
Quaternion getInitialDirection() const
std::string::iterator iterator
void concatenateMaps_m(const map_t &x, map_t &y)
void get_bounds(Vector_t &rmin, Vector_t &rmax)
virtual Vector_t getOrigin3D() const
static void stopTimer(TimerRef t)
std::string getInputBasename()
get input file name without extension
virtual void execute()
Apply the algorithm to the top-level beamline.
std::list< tuple_t > beamline_t
PartBunchBase< double, 3 > * itsBunch_m
The bunch of particles to be tracked.
void setInPrepState(bool state)
Inform & endl(Inform &inf)
void setGlobalTrackStep(long long n)
step in multiple TRACK commands
long long getGlobalTrackStep() const
int truncOrder_m
truncation order of map tracking
Track particles or bunches.