Version: SMASH-3.4
quantumsampling.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2020,2022
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_QUANTUMSAMPLING_H_
11 #define SRC_INCLUDE_SMASH_QUANTUMSAMPLING_H_
12 
13 #include <map>
14 
15 #include "gsl/gsl_multiroots.h"
16 #include "gsl/gsl_vector.h"
17 
18 #include "smash/pdgcode.h"
19 #include "smash/random.h"
20 
21 namespace smash {
22 
23 /**
24  * This class:
25  * - Calculates chemical potentials given density of particle species
26  * - Calculates maxima of a Juttner distribution for these chemical potentials
27  * - Samples Juttner distribution. This is the main intent of this class,
28  * while previous points are auxiliary calculations for it.
29  */
30 
32  public:
33  /**
34  * Constructor of a QuantumSampling object.
35  * \param[in] initial_multiplicities a map of pdg codes of samples particle
36  * species and corresponding multiplicities
37  * \param[in] volume volume V in which the particles are sampled [fm^3],
38  * needed to calculate the density of the species
39  * \param[in] temperature temperature T of the system [GeV]
40  */
41  QuantumSampling(const std::map<PdgCode, int>& initial_multiplicities,
42  double volume, double temperature);
43 
44  /**
45  * Struct object that holds the parameters relevant to finding the momentum
46  * for which the maximum of the distribution occurs.
47  */
49  /// mass m of a particle [GeV]
50  double mass;
51  /// temperature T of the system [GeV]
52  double temperature;
53  /// effective chemical potential mu^* of the particle species
55  /**
56  * quantum statistics of the particles species
57  * (+1 for Fermi, -1 for Bose, 0 for Boltzmann)
58  */
59  double statistics;
60  };
61 
62  /**
63  * Root equation for finding the radial momentum at which the Juttner
64  * distribution function has its maximum.
65  * \param[in] p radial momentum, i.e., length of the momentum vector [GeV]
66  * \param[in] mass (pole) mass m of the particle species [GeV]
67  * \param[in] temperature temperature T of the system [GeV]
68  * \param[in] effective_chemical_potential effective chemical potential mu of
69  * the system [GeV]
70  * \param[in] statistics quantum statistics of the particles species
71  * (+1 for Fermi, -1 for Bose, 0 for Boltzmann)
72  * \return the extremum equation for the maximum of the Juttner distribution
73  */
74  static double p_max_root_equation(double p, double mass, double temperature,
75  double effective_chemical_potential,
76  double statistics);
77 
78  /**
79  * Root equation for finding the radial momentum at which the Juttner
80  * distribution function has its maximum, suited for the GSL root finding
81  * procedure.
82  * \param[in] roots_array an array holding the current best estimate of the
83  * roots of the solved equation
84  * \param[in] parameters refers to the parameters as provided in the GSL
85  * root solving procedure
86  * \param[in] function refers to the root equation(s) as provided in the GSL
87  * root solving procedure (where it's called "function")
88  * \return the root equation suited for GSL root finding procedure
89  */
90  static int p_max_root_equation_for_GSL(const gsl_vector* roots_array,
91  void* parameters,
92  gsl_vector* function);
93 
94  /**
95  * A GSL utility which allows for printing out the status of the solver
96  * during the root finding procedure.
97  * \param[in] iter variable keeping track of how many steps in the root
98  * solving procedure have been taken
99  * \param[in] solver GSL solver object, which has acces to the current best
100  * estimate of the roots and the corresponding function values
101  * \return message about the current state of the solver
102  */
103  static void print_state_p_max(unsigned int iter,
104  gsl_multiroot_fsolver* solver);
105 
106  /**
107  * A GSL root solver for finding the radial momentum value at which the
108  * maximum of the given Juttner distribution function occurs. For the value of
109  * the distribution at the maximum, one shoud use the function
110  * maximum_of_the_distribution().
111  * \param[in] mass (pole) mass m of the particle species [GeV]
112  * \param[in] temperature temperature T of the system [GeV]
113  * \param[in] effective_chemical_potential effective chemical potential mu of
114  * the system [GeV]
115  * \param[in] statistics quantum statistics of the particles species
116  * (+1 for Fermi, -1 for Bose, 0 for Boltzmann)
117  * \param[in] p_max_initial_guess the initial guess for the value of the
118  * solution [GeV]
119  * \param[in] solution_precision precision with which the solution is found
120  * \param[out] p_max the solution (momentum for which the distribution takes
121  * on the maximum value) stored in an array object [GeV]
122  */
124  double mass, double temperature, double effective_chemical_potential,
125  double statistics, double p_max_initial_guess, double solution_precision,
126  double* p_max);
127 
128  /**
129  * A convenience wrapper for finding the maximum value of the Juttner
130  * distribution, returning the value of the distribution for the momentum
131  * at which the maximum occurs, identified by
132  * find_p_at_maximum_of_the_distribution().
133  * \param[in] mass (pole) mass m of the particle species [GeV]
134  * \param[in] temperature temperature T of the system [GeV]
135  * \param[in] effective_chemical_potential effective chemical potential mu of
136  * the system [GeV]
137  * \param[in] statistics quantum statistics of the particles species
138  * (+1 for Fermi, -1 for Bose, 0 for Boltzmann)
139  * \param[in] solution_precision precision with which the solution is found
140  */
141  static double maximum_of_the_distribution(double mass, double temperature,
142  double effective_chemical_potential,
143  double statistics,
144  double solution_precision);
145 
146  /**
147  * Sampling radial momenta of given particle species from Boltzmann, Bose, or
148  * Fermi distribution. This sampler uses the simplest rejection sampling.
149  * \param[in] pdg the pdg code of the sampled particle species
150  * return the sampled momentum [GeV]
151  */
152  double sample(const PdgCode pdg);
153 
154  private:
155  /// Tabulated effective chemical potentials for every particle species
156  std::map<PdgCode, double> effective_chemical_potentials_;
157  /// Tabulated distribution function maxima for every particle species
158  std::map<PdgCode, double> distribution_function_maximums_;
159  /// Volume [fm^3] in which particles sre sampled
160  const double volume_;
161  /// Temperature [GeV]
162  const double temperature_;
163 };
164 
165 } // namespace smash
166 
167 #endif // SRC_INCLUDE_SMASH_QUANTUMSAMPLING_H_
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:108
QuantumSampling(const std::map< PdgCode, int > &initial_multiplicities, double volume, double temperature)
Constructor of a QuantumSampling object.
static double p_max_root_equation(double p, double mass, double temperature, double effective_chemical_potential, double statistics)
Root equation for finding the radial momentum at which the Juttner distribution function has its maxi...
const double temperature_
Temperature [GeV].
static int find_p_at_maximum_of_the_distribution(double mass, double temperature, double effective_chemical_potential, double statistics, double p_max_initial_guess, double solution_precision, double *p_max)
A GSL root solver for finding the radial momentum value at which the maximum of the given Juttner dis...
std::map< PdgCode, double > distribution_function_maximums_
Tabulated distribution function maxima for every particle species.
static double maximum_of_the_distribution(double mass, double temperature, double effective_chemical_potential, double statistics, double solution_precision)
A convenience wrapper for finding the maximum value of the Juttner distribution, returning the value ...
std::map< PdgCode, double > effective_chemical_potentials_
Tabulated effective chemical potentials for every particle species.
const double volume_
Volume [fm^3] in which particles sre sampled.
static void print_state_p_max(unsigned int iter, gsl_multiroot_fsolver *solver)
A GSL utility which allows for printing out the status of the solver during the root finding procedur...
static int p_max_root_equation_for_GSL(const gsl_vector *roots_array, void *parameters, gsl_vector *function)
Root equation for finding the radial momentum at which the Juttner distribution function has its maxi...
double sample(const PdgCode pdg)
Sampling radial momenta of given particle species from Boltzmann, Bose, or Fermi distribution.
constexpr int p
Proton.
Definition: action.h:24
Struct object that holds the parameters relevant to finding the momentum for which the maximum of the...
double statistics
quantum statistics of the particles species (+1 for Fermi, -1 for Bose, 0 for Boltzmann)
double effective_chemical_potential
effective chemical potential mu^* of the particle species