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) {
Hamiltonian::series_t drift(const double &gamma0)
void setOpenMode(OpenMode openMode)
A templated representation for vectors.
double threshold_m
Threshold for element overlaps and gaps.
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
static OpalData * getInstance()
Tps< T > sqrt(const Tps< T > &x)
Square root.
constexpr double c
The velocity of light in m/s.
particle_t particleToVector_m(const Vector_t &R, const Vector_t &P) const
void setInPrepState(bool state)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
void setGlobalPhaseShift(double shift)
units: (sec)
FVps truncate(int trunc)
Truncate.
void setGlobalTrackStep(long long n)
step in multiple TRACK commands
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
bool getRelativeFlag() const
double zstart_m
Start of beam line.
CoordinateSystemTrafo inverted() const
ParticleAttrib< Vector_t > P
Vektor< double, 3 > Vector_t
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
void get_bounds(Vector_t &rmin, Vector_t &rmax) const
Vector_t get_pmean_Distribution() const
Hamiltonian hamiltonian_m
void calcBeamParameters()
IpplTimings::TimerRef mapCombination_m
map accumulation along elements_m -> Transfermap
virtual Quaternion getInitialDirection() const
An abstract sequence of beam line components.
void fillGaps_m()
Fills undefined beam path with a Drift Space.
void swap(OpalBeamline &rhs)
void vectorToParticle_m(const particle_t &particle, Vector_t &R, Vector_t &P) const
std::list< tuple_t > beamline_t
constexpr double Vpm2MVpm
Inform & endl(Inform &inf)
IpplTimings::TimerRef mapTracking_m
track particles trough maps of elements_m
void advanceParticles_m(const map_t &map)
void advanceDispersion_m(fMatrix_t tempMatrix, FMatrix< double, 1, 4 > initialVal, double pos)
Writes Dispersion in X and Y plane.
Vector_t rotateFrom(const Vector_t &r) const
virtual void execute()
Apply the algorithm to the top-level beamline.
beamline_t elements_m
elements in beam line
static void startTimer(TimerRef t)
std::string::iterator iterator
virtual void iterate(BeamlineVisitor &, bool r2l) const
Apply visitor to all elements of the line.
OpalBeamline itsOpalBeamline_m
T euclidean_norm(const Vector< T > &)
Euclidean norm.
Vector_t getOrigin3D() const
double getInitialGamma() const
const Beamline & itsBeamline_m
FVps< T, N > ExpMap(const FTps< T, N > &H, int trunc=FTps< T, N >::EXACT)
Build the exponential series.
size_t getTotalNum() const
The base class for all OPAL exceptions.
void updateParticle_m(particle_t &particle, const map_t &map)
Vector_t rotateTo(const Vector_t &r) const
size_t getLocalNum() const
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
double getInitialBeta() const
unsigned long getFieldAt(const unsigned int &, const Vector_t &, const long &, const double &, Vector_t &, Vector_t &)
void dumpH5(PartBunchBase< double, 3 > *beam, Vector_t FDext[]) const
CoordinateSystemTrafo referenceToLabCSTrafo_m
const PartData itsReference
The reference information.
void concatenateMaps_m(const map_t &x, map_t &y)
long long getGlobalTrackStep() const
FMatrix< T, N, N > linearTerms() const
Extract the linear part of the map.
FMatrix< double, 2 *Dim, 2 *Dim > getSigmaMatrix() const
Vector_t transformTo(const Vector_t &r) const
ParticleAttrib< double > dt
Vector truncated power series in n variables.
void write_m(const map_t &map)
virtual Vector_t getOrigin3D() const
void dumpSDDS(PartBunchBase< double, 3 > *beam, Vector_t FDext[], const double &azimuth=-1) const
FieldList getElementByType(ElementType)
void checkElementOrder_m()
PartBunchBase< double, 3 > * itsBunch_m
The bunch of particles to be tracked.
int truncOrder_m
truncation order of map tracking
std::string getInputBasename()
get input file name without extension
std::list< ClassicField > FieldList
Quaternion getInitialDirection() const
constexpr double e
The value of .
void update_m(const double &spos, const std::size_t &step)
static void stopTimer(TimerRef t)
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
double zstop_m
End of beam line.
double getGamma() const
The relativistic gamma per particle.