OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
EmissionSource.cpp
Go to the documentation of this file.
5
6#include <cmath>
7
10 SIZE, "EMISSIONSOURCE",
11 "The EMISSIONSOURCE statement defines a particle injector with "
12 "position R0, momentum P0, start time t0, and a linked Distribution.") {
14 Attributes::makeString("DISTRIBUTION", "Name of the Distribution to sample from.");
15
16 itsAttr[R0X] = Attributes::makeReal("R0X", "Initial position x [m].", 0.0);
17 itsAttr[R0Y] = Attributes::makeReal("R0Y", "Initial position y [m].", 0.0);
18 itsAttr[R0Z] = Attributes::makeReal("R0Z", "Initial position z [m].", 0.0);
19
20 itsAttr[P0X] = Attributes::makeReal("P0X", "Initial momentum x [beta*gamma].", 0.0);
21 itsAttr[P0Y] = Attributes::makeReal("P0Y", "Initial momentum y [beta*gamma].", 0.0);
22 itsAttr[P0Z] = Attributes::makeReal("P0Z", "Initial momentum z [beta*gamma].", 0.0);
23
24 itsAttr[T0] = Attributes::makeReal("T0", "Start time when sampling begins [s].", 0.0);
25
27 "ZEROFACE_R0Z", "Set Dirichlet boundary conditions (0 potential) in xy plane at R0Z.",
28 false);
29
31 "SHIFTED_GREENS_FUNCTION",
32 "Enforce Dirichlet BCs (0 potential) in xy plane at R0Z via a shifted Green's "
33 "function instead of explicit image charges. Mutually exclusive with ZEROFACE_R0Z. "
34 "Requires the OPEN field solver. Active for ZEROFACE_MAXSTEPS steps (0 = unlimited).",
35 false);
36
38 "ZEROFACEPLANEDUMP",
39 "Dump interpolated potential on the ZEROFACE_R0Z plane every n-th global "
40 "timestep (0 disables dumping, since it's an expensive operation).",
41 0.0);
42
44 "ZEROFACE_MAXSTEPS",
45 "Number of timesteps for which image charges are active. "
46 "After this many steps, the solver continues without image charges. "
47 "0 means unlimited (image charges always active).",
48 0.0);
49
51 "EMISSIONMODEL",
52 "Emission model for cathode emission. "
53 "NONE: thermal momentum applied in z only. "
54 "ASTRA: 3D isotropic thermal emission on forward half-sphere.",
55 {"NONE", "ASTRA"}, "NONE");
56
58}
59
60EmissionSource::EmissionSource(const std::string& name, EmissionSource* parent)
61 : Definition(name, parent) {}
62
64
66 return dynamic_cast<EmissionSource*>(object) != nullptr;
67}
68
69EmissionSource* EmissionSource::clone(const std::string& name) {
70 return new EmissionSource(name, this);
71}
72
74
75EmissionSource* EmissionSource::find(const std::string& name) {
76 Object* obj = OpalData::getInstance()->find(name);
77 auto* es = dynamic_cast<EmissionSource*>(obj);
78 if (!es) {
79 throw OpalException("EmissionSource::find()", "EmissionSource \"" + name + "\" not found.");
80 }
81 return es;
82}
83
87
88ippl::Vector<double, 3> EmissionSource::getR0() const {
89 return ippl::Vector<double, 3>(
92}
93
94ippl::Vector<double, 3> EmissionSource::getP0() const {
95 return ippl::Vector<double, 3>(
98}
99
101
103
107
109 const double rawFrequency = Attributes::getReal(itsAttr[ZEROFACEPLANEDUMP]);
110 const int frequency = static_cast<int>(rawFrequency);
111 if (rawFrequency < 0.0 || std::floor(rawFrequency) != rawFrequency) {
112 throw OpalException(
113 "EmissionSource::getZeroFacePlaneDumpFrequency",
114 "ZEROFACEPLANEDUMP must be a non-negative integer value.");
115 }
116 return frequency;
117}
118
120 const double rawValue = Attributes::getReal(itsAttr[ZEROFACE_MAXSTEPS]);
121 const int value = static_cast<int>(rawValue);
122 if (rawValue < 0.0 || std::floor(rawValue) != rawValue) {
123 throw OpalException(
124 "EmissionSource::getZerofaceMaxSteps",
125 "ZEROFACE_MAXSTEPS must be a non-negative integer value.");
126 }
127 return value;
128}
129
@ SIZE
Definition IndexMap.cpp:179
The base class for all OPAL definitions.
Definition Definition.h:29
ippl::Vector< double, 3 > getP0() const
EmissionSource()
Exemplar constructor.
double getT0() const
int getZerofaceMaxSteps() const
bool getShiftedGreensFunction() const
int getZeroFacePlaneDumpFrequency() const
static EmissionSource * find(const std::string &name)
virtual bool canReplaceBy(Object *object)
Test if replacement is allowed.
bool getZeroFaceR0Z() const
std::string getEmissionModel() const
std::string getDistributionName() const
virtual EmissionSource * clone(const std::string &name)
Return a clone.
virtual ~EmissionSource()
virtual void execute()
Execute the command.
ippl::Vector< double, 3 > getR0() const
The base class for all OPAL objects.
Definition Object.h:45
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition Object.cpp:169
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
Object * find(const std::string &name)
Find entry.
Definition OpalData.cpp:477
static OpalData * getInstance()
Definition OpalData.cpp:193
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.