OPAL (Object Oriented Parallel Accelerator Library) 2022.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
22
23#include "Vektor.h"
24#include "Physics/Physics.h"
25#include "Physics/Units.h"
26
27#include <vector>
28
29class OpalParticle;
30template<class T, unsigned Dim>
31class PartBunchBase;
32
34public:
36
37 void compute(const std::vector<OpalParticle>::const_iterator &,
38 const std::vector<OpalParticle>::const_iterator &);
42 void computePlasmaParameter(double);
43
51 Vector_t getHalo() const;
52 Vector_t getMaxR() const;
53
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
80private:
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();
98
117
119 double stdTime_m;
126 double centroid_m[6];
128
132
137};
138
139inline
141{
142 return meanR_m;
143}
144
145inline
147{
148 return stdR_m;
149}
150
151inline
153{
154 return meanP_m;
155}
156
157inline
159{
160 return stdP_m;
161}
162
163inline
165{
166 return normalizedEps_m;
167}
168
169inline
171{
172 return geometricEps_m;
173}
174
175inline
177{
178 return stdRP_m;
179}
180
181inline
183{
184 return halo_m;
185}
186
187inline
189{
190 return meanTime_m;
191}
192
193inline
195{
196 return stdTime_m;
197}
198
199inline
201{
202 return meanGamma_m;
203}
204
205inline
207{
208 return meanKineticEnergy_m;
209}
210
211// Compute and return the value of temperature in K
212inline
214{
215 return (temperature_m /
218}
219inline
221{
222 return debyeLength_m;
223}
224inline
226{
227 return plasmaParameter_m;
228}
229
230inline
232{
233 return stdKineticEnergy_m;
234}
235
236inline
238{
239 return moments_m(0, 5);
240}
241
242inline
244{
245 return moments_m(1, 5);
246}
247
248inline
250{
251 return moments_m(2, 5);
252}
253
254inline
256{
257 return moments_m(3, 5);
258}
259
260inline
262{
263 return moments_m;
264}
265
266inline
268{
269 return totalCharge_m;
270}
271
272inline
274{
275 return totalMass_m;
276}
277
278inline
280{
281 return totalNumParticles_m;
282}
283
284inline
286{
288}
289
290inline
292{
294}
295
296inline
298{
300}
301
302inline
304{
306}
307
308inline
310{
312}
313
314inline
316{
318}
319
320inline
322{
324}
325
326inline
328{
330}
331
332inline
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
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:84
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
constexpr double kB
Boltzman's constant in eV/K.
Definition: Physics.h:60
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45
constexpr double eV2kg
Definition: Units.h:110
Vector_t getStandardDeviationMomentum() const
Vector_t get99Percentile() const
double getMeanKineticEnergy() const
Vector_t getStandardDeviationPosition() const
void computeDebyeLength(PartBunchBase< double, 3 > const &, double)
double getMeanGamma() const
Vector_t getHalo() const
void computePlasmaParameter(double)
Vector_t getNormalizedEmittance95Percentile() const
Vector_t getNormalizedEmittance68Percentile() const
FMatrix< double, 6, 6 > moments_m
double getTotalCharge() const
static const double percentileFourSigmasNormalDist_m
Vector_t getStandardDeviationRP() const
double getTemperature() const
Vector_t getNormalizedEmittance99_99Percentile() const
Vector_t getNormalizedEmittance99Percentile() const
Vector_t getMeanPosition() const
void computeMeans(const InputIt &, const InputIt &)
Vector_t get99_99Percentile() const
double getDebyeLength() const
Vector_t normalizedEps99_99Percentile_m
void computeMeanKineticEnergy(PartBunchBase< double, 3 > const &)
unsigned int totalNumParticles_m
void compute(const std::vector< OpalParticle >::const_iterator &, const std::vector< OpalParticle >::const_iterator &)
double getStdKineticEnergy() const
Vector_t getNormalizedEmittance() const
std::vector< Vektor< double, 2 > >::const_iterator iterator_t
double getTotalMass() const
double getPlasmaParameter() const
Vector_t getMeanMomentum() const
void computeStatistics(const InputIt &, const InputIt &)
double computeNormalizedEmittance(const iterator_t &begin, const iterator_t &end) const
double getTotalNumParticles() const
Vector_t getMaxR() const
static const double percentileThreeSigmasNormalDist_m
FMatrix< double, 6, 6 > getMoments6x6() const
void computePercentiles(const InputIt &, const InputIt &)
static const double percentileTwoSigmasNormalDist_m
bool isParticleExcluded(const OpalParticle &) const
Vector_t get95Percentile() const
Vector_t get68Percentile() const
Vector_t ninetyNine_NinetyNinePercentile_m
void fillMembers(std::vector< double > 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 percentileOneSigmaNormalDist_m
double getMeanTime() const
Vector_t getGeometricEmittance() const