43 bool revBeam,
bool revTrack)
44 :
Tracker(beamline, reference, revBeam, revTrack)
48 , itsDataSink_m(nullptr)
49 , itsOpalBeamline_m(beamline.getOrigin3D(), beamline.getInitialDirection())
54 , mapCreation_m(
IpplTimings::getTimer(
"mapCreation"))
55 , mapCombination_m(
IpplTimings::getTimer(
"mapCombination"))
56 , mapTracking_m(
IpplTimings::getTimer(
"mapTracking"))
69 bool revBeam,
bool revTrack,
70 const std::vector<unsigned long long> &,
72 const std::vector<double> &zstop,
73 const std::vector<double> &,
74 const int& truncOrder)
75 :
Tracker(beamline, bunch, reference, revBeam, revTrack)
76 , hamiltonian_m(truncOrder)
80 , itsOpalBeamline_m(beamline.getOrigin3D(), beamline.getInitialDirection())
84 , truncOrder_m(truncOrder)
85 , mapCreation_m(
IpplTimings::getTimer(
"mapCreation"))
86 , mapCombination_m(
IpplTimings::getTimer(
"mapCombination"))
87 , mapTracking_m(
IpplTimings::getTimer(
"mapTracking"))
89 if ( zstop.size() > 1 )
91 "Multiple tracks not yet supported.");
241 beamline_t::const_iterator el =
elements_m.cbegin();
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();
277 tmp.push_back( *el );
279 double pos = it->getElement()->getElementPosition();
281 double length =
std::abs(pos - currentEnd);
288 currentEnd = pos + std::get<2>(*el);
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)
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;
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];
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;
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) );
613 for (
unsigned int i = 0; i < localNum; ++i) {
Tps< T > sqrt(const Tps< T > &x)
Square root.
T euclidean_norm(const Vector< T > &)
Euclidean norm.
FVps< T, N > ExpMap(const FTps< T, N > &H, int trunc=FTps< T, N >::EXACT)
Build the exponential series.
std::list< ClassicField > FieldList
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Inform & endl(Inform &inf)
constexpr double e
The value of.
constexpr double c
The velocity of light in m/s.
std::string::iterator iterator
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.
size_t getLocalNum() const
size_t getTotalNum() const
ParticleAttrib< Vector_t > P
double getInitialBeta() const
void calcBeamParameters()
double getInitialGamma() const
Vector_t get_pmean_Distribution() const
ParticleAttrib< double > dt
void get_bounds(Vector_t &rmin, Vector_t &rmax)
void setGlobalTrackStep(long long n)
step in multiple TRACK commands
FMatrix< double, 2 *Dim, 2 *Dim > getSigmaMatrix()
long long getGlobalTrackStep() const
void setOpenMode(OPENMODE openMode)
std::string getInputBasename()
get input file name without extension
void setInPrepState(bool state)
void setGlobalPhaseShift(double shift)
units: (sec)
static OpalData * getInstance()
Hamiltonian::series_t drift(const double &gamma0)
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)
void checkElementOrder_m()
double zstart_m
Start of beam line.
double zstop_m
End of beam line.
Vector truncated power series in n variables.
FVps truncate(int trunc)
Truncate.
FMatrix< T, N, N > linearTerms() const
Extract the linear part of the map.
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
const PartData itsReference
The reference information.
Vector_t rotateFrom(const Vector_t &r) const
Vector_t transformTo(const Vector_t &r) const
Vector_t rotateTo(const Vector_t &r) const
CoordinateSystemTrafo inverted() const
double getGamma() const
The relativistic gamma per particle.
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 vectors.
FieldList getElementByType(ElementBase::ElementType)
void merge(OpalBeamline &rhs)
unsigned long getFieldAt(const unsigned int &, const Vector_t &, const long &, const double &, Vector_t &, Vector_t &)
void swap(OpalBeamline &rhs)
void dumpSDDS(PartBunchBase< double, 3 > *beam, Vector_t FDext[], const double &azimuth=-1) const
void dumpH5(PartBunchBase< double, 3 > *beam, Vector_t FDext[]) const
The base class for all OPAL exceptions.
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
Vektor< double, 3 > Vector_t