Version: SMASH-3.4
grandcan_thermalizer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020,2022,2024-2025
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_GRANDCAN_THERMALIZER_H_
8 #define SRC_INCLUDE_SMASH_GRANDCAN_THERMALIZER_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "angles.h"
14 #include "clock.h"
15 #include "configuration.h"
16 #include "density.h"
17 #include "distributions.h"
18 #include "forwarddeclarations.h"
19 #include "hadgas_eos.h"
20 #include "input_keys.h"
21 #include "lattice.h"
22 #include "particledata.h"
23 #include "quantumnumbers.h"
24 
25 namespace smash {
26 
27 /**
28  * The ThermLatticeNode class is intended to compute thermodynamical quantities
29  * in a cell given a set of particles. It accumulates the upper row of the
30  * energy-momentum tensor \f$ T^{\mu 0}\f$, net baryon density nb and net
31  * strangeness densities in the computational frame. From these quantities
32  * it allows to compute the local rest frame quantites: temperature T,
33  * chemical potentials mub, mus and muq, the velocity of the local rest frame
34  * with respect to the computational frame.
35  *
36  * An example of the intended use is:
37  *
38  * ThermLatticeNode node;
39  * for (const ParticleData &particle: some_particles_list) {
40  * const double some_smearing_factor = ...;
41  * node.add_particle(particle, some_smearing_factor);
42  * }
43  * HadronGasEos eos = HadronGasEos(false);
44  * node.compute_rest_frame_quantities(eos);
45  *
46  * Note that before calling the compute_rest_frame_quantities T, mu, p and e
47  * are set to zero.
48  */
50  public:
51  /**
52  * Default constructor of thermal quantities on the lattice returning
53  * thermodynamic quantities in computational frame
54  * \return Tmu0_ Four vector \f$T^{\mu 0}\f$, nb_ Net baryon density at
55  * this location, ns_ Net strangeness density, nq_ Net charge density,
56  * e_ Energy density, v_ 3 vector velocity of local rest frame, T_ Temperature
57  * mub_ Net baryon chemical potential, mus_ Net strangeness chemical
58  * potential, muq_ Net charge chemical potential
59  */
61  /**
62  * Add particle contribution to Tmu0, nb, ns and nq
63  * May look like unused at first glance, but it is actually used
64  * by update_lattice, where the node type of the lattice
65  * is templated.
66  */
67  void add_particle(const ParticleData& p, double factor);
68  /// dummy function for update_lattice
70  /**
71  * Temperature, chemical potentials and rest frame velocity are
72  * calculated given the hadron gas equation of state object
73  * \param[in] eos \see HadronGasEos based on Tmu0, nb, ns and nq
74  * \return Temperature T, net baryon chemical potential mub,
75  * net strangeness chemical potential mus, net charge chemical potential muq
76  * and the velocity of the Landau rest frame, under assumption that the
77  * energy-momentum tensor has an ideal-fluid form. For more details and
78  * discussion see \iref{Oliinychenko:2015lva}. The advantage of this rest
79  * frame transformation is that it conserves energy and momentum, even
80  * though the dissipative part of the energy-momentum tensor is neglected.
81  */
83  /**
84  * Set all the rest frame quantities to some values, this is useful
85  * for testing.
86  * \param[out] T0 Rest frame temperature
87  * \param[out] mub0 Rest frame net baryon chemical potential
88  * \param[out] mus0 Rest frame net strangeness chemical potential
89  * \param[out] muq0 Rest frame net charge chemical potential
90  * \param[out] v0 Velocity of the rest frame
91  */
92  void set_rest_frame_quantities(double T0, double mub0, double mus0,
93  double muq0, const ThreeVector v0);
94  /// Get Four-momentum flow of the cell
95  FourVector Tmu0() const { return Tmu0_; }
96  /// Get net baryon density of the cell in the computational frame
97  double nb() const { return nb_; }
98  /// Get net strangeness density of the cell in the computational frame
99  double ns() const { return ns_; }
100  /// Get net charge density of the cell in the computational frame
101  double nq() const { return nq_; }
102  /// Get energy density in the rest frame
103  double e() const { return e_; }
104  /// Get pressure in the rest frame
105  double p() const { return p_; }
106  /// Get 3-velocity of the rest frame
107  ThreeVector v() const { return v_; }
108  /// Get the temperature
109  double T() const { return T_; }
110  /// Get the net baryon chemical potential
111  double mub() const { return mub_; }
112  /// Get the net strangeness chemical potential
113  double mus() const { return mus_; }
114  /// Get the net charge chemical potential
115  double muq() const { return muq_; }
116 
117  private:
118  /// Four-momentum flow of the cell
120  /// Net baryon density of the cell in the computational frame
121  double nb_;
122  /// Net strangeness density of the cell in the computational frame
123  double ns_;
124  /// Net charge density of the cell in the computational frame
125  double nq_;
126  /// Energy density in the rest frame
127  double e_;
128  /// Pressure in the rest frame
129  double p_;
130  /// Velocity of the rest frame
132  /// Temperature
133  double T_;
134  /// Net baryon chemical potential
135  double mub_;
136  /// Net strangeness chemical potential
137  double mus_;
138  /// Net charge chemical potential
139  double muq_;
140 };
141 
142 /**
143  * This operator writes all the thermodynamic quantities at a certain
144  * position to the file out
145  * \param[in] s location of the output
146  * \param[in] node position on the lattice, where the output is generated
147  */
148 std::ostream& operator<<(std::ostream& s, const ThermLatticeNode& node);
149 
150 /**
151  * Specifier to classify the different hadron species according to
152  * their quantum numbers
153  */
154 enum class HadronClass {
155  /// All baryons
156  Baryon = 0,
157  /// All anti-baryons
158  Antibaryon = 1,
159  /// Mesons with strangeness S > 0
160  PositiveSMeson = 2,
161  /// Mesons with strangeness S < 0
162  NegativeSMeson = 3,
163  /// Non-strange mesons (S = 0) with electric cherge Q > 0
165  /// Non-strange mesons (S = 0) with electric cherge Q < 0
167  /// Neutral non-strange mesons
168  ZeroQZeroSMeson = 6,
169 };
170 
171 /**
172  * The GrandCanThermalizer class implements the following functionality:
173  * 1. Create a lattice and find the local rest frame energy density in each
174  * cell from the particles.
175  * 2. Remove particles from the cells, where the energy density is high enough.
176  * Save the energy, momentum and quantum numbers of the removed particles.
177  * 3. Sample new particles instead of the removed ones according to the
178  * grand-canonical thermal distribution, but with an additional constraint:
179  * the energy, momentum and quantum numbers should be the same as those of
180  * the removed particles.
181  *
182  * The step 3. is a challenging task, so several algorithms are implemented
183  * that try to fulfil the requirements. The algorithms are a trade-off between
184  * mathematical rigour and computational speed. All of them are shown
185  * to reproduce the mean values of multiplicities correctly. However, this
186  * is not the case for multiplicity fluctuations. For details see
187  * \iref{Oliinychenko:2016vkg}.
188  */
190  public:
191  /**
192  * Default constructor for the GranCanThermalizer to allocate the lattice
193  * \param[in] lat_sizes Size of lattice in x,y and z-direction in fm.
194  * \param[in] n_cells Number of cells in x, y and z-direction.
195  * \param[in] origin Coordinates of the left, down, near corner of
196  * the lattice in fm.
197  * \param[in] periodicity Boolean to decide, if the lattice is periodically
198  * extended to infinity or not
199  * \param[in] e_critical Critical energy density above which the cells are
200  * thermalized
201  * \param[in] t_start Starting time of the simulation
202  * \param[in] delta_t Timestep of the simulation
203  * \param[in] algo Choice of algorithm for the canonical sampling
204  * \param[in] BF_microcanonical Enforce energy conservation in BF sampling
205  * algorithms or nor
206  */
207  GrandCanThermalizer(const std::array<double, 3> lat_sizes,
208  const std::array<int, 3> n_cells,
209  const std::array<double, 3> origin, bool periodicity,
210  double e_critical, double t_start, double delta_t,
211  ThermalizationAlgorithm algo, bool BF_microcanonical);
212  /// \see GrandCanThermalizer Exactly the same but taking values from config
214  const std::array<double, 3> lat_sizes,
215  const std::array<double, 3> origin, bool periodicity)
217  lat_sizes, conf.take(InputKeys::forcedThermalization_cellNumber),
218  origin, periodicity,
219  conf.take(InputKeys::forcedThermalization_criticalEDensity),
220  conf.take(InputKeys::forcedThermalization_startTime),
221  conf.take(InputKeys::forcedThermalization_timestep),
222  conf.take(InputKeys::forcedThermalization_algorithm),
223  conf.take(InputKeys::forcedThermalization_microcanonical)) {}
224  /**
225  * Check that the clock is close to n * period of thermalization, since
226  * the thermalization only happens at these times
227  * \param[in] clock Current system time
228  */
229  bool is_time_to_thermalize(std::unique_ptr<Clock>& clock) const {
230  const double t = clock->current_time();
231  const int n = static_cast<int>(std::floor((t - t_start_) / period_));
232  return (t > t_start_ &&
233  t < t_start_ + n * period_ + clock->timestep_duration());
234  }
235  /**
236  * Compute all the thermodynamical quantities on the lattice from particles.
237  * \param[in] ensembles Current list of particles in all ensembles
238  * \see Particles
239  * \see ExperimentParameters
240  * \param[in] par Parameters necessary for density determination
241  * \see DensityParameters
242  * \param[in] ignore_cells_under_threshold Boolean that is true by default
243  */
244  void update_thermalizer_lattice(const std::vector<Particles>& ensembles,
245  const DensityParameters& par,
246  bool ignore_cells_under_threshold = true);
247  /// \return 3 vector uniformly sampled from the rectangular cell.
249  /**
250  * Changes energy and momenta of the particles in plist to match the
251  * required_total_momentum. The procedure is described in
252  * \iref{Oliinychenko:2016vkg}.
253  * \param[in] plist List of particles \see ParticleList
254  * \param[in] required_total_momentum The necessary total momentum of the cell
255  */
256  void renormalize_momenta(ParticleList& plist,
257  const FourVector required_total_momentum);
258 
259  // Functions for BF-sampling algorithm
260 
261  /**
262  * The sample_multinomial function samples integer numbers n_i distributed
263  * according to the multinomial distribution with sum N: \f$ p(n_1, n_2,
264  * \dots) = \prod a_i^{n_i} \times \frac{N!}{n_1!n_2! \dots} \f$ if \f$ \sum
265  * n_i = N \f$ and \f$ p = 0 \f$ otherwise.
266  * \param[in] particle_class A certain group of hadron species \see
267  * HadronClass \param[out] N Number of particles to be sampled
268  */
269  void sample_multinomial(HadronClass particle_class, int N);
270  /**
271  * The total number of particles of species type_index is defined by mult_int_
272  * array that is returned by \see sample_multinomial.
273  * This function samples mult_int_[type_index] particles. It chooses
274  * randomly the cell to sample and picks up momentum and coordinate from the
275  * corresponding distributions.
276  * \param[out] plist \see ParticleList of newly produced particles
277  * \param[in] time Current time in the simulation to become zero component of
278  * sampled particles
279  * \param[in] type_index Species that should be sampled
280  */
281  void sample_in_random_cell_BF_algo(ParticleList& plist, const double time,
282  size_t type_index);
283  /**
284  * Samples particles according to the BF algorithm by making use of the
285  * \see sample_in_random_cell_BF_algo.
286  * Quantum numbers of the sampled particles are required to be equal to the
287  * original particles in this region.
288  * \param[in] conserved_initial The quantum numbers of the total ensemble of
289  * of particles in the region to be thermalized
290  * \param[in] time Current time of the simulation
291  * \param[in] ntest Number of testparticles
292  * \return Particle list with newly sampled particles according to
293  * Becattini-Feroni algorithm
294  */
295  void thermalize_BF_algo(QuantumNumbers& conserved_initial, double time,
296  int ntest);
297 
298  // Functions for mode-sampling algorithm
299 
300  /**
301  * Computes average number of particles in each cell for the mode algorithm.
302  * \param[in] condition Specifies the current mode (1 to 7)
303  */
304  template <typename F>
305  void compute_N_in_cells_mode_algo(F&& condition) {
306  N_in_cells_.clear();
307  N_total_in_cells_ = 0.0;
308  for (auto cell_index : cells_to_sample_) {
309  const ThermLatticeNode cell = (*lat_)[cell_index];
310  const double gamma = 1.0 / std::sqrt(1.0 - cell.v().sqr());
311  double N_tot = 0.0;
312  for (ParticleTypePtr i : eos_typelist_) {
313  if (condition(i->strangeness(), i->baryon_number(), i->charge())) {
314  // N_i = n u^mu dsigma_mu = (isochronous hypersurface) n * V * gamma
315  N_tot += lat_cell_volume_ * gamma *
316  HadronGasEos::partial_density(*i, cell.T(), cell.mub(),
317  cell.mus(), 0.0);
318  }
319  }
320  N_in_cells_.push_back(N_tot);
321  N_total_in_cells_ += N_tot;
322  }
323  }
324 
325  /**
326  * Samples one particle and the species, cell, momentum and coordinate
327  * are chosen from the corresponding distributions. The condition
328  * function limits the choice of possible species.
329  *
330  * Condition is a function of the signature of quantum number S, B and Q.
331  * bool condition(int strangeness, int baryon_number, int charge);
332  * \param[in] time Current time in simulation
333  * \param[in] condition Specifies the actual mode (1 to 7)
334  * \param[in] spin_interaction_type Type of spin interactions to be considered
335  */
336  template <typename F>
338  const double time, F&& condition,
339  SpinInteractionType spin_interaction_type = SpinInteractionType::Off) {
340  // Choose random cell, probability = N_in_cell/N_total
341  double r = random::uniform(0.0, N_total_in_cells_);
342  double partial_sum = 0.0;
343  int index_only_thermalized = -1;
344  while (partial_sum < r) {
345  index_only_thermalized++;
346  partial_sum += N_in_cells_[index_only_thermalized];
347  }
348  const int cell_index = cells_to_sample_[index_only_thermalized];
349  const ThermLatticeNode cell = (*lat_)[cell_index];
350  const ThreeVector cell_center = lat_->cell_center(cell_index);
351  const double gamma = 1.0 / std::sqrt(1.0 - cell.v().sqr());
352  const double N_in_cell = N_in_cells_[index_only_thermalized];
353  // Which sort to sample - probability N_i/N_tot
354  r = random::uniform(0.0, N_in_cell);
355  double N_sum = 0.0;
356  ParticleTypePtr type_to_sample;
357  for (ParticleTypePtr i : eos_typelist_) {
358  if (!condition(i->strangeness(), i->baryon_number(), i->charge())) {
359  continue;
360  }
361  N_sum += lat_cell_volume_ * gamma *
362  HadronGasEos::partial_density(*i, cell.T(), cell.mub(),
363  cell.mus(), 0.0);
364  if (N_sum >= r) {
365  type_to_sample = i;
366  break;
367  }
368  }
369  ParticleData particle(*type_to_sample);
370  // Note: it's pole mass for resonances!
371  const double m = type_to_sample->mass();
372  // Position
373  particle.set_4position(FourVector(time, cell_center + uniform_in_cell()));
374  // Momentum
375  double momentum_radial = sample_momenta_from_thermal(cell.T(), m);
376  Angles phitheta;
377  phitheta.distribute_isotropically();
378  particle.set_4momentum(m, phitheta.threevec() * momentum_radial);
379  particle.boost_momentum(-cell.v());
380  particle.set_formation_time(time);
381  if (spin_interaction_type != SpinInteractionType::Off) {
382  particle.set_unpolarized_spin_vector();
383  }
384  return particle;
385  }
386 
387  /**
388  * Samples particles to the according to the mode algorithm.
389  * Quantum numbers of the sampled particles are required to be as in
390  * conserved_initial.
391  * \param[in] conserved_initial Quantum numbers of the original particles
392  * in the region to be thermalized
393  * \param[in] time Current time of the simulation
394  * \param[in] spin_interaction_type Type of spin interactions to be considered
395  */
397  QuantumNumbers& conserved_initial, double time,
398  SpinInteractionType spin_interaction_type = SpinInteractionType::Off);
399  /**
400  * Main thermalize function, that chooses the algorithm to follow
401  * (BF or mode sampling).
402  * \param[out] particles List of sampled particles in thermalized region
403  * \param[in] time Current time of the simulation
404  * \param[in] ntest number of testparticles
405  * \param[in] spin_interaction_type Type of spin interactions to be considered
406  */
407  void thermalize(
408  const Particles& particles, double time, int ntest,
409  SpinInteractionType spin_interaction_type = SpinInteractionType::Off);
410 
411  /**
412  * Generates standard output with information about the thermodynamic
413  * properties of the lattice, the thermalized region and the volume to
414  * be thermalized above the critical energy density
415  * \param[in] clock Current time of the simulation
416  */
417  void print_statistics(const Clock& clock) const;
418  /// Getter function for the lattice
420  /// Get the critical energy density
421  double e_crit() const { return e_crit_; }
422  /// List of particles to be removed from the simulation
423  ParticleList particles_to_remove() const { return to_remove_; }
424  /// List of newly created particles to be inserted in the simulation
425  ParticleList particles_to_insert() const { return sampled_list_; }
426 
427  private:
428  /**
429  * Extracts the particles in the hadron gas equation of state from the
430  * complete list of particle types in SMASH
431  */
432  ParticleTypePtrList list_eos_particles() const {
433  ParticleTypePtrList res;
434  for (const ParticleType& ptype : ParticleType::list_all()) {
435  if (HadronGasEos::is_eos_particle(ptype)) {
436  res.push_back(&ptype);
437  }
438  }
439  return res;
440  }
441  /**
442  * Defines the class of hadrons by quantum numbers
443  * \param[in] typelist_index Index for a certain quantum number
444  */
445  HadronClass get_class(size_t typelist_index) const {
446  const int B = eos_typelist_[typelist_index]->baryon_number();
447  const int S = eos_typelist_[typelist_index]->strangeness();
448  const int ch = eos_typelist_[typelist_index]->charge();
449  // clang-format off
450  return (B > 0) ? HadronClass::Baryon :
451  (B < 0) ? HadronClass::Antibaryon :
457  // clang-format on
458  }
459  /// \param[out] cl Multiplicity of the hadron class
460  double mult_class(const HadronClass cl) const {
461  return mult_classes_[static_cast<size_t>(cl)];
462  }
463  /// Number of particles to be sampled in one cell
464  std::vector<double> N_in_cells_;
465  /// Cells above critical energy density
466  std::vector<size_t> cells_to_sample_;
467  /// Hadron gas equation of state
469  /// The lattice on which the thermodynamic quantities are calculated
470  std::unique_ptr<RectangularLattice<ThermLatticeNode>> lat_;
471  /// Particles to be removed after this thermalization step
472  ParticleList to_remove_;
473  /// Newly generated particles by thermalizer
474  ParticleList sampled_list_;
475  /**
476  * List of particle types from which equation of state is computed.
477  * Most particles are included, but not all of them.
478  * For example, photons and leptons are not included. Heavy hadrons, that
479  * can originate from Pythia, but do not interact in SMASH are not included.
480  * The latter are excluded to avoid violations of charm and bottomness
481  * conservation, when HadronGasEoS is used for forced thermalization.
482  */
483  const ParticleTypePtrList eos_typelist_;
484  /// Number of different species to be sampled
485  const size_t N_sorts_;
486  /// Real number multiplicity for each particle type
487  std::vector<double> mult_sort_;
488  /// Integer multiplicity for each particle type
489  std::vector<int> mult_int_;
490  /**
491  * The different hadron species according to the enum defined
492  * in \see HadronClass
493  */
494  std::array<double, 7> mult_classes_;
495  /// Total number of particles over all cells in thermalization region
497  /**
498  * Volume of a single lattice cell, necessary to convert thermal densities to
499  * actual particle numbers
500  */
502  /// Critical energy density above which cells are thermalized
503  const double e_crit_;
504  /// Starting time of the simulation
505  const double t_start_;
506  /// Defines periodicity of the lattice in fm
507  const double period_;
508  /// Algorithm to choose for sampling of particles obeying conservation laws
510  /// Enforce energy conservation as part of BF sampling algorithm or not
512 };
513 
514 } // namespace smash
515 
516 #endif // SRC_INCLUDE_SMASH_GRANDCAN_THERMALIZER_H_
Angles provides a common interface for generating directions: i.e., two angles that should be interpr...
Definition: angles.h:59
ThreeVector threevec() const
Definition: angles.h:288
void distribute_isotropically()
Populate the object with a new direction.
Definition: angles.h:199
Clock tracks the time in the simulation.
Definition: clock.h:87
Interface to the SMASH configuration files.
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:92
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
The GrandCanThermalizer class implements the following functionality:
void thermalize_BF_algo(QuantumNumbers &conserved_initial, double time, int ntest)
Samples particles according to the BF algorithm by making use of the.
void compute_N_in_cells_mode_algo(F &&condition)
Computes average number of particles in each cell for the mode algorithm.
void print_statistics(const Clock &clock) const
Generates standard output with information about the thermodynamic properties of the lattice,...
void thermalize_mode_algo(QuantumNumbers &conserved_initial, double time, SpinInteractionType spin_interaction_type=SpinInteractionType::Off)
Samples particles to the according to the mode algorithm.
std::vector< double > mult_sort_
Real number multiplicity for each particle type.
std::vector< int > mult_int_
Integer multiplicity for each particle type.
GrandCanThermalizer(Configuration &conf, const std::array< double, 3 > lat_sizes, const std::array< double, 3 > origin, bool periodicity)
HadronGasEos eos_
Hadron gas equation of state.
ParticleList to_remove_
Particles to be removed after this thermalization step.
const bool BF_enforce_microcanonical_
Enforce energy conservation as part of BF sampling algorithm or not.
ThreeVector uniform_in_cell() const
std::unique_ptr< RectangularLattice< ThermLatticeNode > > lat_
The lattice on which the thermodynamic quantities are calculated.
ParticleList particles_to_insert() const
List of newly created particles to be inserted in the simulation.
double mult_class(const HadronClass cl) const
void thermalize(const Particles &particles, double time, int ntest, SpinInteractionType spin_interaction_type=SpinInteractionType::Off)
Main thermalize function, that chooses the algorithm to follow (BF or mode sampling).
ParticleList particles_to_remove() const
List of particles to be removed from the simulation.
HadronClass get_class(size_t typelist_index) const
Defines the class of hadrons by quantum numbers.
GrandCanThermalizer(const std::array< double, 3 > lat_sizes, const std::array< int, 3 > n_cells, const std::array< double, 3 > origin, bool periodicity, double e_critical, double t_start, double delta_t, ThermalizationAlgorithm algo, bool BF_microcanonical)
Default constructor for the GranCanThermalizer to allocate the lattice.
const double t_start_
Starting time of the simulation.
const double period_
Defines periodicity of the lattice in fm.
ParticleTypePtrList list_eos_particles() const
Extracts the particles in the hadron gas equation of state from the complete list of particle types i...
const double e_crit_
Critical energy density above which cells are thermalized.
ParticleList sampled_list_
Newly generated particles by thermalizer.
std::array< double, 7 > mult_classes_
The different hadron species according to the enum defined in.
void sample_in_random_cell_BF_algo(ParticleList &plist, const double time, size_t type_index)
The total number of particles of species type_index is defined by mult_int_ array that is returned by...
void update_thermalizer_lattice(const std::vector< Particles > &ensembles, const DensityParameters &par, bool ignore_cells_under_threshold=true)
Compute all the thermodynamical quantities on the lattice from particles.
std::vector< size_t > cells_to_sample_
Cells above critical energy density.
const ThermalizationAlgorithm algorithm_
Algorithm to choose for sampling of particles obeying conservation laws.
bool is_time_to_thermalize(std::unique_ptr< Clock > &clock) const
Check that the clock is close to n * period of thermalization, since the thermalization only happens ...
RectangularLattice< ThermLatticeNode > & lattice() const
Getter function for the lattice.
double e_crit() const
Get the critical energy density.
const ParticleTypePtrList eos_typelist_
List of particle types from which equation of state is computed.
std::vector< double > N_in_cells_
Number of particles to be sampled in one cell.
double lat_cell_volume_
Volume of a single lattice cell, necessary to convert thermal densities to actual particle numbers.
ParticleData sample_in_random_cell_mode_algo(const double time, F &&condition, SpinInteractionType spin_interaction_type=SpinInteractionType::Off)
Samples one particle and the species, cell, momentum and coordinate are chosen from the corresponding...
const size_t N_sorts_
Number of different species to be sampled.
double N_total_in_cells_
Total number of particles over all cells in thermalization region.
void renormalize_momenta(ParticleList &plist, const FourVector required_total_momentum)
Changes energy and momenta of the particles in plist to match the required_total_momentum.
void sample_multinomial(HadronClass particle_class, int N)
The sample_multinomial function samples integer numbers n_i distributed according to the multinomial ...
Class to handle the equation of state (EoS) of the hadron gas, consisting of all hadrons included in ...
Definition: hadgas_eos.h:124
static double partial_density(const ParticleType &ptype, double T, double mub, double mus, double muq, bool account_for_resonance_widths=false)
Compute partial density of one hadron sort.
Definition: hadgas_eos.cc:273
static bool is_eos_particle(const ParticleType &ptype)
Check if a particle belongs to the EoS.
Definition: hadgas_eos.h:354
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:59
void set_4momentum(const FourVector &momentum_vector)
Set the particle's 4-momentum directly.
Definition: particledata.h:177
void set_4position(const FourVector &pos)
Set the particle's 4-position directly.
Definition: particledata.h:222
void set_formation_time(double form_time)
Set the absolute formation time.
Definition: particledata.h:264
void boost_momentum(const ThreeVector &v)
Apply a Lorentz-boost to only the momentum.
Definition: particledata.h:352
void set_unpolarized_spin_vector()
Set the 4 components of the spin vector such that the particle is unpolarized.
Definition: particledata.cc:92
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:731
Particle type contains the static properties of a particle species.
Definition: particletype.h:100
static const ParticleTypeList & list_all()
Definition: particletype.cc:51
double mass() const
Definition: particletype.h:147
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
A container for storing conserved values.
A container class to hold all the arrays on the lattice and access them.
Definition: lattice.h:49
The ThermLatticeNode class is intended to compute thermodynamical quantities in a cell given a set of...
void compute_rest_frame_quantities(HadronGasEos &eos)
Temperature, chemical potentials and rest frame velocity are calculated given the hadron gas equation...
double muq() const
Get the net charge chemical potential.
FourVector Tmu0() const
Get Four-momentum flow of the cell.
double ns_
Net strangeness density of the cell in the computational frame.
void set_rest_frame_quantities(double T0, double mub0, double mus0, double muq0, const ThreeVector v0)
Set all the rest frame quantities to some values, this is useful for testing.
double p() const
Get pressure in the rest frame.
double p_
Pressure in the rest frame.
double mus_
Net strangeness chemical potential.
ThreeVector v() const
Get 3-velocity of the rest frame.
double ns() const
Get net strangeness density of the cell in the computational frame.
double e_
Energy density in the rest frame.
double nb_
Net baryon density of the cell in the computational frame.
void add_particle(const ParticleData &p, double factor)
Add particle contribution to Tmu0, nb, ns and nq May look like unused at first glance,...
double muq_
Net charge chemical potential.
void add_particle_for_derivatives(const ParticleData &, double, ThreeVector)
dummy function for update_lattice
double nq() const
Get net charge density of the cell in the computational frame.
double mub_
Net baryon chemical potential.
FourVector Tmu0_
Four-momentum flow of the cell.
double mus() const
Get the net strangeness chemical potential.
ThreeVector v_
Velocity of the rest frame.
ThermLatticeNode()
Default constructor of thermal quantities on the lattice returning thermodynamic quantities in comput...
double mub() const
Get the net baryon chemical potential.
double nb() const
Get net baryon density of the cell in the computational frame.
double nq_
Net charge density of the cell in the computational frame.
double e() const
Get energy density in the rest frame.
double T() const
Get the temperature.
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
double sqr() const
Definition: threevector.h:275
ThermalizationAlgorithm
Defines the algorithm used for the forced thermalization.
SpinInteractionType
Possible spin interaction types.
@ Off
No spin interactions.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:546
constexpr int n
Neutron.
T uniform(T min, T max)
Definition: random.h:91
Definition: action.h:24
double sample_momenta_from_thermal(const double temperature, const double mass)
Samples a momentum from the Maxwell-Boltzmann (thermal) distribution in a faster way,...
HadronClass
Specifier to classify the different hadron species according to their quantum numbers.
@ Antibaryon
All anti-baryons.
@ ZeroQZeroSMeson
Neutral non-strange mesons.
@ NegativeSMeson
Mesons with strangeness S < 0.
@ NegativeQZeroSMeson
Non-strange mesons (S = 0) with electric cherge Q < 0.
@ PositiveSMeson
Mesons with strangeness S > 0.
@ Baryon
All baryons.
@ PositiveQZeroSMeson
Non-strange mesons (S = 0) with electric cherge Q > 0.
#define S(x, n)
Definition: sha256.cc:54
A container to keep track of all ever existed input keys.
Definition: input_keys.h:1255