OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
MultiVariateGaussian.h
Go to the documentation of this file.
1#ifndef IPPL_MULTI_VARIATE_GAUSSIAN_H
2#define IPPL_MULTI_VARIATE_GAUSSIAN_H
3
4#include <Kokkos_Random.hpp>
5#include <cmath>
6#include <memory>
7#include "Distribution.h"
8#include "Ippl.h"
9#include "OPALTypes.h"
10#include "SamplingBase.hpp"
11#include "Utilities/Options.h"
12
13using GeneratorPool = typename Kokkos::Random_XorShift64_Pool<>;
14using Dist_t = ippl::random::NormalDistribution<double, 3>;
15using Matrix_t = ippl::Vector<ippl::Vector<double, 6>, 6>;
16
30public:
39 std::shared_ptr<ParticleContainer_t> pc, std::shared_ptr<FieldContainer_t> fc,
40 Distribution_t* opalDist);
41
54 std::shared_ptr<ParticleContainer_t> pc, const Vector_t<double, 3>& meanR,
55 const Vector_t<double, 3>& meanP, const Vector_t<double, 3>& sigmaR,
56 const Vector_t<double, 3>& sigmaP, const Vector_t<double, 3>& cutoffR,
57 const Vector_t<double, 3>& cutoffP, bool fixMeanR = true, bool fixMeanP = true);
58
71 std::shared_ptr<ParticleContainer_t> pc, const Vector_t<double, 3>& meanR,
72 const Vector_t<double, 3>& meanP, const Matrix_t& cov,
73 const Vector_t<double, 3>& cutoffR, const Vector_t<double, 3>& cutoffP,
74 bool fixMeanR = true, bool fixMeanP = true);
79
84
91 void generateParticles(size_t& numberOfParticles, Vector_t<double, 3> nr) override;
92
100 void emitParticles(double t, double dt) override;
101
105 IpplTimings::TimerRef samplerTimer_m;
106
107 void setMeanR(const Vector_t<double, 3>& meanR) { meanR_m = meanR; }
108
109 void setMeanP(const Vector_t<double, 3>& meanP) { meanP_m = meanP; }
110
111 void setCutoffR(const Vector_t<double, 3>& cutoffR) { cutoffR_m = cutoffR; }
112
113 void setCutoffP(const Vector_t<double, 3>& cutoffP) { cutoffP_m = cutoffP; }
114
115 void setFixMeanR(bool fixMeanR) { fixMeanR_m = fixMeanR; }
116
117 void setFixMeanP(bool fixMeanP) { fixMeanP_m = fixMeanP; }
118
119 void setSigmaR(const Vector_t<double, 3>& sigmaR) { sigmaR_m = sigmaR; }
120 void setSigmaP(const Vector_t<double, 3>& sigmaP) { sigmaP_m = sigmaP; }
121
122 void setCovarianceMatrix(const Matrix_t& cov) { cov_m = cov; }
123
124 void setL(const Matrix_t& L) { L_m = L; }
125
126private:
127 /*
128 * @brief Mean vectors for position and momentum.
129 */
131
132 /*
133 * @brief Covariance matrix for the Gaussian distribution.
134 */
136
137 /*
138 * @brief Cholesky cov=LT*L factorized matrix for the Gaussian distribution.
139 */
141
142 /*
143 * @brief Sampling bounds for the particle distribution.
144 */
146
147 /*
148 * @brief Normalized sampling bounds for the particle distribution.
149 */
151
156
162
166 void initRandomPool();
167
172
178
184};
185
186#endif // IPPL_MULTI_VARIATE_GAUSSIAN_H
ippl::Vector< T, Dim > Vector_t
typename Kokkos::Random_XorShift64_Pool<> GeneratorPool
const int nr
ippl::random::NormalDistribution< double, 3 > Dist_t
Definition FlatTop.cpp:8
ippl::Vector< ippl::Vector< double, 6 >, 6 > Matrix_t
typename Kokkos::Random_XorShift64_Pool<> GeneratorPool
A particle generation method following multivariate Gaussian distribution.
void emitParticles(double t, double dt) override
Time-stepped emission hook for one-shot delayed injection.
void setCovarianceMatrix(const Matrix_t &cov)
Vector_t< double, 6 > normMax_m
Vector_t< double, 3 > sigmaP_m
IpplTimings::TimerRef samplerTimer_m
Timer for performance profiling.
bool fixMeanR_m
Flag to exactly fix the mean R and P of particles after sampling.
Vector_t< double, 3 > meanP_m
void setCutoffR(const Vector_t< double, 3 > &cutoffR)
void setMeanP(const Vector_t< double, 3 > &meanP)
Vector_t< double, 6 > max_m
Vector_t< double, 3 > normPmin_m
void setCutoffP(const Vector_t< double, 3 > &cutoffP)
Vector_t< double, 3 > pmax_m
void ComputeCholeskyFactorization()
Computes the Cholesky factorization of the covariance matrix.
Vector_t< double, 3 > rmin_m
Vector_t< double, 3 > rmax_m
Vector_t< double, 3 > pmin_m
Vector_t< double, 3 > cutoffR_m
Cutoff multipliers for position and momentum distributions.
Vector_t< double, 6 > min_m
Min and Max bounds for all 6 dimensions (R0,P0,R1,P1,R2,P2).
Vector_t< double, 3 > normPmax_m
void setL(const Matrix_t &L)
void setFixMeanR(bool fixMeanR)
void setMeanR(const Vector_t< double, 3 > &meanR)
Vector_t< double, 6 > normMin_m
void initRandomPool()
Initializes the random number generator pool.
Vector_t< double, 3 > normRmax_m
void generateParticles(size_t &numberOfParticles, Vector_t< double, 3 > nr) override
Generates particles based on the defined Gaussian distribution.
Vector_t< double, 3 > meanR_m
Vector_t< double, 3 > sigmaR_m
Standard deviations for position and momentum distributions.
void setSigmaP(const Vector_t< double, 3 > &sigmaP)
GeneratorPool randPool_m
Pool of random number generators for parallel sampling.
void setSigmaR(const Vector_t< double, 3 > &sigmaR)
void ComputeCenteredBounds()
Computes centered bounds for the particle distribution.
Vector_t< double, 3 > cutoffP_m
Vector_t< double, 3 > normRmin_m
void setFixMeanP(bool fixMeanP)