|
OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
|
#include <gtest/gtest.h>#include <mpi.h>#include <algorithm>#include <cmath>#include <memory>#include "Distribution/FlatTop.h"#include "Ippl.h"#include "PartBunch/BunchStateHandler.h"#include "Utility/IpplTimings.h"
Go to the source code of this file.
Classes | |
| class | FlatTopTest |
Functions | |
| TEST_F (FlatTopTest, UniformDiskStatisticsAndBounds) | |
| Testing generatiioin of uniform sampples on an elliptical disk. | |
| TEST_F (FlatTopTest, CountEnteringParticles_NoDomainDecomp) | |
| This test counts the number of particles entering the domain per rank for a FlatTop pulse. | |
| TEST_F | ( | FlatTopTest | , |
| CountEnteringParticles_NoDomainDecomp | |||
| ) |
This test counts the number of particles entering the domain per rank for a FlatTop pulse.
This test verifies that FlatTop::countEnteringParticlesPerRank correctly counts the number of particles entering the domain within a given time window when domain decomposition is disabled.
A total of \(N_{\mathrm{tot}}\) particles are emitted over the full pulse duration according to a normalized FlatTop temporal profile \(f(t)\). The expected number of particles entering during a time window \([t_0, t_f]\) is computed analytically.
The number of particles emitted in the interval \([t_0, t_f]\) is
\[ N_{\mathrm{new}} = \left\lfloor N_{\mathrm{tot}} \frac{ \int_{t_0}^{t_f} f(t)\,dt }{ \int f(t)\,dt } \right\rfloor. \]
The integral over the time window is approximated using a trapezoidal rule:
\[ \int_{t_0}^{t_f} f(t)\,dt \approx \frac{1}{2} \left( f(t_0) + f(t_f) \right) (t_f - t_0). \]
With domain decomposition disabled, particles are distributed evenly across all MPI ranks. The expected number of particles per rank is therefore
\[ N_{\mathrm{new,local}}} = \left\lfloor \frac{N_{\mathrm{new}}}{{\mathrm{\#ranks}}} \right\rfloor, \]
with the remainder
\[ remainder = N_{\mathrm{new}} - \#{\mathrm{rank}} N_{\mathrm{new,local}} \]
assigned to rank 0, leading to
\[ N_{\mathrm{new,local}}^{(0)} = N_{\mathrm{new,local}} + remainder. \]
and \(N_{\mathrm{new,local}}^{(r)} = N_{\mathrm{new,local}}\) for \(r > 0\).
The total number of particles entering the domain is therefore
\[ N_{\mathrm{new,global}} = \sum_{r=0}^{N_{\mathrm{ranks}}-1} N_{\mathrm{new,local}}^{(r)}. \]
The test verifies that
\[ N_{\mathrm{new,global}} = N_{\mathrm{expected}}, \]
The test verifies that the number of particles counted on each rank matches this analytic expectation exactly.
Definition at line 252 of file TestFlatTop.cpp.
References FlatTop::allocateParticles(), FlatTop::countEnteringParticlesPerRank(), FlatTop::FlatTopProfile(), FlatTop::getDistArea(), and FlatTop::setWithDomainDecomp().

| TEST_F | ( | FlatTopTest | , |
| UniformDiskStatisticsAndBounds | |||
| ) |
Testing generatiioin of uniform sampples on an elliptical disk.
This test verifies that FlatTop::generateUniformDisk generates particle positions uniformly over the elliptical region
\[ \mathcal{D} = \left\{ (x,y) \in \mathbb{R}^2 : \frac{R_x^2}{\sigma_x^2} + \frac{R_y^2}{\sigma_y^2} \le 1 \right\}. \]
The test checks the following properties:
\[ \frac{R_x^2}{\sigma_x^2} + \frac{R_y^2}{\sigma_y^2} \le 1. \]
\[ \mathbf{P}_i = \mathbf{0}. \]
\[ \mathbb{E}[R_x] = \mathbb{E}[R_y] = 0. \]
\[ \mathbb{E}[R_x^2] = \frac{\sigma_x^2}{4}, \qquad \mathbb{E}[R_y^2] = \frac{\sigma_y^2}{4}. \]
The empirical sample moments are compared against these analytic values using a finite-sample tolerance.
Definition at line 104 of file TestFlatTop.cpp.
References FlatTop::generateUniformDisk().
