OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
DistributionMoments.h
Go to the documentation of this file.
1 //
2 // Class DistributionMoments
3 // Computes the statistics of particle distributions.
4 //
5 // Copyright (c) 2021, Christof Metzger-Kraus
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
18 #ifndef DISTRIBUTIONMOMENTS_H
19 #define DISTRIBUTIONMOMENTS_H
20 
21 #include "FixedAlgebra/FMatrix.h"
22 
23 #include "Vektor.h"
24 #include "Physics/Physics.h"
25 #include "Physics/Units.h"
26 
27 #include <vector>
28 
29 class OpalParticle;
30 template<class T, unsigned Dim>
31 class PartBunchBase;
32 
34 public:
36 
37  void compute(const std::vector<OpalParticle>::const_iterator &,
38  const std::vector<OpalParticle>::const_iterator &);
39  void compute(PartBunchBase<double, 3> const&);
41  void computeDebyeLength(PartBunchBase<double, 3> const&, double);
42  void computePlasmaParameter(double);
43 
44  Vector_t getMeanPosition() const;
46  Vector_t getMeanMomentum() const;
51  Vector_t getHalo() const;
52  Vector_t getMaxR() const;
53 
54  Vector_t get68Percentile() const;
55  Vector_t get95Percentile() const;
56  Vector_t get99Percentile() const;
62 
63  double getMeanTime() const;
64  double getStdTime() const;
65  double getMeanGamma() const;
66  double getMeanKineticEnergy() const;
67  double getTemperature() const;
68  double getDebyeLength() const;
69  double getPlasmaParameter() const;
70  double getStdKineticEnergy() const;
71  double getDx() const;
72  double getDDx() const;
73  double getDy() const;
74  double getDDy() const;
76  double getTotalCharge() const;
77  double getTotalMass() const;
78  double getTotalNumParticles() const;
79 
80 private:
81  bool isParticleExcluded(const OpalParticle &) const;
82  template<class InputIt>
83  void computeMeans(const InputIt &, const InputIt &);
84  template<class InputIt>
85  void computeStatistics(const InputIt &, const InputIt &);
86  template<class InputIt>
87  void computePercentiles(const InputIt &, const InputIt &);
88  using iterator_t = std::vector<Vektor<double, 2>>::const_iterator;
89  std::pair<double, iterator_t> determinePercentilesDetail(const iterator_t& begin, const iterator_t& end,
90  const std::vector<int>& globalAccumulatedHistogram,
91  const std::vector<int>& localAccumulatedHistogram,
92  unsigned int dimension,
93  int numRequiredParticles) const;
94  double computeNormalizedEmittance(const iterator_t& begin, const iterator_t& end) const;
95  void fillMembers(std::vector<double> const&);
96  void reset();
97  void resetPlasmaParameters();
98 
117 
118  double meanTime_m;
119  double stdTime_m;
125  double meanGamma_m;
126  double centroid_m[6];
128 
130  double totalMass_m;
131  unsigned int totalNumParticles_m;
132 
133  static const double percentileOneSigmaNormalDist_m;
134  static const double percentileTwoSigmasNormalDist_m;
136  static const double percentileFourSigmasNormalDist_m;
137 };
138 
139 inline
141 {
142  return meanR_m;
143 }
144 
145 inline
147 {
148  return stdR_m;
149 }
150 
151 inline
153 {
154  return meanP_m;
155 }
156 
157 inline
159 {
160  return stdP_m;
161 }
162 
163 inline
165 {
166  return normalizedEps_m;
167 }
168 
169 inline
171 {
172  return geometricEps_m;
173 }
174 
175 inline
177 {
178  return stdRP_m;
179 }
180 
181 inline
183 {
184  return halo_m;
185 }
186 
187 inline
189 {
190  return meanTime_m;
191 }
192 
193 inline
195 {
196  return stdTime_m;
197 }
198 
199 inline
201 {
202  return meanGamma_m;
203 }
204 
205 inline
207 {
208  return meanKineticEnergy_m;
209 }
210 
211 // Compute and return the value of temperature in K
212 inline
214 {
215  return (temperature_m /
218 }
219 inline
221 {
222  return debyeLength_m;
223 }
224 inline
226 {
227  return plasmaParameter_m;
228 }
229 
230 inline
232 {
233  return stdKineticEnergy_m;
234 }
235 
236 inline
238 {
239  return moments_m(0, 5);
240 }
241 
242 inline
244 {
245  return moments_m(1, 5);
246 }
247 
248 inline
250 {
251  return moments_m(2, 5);
252 }
253 
254 inline
256 {
257  return moments_m(3, 5);
258 }
259 
260 inline
262 {
263  return moments_m;
264 }
265 
266 inline
268 {
269  return totalCharge_m;
270 }
271 
272 inline
274 {
275  return totalMass_m;
276 }
277 
278 inline
280 {
281  return totalNumParticles_m;
282 }
283 
284 inline
286 {
287  return sixtyEightPercentile_m;
288 }
289 
290 inline
292 {
294 }
295 
296 inline
298 {
299  return ninetyFivePercentile_m;
300 }
301 
302 inline
304 {
306 }
307 
308 inline
310 {
311  return ninetyNinePercentile_m;
312 }
313 
314 inline
316 {
318 }
319 
320 inline
322 {
324 }
325 
326 inline
328 {
330 }
331 
332 inline
334 {
335  Vector_t maxDistance;
336  for (unsigned int i = 0; i < 3; ++ i) {
337  maxDistance[i] = std::max(std::abs(maxR_m[i]), std::abs(minR_m[i]));
338  }
339  return maxDistance;
340 }
341 
342 #endif
std::vector< Vektor< double, 2 >>::const_iterator iterator_t
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45
double getStdKineticEnergy() const
Vector_t getNormalizedEmittance() const
Vector_t ninetyNine_NinetyNinePercentile_m
Vector_t getStandardDeviationPosition() const
Vector_t get95Percentile() const
double getTotalMass() const
Vector_t getNormalizedEmittance99_99Percentile() const
double getMeanTime() const
std::pair< double, iterator_t > determinePercentilesDetail(const iterator_t &begin, const iterator_t &end, const std::vector< int > &globalAccumulatedHistogram, const std::vector< int > &localAccumulatedHistogram, unsigned int dimension, int numRequiredParticles) const
static const double percentileFourSigmasNormalDist_m
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
void computeStatistics(const InputIt &, const InputIt &)
Vector_t getHalo() const
void computeMeanKineticEnergy(PartBunchBase< double, 3 > const &)
Vector_t getStandardDeviationRP() const
static const double percentileThreeSigmasNormalDist_m
constexpr double eV2kg
Definition: Units.h:110
double getTotalCharge() const
clearpage the user may choose between constant or variable radius This model includes fringe fields begin
Definition: multipole_t.tex:6
double getTemperature() const
Vector_t getMeanPosition() const
Vector_t getNormalizedEmittance99Percentile() const
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:84
double getTotalNumParticles() const
double getPlasmaParameter() const
Vector_t get68Percentile() const
Vector_t getNormalizedEmittance95Percentile() const
Vector_t getGeometricEmittance() const
void computePercentiles(const InputIt &, const InputIt &)
double getMeanKineticEnergy() const
double computeNormalizedEmittance(const iterator_t &begin, const iterator_t &end) const
constexpr double kB
Boltzman&#39;s constant in eV/K.
Definition: Physics.h:60
double getStdTime() const
Vector_t getNormalizedEmittance68Percentile() const
Vector_t getMaxR() const
void fillMembers(std::vector< double > const &)
Vector_t get99Percentile() const
double getDebyeLength() const
Vector_t get99_99Percentile() const
void computeDebyeLength(PartBunchBase< double, 3 > const &, double)
unsigned int totalNumParticles_m
Vector_t normalizedEps99_99Percentile_m
void computeMeans(const InputIt &, const InputIt &)
bool isParticleExcluded(const OpalParticle &) const
void compute(const std::vector< OpalParticle >::const_iterator &, const std::vector< OpalParticle >::const_iterator &)
double getMeanGamma() const
Vector_t getStandardDeviationMomentum() const
static const double percentileOneSigmaNormalDist_m
FMatrix< double, 6, 6 > moments_m
static const double percentileTwoSigmasNormalDist_m
Vector_t getMeanMomentum() const
FMatrix< double, 6, 6 > getMoments6x6() const
end
Definition: multipole_t.tex:9
void computePlasmaParameter(double)