OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OrbitThreader.h
Go to the documentation of this file.
1//
2// Class OrbitThreader
3//
4// This class determines the design path by tracking the reference particle through
5// the 3D lattice.
6//
7// Copyright (c) 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany
8// 2017 - 2020 Christof Metzger-Kraus
9//
10// All rights reserved
11//
12// This file is part of OPAL.
13//
14// OPAL is free software: you can redistribute it and/or modify
15// it under the terms of the GNU General Public License as published by
16// the Free Software Foundation, either version 3 of the License, or
17// (at your option) any later version.
18//
19// You should have received a copy of the GNU General Public License
20// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21//
22#ifndef OPAL_ORBITTHREADER_H
23#define OPAL_ORBITTHREADER_H
24
25#include "Algorithms/IndexMap.h"
27#include "Algorithms/Vektor.h"
32
33#include <string>
34#include <map>
35
37{
38public:
39
41 const Vector_t &r,
42 const Vector_t &p,
43 double s,
44 double maxDiffZBunch,
45 double t,
46 double dT,
47 StepSizeConfig stepSizes,
48 OpalBeamline &bl);
49
50 void execute();
51
54
56 double position) const;
58
60
61private:
72 double time_m;
74 double dt_m;
77
80 const double zstop_m;
82
85
86 unsigned int errorFlag_m;
87
90
91 std::ofstream logger_m;
93
95
98 double endField_m;
100 };
101
103 bool operator() (const elementPosition &a, const elementPosition &b) const {
104 return a.elementEdge_m < b.elementEdge_m;
105 }
106 };
107
108 std::multimap<std::string, elementPosition> elementRegistry_m;
109
110 void trackBack();
111 void integrate(const IndexMap::value_t &activeSet, double maxDrift = 10.0);
112 bool containsCavity(const IndexMap::value_t &activeSet);
113 void autophaseCavities(const IndexMap::value_t &activeSet, const std::set<std::string> &visitedElements);
114 double getMaxDesignEnergy(const IndexMap::value_t &elementSet) const;
115
116 void registerElement(const IndexMap::value_t &elementSet, double, const Vector_t &r, const Vector_t &p);
118 void setDesignEnergy(FieldList &allElements, const std::set<std::string> &visitedElements);
119 void computeBoundingBox();
121 double computeDriftLengthToBoundingBox(const std::set<std::shared_ptr<Component>> & elements,
122 const Vector_t & position,
123 const Vector_t & direction) const;
124
125 void checkElementLengths(const std::set<std::shared_ptr<Component>>& elements);
126};
127
128inline
131 return imap_m.query(pathLength, length);
132}
133
134inline
136 double position) const {
137 return imap_m.getRange(element, position);
138}
139
140inline
142 return imap_m.getTouchingElements(range);
143}
144
145inline
147 return globalBoundingBox_m;
148}
149#endif
std::list< ClassicField > FieldList
Definition: ClassicField.h:43
T * value_type(const SliceIterator< T > &)
elements
Definition: IndexMap.cpp:163
std::complex< double > a
std::set< std::shared_ptr< Component > > value_t
Definition: IndexMap.h:47
value_t getTouchingElements(const key_t &range) const
Definition: IndexMap.cpp:396
key_t getRange(const IndexMap::value_t::value_type &element, double position) const
Definition: IndexMap.cpp:375
value_t query(key_t::first_type s, key_t::second_type ds)
Definition: IndexMap.cpp:76
double first_type
Definition: IndexMap.h:41
double second_type
Definition: IndexMap.h:42
void processElementRegister()
void updateBoundingBoxWithCurrentPosition()
void checkElementLengths(const std::set< std::shared_ptr< Component > > &elements)
double distTrackBack_m
Definition: OrbitThreader.h:70
void setDesignEnergy(FieldList &allElements, const std::set< std::string > &visitedElements)
IndexMap::value_t query(IndexMap::key_t::first_type step, IndexMap::key_t::second_type length)
BorisPusher integrator_m
Definition: OrbitThreader.h:88
ValueRange< double > pathLengthRange_m
Definition: OrbitThreader.h:81
IndexMap imap_m
Definition: OrbitThreader.h:84
BoundingBox getBoundingBox() const
ValueRange< long > stepRange_m
Definition: OrbitThreader.h:75
unsigned int errorFlag_m
Definition: OrbitThreader.h:86
double dt_m
the time step
Definition: OrbitThreader.h:74
double time_m
the simulated time
Definition: OrbitThreader.h:72
OpalBeamline & itsOpalBeamline_m
Definition: OrbitThreader.h:83
double computeDriftLengthToBoundingBox(const std::set< std::shared_ptr< Component > > &elements, const Vector_t &position, const Vector_t &direction) const
std::multimap< std::string, elementPosition > elementRegistry_m
Vector_t r_m
position of reference particle in lab coordinates
Definition: OrbitThreader.h:63
const PartData & reference_m
Definition: OrbitThreader.h:89
std::ofstream logger_m
Definition: OrbitThreader.h:91
BoundingBox globalBoundingBox_m
Definition: OrbitThreader.h:94
Vector_t p_m
momentum of reference particle
Definition: OrbitThreader.h:65
bool containsCavity(const IndexMap::value_t &activeSet)
void integrate(const IndexMap::value_t &activeSet, double maxDrift=10.0)
OrbitThreader(const PartData &ref, const Vector_t &r, const Vector_t &p, double s, double maxDiffZBunch, double t, double dT, StepSizeConfig stepSizes, OpalBeamline &bl)
StepSizeConfig stepSizes_m
final position in path length
Definition: OrbitThreader.h:79
double getMaxDesignEnergy(const IndexMap::value_t &elementSet) const
IndexMap::value_t getTouchingElements(const IndexMap::key_t &range) const
IndexMap::key_t getRange(const IndexMap::value_t::value_type &element, double position) const
void registerElement(const IndexMap::value_t &elementSet, double, const Vector_t &r, const Vector_t &p)
double pathLength_m
position of reference particle in path length
Definition: OrbitThreader.h:67
void autophaseCavities(const IndexMap::value_t &activeSet, const std::set< std::string > &visitedElements)
void computeBoundingBox()
size_t loggingFrequency_m
Definition: OrbitThreader.h:92
const double zstop_m
Definition: OrbitThreader.h:80
bool operator()(const elementPosition &a, const elementPosition &b) const
Particle reference data.
Definition: PartData.h:35