OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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  using Component::apply;
46  void apply(PartBunchBase<double, 3>* itsBunch, CoordinateSystemTrafo const& refToLocalCSTrafo);
47 
48  virtual void finalise();
49 
50  virtual bool bends() const;
51 
52  virtual ElementType getType() const;
53 
54  virtual void getDimensions(double& zBegin, double& zEnd) const;
55 
56  void setK(double k);
57  double getK() const;
58  void setLambda(double lambda);
59  double getLambda() const;
60  void setNumPeriods(unsigned int np);
61  unsigned int getNumPeriods() const;
62  void setAngle(double theta);
63  double getAngle() const;
64  void setFilename(const std::string& fname);
65  const std::string& getFilename() const;
66  void setMeshLength(const std::vector<double>& ml);
67  std::vector<double> getMeshLength() const;
68  void setMeshResolution(const std::vector<double>& mr);
69  std::vector<double> getMeshResolution() const;
70  void setTruncationOrder(unsigned int trunOrder);
71  unsigned int getTruncationOrder() const;
72  void setTotalTime(double tt);
73  double getTotalTime() const;
74  void setDtBunch(double dtb);
75  double getDtBunch() const;
76  void setHasBeenSimulated(bool hbs);
77  bool getHasBeenSimulated() const;
78 
79 private:
81  double k_m;
82 
84  double lambda_m;
85 
87  unsigned int numPeriods_m;
88 
90  double angle_m;
91 
93  std::string fname_m;
94 
96  std::vector<double> meshLength_m;
97 
99  std::vector<double> meshResolution_m;
100 
102  unsigned int truncationOrder_m;
103 
105  double totalTime_m;
106 
108  double dtBunch_m;
109 
112 
113  // Not implemented.
114  void operator=(const Undulator&);
115 };
116 
117 #endif // CLASSIC_Undulator_HH
double getTotalTime() const
Definition: Undulator.cpp:333
unsigned int numPeriods_m
Number of periods.
Definition: Undulator.h:87
virtual bool bends() const
Definition: Undulator.cpp:263
std::vector< double > meshLength_m
Size of computational domain.
Definition: Undulator.h:96
void setAngle(double theta)
Definition: Undulator.cpp:295
bool getHasBeenSimulated() const
Definition: Undulator.cpp:347
void setFilename(const std::string &fname)
Definition: Undulator.cpp:302
void operator=(const Undulator &)
double dtBunch_m
Time step for the bunch position update.
Definition: Undulator.h:108
const std::string & getFilename() const
Definition: Undulator.cpp:305
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
Definition: Undulator.cpp:82
void setDtBunch(double dtb)
Definition: Undulator.cpp:337
void setTruncationOrder(unsigned int trunOrder)
Definition: Undulator.cpp:323
bool hasBeenSimulated_m
Boolean to indicate whether this undulator has already been simulated.
Definition: Undulator.h:111
virtual void finalise()
Definition: Undulator.cpp:260
double getAngle() const
Definition: Undulator.cpp:298
void setMeshResolution(const std::vector< double > &mr)
Definition: Undulator.cpp:316
std::vector< double > getMeshLength() const
Definition: Undulator.cpp:312
void setNumPeriods(unsigned int np)
Definition: Undulator.cpp:288
double totalTime_m
Total time to run undulator.
Definition: Undulator.h:105
virtual void accept(BeamlineVisitor &) const
Apply visitor to Undulator.
Definition: Undulator.cpp:78
std::string fname_m
Mithra file with output information.
Definition: Undulator.h:93
void setLambda(double lambda)
Definition: Undulator.cpp:281
virtual ElementType getType() const
Get element type std::string.
Definition: Undulator.cpp:270
unsigned int getTruncationOrder() const
Definition: Undulator.cpp:326
virtual void getDimensions(double &zBegin, double &zEnd) const
Definition: Undulator.cpp:267
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
Definition: Component.cpp:99
std::vector< double > meshResolution_m
Mesh dx, dy, dz.
Definition: Undulator.h:99
void apply(PartBunchBase< double, 3 > *itsBunch, CoordinateSystemTrafo const &refToLocalCSTrafo)
Definition: Undulator.cpp:87
virtual ~Undulator()
Definition: Undulator.cpp:75
ElementType
Definition: ElementBase.h:88
double lambda_m
Undulator period.
Definition: Undulator.h:84
double getDtBunch() const
Definition: Undulator.cpp:340
void setTotalTime(double tt)
Definition: Undulator.cpp:330
std::vector< double > getMeshResolution() const
Definition: Undulator.cpp:319
double getLambda() const
Definition: Undulator.cpp:284
void setK(double k)
Definition: Undulator.cpp:274
unsigned int getNumPeriods() const
Definition: Undulator.cpp:291
void setMeshLength(const std::vector< double > &ml)
Definition: Undulator.cpp:309
const std::string name
double angle_m
Polarisation angle of the undulator field.
Definition: Undulator.h:90
double k_m
The undulator parameter.
Definition: Undulator.h:81
Interface for a single beam element.
Definition: Component.h:50
unsigned int truncationOrder_m
First or second order absorbing boundary conditions.
Definition: Undulator.h:102
double getK() const
Definition: Undulator.cpp:277
void setHasBeenSimulated(bool hbs)
Definition: Undulator.cpp:344