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
23
24#include "Vektor.h"
25#include "Physics/Physics.h"
26#include "Physics/Units.h"
27
28#include <algorithm>
29#include <cmath>
30#include <utility>
31#include <vector>
32
33template<class T, unsigned Dim> class PartBunchBase;
34
36public:
38
39 void compute(const std::vector<OpalParticle>::const_iterator &,
40 const std::vector<OpalParticle>::const_iterator &);
44 void computePlasmaParameter(double);
45
53 Vector_t getHalo() const;
54 Vector_t getMaxR() const;
55
64
65 double getMeanTime() const;
66 double getStdTime() const;
67 double getMeanGamma() const;
68 double getMeanKineticEnergy() const;
69 double getTemperature() const;
70 double getDebyeLength() const;
71 double getPlasmaParameter() const;
72 double getStdKineticEnergy() const;
73 double getDx() const;
74 double getDDx() const;
75 double getDy() const;
76 double getDDy() const;
78 double getTotalCharge() const;
79 double getTotalMass() const;
80 double getTotalNumParticles() const;
81
82private:
83 bool isParticleExcluded(const OpalParticle &) const;
84 template<class InputIt>
85 void computeMeans(const InputIt &, const InputIt &);
86 template<class InputIt>
87 void computeStatistics(const InputIt &, const InputIt &);
88 template<class InputIt>
89 void computePercentiles(const InputIt &, const InputIt &);
90 using iterator_t = std::vector<Vektor<double, 2>>::const_iterator;
91 std::pair<double, iterator_t> determinePercentilesDetail(const iterator_t& begin, const iterator_t& end,
92 const std::vector<int>& globalAccumulatedHistogram,
93 const std::vector<int>& localAccumulatedHistogram,
94 unsigned int dimension,
95 int numRequiredParticles) const;
96 double computeNormalizedEmittance(const iterator_t& begin, const iterator_t& end) const;
97 void fillMembers(std::vector<double> const&);
98 void reset();
100
119
121 double stdTime_m;
128 double centroid_m[6];
130
134
139};
140
141inline
146
147inline
152
153inline
158
159inline
164
165inline
170
171inline
176
177inline
182
183inline
185{
186 return halo_m;
187}
188
189inline
191{
192 return meanTime_m;
193}
194
195inline
197{
198 return stdTime_m;
199}
200
201inline
203{
204 return meanGamma_m;
205}
206
207inline
212
213// Compute and return the value of temperature in K
214inline
221inline
223{
224 return debyeLength_m;
225}
226inline
231
232inline
237
238inline
240{
241 return moments_m(0, 5);
242}
243
244inline
246{
247 return moments_m(1, 5);
248}
249
250inline
252{
253 return moments_m(2, 5);
254}
255
256inline
258{
259 return moments_m(3, 5);
260}
261
262inline
267
268inline
270{
271 return totalCharge_m;
272}
273
274inline
276{
277 return totalMass_m;
278}
279
280inline
285
286inline
291
292inline
297
298inline
303
304inline
309
310inline
315
316inline
321
322inline
327
328inline
333
334inline
336{
337 Vector_t maxDistance;
338 for (unsigned int i = 0; i < 3; ++ i) {
339 maxDistance[i] = std::max(std::abs(maxR_m[i]), std::abs(minR_m[i]));
340 }
341 return maxDistance;
342}
343
344#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
std::vector< Vektor< double, 2 > >::const_iterator iterator_t
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
Vector_t getGeometricEmittance() const
A templated representation for matrices.
Definition FMatrix.h:39