OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Undulator.h
Go to the documentation of this file.
1 //
2 // Class Undulator
3 // Defines all the methods used by the Undulator element.
4 // The Undulator element uses a full wave solver from the
5 // MITHRA library, see <https://github.com/aryafallahi/mithra/>.
6 //
7 // Copyright (c) 2020, Arnau AlbĂ , Paul Scherrer Institut, Villigen PSI, Switzerland
8 // All rights reserved.
9 //
10 // Implemented as part of the MSc thesis
11 // "Start-to-End Modelling of the AWA Micro-Bunched Electron Cooling POP-Experiment"
12 //
13 // This file is part of OPAL.
14 //
15 // OPAL is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
22 //
23 #ifndef CLASSIC_Undulator_HH
24 #define CLASSIC_Undulator_HH
25 
26 #include <string>
27 #include <vector>
28 
29 #include "AbsBeamline/Component.h"
30 
31 class Undulator : public Component {
32 public:
34  explicit Undulator(const std::string& name);
35 
36  Undulator();
37  Undulator(const Undulator& right);
38  virtual ~Undulator();
39 
41  virtual void accept(BeamlineVisitor&) const;
42 
43  virtual void initialise(PartBunchBase<double, 3>* bunch, double& startField, double& endField);
44 
45  void apply(PartBunchBase<double, 3>* itsBunch, CoordinateSystemTrafo const& refToLocalCSTrafo);
46 
47  virtual void finalise();
48 
49  virtual bool bends() const;
50 
51  virtual ElementBase::ElementType getType() const;
52 
53  virtual void getDimensions(double& zBegin, double& zEnd) const;
54 
55  void setK(double k);
56  double getK() const;
57  void setLambda(double lambda);
58  double getLambda() const;
59  void setNumPeriods(unsigned int np);
60  unsigned int getNumPeriods() const;
61  void setAngle(double theta);
62  double getAngle() const;
63  void setFilename(const std::string& fname);
64  const std::string& getFilename() const;
65  void setMeshLength(const std::vector<double>& ml);
66  std::vector<double> getMeshLength() const;
67  void setMeshResolution(const std::vector<double>& mr);
68  std::vector<double> getMeshResolution() const;
69  void setTruncationOrder(unsigned int trunOrder);
70  unsigned int getTruncationOrder() const;
71  void setTotalTime(double tt);
72  double getTotalTime() const;
73  void setDtBunch(double dtb);
74  double getDtBunch() const;
75  void setHasBeenSimulated(bool hbs);
76  bool getHasBeenSimulated() const;
77 
78 private:
80  double k_m;
81 
83  double lambda_m;
84 
86  unsigned int numPeriods_m;
87 
89  double angle_m;
90 
92  std::string fname_m;
93 
95  std::vector<double> meshLength_m;
96 
98  std::vector<double> meshResolution_m;
99 
101  unsigned int truncationOrder_m;
102 
104  double totalTime_m;
105 
107  double dtBunch_m;
108 
111 
112  // Not implemented.
113  void operator=(const Undulator&);
114 };
115 
116 #endif // CLASSIC_Undulator_HH
const std::string name
Interface for a single beam element.
Definition: Component.h:50
unsigned int numPeriods_m
Number of periods.
Definition: Undulator.h:86
void setAngle(double theta)
Definition: Undulator.cpp:294
double angle_m
Polarisation angle of the undulator field.
Definition: Undulator.h:89
double getK() const
Definition: Undulator.cpp:276
std::vector< double > getMeshLength() const
Definition: Undulator.cpp:311
double lambda_m
Undulator period.
Definition: Undulator.h:83
std::vector< double > meshResolution_m
Mesh dx, dy, dz.
Definition: Undulator.h:98
std::string fname_m
Mithra file with output information.
Definition: Undulator.h:92
double totalTime_m
Total time to run undulator.
Definition: Undulator.h:104
virtual ~Undulator()
Definition: Undulator.cpp:74
void setMeshLength(const std::vector< double > &ml)
Definition: Undulator.cpp:308
void apply(PartBunchBase< double, 3 > *itsBunch, CoordinateSystemTrafo const &refToLocalCSTrafo)
Definition: Undulator.cpp:86
void setLambda(double lambda)
Definition: Undulator.cpp:280
void setFilename(const std::string &fname)
Definition: Undulator.cpp:301
double getDtBunch() const
Definition: Undulator.cpp:339
void setTotalTime(double tt)
Definition: Undulator.cpp:329
virtual void finalise()
Definition: Undulator.cpp:259
void setTruncationOrder(unsigned int trunOrder)
Definition: Undulator.cpp:322
void setNumPeriods(unsigned int np)
Definition: Undulator.cpp:287
virtual bool bends() const
Definition: Undulator.cpp:262
unsigned int getTruncationOrder() const
Definition: Undulator.cpp:325
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
Definition: Undulator.cpp:81
double getTotalTime() const
Definition: Undulator.cpp:332
double dtBunch_m
Time step for the bunch position update.
Definition: Undulator.h:107
const std::string & getFilename() const
Definition: Undulator.cpp:304
bool getHasBeenSimulated() const
Definition: Undulator.cpp:346
unsigned int getNumPeriods() const
Definition: Undulator.cpp:290
void setDtBunch(double dtb)
Definition: Undulator.cpp:336
void operator=(const Undulator &)
double getAngle() const
Definition: Undulator.cpp:297
std::vector< double > getMeshResolution() const
Definition: Undulator.cpp:318
std::vector< double > meshLength_m
Size of computational domain.
Definition: Undulator.h:95
void setMeshResolution(const std::vector< double > &mr)
Definition: Undulator.cpp:315
bool hasBeenSimulated_m
Boolean to indicate whether this undulator has already been simulated.
Definition: Undulator.h:110
double getLambda() const
Definition: Undulator.cpp:283
virtual ElementBase::ElementType getType() const
Get element type std::string.
Definition: Undulator.cpp:269
void setK(double k)
Definition: Undulator.cpp:273
virtual void getDimensions(double &zBegin, double &zEnd) const
Definition: Undulator.cpp:266
virtual void accept(BeamlineVisitor &) const
Apply visitor to Undulator.
Definition: Undulator.cpp:77
double k_m
The undulator parameter.
Definition: Undulator.h:80
void setHasBeenSimulated(bool hbs)
Definition: Undulator.cpp:343
unsigned int truncationOrder_m
First or second order absorbing boundary conditions.
Definition: Undulator.h:101