  | 
  
     Version: SMASH-2.0 
   | 
           
 | 
 
 
 
 
#include <grandcan_thermalizer.h>
The GrandCanThermalizer class implements the following functionality: 
- Create a lattice and find the local rest frame energy density in each cell from the particles.
 
- Remove particles from the cells, where the energy density is high enough. Save the energy, momentum and quantum numbers of the removed particles.
 
- Sample new particles instead of the removed ones according to the grand-canonical thermal distribution, but with an additional constraint: the energy, momentum and quantum numbers should be the same as those of the removed particles.
 
The step 3. is a challenging task, so several algorithms are implemented that try to fulfil the requirements. The algorithms are a trade-off between mathematical rigour and computational speed. All of them are shown to reproduce the mean values of multiplicities correctly. However, this is not the case for multiplicity fluctuations. For details see Oliinychenko:2016vkg [36]. 
Definition at line 227 of file grandcan_thermalizer.h.
 
 | 
|   | 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.  More...
  | 
|   | 
|   | GrandCanThermalizer (Configuration &conf, const std::array< double, 3 > lat_sizes, const std::array< double, 3 > origin, bool periodicity) | 
|   | 
| 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 at these times.  More...
  | 
|   | 
| void  | update_thermalizer_lattice (const Particles &particles, const DensityParameters &par, bool ignore_cells_under_threshold=true) | 
|   | Compute all the thermodynamical quantities on the lattice from particles.  More...
  | 
|   | 
| ThreeVector  | uniform_in_cell () const | 
|   | 
| 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.  More...
  | 
|   | 
| void  | sample_multinomial (HadronClass particle_class, int N) | 
|   | The sample_multinomial function samples integer numbers n_i distributed according to the multinomial distribution with sum N: \( p(n_1, n_2, \dots) = \prod a_i^{n_i} \times \frac{N!}{n_1!n_2! \dots} \) if \( \sum n_i = N \) and \( p = 0 \) otherwise.  More...
  | 
|   | 
| 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.  More...
  | 
|   | 
| void  | thermalize_BF_algo (QuantumNumbers &conserved_initial, double time, int ntest) | 
|   | Samples particles according to the BF algorithm by making use of the.  More...
  | 
|   | 
| template<typename F >  | 
| void  | compute_N_in_cells_mode_algo (F &&condition) | 
|   | Computes average number of particles in each cell for the mode algorithm.  More...
  | 
|   | 
| template<typename F >  | 
| ParticleData  | sample_in_random_cell_mode_algo (const double time, F &&condition) | 
|   | Samples one particle and the species, cell, momentum and coordinate are chosen from the corresponding distributions.  More...
  | 
|   | 
| void  | thermalize_mode_algo (QuantumNumbers &conserved_initial, double time) | 
|   | Samples particles to the according to the mode algorithm.  More...
  | 
|   | 
| void  | thermalize (const Particles &particles, double time, int ntest) | 
|   | Main thermalize function, that chooses the algorithm to follow (BF or mode sampling).  More...
  | 
|   | 
| void  | print_statistics (const Clock &clock) const | 
|   | Generates standard output with information about the thermodynamic properties of the lattice, the thermalized region and the volume to be thermalized above the critical energy density.  More...
  | 
|   | 
| RectangularLattice< ThermLatticeNode > &  | lattice () const | 
|   | Getter function for the lattice.  More...
  | 
|   | 
| double  | e_crit () const | 
|   | Get the critical energy density.  More...
  | 
|   | 
| ParticleList  | particles_to_remove () const | 
|   | List of particles to be removed from the simulation.  More...
  | 
|   | 
| ParticleList  | particles_to_insert () const | 
|   | List of newly created particles to be inserted in the simulation.  More...
  | 
|   | 
◆ GrandCanThermalizer() [1/2]
      
        
          | smash::GrandCanThermalizer::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. 
- Parameters
 - 
  
    | [in] | lat_sizes | Size of lattice in x,y and z-direction in fm.  | 
    | [in] | n_cells | Number of cells in x, y and z-direction.  | 
    | [in] | origin | Coordinates of the left, down, near corner of the lattice in fm.  | 
    | [in] | periodicity | Boolean to decide, if the lattice is periodically extended to infinity or not  | 
    | [in] | e_critical | Critical energy density above which the cells are thermalized  | 
    | [in] | t_start | Starting time of the simulation  | 
    | [in] | delta_t | Timestep of the simulation  | 
    | [in] | algo | Choice of algorithm for the canonical sampling  | 
    | [in] | BF_microcanonical | Enforce energy conservation in BF sampling algorithms or nor  | 
  
   
Definition at line 106 of file grandcan_thermalizer.cc.
  121   lat_ = make_unique<RectangularLattice<ThermLatticeNode>>(
 
  122       lat_sizes, n_cells, origin, periodicity, upd);
 
  123   const std::array<double, 3> abc = 
lat_->cell_sizes();
 
 
 
 
◆ GrandCanThermalizer() [2/2]
  
  
      
        
          | smash::GrandCanThermalizer::GrandCanThermalizer  | 
          ( | 
          Configuration &  | 
          conf,  | 
         
        
           | 
           | 
          const std::array< double, 3 >  | 
          lat_sizes,  | 
         
        
           | 
           | 
          const std::array< double, 3 >  | 
          origin,  | 
         
        
           | 
           | 
          bool  | 
          periodicity  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
- See also
 - GrandCanThermalizer Exactly the same but taking values from config 
 
Definition at line 251 of file grandcan_thermalizer.h.
  255             lat_sizes, conf.take({
"Cell_Number"}), origin, periodicity,
 
  256             conf.take({
"Critical_Edens"}), conf.take({
"Start_Time"}),
 
  257             conf.take({
"Timestep"}),
 
  259             conf.take({
"Microcanonical"}, 
false)) {}
 
 
 
 
◆ is_time_to_thermalize()
  
  
      
        
          | bool smash::GrandCanThermalizer::is_time_to_thermalize  | 
          ( | 
          std::unique_ptr< Clock > &  | 
          clock | ) | 
           const | 
         
       
   | 
  
inline   | 
  
 
Check that the clock is close to n * period of thermalization, since the thermalization only happens at these times. 
- Parameters
 - 
  
    | [in] | clock | Current system time  | 
  
   
Definition at line 265 of file grandcan_thermalizer.h.
  266     const double t = clock->current_time();
 
  269             t < t_start_ + n * period_ + clock->timestep_duration());
 
 
 
 
◆ update_thermalizer_lattice()
      
        
          | void smash::GrandCanThermalizer::update_thermalizer_lattice  | 
          ( | 
          const Particles &  | 
          particles,  | 
        
        
           | 
           | 
          const DensityParameters &  | 
          par,  | 
        
        
           | 
           | 
          bool  | 
          ignore_cells_under_threshold = true  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Compute all the thermodynamical quantities on the lattice from particles. 
- Parameters
 - 
  
    | [in] | particles | Current list of particles  | 
  
   
- See also
 - Particles 
 
- Parameters
 - 
  
    | [in] | par | Parameters necessary for density determination  | 
  
   
- See also
 - DensityParameters 
 
- Parameters
 - 
  
    | [in] | ignore_cells_under_threshold | Boolean that is true by default  | 
  
   
Definition at line 130 of file grandcan_thermalizer.cc.
  136   for (
auto &node : *
lat_) {
 
  140     if (!ignore_cells_under_treshold ||
 
  141         node.Tmu0().x0() + std::abs(node.Tmu0().x1()) +
 
  142                 std::abs(node.Tmu0().x2()) + std::abs(node.Tmu0().x3()) >=
 
  144       node.compute_rest_frame_quantities(
eos_);
 
  146       node = ThermLatticeNode();
 
 
 
 
◆ uniform_in_cell()
      
        
          | ThreeVector smash::GrandCanThermalizer::uniform_in_cell  | 
          ( | 
           | ) | 
           const | 
        
      
 
- Returns
 - 3 vector uniformly sampled from the rectangular cell. 
 
Definition at line 151 of file grandcan_thermalizer.cc.
  153                                      +0.5 * 
lat_->cell_sizes()[0]),
 
  155                                      +0.5 * 
lat_->cell_sizes()[1]),
 
  157                                      +0.5 * 
lat_->cell_sizes()[2]));
 
 
 
 
◆ renormalize_momenta()
      
        
          | void smash::GrandCanThermalizer::renormalize_momenta  | 
          ( | 
          ParticleList &  | 
          plist,  | 
        
        
           | 
           | 
          const FourVector  | 
          required_total_momentum  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Changes energy and momenta of the particles in plist to match the required_total_momentum. 
The procedure is described in Oliinychenko:2016vkg [36]. 
- Parameters
 - 
  
    | [in] | plist | List of particles  | 
  
   
- See also
 - ParticleList 
 
- Parameters
 - 
  
    | [in] | required_total_momentum | The necessary total momentum of the cell  | 
  
   
Definition at line 160 of file grandcan_thermalizer.cc.
  163   QuantumNumbers conserved = QuantumNumbers(plist);
 
  165                                   required_total_momentum);
 
  167   const ThreeVector mom_to_add =
 
  168       (required_total_momentum.threevec() - conserved.momentum().threevec()) /
 
  171   for (
auto &particle : plist) {
 
  172     particle.set_4momentum(particle.type().mass(),
 
  173                            particle.momentum().threevec() + mom_to_add);
 
  177   conserved = QuantumNumbers(plist);
 
  178   const ThreeVector beta_CM_generated = conserved.momentum().velocity();
 
  179   const ThreeVector beta_CM_required = required_total_momentum.velocity();
 
  182   double E_expected = required_total_momentum.abs();
 
  183   for (
auto &particle : plist) {
 
  184     particle.boost_momentum(beta_CM_generated);
 
  185     E += particle.momentum().x0();
 
  189   double a, a_min, a_max, er;
 
  190   const int max_iter = 100;
 
  192   if (E_expected >= E) {
 
  200     a = 0.5 * (a_min + a_max);
 
  202     for (
const auto &particle : plist) {
 
  203       const double p2 = particle.momentum().threevec().sqr();
 
  204       const double E2 = particle.momentum().x0() * particle.momentum().x0();
 
  205       E += std::sqrt(E2 + a * (a + 2.0) * p2);
 
  216   } 
while (std::abs(er) > tolerance && iter < max_iter);
 
  220   for (
auto &particle : plist) {
 
  221     particle.set_4momentum(particle.type().mass(),
 
  222                            (1 + a) * particle.momentum().threevec());
 
  223     particle.boost_momentum(-beta_CM_required);
 
 
 
 
◆ sample_multinomial()
      
        
          | void smash::GrandCanThermalizer::sample_multinomial  | 
          ( | 
          HadronClass  | 
          particle_class,  | 
        
        
           | 
           | 
          int  | 
          N  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
The sample_multinomial function samples integer numbers n_i distributed according to the multinomial distribution with sum N: \( p(n_1, n_2, \dots) = \prod a_i^{n_i} \times \frac{N!}{n_1!n_2! \dots} \) if \( \sum n_i = N \) and \( p = 0 \) otherwise. 
- Parameters
 - 
  
    | [in] | particle_class | A certain group of hadron species  | 
  
   
- See also
 - HadronClass
 
- Parameters
 - 
  
    | [out] | N | Number of particles to be sampled  | 
  
   
- Todo:
 - (oliiny) what to do with this output? 
 
Definition at line 227 of file grandcan_thermalizer.cc.
  234   for (
size_t i_type = 0; (i_type < 
N_sorts_) && (N_to_sample > 0); i_type++) {
 
  235     if (
get_class(i_type) != particle_class) {
 
 
 
 
◆ sample_in_random_cell_BF_algo()
      
        
          | void smash::GrandCanThermalizer::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. 
- See also
 - sample_multinomial. This function samples mult_int_[type_index] particles. It chooses randomly the cell to sample and picks up momentum and coordinate from the corresponding distributions. 
 
- Parameters
 - 
  
  
 
- See also
 - ParticleList of newly produced particles 
 
- Parameters
 - 
  
    | [in] | time | Current time in the simulation to become zero component of sampled particles  | 
    | [in] | type_index | Species that should be sampled  | 
  
   
Definition at line 252 of file grandcan_thermalizer.cc.
  258     const ThermLatticeNode cell = (*lat_)[cell_index];
 
  259     const double gamma = 1.0 / std::sqrt(1.0 - cell.v().sqr());
 
  260     const double N_this_cell =
 
  263                                       cell.mub(), cell.mus(), cell.muq());
 
  268   for (
int i = 0; i < 
mult_int_[type_index]; i++) {
 
  271     double partial_sum = 0.0;
 
  272     int index_only_thermalized = -1;
 
  273     while (partial_sum < r) {
 
  274       index_only_thermalized++;
 
  275       partial_sum += 
N_in_cells_[index_only_thermalized];
 
  278     const ThermLatticeNode cell = (*lat_)[cell_index];
 
  279     const ThreeVector cell_center = 
lat_->cell_center(cell_index);
 
  285     particle.set_4position(FourVector(time, cell_center + 
uniform_in_cell()));
 
  289     phitheta.distribute_isotropically();
 
  290     particle.set_4momentum(m, phitheta.threevec() * momentum_radial);
 
  291     particle.boost_momentum(-cell.v());
 
  292     particle.set_formation_time(time);
 
  294     plist.push_back(particle);
 
 
 
 
◆ thermalize_BF_algo()
      
        
          | void smash::GrandCanThermalizer::thermalize_BF_algo  | 
          ( | 
          QuantumNumbers &  | 
          conserved_initial,  | 
        
        
           | 
           | 
          double  | 
          time,  | 
        
        
           | 
           | 
          int  | 
          ntest  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Samples particles according to the BF algorithm by making use of the. 
- See also
 - sample_in_random_cell_BF_algo. Quantum numbers of the sampled particles are required to be equal to the original particles in this region. 
 
- Parameters
 - 
  
    | [in] | conserved_initial | The quantum numbers of the total ensemble of of particles in the region to be thermalized  | 
    | [in] | time | Current time of the simulation  | 
    | [in] | ntest | Number of testparticles  | 
  
   
- Returns
 - Particle list with newly sampled particles according to Becattini-Feroni algorithm 
 
Definition at line 298 of file grandcan_thermalizer.cc.
  302     const ThermLatticeNode cell = (*lat_)[cell_index];
 
  303     const double gamma = 1.0 / std::sqrt(1.0 - cell.v().sqr());
 
  304     for (
size_t i = 0; i < 
N_sorts_; i++) {
 
  309                                         cell.mus(), cell.muq());
 
  314   for (
size_t i = 0; i < 
N_sorts_; i++) {
 
  320                                          conserved_initial.baryon_number());
 
  325     const auto Nbar_antibar = bessel_sampler_B.sample();
 
  332     for (
size_t i = 0; i < 
N_sorts_; i++) {
 
  336     std::pair<int, int> NS_antiS;
 
  338       random::BesselSampler bessel_sampler_S(
 
  341           conserved_initial.strangeness() - S_sampled);
 
  342       NS_antiS = bessel_sampler_S.sample();
 
  344       NS_antiS = std::make_pair(
 
  347       if (NS_antiS.first - NS_antiS.second !=
 
  348           conserved_initial.strangeness() - S_sampled) {
 
  357     for (
size_t i = 0; i < 
N_sorts_; i++) {
 
  361     std::pair<int, int> NC_antiC;
 
  363       random::BesselSampler bessel_sampler_C(
 
  366           conserved_initial.charge() - ch_sampled);
 
  367       NC_antiC = bessel_sampler_C.sample();
 
  369       NC_antiC = std::make_pair(
 
  372       if (NC_antiC.first - NC_antiC.second !=
 
  373           conserved_initial.charge() - ch_sampled) {
 
  384     for (
size_t itype = 0; itype < 
N_sorts_; itype++) {
 
  389       const double e_init = conserved_initial.momentum().x0();
 
  392         e_tot += particle.momentum().x0();
 
  394       if (std::abs(e_tot - e_init) > 0.01 * e_init) {
 
  396                                         " too far from ", e_init);
 
 
 
 
◆ compute_N_in_cells_mode_algo()
template<typename F > 
  
  
      
        
          | void smash::GrandCanThermalizer::compute_N_in_cells_mode_algo  | 
          ( | 
          F &&  | 
          condition | ) | 
           | 
         
       
   | 
  
inline   | 
  
 
Computes average number of particles in each cell for the mode algorithm. 
- Parameters
 - 
  
    | [in] | condition | Specifies the current mode (1 to 7)  | 
  
   
Definition at line 339 of file grandcan_thermalizer.h.
  343       const ThermLatticeNode cell = (*lat_)[cell_index];
 
  344       const double gamma = 1.0 / std::sqrt(1.0 - cell.v().sqr());
 
  347         if (condition(i->strangeness(), i->baryon_number(), i->charge())) {
 
 
 
 
◆ sample_in_random_cell_mode_algo()
template<typename F > 
  
  
      
        
          | ParticleData smash::GrandCanThermalizer::sample_in_random_cell_mode_algo  | 
          ( | 
          const double  | 
          time,  | 
         
        
           | 
           | 
          F &&  | 
          condition  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
inline   | 
  
 
Samples one particle and the species, cell, momentum and coordinate are chosen from the corresponding distributions. 
The condition function limits the choice of possible species.
Condition is a function of the signature of quantum number S, B and Q. bool condition(int strangeness, int baryon_number, int charge); 
- Parameters
 - 
  
    | [in] | time | Current time in simulation  | 
    | [in] | condition | Specifies the actual mode (1 to 7)  | 
  
   
Definition at line 370 of file grandcan_thermalizer.h.
  374     double partial_sum = 0.0;
 
  375     int index_only_thermalized = -1;
 
  376     while (partial_sum < r) {
 
  377       index_only_thermalized++;
 
  378       partial_sum += 
N_in_cells_[index_only_thermalized];
 
  381     const ThermLatticeNode cell = (*lat_)[cell_index];
 
  382     const ThreeVector cell_center = 
lat_->cell_center(cell_index);
 
  383     const double gamma = 1.0 / std::sqrt(1.0 - cell.v().sqr());
 
  384     const double N_in_cell = 
N_in_cells_[index_only_thermalized];
 
  388     ParticleTypePtr type_to_sample;
 
  390       if (!condition(i->strangeness(), i->baryon_number(), i->charge())) {
 
  401     ParticleData particle(*type_to_sample);
 
  403     const double m = type_to_sample->mass();
 
  405     particle.set_4position(FourVector(time, cell_center + 
uniform_in_cell()));
 
  409     phitheta.distribute_isotropically();
 
  410     particle.set_4momentum(m, phitheta.threevec() * momentum_radial);
 
  411     particle.boost_momentum(-cell.v());
 
  412     particle.set_formation_time(time);
 
 
 
 
◆ thermalize_mode_algo()
      
        
          | void smash::GrandCanThermalizer::thermalize_mode_algo  | 
          ( | 
          QuantumNumbers &  | 
          conserved_initial,  | 
        
        
           | 
           | 
          double  | 
          time  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Samples particles to the according to the mode algorithm. 
Quantum numbers of the sampled particles are required to be as in conserved_initial. 
- Parameters
 - 
  
    | [in] | conserved_initial | Quantum numbers of the original particles in the region to be thermalized  | 
    | [in] | time | Current time of the simulation  | 
  
   
Definition at line 404 of file grandcan_thermalizer.cc.
  407   int S_plus = 0, S_minus = 0, B_plus = 0, B_minus = 0, E_plus = 0, E_minus = 0;
 
  409   auto condition1 = [](int, int, int) { 
return true; };
 
  411   while (conserved_initial.momentum().x0() > energy ||
 
  412          S_plus < conserved_initial.strangeness()) {
 
  414     energy += 
p.momentum().x0();
 
  415     if (
p.pdgcode().strangeness() > 0) {
 
  417       S_plus += 
p.pdgcode().strangeness();
 
  422   auto condition2 = [](
int S, int, int) { 
return (
S < 0); };
 
  424   while (S_plus + S_minus > conserved_initial.strangeness()) {
 
  426     const int s_part = 
p.pdgcode().strangeness();
 
  428     if (S_plus + S_minus + s_part >= conserved_initial.strangeness()) {
 
  435   auto condition3 = [](
int S, int, int) { 
return (
S == 0); };
 
  436   QuantumNumbers conserved_remaining =
 
  440   while (conserved_remaining.momentum().x0() > energy ||
 
  441          B_plus < conserved_remaining.baryon_number()) {
 
  443     energy += 
p.momentum().x0();
 
  444     if (
p.pdgcode().baryon_number() > 0) {
 
  446       B_plus += 
p.pdgcode().baryon_number();
 
  451   auto condition4 = [](
int S, 
int B, int) { 
return (
S == 0) && (B < 0); };
 
  453   while (B_plus + B_minus > conserved_remaining.baryon_number()) {
 
  455     const int bar = 
p.pdgcode().baryon_number();
 
  456     if (B_plus + B_minus + bar >= conserved_remaining.baryon_number()) {
 
  463   auto condition5 = [](
int S, 
int B, int) { 
return (
S == 0) && (B == 0); };
 
  464   conserved_remaining = conserved_initial - QuantumNumbers(
sampled_list_);
 
  467   while (conserved_remaining.momentum().x0() > energy ||
 
  468          E_plus < conserved_remaining.charge()) {
 
  470     energy += 
p.momentum().x0();
 
  471     if (
p.pdgcode().charge() > 0) {
 
  473       E_plus += 
p.pdgcode().charge();
 
  478   auto condition6 = [](
int S, 
int B, 
int C) {
 
  479     return (
S == 0) && (B == 0) && (C < 0);
 
  482   while (E_plus + E_minus > conserved_remaining.charge()) {
 
  484     const int charge = 
p.pdgcode().charge();
 
  485     if (E_plus + E_minus + charge >= conserved_remaining.charge()) {
 
  492   auto condition7 = [](
int S, 
int B, 
int C) {
 
  493     return (
S == 0) && (B == 0) && (C == 0);
 
  495   conserved_remaining = conserved_initial - QuantumNumbers(
sampled_list_);
 
  498   while (conserved_remaining.momentum().x0() > energy) {
 
  501     energy += 
p.momentum().x0();
 
 
 
 
◆ thermalize()
      
        
          | void smash::GrandCanThermalizer::thermalize  | 
          ( | 
          const Particles &  | 
          particles,  | 
        
        
           | 
           | 
          double  | 
          time,  | 
        
        
           | 
           | 
          int  | 
          ntest  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Main thermalize function, that chooses the algorithm to follow (BF or mode sampling). 
- Parameters
 - 
  
    | [out] | particles | List of sampled particles in thermalized region  | 
    | [in] | time | Current time of the simulation  | 
    | [in] | ntest | number of testparticles  | 
  
   
Definition at line 505 of file grandcan_thermalizer.cc.
  513   QuantumNumbers conserved_initial = QuantumNumbers();
 
  514   ThermLatticeNode node;
 
  515   for (
auto &particle : particles) {
 
  516     const bool is_on_lattice =
 
  517         lat_->value_at(particle.position().threevec(), node);
 
  518     if (is_on_lattice && node.e() > 
e_crit_) {
 
  526       conserved_initial.add_values(particle);
 
  530     conserved_initial = QuantumNumbers();
 
  535   if (conserved_initial == QuantumNumbers()) {
 
  540   const size_t lattice_total_cells = 
lat_->size();
 
  541   for (
size_t i = 0; i < lattice_total_cells; i++) {
 
  547       "Number of cells in the thermalization region = ",
 
  550       ", in % of lattice: ",
 
  562       throw std::invalid_argument(
 
  563           "This thermalization algorithm is" 
  564           " not yet implemented");
 
 
 
 
◆ print_statistics()
      
        
          | void smash::GrandCanThermalizer::print_statistics  | 
          ( | 
          const Clock &  | 
          clock | ) | 
           const | 
        
      
 
Generates standard output with information about the thermodynamic properties of the lattice, the thermalized region and the volume to be thermalized above the critical energy density. 
- Parameters
 - 
  
    | [in] | clock | Current time of the simulation  | 
  
   
Definition at line 573 of file grandcan_thermalizer.cc.
  583   struct to_average on_lattice = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 
  584   struct to_average in_therm_reg = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 
  585   double e_sum_on_lattice = 0.0, e_sum_in_therm_reg = 0.0;
 
  586   int node_counter = 0;
 
  587   for (
const auto &node : *
lat_) {
 
  588     const double e = node.e();
 
  589     on_lattice.T += node.T() * e;
 
  590     on_lattice.mub += node.mub() * e;
 
  591     on_lattice.mus += node.mus() * e;
 
  592     on_lattice.muq += node.muq() * e;
 
  593     on_lattice.nb += node.nb() * e;
 
  594     on_lattice.ns += node.ns() * e;
 
  595     on_lattice.nq += node.nq() * e;
 
  596     e_sum_on_lattice += e;
 
  598       in_therm_reg.T += node.T() * e;
 
  599       in_therm_reg.mub += node.mub() * e;
 
  600       in_therm_reg.mus += node.mus() * e;
 
  601       in_therm_reg.muq += node.muq() * e;
 
  602       in_therm_reg.nb += node.nb() * e;
 
  603       in_therm_reg.ns += node.ns() * e;
 
  604       in_therm_reg.nq += node.nq() * e;
 
  605       e_sum_in_therm_reg += e;
 
  610     on_lattice.T /= e_sum_on_lattice;
 
  611     on_lattice.mub /= e_sum_on_lattice;
 
  612     on_lattice.mus /= e_sum_on_lattice;
 
  613     on_lattice.muq /= e_sum_on_lattice;
 
  614     on_lattice.nb /= e_sum_on_lattice;
 
  615     on_lattice.ns /= e_sum_on_lattice;
 
  616     on_lattice.nq /= e_sum_on_lattice;
 
  619     in_therm_reg.T /= e_sum_in_therm_reg;
 
  620     in_therm_reg.mub /= e_sum_in_therm_reg;
 
  621     in_therm_reg.mus /= e_sum_in_therm_reg;
 
  622     in_therm_reg.muq /= e_sum_in_therm_reg;
 
  623     in_therm_reg.nb /= e_sum_in_therm_reg;
 
  624     in_therm_reg.ns /= e_sum_in_therm_reg;
 
  625     in_therm_reg.nq /= e_sum_in_therm_reg;
 
  628   std::cout << 
"Current time [fm/c]: " << clock.current_time() << std::endl;
 
  629   std::cout << 
"Averages on the lattice - T[GeV], mub[GeV], mus[GeV], muq[GeV] " 
  630             << 
"nb[fm^-3], ns[fm^-3], nq[fm^-3]: " << on_lattice.T << 
" " 
  631             << on_lattice.mub << 
" " << on_lattice.mus << 
" " << on_lattice.muq
 
  632             << 
" " << on_lattice.nb << 
" " << on_lattice.ns << 
" " 
  633             << on_lattice.nq << std::endl;
 
  635       << 
"Averages in therm. region - T[GeV], mub[GeV], mus[GeV], muq[GeV] " 
  636       << 
"nb[fm^-3], ns[fm^-3], nq[fm^-3]: " << in_therm_reg.T << 
" " 
  637       << in_therm_reg.mub << 
" " << in_therm_reg.mus << 
" " << in_therm_reg.muq
 
  638       << 
" " << in_therm_reg.nb << 
" " << in_therm_reg.ns << 
" " 
  639       << in_therm_reg.nq << std::endl;
 
  640   std::cout << 
"Volume with e > e_crit [fm^3]: " 
 
 
 
◆ lattice()
◆ e_crit()
  
  
      
        
          | double smash::GrandCanThermalizer::e_crit  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inline   | 
  
 
 
◆ particles_to_remove()
  
  
      
        
          | ParticleList smash::GrandCanThermalizer::particles_to_remove  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inline   | 
  
 
 
◆ particles_to_insert()
  
  
      
        
          | ParticleList smash::GrandCanThermalizer::particles_to_insert  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inline   | 
  
 
 
◆ list_eos_particles()
  
  
      
        
          | ParticleTypePtrList smash::GrandCanThermalizer::list_eos_particles  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
inlineprivate   | 
  
 
Extracts the particles in the hadron gas equation of state from the complete list of particle types in SMASH. 
Definition at line 455 of file grandcan_thermalizer.h.
  456     ParticleTypePtrList res;
 
  459         res.push_back(&ptype);
 
 
 
 
◆ get_class()
  
  
      
        
          | HadronClass smash::GrandCanThermalizer::get_class  | 
          ( | 
          size_t  | 
          typelist_index | ) | 
           const | 
         
       
   | 
  
inlineprivate   | 
  
 
Defines the class of hadrons by quantum numbers. 
- Parameters
 - 
  
    | [in] | typelist_index | Index for a certain quantum number  | 
  
   
Definition at line 468 of file grandcan_thermalizer.h.
  469     const int B = 
eos_typelist_[typelist_index]->baryon_number();
 
 
 
 
◆ mult_class()
  
  
      
        
          | double smash::GrandCanThermalizer::mult_class  | 
          ( | 
          const HadronClass  | 
          cl | ) | 
           const | 
         
       
   | 
  
inlineprivate   | 
  
 
 
◆ N_in_cells_
  
  
      
        
          | std::vector<double> smash::GrandCanThermalizer::N_in_cells_ | 
         
       
   | 
  
private   | 
  
 
 
◆ cells_to_sample_
  
  
      
        
          | std::vector<size_t> smash::GrandCanThermalizer::cells_to_sample_ | 
         
       
   | 
  
private   | 
  
 
 
◆ eos_
◆ lat_
◆ to_remove_
  
  
      
        
          | ParticleList smash::GrandCanThermalizer::to_remove_ | 
         
       
   | 
  
private   | 
  
 
 
◆ sampled_list_
  
  
      
        
          | ParticleList smash::GrandCanThermalizer::sampled_list_ | 
         
       
   | 
  
private   | 
  
 
 
◆ eos_typelist_
  
  
      
        
          | const ParticleTypePtrList smash::GrandCanThermalizer::eos_typelist_ | 
         
       
   | 
  
private   | 
  
 
List of particle types from which equation of state is computed. 
Most particles are included, but not all of them. For example, photons and leptons are not included. Heavy hadrons, that can originate from Pythia, but do not interact in SMASH are not included. The latter are excluded to avoid violations of charm and bottomness conservation, when HadronGasEoS is used for forced thermalization. 
Definition at line 506 of file grandcan_thermalizer.h.
 
 
◆ N_sorts_
  
  
      
        
          | const size_t smash::GrandCanThermalizer::N_sorts_ | 
         
       
   | 
  
private   | 
  
 
 
◆ mult_sort_
  
  
      
        
          | std::vector<double> smash::GrandCanThermalizer::mult_sort_ | 
         
       
   | 
  
private   | 
  
 
 
◆ mult_int_
  
  
      
        
          | std::vector<int> smash::GrandCanThermalizer::mult_int_ | 
         
       
   | 
  
private   | 
  
 
 
◆ mult_classes_
  
  
      
        
          | std::array<double, 7> smash::GrandCanThermalizer::mult_classes_ | 
         
       
   | 
  
private   | 
  
 
 
◆ N_total_in_cells_
  
  
      
        
          | double smash::GrandCanThermalizer::N_total_in_cells_ | 
         
       
   | 
  
private   | 
  
 
 
◆ lat_cell_volume_
  
  
      
        
          | double smash::GrandCanThermalizer::lat_cell_volume_ | 
         
       
   | 
  
private   | 
  
 
Volume of a single lattice cell, necessary to convert thermal densities to actual particle numbers. 
Definition at line 524 of file grandcan_thermalizer.h.
 
 
◆ e_crit_
  
  
      
        
          | const double smash::GrandCanThermalizer::e_crit_ | 
         
       
   | 
  
private   | 
  
 
 
◆ t_start_
  
  
      
        
          | const double smash::GrandCanThermalizer::t_start_ | 
         
       
   | 
  
private   | 
  
 
 
◆ period_
  
  
      
        
          | const double smash::GrandCanThermalizer::period_ | 
         
       
   | 
  
private   | 
  
 
 
◆ algorithm_
Algorithm to choose for sampling of particles obeying conservation laws. 
Definition at line 532 of file grandcan_thermalizer.h.
 
 
◆ BF_enforce_microcanonical_
  
  
      
        
          | const bool smash::GrandCanThermalizer::BF_enforce_microcanonical_ | 
         
       
   | 
  
private   | 
  
 
 
The documentation for this class was generated from the following files:
 
 
LatticeUpdate
Enumerator option for lattice updates.
 
void sample_multinomial(HadronClass particle_class, int N)
The sample_multinomial function samples integer numbers n_i distributed according to the multinomial ...
 
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.
 
Mesons with strangeness S < 0.
 
const double t_start_
Starting time of the simulation.
 
ParticleTypePtrList list_eos_particles() const
Extracts the particles in the hadron gas equation of state from the complete list of particle types i...
 
const size_t N_sorts_
Number of different species to be sampled.
 
Non-strange mesons (S = 0) with electric cherge Q < 0.
 
const ThermalizationAlgorithm algorithm_
Algorithm to choose for sampling of particles obeying conservation laws.
 
const double period_
Defines periodicity of the lattice in fm.
 
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.
 
void thermalize_BF_algo(QuantumNumbers &conserved_initial, double time, int ntest)
Samples particles according to the BF algorithm by making use of the.
 
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
 
constexpr double really_small
Numerical error tolerance.
 
double lat_cell_volume_
Volume of a single lattice cell, necessary to convert thermal densities to actual particle numbers.
 
int binomial(const int N, const T &p)
Returns a binomially distributed random number.
 
void update_lattice(RectangularLattice< T > *lat, const LatticeUpdate update, const DensityType dens_type, const DensityParameters &par, const Particles &particles, const bool compute_gradient=false)
Updates the contents on the lattice.
 
const bool BF_enforce_microcanonical_
Enforce energy conservation as part of BF sampling algorithm or not.
 
double N_total_in_cells_
Total number of particles over all cells in thermalization region.
 
Neutral non-strange mesons.
 
HadronClass get_class(size_t typelist_index) const
Defines the class of hadrons by quantum numbers.
 
ThreeVector uniform_in_cell() const
 
Mesons with strangeness S > 0.
 
Non-strange mesons (S = 0) with electric cherge Q > 0.
 
int poisson(const T &lam)
Returns a Poisson distributed random number.
 
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.
 
ParticleData sample_in_random_cell_mode_algo(const double time, F &&condition)
Samples one particle and the species, cell, momentum and coordinate are chosen from the corresponding...
 
void compute_N_in_cells_mode_algo(F &&condition)
Computes average number of particles in each cell for the mode algorithm.
 
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...
 
std::vector< double > N_in_cells_
Number of particles to be sampled in one cell.
 
ParticleList sampled_list_
Newly generated particles by thermalizer.
 
std::vector< size_t > cells_to_sample_
Cells above critical energy density.
 
std::array< double, 7 > mult_classes_
The different hadron species according to the enum defined in.
 
DensityType
Allows to choose which kind of density to calculate.
 
static bool is_eos_particle(const ParticleType &ptype)
Check if a particle belongs to the EoS.
 
HadronGasEos eos_
Hadron gas equation of state.
 
std::vector< double > mult_sort_
Real number multiplicity for each particle type.
 
std::vector< int > mult_int_
Integer multiplicity for each particle type.
 
const ParticleTypePtrList eos_typelist_
List of particle types from which equation of state is computed.
 
double mult_class(const HadronClass cl) const
 
void thermalize_mode_algo(QuantumNumbers &conserved_initial, double time)
Samples particles to the according to the mode algorithm.
 
double sample_momenta_from_thermal(const double temperature, const double mass)
Samples a momentum from the Maxwell-Boltzmann (thermal) distribution in a faster way,...
 
ParticleList to_remove_
Particles to be removed after this thermalization step.
 
const double e_crit_
Critical energy density above which cells are thermalized.
 
static constexpr int LGrandcanThermalizer
 
std::unique_ptr< RectangularLattice< ThermLatticeNode > > lat_
The lattice on which the thermodynamic quantities are calculated.
 
static const ParticleTypeList & list_all()