specialize a type for all of the STL containers. More...
Classes | |
| struct | KeyTraits |
| Class template to store Key traits outside the Key class, allowing for reuse both in the Key class itself and in helper implementation details. More... | |
| struct | is_stl_container |
| Implementation of the type trait to infer if a type is an STL container. More... | |
| struct | is_stl_container< std::vector< Args... > > |
Trait specialization for std::vector. More... | |
| struct | is_stl_container< std::set< Args... > > |
Trait specialization for std::set. More... | |
| struct | is_stl_container< std::map< Args... > > |
Trait specialization for std::map. More... | |
Functions | |
| void | sample_manybody_phasespace_impl (double sqrts, const ParticleTypePtrList &types, std::vector< FourVector > &sampled_momenta) |
| Implementation of the full n-body phase-space sampling (masses, momenta, angles) in the center-of-mass frame for the final state particles, using the M-method from CERN-68-15, paragraph 9.6. More... | |
| void | sample_manybody_phasespace_MCMC (const ParticleTypePtrList &types, std::vector< FourVector > &sampled_momenta) |
| Metropolis–Hastings sampling of the many body phase space, starting from an initial guess in sampled_momenta that is assumed appropriate. More... | |
| double | interpolate_trilinear (double ax, double ay, double az, double f1, double f2, double f3, double f4, double f5, double f6, double f7, double f8) |
| Perform a trilinear 1st order interpolation. More... | |
| template<typename T > | |
| const KeyTraits< T >::validator_type & | get_default_validator () noexcept |
| Function template to get a default trivial validator. More... | |
| template<typename T > | |
| constexpr auto | type_name () |
| Get type of variable as string in a human-readable way. More... | |
| template<typename N , typename = std::enable_if_t<std::is_floating_point_v<N>>> | |
| bool | almost_equal_knuthish (const N x, const N y, const N epsilon, const N threshold=N{0.0}) noexcept |
| Compare whether two floating-point numbers are approximately equal à la Knuth up to a given tolerance. More... | |
| template<typename Converter , class Range , std::enable_if_t< std::is_same_v< Range, Particles >||std::is_same_v< Range, ParticleList >, bool > = true> | |
| void | write_in_chunk_impl (const Range &particles, const OutputFormatter< Converter > &formatter, std::function< void(const typename Converter::type &)> write, std::size_t max_buffer_bytes=1 '000 '000 '000) |
| Writes particle data in multiple chunks if the total buffer size exceeds a predefined maximum. More... | |
specialize a type for all of the STL containers.
| void smash::detail::sample_manybody_phasespace_impl | ( | double | sqrts, |
| const ParticleTypePtrList & | types, | ||
| std::vector< FourVector > & | sampled_momenta | ||
| ) |
Implementation of the full n-body phase-space sampling (masses, momenta, angles) in the center-of-mass frame for the final state particles, using the M-method from CERN-68-15, paragraph 9.6.
The algorithm proceeds in two stages:
Generate invariant masses \(M_{12}, M_{123}, M_{1234}, \ldots\) from the measure
\[ dM_{12}\, dM_{123}\, dM_{1234}\, \cdots, \]
while respecting non-trivial kinematic limits.
Introduce shifted variables
\[ T_{12} = M_{12} - (m_1 + m_2),\qquad T_{123} = M_{123} - (m_1 + m_2 + m_3),\ \ldots \]
and sample uniformly under the ordering constraint
\[ 0 \le T_{12} \le T_{123} \le T_{1234} \le \cdots \le \sqrt{s} - \sum_i m_i. \]
A practical trick is to draw values uniformly in \([0,\,\sqrt{s} - \sum_i m_i]\) and sort them.
\[ R_2(\sqrt{s}, M_{n-1}, m_n) \times R_2(M_{n-1}, M_{n-2}, m_{n-1}) \times \cdots \times R_2(M_2, m_1, m_2) \times \prod_i M_i. \]
The maximum weight is estimated heuristically; following an idea by Scott Pratt, it is expected near
\[ T_{12} = T_{123} = T_{1234} = \cdots = \frac{\sqrt{s} - \sum_i m_i}{n - 1}. \]
Definition at line 410 of file action.cc.
| void smash::detail::sample_manybody_phasespace_MCMC | ( | const ParticleTypePtrList & | types, |
| std::vector< FourVector > & | sampled_momenta | ||
| ) |
Metropolis–Hastings sampling of the many body phase space, starting from an initial guess in sampled_momenta that is assumed appropriate.
The algorithm works by repeatedly picking a random pair of particles, resampling their masses from the spectral functions, and adjusting their momenta accordingly in the CM frame of the pair, which conserves energy and momentum. This is done for a fixed number of iterations heuristically chosen (200), but no systematic analysis was done.
The function is for now used as a fallback for the rejection algorithm in sample_manybody_phasespace_impl and takes its initial guess from there.
Definition at line 552 of file action.cc.
| double smash::detail::interpolate_trilinear | ( | double | ax, |
| double | ay, | ||
| double | az, | ||
| double | f1, | ||
| double | f2, | ||
| double | f3, | ||
| double | f4, | ||
| double | f5, | ||
| double | f6, | ||
| double | f7, | ||
| double | f8 | ||
| ) |
Perform a trilinear 1st order interpolation.
Assume, we seek the value of a function \( f \) at position \((x, y, z)\). We know the position \((x, y, z)\) lies within a 3D cube, for which the values of the function f are known at each corner \((f_1, ..., f_8)\). We can now interpolate those values trilinearly to obtain an estimate of \( f \) at position \((x, y, z)\).
For this interpolation, linear functions are used in each direction \(x\), \(y\), and \(z\) respectively with \( a_x \), \( a_y \), and \( a_z \) as the slope parameters, e.g., \( f_1 + a_y \cdot (f_3 - f_1) \) for an approximation between the corners \( f_1 \) and \( f_3 \). For the \(y\)-direction, the linear functions are based on the cube's corners. The \(x\)-direction then uses the four obtained values from the interpolation in \(y\)-direction and finally the \(z\)-direction interpolation is based on the two values obtained by the combined interpolations in \(x\)- and \(y\)-direction. Since the position \((x, y, z)\) of the wanted value of function \( f \) is within the cube, the allowed values for \( a_x \), \( a_y \), and \( a_z \) are between 0 and 1.
Positional placement of the cube:
| [in] | ax | Fraction of the step in x-direction and used as slope parameter |
| [in] | ay | Fraction of the step in y-direction and used as slope parameter |
| [in] | az | Fraction of the step in z-direction and used as slope parameter |
| [in] | f1 | Value at the lower left front corner of the cube |
| [in] | f2 | Value at the lower right front corner of the cube |
| [in] | f3 | Value at the upper left front corner of the cube |
| [in] | f4 | Value at the upper right front corner of the cube |
| [in] | f5 | Value at the lower left back corner of the cube |
| [in] | f6 | Value at the lower right back corner of the cube |
| [in] | f7 | Value at the upper left back corner of the cube |
| [in] | f8 | Value at the upper right back corner of the cube |
Definition at line 658 of file hadgas_eos.cc.
|
noexcept |
Function template to get a default trivial validator.
true .Key constructors which are used by the InputKeys class, that is a collection of static Keys. Hence, since initialization order of static/global objects in C++ is undefined, we need to do something else. We use therefore the "construct on first use idiom", making the functor a static object in a function scope. For more information, refer for example to ISO C++ FAQ.
|
constexpr |
Get type of variable as string in a human-readable way.
| T | The type to be returned. |
std::string containing the name of the type. Definition at line 27 of file numeric_cast.h.
|
noexcept |
Compare whether two floating-point numbers are approximately equal à la Knuth up to a given tolerance.
On top of Knuth's tolerance predicate some corner cases are treated and the caller can specify a threshold as last parameter to make the test consider numbers equal if the absolute value of their difference is below of it.
| [in] | x | First of the two numbers. |
| [in] | y | Second of the two numbers. |
| [in] | epsilon | The relative tolerance for the test. |
| [in] | threshold | Threshold for the number comparison. By default this is zero, implying no threshold is considered. |
false if either x or y is not a finite number, provided that the type supports non-numeric representations (i.e. is infinite or NAN); true if x == y; true if x == 0 and if \( |x| \le \varepsilon\); true if y == 0 and if \( |y| \le \varepsilon\); true if \( |x - y| \le M_\mathrm{threshold} \); true if \( |x - y| \le \varepsilon \cdot \max(|x|, |y|) \) (Knuth's tolerance predicate); false otherwise. Definition at line 59 of file numerics.h.
| void smash::detail::write_in_chunk_impl | ( | const Range & | particles, |
| const OutputFormatter< Converter > & | formatter, | ||
| std::function< void(const typename Converter::type &)> | write, | ||
| std::size_t | max_buffer_bytes = 1'000'000'000 |
||
| ) |
Writes particle data in multiple chunks if the total buffer size exceeds a predefined maximum.
This method avoids creating a single excessively large binary buffer when writing many particles at once. Instead, it splits the write into several smaller chunks. This can prevent excessive memory usage and improve stability on systems or filesystems that may have trouble with very large write calls.
The maximum buffer size is currently set to 1 GB (10^9 bytes), but this can be adapted in the future if needed. If the total data size of the particle block is below this threshold, the method simply delegates to the write function which should perform a single write call.
Otherwise, the data is accumulated particle by particle until the buffer reaches the threshold. The buffer is then given to the write function which should flush to disk.
| Converter | Converter used by OutputFormatter to produce the buffer type (must define Converter::type). |
| Range | Container type — enforced to be either Particles or ParticleList. |
| [in] | particles | Container of particles whose particle_line representation is to be written. |
| [in] | formatter | Formatter responsible for converting particles into the corresponding Converter::type buffer representation. |
| [in] | write | Callable that receives each filled buffer chunk and performs the actual write to the underlying output (e.g. file). |
| [in] | max_buffer_bytes | Maximum buffer size in bytes before the accumulated data is flushed via write (default: 1'000'000'000). |
| std::runtime_error | If the estimated size of a single particle line exceeds half of max_buffer_bytes. In that case, only one particle would fit per chunk, which defeats the purpose of chunked writing, and the caller must increase max_buffer_bytes accordingly. |
Definition at line 695 of file outputformatter.h.