43 bool revBeam,
bool revTrack)
44 :
Tracker(beamline, reference, revBeam, revTrack)
69 bool revBeam,
bool revTrack,
70 const std::vector<unsigned long long> &,
72 const std::vector<double> &zstop,
73 const std::vector<double> &,
75 :
Tracker(beamline, bunch, reference, revBeam, revTrack)
89 if ( zstop.size() > 1 )
91 "Multiple tracks not yet supported.");
241 beamline_t::const_iterator el =
elements_m.cbegin();
244 for (FieldList::iterator it =
elements.begin(); it !=
elements.end(); ++it) {
245 double pos = it->getElement()->getElementPosition();
250 std::string(
"Elements are not in ascending order or overlap.") +
251 " Element Name: " + it->getElement()->getName() +
252 " ELEMEDGE position: " + std::to_string(pos) +
253 " Beamline end " + std::to_string(currentEnd) +
254 " element length " + std::to_string(std::get<2>(*el))) ;
256 currentEnd = pos + std::get<2>(*el);
258 while (std::get<2>(*el) == 0) ++el;
272 beamline_t::const_iterator el =
elements_m.cbegin();
275 for (FieldList::iterator it =
elements.begin(); it !=
elements.end(); ++it) {
277 tmp.push_back( *el );
279 double pos = it->getElement()->getElementPosition();
281 double length = std::abs(pos - currentEnd);
285 tmp.push_back(std::make_tuple(
hamiltonian_m.drift(gamma), 1, length));
288 currentEnd = pos + std::get<2>(*el);
292 double length = std::abs(
zstop_m - currentEnd);
296 tmp.push_back(std::make_tuple(
hamiltonian_m.drift(gamma), 1, length));
308 for (
int i=0; i<6; i++){
313 for (
int i=2; i<4; i++){
314 dispInitialVal[0][i]=0;
328 std::size_t step = 0;
336 const series_t& H = std::get<0>(*it);
337 const std::size_t& nSlices = std::get<1>(*it);
338 const double& length = std::get<2>(*it);
340 const double ds = length / double(nSlices);
347 for (std::size_t slice = 0; slice < nSlices; ++slice) {
381 for (
int d = 0; d < 3; ++d) {
382 particle[2 * d] = R(d);
383 particle[2 *d + 1] = P(d);
393 for (
int d = 0; d < 3; ++d) {
394 R(d) = particle[2 * d];
395 P(d) = particle[2 *d + 1];
404 static bool first =
true;
412 out.open(fn, std::ios::out);
414 out.open(fn, std::ios::app);
417 out << std::setprecision(16)
427 for (std::size_t ip = 0; ip <
itsBunch_m->getLocalNum(); ++ip) {
457 double pParticle= std::sqrt( particle[1] * particle[1] +
458 particle[3] * particle[3] +
459 particle[5] * particle[5]);
461 particle[1] /= betagamma;
462 particle[3] /= betagamma;
464 particle[5] = std::sqrt( 1.0 + pParticle * pParticle ) / betagamma
468 particle = map * particle;
471 particle[1] *= betagamma;
472 particle[3] *= betagamma;
474 double tempGamma = (particle[5] + 1.0 /
itsBunch_m->getInitialBeta())
477 pParticle = std::sqrt( tempGamma * tempGamma -1.0);
479 particle[5] = std::sqrt(pParticle * pParticle -
480 particle[1] * particle[1] -
481 particle[3] * particle[3] );
507 static bool first =
true;
514 out.open(fn, std::ios::out);
516 out.open(fn, std::ios::app);
519 out << std::setprecision(16);
526 for (
int i=0; i<2; i++){
527 dxi[i][0]= initialVal[0][i];
528 dyi[i][0]= initialVal[0][i+2];
530 subdx[i][0]=tempMatrix[i][5]*
itsBunch_m->getInitialBeta();
531 subdy[i][0]=tempMatrix[i+2][5]*
itsBunch_m->getInitialBeta();
533 for (
int j=0; j<2; j++){
535 subx[i][j]=tempMatrix[i][j];
536 suby[i][j]=tempMatrix[i+2][j+2];
541 dx= subx*dxi + subdx;
542 dy= suby*dyi + subdy;
546 out <<pos<<
"\t" << dx[0][0] <<
"\t" << dx[0][1] <<
"\t" << dy[0][0] <<
"\t" << dy[0][1] << std::endl;
560 const std::size_t step =
itsBunch_m->getGlobalTrackStep();
571 if (psDump || statDump) {
595 std::vector<std::pair<std::string, unsigned int> > collimatorLosses;
602 const std::size_t& step)
607 double beta = std::sqrt(1.0 - 1.0 / (gamma * gamma) );
612 const unsigned int localNum =
itsBunch_m->getLocalNum();
613 for (
unsigned int i = 0; i < localNum; ++i) {
FVps< T, N > ExpMap(const FTps< T, N > &H, int trunc=FTps< T, N >::EXACT)
Build the exponential series.
std::list< ClassicField > FieldList
TBeamline< FlaggedElmPtr > FlaggedBeamline
A beam line with flagged elements.
T euclidean_norm(const Vector< T > &)
Euclidean norm.
Inform & endl(Inform &inf)
constexpr double c
The velocity of light in m/s.
constexpr double Vpm2MVpm
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
std::string getInputBasename()
get input file name without extension
void setInPrepState(bool state)
void setGlobalPhaseShift(double shift)
units: (sec)
static OpalData * getInstance()
void setOpenMode(OpenMode openMode)
OpalBeamline itsOpalBeamline_m
void advanceDispersion_m(fMatrix_t tempMatrix, FMatrix< double, 1, 4 > initialVal, double pos)
Writes Dispersion in X and Y plane.
int truncOrder_m
truncation order of map tracking
std::list< tuple_t > beamline_t
particle_t particleToVector_m(const Vector_t &R, const Vector_t &P) const
void fillGaps_m()
Fills undefined beam path with a Drift Space.
CoordinateSystemTrafo referenceToLabCSTrafo_m
void advanceParticles_m(const map_t &map)
double threshold_m
Threshold for element overlaps and gaps.
beamline_t elements_m
elements in beam line
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
void concatenateMaps_m(const map_t &x, map_t &y)
void updateParticle_m(particle_t &particle, const map_t &map)
void write_m(const map_t &map)
Hamiltonian hamiltonian_m
void vectorToParticle_m(const particle_t &particle, Vector_t &R, Vector_t &P) const
IpplTimings::TimerRef mapTracking_m
track particles trough maps of elements_m
IpplTimings::TimerRef mapCombination_m
map accumulation along elements_m -> Transfermap
virtual void execute()
Apply the algorithm to the top-level beamline.
void update_m(const double &spos, const std::size_t &step)
Hamiltonian::series_t series_t
void checkElementOrder_m()
double zstart_m
Start of beam line.
FMatrix< double, 6, 6 > fMatrix_t
double zstop_m
End of beam line.
FVector< double, 6 > particle_t
IpplTimings::TimerRef mapCreation_m
creation of elements_m
FVps truncate(int trunc)
Truncate.
FMatrix< T, N, N > linearTerms() const
Extract the linear part of the map.
const PartData itsReference
The reference information.
CoordinateSystemTrafo inverted() const
Tracker(const Beamline &, const PartData &, bool backBeam, bool backTrack)
Constructor.
const Beamline & itsBeamline_m
PartBunchBase< double, 3 > * itsBunch_m
The bunch of particles to be tracked.
An abstract sequence of beam line components.
virtual Quaternion getInitialDirection() const
virtual Vector_t getOrigin3D() const
bool getRelativeFlag() const
Quaternion getInitialDirection() const
Vector_t getOrigin3D() const
virtual void iterate(BeamlineVisitor &, bool r2l) const
Apply visitor to all elements of the line.
A templated representation for matrices.
void merge(OpalBeamline &rhs)
void swap(OpalBeamline &rhs)
The base class for all OPAL exceptions.
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
Vektor< double, 3 > Vector_t