OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
144
145inline
150
151inline
156
157inline
162
163inline
168
169inline
174
175inline
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
210
211// Compute and return the value of temperature in K
212inline
219inline
221{
222 return debyeLength_m;
223}
224inline
229
230inline
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
265
266inline
268{
269 return totalCharge_m;
270}
271
272inline
274{
275 return totalMass_m;
276}
277
278inline
283
284inline
289
290inline
295
296inline
301
302inline
307
308inline
313
314inline
319
320inline
325
326inline
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)
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)
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
void computeMeanKineticEnergy(PartBunchBase< double, 3 > const &)
void compute(const std::vector< OpalParticle >::const_iterator &, const std::vector< OpalParticle >::const_iterator &)
double getStdKineticEnergy() const
Vector_t getNormalizedEmittance() 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
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
std::vector< Vektor< double, 2 > >::const_iterator iterator_t
Vector_t getGeometricEmittance() const
A templated representation for matrices.
Definition FMatrix.h:39
Vektor< double, 3 > Vector_t