34#include "Utility/IpplTimings.h"
36#include <gsl/gsl_linalg.h>
37#include <gsl/gsl_randist.h>
38#include <gsl/gsl_rng.h>
39#include <gsl/gsl_sf_erf.h>
41#include <boost/filesystem.hpp>
42#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
43#include <boost/regex.hpp>
58using Base = ippl::ParticleBase<ippl::ParticleSpatialLayout<T, Dim>>;
83 "The DISTRIBUTION statement defines data for the 6D particle distribution."),
121 "on flat top portion of emitted GAUSS "
122 "distribtuion (in percent of flat top "
127 "flat top portion of emitted GAUSS "
128 "distribution", 0.0);
132 "an injected beam.",
false);
153 size_t locNumber = n / ippl::Comm->size();
156 size_t remainder = n % ippl::Comm->size();
157 size_t myNode = ippl::Comm->rank();
158 if (myNode < remainder)
181void Distribution::create(
size_t& numberOfParticles,
double massIneV,
double charge, ippl::ParticleAttrib<ippl::Vector<double, 3>>& R, ippl::ParticleAttrib<ippl::Vector<double, 3>>& P, std::shared_ptr<ParticleContainer_t> &pc, std::shared_ptr<FieldContainer_t> &fc,
Vector_t<double, 3> nr) {
189 throw OpalException(
"Distribution::find()",
"Distribution \"" + name +
"\" not found.");
197 <<
"* ************* D I S T R I B U T I O N ********************************************"
201 os <<
"* In restart. Distribution read in from .h5 file." << endl;
214 throw OpalException(
"Distribution Param",
"Unknown \"TYPE\" of \"DISTRIBUTION\"");
217 os <<
"* Distribution is injected." << endl;
220 os <<
"* **********************************************************************************"
275 for (
unsigned int i = 0; i < 6; ++ i) {
276 for (
unsigned int j = 0; j < 6; ++ j) {
288 for (
unsigned int i = 0; i < 3; ++ i){
297 if (cr.size() == 15) {
298 *
gmsg <<
"* Use r to specify correlations" << endl;
300 for (
unsigned int i = 0; i < 5; ++ i) {
301 for (
unsigned int j = i + 1; j < 6; ++ j, ++ k) {
309 "Inconsistent set of correlations specified, check manual");
326 for (
unsigned int i = 0; i < 6; ++ i) {
327 for (
unsigned int j = 0; j < 6; ++ j) {
365 double timeRatio = std::sqrt(2.0 * std::log(10.0)) - std::sqrt(2.0 * std::log(10.0 / 9.0));
458 os <<
"* Distribution type: GAUSS" << endl;
460 os <<
"* SIGMAX = " <<
sigmaR_m[0] <<
" [m]" << endl;
461 os <<
"* SIGMAY = " <<
sigmaR_m[1] <<
" [m]" << endl;
462 os <<
"* SIGMAZ = " <<
sigmaR_m[2] <<
" [m]" << endl;
463 os <<
"* SIGMAPX = " <<
sigmaP_m[0] <<
" [Beta Gamma]" << endl;
464 os <<
"* SIGMAPY = " <<
sigmaP_m[1] <<
" [Beta Gamma]" << endl;
465 os <<
"* SIGMAPZ = " <<
sigmaP_m[2] <<
" [Beta Gamma]" << endl;
469 os <<
"* Distribution type: MULTIVARIATEGAUSS" << endl;
471 os <<
"* SIGMAX = " <<
sigmaR_m[0] <<
" [m]" << endl;
472 os <<
"* SIGMAY = " <<
sigmaR_m[1] <<
" [m]" << endl;
473 os <<
"* SIGMAZ = " <<
sigmaR_m[2] <<
" [m]" << endl;
474 os <<
"* SIGMAPX = " <<
sigmaP_m[0] <<
" [Beta Gamma]" << endl;
475 os <<
"* SIGMAPY = " <<
sigmaP_m[1] <<
" [Beta Gamma]" << endl;
476 os <<
"* SIGMAPZ = " <<
sigmaP_m[2] <<
" [Beta Gamma]" << endl;
478 os <<
"* input cov matrix = ";
479 for (
unsigned int i = 0; i < 6; ++ i) {
480 for (
unsigned int j = 0; j < 6; ++ j) {
488 os <<
"* Distribution type: FLATTOP" << endl;
490 os <<
"* SIGMAX = " <<
sigmaR_m[0] <<
" [m]" << endl;
491 os <<
"* SIGMAY = " <<
sigmaR_m[1] <<
" [m]" << endl;
500 os <<
"* Longitudinal cutoff = " <<
cutoffR_m[2]
501 <<
" [units of Sigma Time]" << endl;
510 os <<
"* SIGMAZ = " <<
sigmaR_m[2] <<
" [m]" << endl;
533 throw OpalException(
"Distribution Param",
"Unknown \"TYPE\" of \"DISTRIBUTION\"");
538 static const std::map<std::string, DistributionType> typeStringToDistType_s = {
549 "Distribution::setDistType",
550 "The attribute \"TYPE\" isn't set for the \"DISTRIBUTION\"!");
ippl::Vector< T, Dim > Vector_t
typename Kokkos::Random_XorShift64_Pool<> GeneratorPool
ippl::ParticleBase< ippl::ParticleSpatialLayout< T, Dim > > Base
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
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.
Definition(int size, const char *name, const char *help)
Constructor for exemplars.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Object(int size, const char *name, const char *help)
Constructor for exemplars.
std::vector< Attribute > itsAttr
The object attributes.
Object * find(const std::string &name)
Find entry.
static OpalData * getInstance()
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
DistributionType distrTypeT_m
void setDistParametersMultiVariateGauss()
virtual Distribution * clone(const std::string &name)
Return a clone.
virtual void update()
Update this object.
void printDistMultiVariateGauss(Inform &os) const
ippl::Vector< double, 3 > cutoffP_m
size_t getNumOfLocalParticlesToCreate(size_t n)
void setTEmission(double tEmission)
void setDistParametersFlatTop()
void createDistributionGauss(size_t numberOfParticles, double massIneV, ippl::ParticleAttrib< ippl::Vector< double, 3 > > &R, ippl::ParticleAttrib< ippl::Vector< double, 3 > > &P, std::shared_ptr< ParticleContainer< double, 3 > > &pc, std::shared_ptr< FieldContainer_t > &fc, Vector_t< double, 3 > nr)
void printDist(Inform &os, size_t numberOfParticles) const
void setAvrgPz(double avrgpz)
void printDistGauss(Inform &os) const
Inform & printInfo(Inform &os) const
void create(size_t &numberOfParticles, double massIneV, double charge, ippl::ParticleAttrib< ippl::Vector< double, 3 > > &R, ippl::ParticleAttrib< ippl::Vector< double, 3 > > &P, std::shared_ptr< ParticleContainer< double, 3 > > &pc, std::shared_ptr< FieldContainer_t > &fc, Vector_t< double, 3 > nr)
Matrix_t correlationMatrix_m
void setDistParametersGauss()
The base class for all OPAL exceptions.