OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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 <cstddef>
34#include <fstream>
35#include <map>
36#include <memory>
37#include <set>
38#include <string>
39
41{
42public:
43
44 OrbitThreader(const PartData& ref,
45 const Vector_t& r,
46 const Vector_t& p,
47 double s,
48 double maxDiffZBunch,
49 double t,
50 double dT,
51 StepSizeConfig stepSizes,
52 OpalBeamline& bl);
53
54 void execute();
55
58
59 IndexMap::key_t getRange(const IndexMap::value_t::value_type& element,
60 double position) const;
62
64
65private:
76 double time_m;
78 double dt_m;
81
84 const double zstop_m;
86
89
90 unsigned int errorFlag_m;
91
94
95 std::ofstream logger_m;
97
99
104 };
105
107 bool operator() (const elementPosition& a, const elementPosition& b) const {
108 return a.elementEdge_m < b.elementEdge_m;
109 }
110 };
111
112 std::multimap<std::string, elementPosition> elementRegistry_m;
113
114 void trackBack();
115 void integrate(const IndexMap::value_t& activeSet, double maxDrift = 10.0);
116 bool containsCavity(const IndexMap::value_t& activeSet);
117 void autophaseCavities(const IndexMap::value_t& activeSet, const std::set<std::string>& visitedElements);
118 double getMaxDesignEnergy(const IndexMap::value_t& elementSet) const;
119
120 void registerElement(const IndexMap::value_t& elementSet, double, const Vector_t& r, const Vector_t& p);
122 void setDesignEnergy(FieldList& allElements, const std::set<std::string>& visitedElements);
123 void computeBoundingBox();
125 double computeDriftLengthToBoundingBox(const std::set<std::shared_ptr<Component>>& elements,
126 const Vector_t& position,
127 const Vector_t& direction) const;
128
129 void checkElementLengths(const std::set<std::shared_ptr<Component>>& elements);
130};
131
132inline
137
138inline
139IndexMap::key_t OrbitThreader::getRange(const IndexMap::value_t::value_type& element,
140 double position) const {
141 return imap_m.getRange(element, position);
142}
143
144inline
148
149inline
153#endif
std::list< ClassicField > FieldList
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
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
ValueRange< double > pathLengthRange_m
IndexMap imap_m
BoundingBox getBoundingBox() const
ValueRange< long > stepRange_m
unsigned int errorFlag_m
double dt_m
the time step
double time_m
the simulated time
OpalBeamline & itsOpalBeamline_m
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
const PartData & reference_m
std::ofstream logger_m
BoundingBox globalBoundingBox_m
Vector_t p_m
momentum of reference particle
bool containsCavity(const IndexMap::value_t &activeSet)
void integrate(const IndexMap::value_t &activeSet, double maxDrift=10.0)
StepSizeConfig stepSizes_m
final position in path length
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
void autophaseCavities(const IndexMap::value_t &activeSet, const std::set< std::string > &visitedElements)
void computeBoundingBox()
size_t loggingFrequency_m
const double zstop_m
bool operator()(const elementPosition &a, const elementPosition &b) const