OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
OpalUndulator.cpp
Go to the documentation of this file.
1//
2// Class OpalUndulator
3// Defines the Undulator/Wiggler element and its attributes.
4//
5// Copyright (c) 2020, Arnau Albà, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved.
7//
8// Implemented as part of the MSc thesis
9// "Start-to-End Modelling of the AWA Micro-Bunched Electron Cooling POP-Experiment"
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
22
25
27 : OpalElement(SIZE, "UNDULATOR", "The \"UNDULATOR\" element defines an undulator or wiggler.") {
28 itsAttr[K] = Attributes::makeReal("K", "Undulator strength parameter [unitless].", 1);
29
30 itsAttr[LAMBDA] = Attributes::makeReal("LAMBDA", "Undulator period [m].", 0.0);
31
32 itsAttr[NUMPERIODS] = Attributes::makeReal("NUMPERIODS", "Number of undulator periods.", 0.0);
33
35 "ANGLE", "Polarisation angle of the undulator magnetic field [rad].", 0.0);
36
38 "FNAME", "Jobfile specifying the output data from the undulator.", "");
39
41 Attributes::makeRealArray("MESHLENGTH", "Size of computational mesh [m].");
42
44 Attributes::makeRealArray("MESHRESOLUTION", "{dx, dy, dz} of the mesh [m].");
45
47 Attributes::makeReal("TRUNORDER", "Order of absorbing boundary conditions. 1st or 2nd.", 2);
48
50 Attributes::makeReal("TOTALTIME", "Total time of the full-wave simulation [s].", 0.0);
51
53 "DTBUNCH",
54 "Time step for the particle update can be smaller than the field update step [s].", 0.0);
55
57
58 setElement(new UndulatorRep("UNDULATOR"));
59}
60
62 : OpalElement(name, parent) {
64}
65
67}
68
70 return new OpalUndulator(name, this);
71}
72
75
76 UndulatorRep* ur = static_cast<UndulatorRep*>(getElement());
77 /* The element length is given by the number and length of the undulator periods, plus the
78 * length of the two fringe fields, each measuring 2 * lambda. */
91
92 // Transmit "unknown" attributes.
94}
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
Definition: Attributes.cpp:289
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
Definition: Attributes.cpp:294
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:418
void setAngle(double theta)
Definition: Undulator.cpp:295
void setMeshLength(const std::vector< double > &ml)
Definition: Undulator.cpp:309
void setLambda(double lambda)
Definition: Undulator.cpp:281
void setFilename(const std::string &fname)
Definition: Undulator.cpp:302
void setTotalTime(double tt)
Definition: Undulator.cpp:330
void setTruncationOrder(unsigned int trunOrder)
Definition: Undulator.cpp:323
void setNumPeriods(unsigned int np)
Definition: Undulator.cpp:288
void setDtBunch(double dtb)
Definition: Undulator.cpp:337
void setMeshResolution(const std::vector< double > &mr)
Definition: Undulator.cpp:316
void setK(double k)
Definition: Undulator.cpp:274
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC drift.
virtual ~OpalUndulator()
virtual OpalUndulator * clone(const std::string &name)
Make clone.
OpalUndulator()
Exemplar constructor.