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