32#include "Utility/IpplTimings.h"
107 "The DISTRIBUTION statement defines data for the 6D particle distribution."),
108 totalNumberParticles_m(0),
112 "TYPE",
"Distribution type.",
113 {
"GAUSS",
"MULTIVARIATEGAUSS",
"FLATTOP",
"OPALFLATTOP",
"FROMFILE",
130 "CUTOFFPX",
"Distribution cutoff px dimension in units of sigma.", 3.0);
132 "CUTOFFPY",
"Distribution cutoff py dimension in units of sigma.", 3.0);
134 "CUTOFFPZ",
"Distribution cutoff pz dimension in units of sigma.", 3.0);
137 "CUTOFFX",
"Distribution cutoff x direction in units of sigma.", 3.0);
139 "CUTOFFY",
"Distribution cutoff r direction in units of sigma.", 3.0);
141 "CUTOFFLONG",
"Distribution cutoff z or t direction in units of sigma.", 3.0);
162 "Amplitude of oscillations superimposed "
163 "on flat top portion of emitted GAUSS "
164 "distribtuion (in percent of flat top "
170 "Number of oscillations superimposed on "
171 "flat top portion of emitted GAUSS "
177 "Emitted beam, from cathode, as opposed to "
183 "Number of OPAL-like time steps to use during OPALFLATTOP or EMITTEDFROMFILE "
189 "Number of macroparticles for this DISTRIBUTION. "
190 "If 0 or negative, this distribution does not specify its own count.",
210 size_t locNumber = n / ippl::Comm->size();
213 size_t remainder = n % ippl::Comm->size();
214 size_t myNode = ippl::Comm->rank();
215 if (myNode < remainder) ++locNumber;
234 throw OpalException(
"Distribution::find()",
"Distribution \"" + name +
"\" not found.");
242 <<
"* ************* D I S T R I B U T I O N ********************************************"
246 os <<
"* In restart. Distribution read in from .h5 file." << endl;
264 throw OpalException(
"Distribution Param",
"Unknown \"TYPE\" of \"DISTRIBUTION\"");
267 os <<
"* Distribution is injected." << endl;
270 os <<
"* **********************************************************************************"
287 return static_cast<size_t>(std::ceil(raw));
326 for (
unsigned int i = 0; i < 6; ++i) {
327 for (
unsigned int j = 0; j < 6; ++j) {
339 for (
unsigned int i = 0; i < 3; ++i) {
348 if (cr.size() == 15) {
349 *
gmsg <<
"* Use r to specify correlations" << endl;
351 for (
unsigned int i = 0; i < 5; ++i) {
352 for (
unsigned int j = i + 1; j < 6; ++j, ++k) {
359 "Distribution::SetDistParametersGauss",
360 "Inconsistent set of correlations specified, check manual");
379 for (
unsigned int i = 0; i < 6; ++i) {
380 for (
unsigned int j = 0; j < 6; ++j) {
418 std::sqrt(2.0 * std::log(10.0)) - std::sqrt(2.0 * std::log(10.0 / 9.0));
435 os <<
"* Distribution type: GAUSS" << endl;
437 os <<
"* SIGMAX = " <<
sigmaR_m[0] <<
" [m]" << endl;
438 os <<
"* SIGMAY = " <<
sigmaR_m[1] <<
" [m]" << endl;
439 os <<
"* SIGMAZ = " <<
sigmaR_m[2] <<
" [m]" << endl;
440 os <<
"* SIGMAPX = " <<
sigmaP_m[0] <<
" [Beta Gamma]" << endl;
441 os <<
"* SIGMAPY = " <<
sigmaP_m[1] <<
" [Beta Gamma]" << endl;
442 os <<
"* SIGMAPZ = " <<
sigmaP_m[2] <<
" [Beta Gamma]" << endl;
446 os <<
"* Distribution type: MULTIVARIATEGAUSS" << endl;
448 os <<
"* SIGMAX = " <<
sigmaR_m[0] <<
" [m]" << endl;
449 os <<
"* SIGMAY = " <<
sigmaR_m[1] <<
" [m]" << endl;
450 os <<
"* SIGMAZ = " <<
sigmaR_m[2] <<
" [m]" << endl;
451 os <<
"* SIGMAPX = " <<
sigmaP_m[0] <<
" [Beta Gamma]" << endl;
452 os <<
"* SIGMAPY = " <<
sigmaP_m[1] <<
" [Beta Gamma]" << endl;
453 os <<
"* SIGMAPZ = " <<
sigmaP_m[2] <<
" [Beta Gamma]" << endl;
455 os <<
"* input cov matrix = ";
456 for (
unsigned int i = 0; i < 6; ++i) {
457 for (
unsigned int j = 0; j < 6; ++j) {
465 os <<
"* Distribution type: " <<
distT_m << endl;
467 os <<
"* SIGMAX = " <<
sigmaR_m[0] <<
" [m]" << endl;
468 os <<
"* SIGMAY = " <<
sigmaR_m[1] <<
" [m]" << endl;
471 os <<
"* Sigma Time Rise = " <<
sigmaTRise_m <<
" [sec]" << endl;
473 os <<
"* Sigma Time Fall = " <<
sigmaTFall_m <<
" [sec]" << endl;
474 os <<
"* Longitudinal cutoff = " <<
cutoffR_m[2] <<
" [units of Sigma Time]"
483 os <<
"* SIGMAZ = " <<
sigmaR_m[2] <<
" [m]" << endl;
488 os <<
"* Distribution type: " <<
distT_m << endl;
491 if (!fname.empty()) {
492 os <<
"* Filename: " << fname << endl;
494 os <<
"* Filename: (not set)" << endl;
510 npartDist > 0.0 ?
static_cast<size_t>(npartDist) :
static_cast<size_t>(0);
533 throw OpalException(
"Distribution Param",
"Unknown \"TYPE\" of \"DISTRIBUTION\"");
538 static const std::map<std::string, DistributionType> typeStringToDistType_s = {
551 "Distribution::setDistType",
552 "The attribute \"TYPE\" isn't set for the \"DISTRIBUTION\"!");
typename Kokkos::Random_XorShift64_Pool<> GeneratorPool
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
The base class for all OPAL definitions.
static Distribution * find(const std::string &name)
ippl::Vector< double, 3 > sigmaR_m
void printDistFlatTop(Inform &os) const
ippl::Vector< double, 3 > sigmaP_m
double tPulseLengthFWHM_m
virtual void execute()
Execute the command.
double getTEmission() const
virtual bool canReplaceBy(Object *object)
Distribution can only be replaced by another distribution.
ippl::Vector< double, 3 > cutoffR_m
std::string getFilename() const
DistributionType distrTypeT_m
void setDistParametersMultiVariateGauss()
void printDistFromFile(Inform &os) const
virtual Distribution * clone(const std::string &name)
Return a clone.
void printDistMultiVariateGauss(Inform &os) const
ippl::Vector< double, 3 > cutoffP_m
size_t totalNumberParticles_m
size_t getNumOfLocalParticlesToCreate(size_t n)
void setTEmission(double tEmission)
void setDistParametersFlatTop()
void setAvrgPz(double avrgpz)
void printDistGauss(Inform &os) const
Inform & printInfo(Inform &os) const
size_t getEmissionSteps() const
Matrix_t correlationMatrix_m
void setDistParametersGauss()
The base class for all OPAL objects.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
virtual void update()
Update this object.
std::vector< Attribute > itsAttr
The object attributes.
Object * find(const std::string &name)
Find entry.
static OpalData * getInstance()
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.
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.