Version: SMASH-1.7
spheremodus.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2013-2019
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #include <cmath>
11 #include <cstdio>
12 #include <cstdlib>
13 #include <list>
14 #include <map>
15 #include <utility>
16 #include <vector>
17 
18 #include "smash/algorithms.h"
19 #include "smash/angles.h"
20 #include "smash/configuration.h"
21 #include "smash/constants.h"
22 #include "smash/distributions.h"
24 #include "smash/fourvector.h"
25 #include "smash/hadgas_eos.h"
26 #include "smash/logging.h"
27 #include "smash/macros.h"
28 #include "smash/particles.h"
29 #include "smash/random.h"
30 #include "smash/spheremodus.h"
31 #include "smash/threevector.h"
32 
33 namespace smash {
34 
165  const ExperimentParameters &)
166  : radius_(modus_config.take({"Sphere", "Radius"})),
167  sphere_temperature_(modus_config.take({"Sphere", "Temperature"})),
168  start_time_(modus_config.take({"Sphere", "Start_Time"}, 0.)),
169  use_thermal_(
170  modus_config.take({"Sphere", "Use_Thermal_Multiplicities"}, false)),
171  mub_(modus_config.take({"Sphere", "Baryon_Chemical_Potential"}, 0.)),
172  mus_(modus_config.take({"Sphere", "Strange_Chemical_Potential"}, 0.)),
174  modus_config.take({"Sphere", "Account_Resonance_Widths"}, true)),
176  ? std::map<PdgCode, int>()
177  : modus_config.take({"Sphere", "Init_Multiplicities"})
178  .convert_for(init_multipl_)),
179  init_distr_(modus_config.take({"Sphere", "Initial_Condition"},
181  insert_jet_(modus_config.has_value({"Sphere", "Jet", "Jet_PDG"})),
182  jet_pdg_(insert_jet_ ? modus_config.take({"Sphere", "Jet", "Jet_PDG"})
183  .convert_for(jet_pdg_)
184  : pdg::p), // dummy default; never used
185  jet_mom_(modus_config.take({"Sphere", "Jet", "Jet_Momentum"}, 20.)) {}
186 
187 /* console output on startup of sphere specific parameters */
188 std::ostream &operator<<(std::ostream &out, const SphereModus &m) {
189  out << "-- Sphere Modus:\nRadius of the sphere: " << m.radius_ << " fm\n";
190  if (m.use_thermal_) {
191  out << "Thermal multiplicities (T = " << m.sphere_temperature_
192  << " GeV, muB = " << m.mub_ << " GeV, muS = " << m.mus_ << " GeV)\n";
193  } else {
194  for (const auto &p : m.init_multipl_) {
195  ParticleTypePtr ptype = &ParticleType::find(p.first);
196  out << ptype->name() << " initial multiplicity " << p.second << '\n';
197  }
198  }
199  out << "Boltzmann momentum distribution with T = " << m.sphere_temperature_
200  << " GeV.\n";
201  if (m.insert_jet_) {
203  out << "Adding a " << ptype->name() << " as a jet in the middle "
204  << "of the sphere with " << m.jet_mom_ << " GeV initial momentum.\n";
205  }
206  return out;
207 }
208 
209 /* initial_conditions - sets particle data for @particles */
211  const ExperimentParameters &parameters) {
212  const auto &log = logger<LogArea::Sphere>();
213  FourVector momentum_total(0, 0, 0, 0);
214  const double T = this->sphere_temperature_;
215  /* Create NUMBER OF PARTICLES according to configuration */
216  if (use_thermal_) {
217  const double V = 4.0 / 3.0 * M_PI * radius_ * radius_ * radius_;
218  if (average_multipl_.empty()) {
219  for (const ParticleType &ptype : ParticleType::list_all()) {
220  if (HadronGasEos::is_eos_particle(ptype)) {
221  const double n = HadronGasEos::partial_density(
223  average_multipl_[ptype.pdgcode()] = n * V * parameters.testparticles;
224  }
225  }
226  }
227  double nb_init = 0.0, ns_init = 0.0;
228  for (const auto &mult : average_multipl_) {
229  const int thermal_mult_int = random::poisson(mult.second);
230  particles->create(thermal_mult_int, mult.first);
231  nb_init += mult.second * mult.first.baryon_number();
232  ns_init += mult.second * mult.first.strangeness();
233  log.debug(mult.first, " initial multiplicity ", thermal_mult_int);
234  }
235  log.info("Initial hadron gas baryon density ", nb_init);
236  log.info("Initial hadron gas strange density ", ns_init);
237  } else {
238  for (const auto &p : init_multipl_) {
239  particles->create(p.second * parameters.testparticles, p.first);
240  log.debug("Particle ", p.first, " initial multiplicity ", p.second);
241  }
242  }
243  /* loop over particle data to fill in momentum and position information */
244  for (ParticleData &data : *particles) {
245  Angles phitheta;
246  /* thermal momentum according Maxwell-Boltzmann distribution */
247  double momentum_radial, mass = data.pole_mass();
248  /* assign momentum_radial according to requested distribution */
249  switch (init_distr_) {
251  momentum_radial = sample_momenta_IC_ES(T);
252  break;
254  momentum_radial = sample_momenta_1M_IC(T, mass);
255  break;
257  momentum_radial = sample_momenta_2M_IC(T, mass);
258  break;
260  momentum_radial = sample_momenta_non_eq_mass(T, mass);
261  break;
263  default:
265  ? data.type().mass()
266  : HadronGasEos::sample_mass_thermal(data.type(), 1.0 / T);
267  momentum_radial = sample_momenta_from_thermal(T, mass);
268  break;
269  }
270  phitheta.distribute_isotropically();
271  log.debug(data.type().name(), "(id ", data.id(), ") radial momentum ",
272  momentum_radial, ", direction", phitheta);
273  data.set_4momentum(mass, phitheta.threevec() * momentum_radial);
274  momentum_total += data.momentum();
275  /* uniform sampling in a sphere with radius r */
276  double position_radial;
277  position_radial = std::cbrt(random::canonical()) * radius_;
278  Angles pos_phitheta;
279  pos_phitheta.distribute_isotropically();
280  data.set_4position(
281  FourVector(start_time_, pos_phitheta.threevec() * position_radial));
282  data.set_formation_time(start_time_);
283  }
284  /* Make total 3-momentum 0 */
285  for (ParticleData &data : *particles) {
286  data.set_4momentum(data.momentum().abs(),
287  data.momentum().threevec() -
288  momentum_total.threevec() / particles->size());
289  }
290 
291  /* Add a single highly energetic particle in the center of the sphere (jet) */
292  if (insert_jet_) {
293  auto &jet_particle = particles->create(jet_pdg_);
294  jet_particle.set_formation_time(start_time_);
295  jet_particle.set_4position(FourVector(start_time_, 0., 0., 0.));
296  jet_particle.set_4momentum(ParticleType::find(jet_pdg_).mass(),
297  ThreeVector(jet_mom_, 0., 0.));
298  }
299 
300  /* Recalculate total momentum */
301  momentum_total = FourVector(0, 0, 0, 0);
302  for (ParticleData &data : *particles) {
303  momentum_total += data.momentum();
304  /* IC: debug checks */
305  log.debug() << data;
306  }
307  /* allows to check energy conservation */
308  log.debug() << "Sphere initial total 4-momentum [GeV]: " << momentum_total;
309  return start_time_;
310 }
311 } // namespace smash
double radius_
Sphere radius (in fm/c)
Definition: spheremodus.h:78
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
const SphereInitialCondition init_distr_
Initialization scheme for momenta in the sphere; used for expanding metric setup. ...
Definition: spheremodus.h:118
double sample_momenta_2M_IC(const double temperature, const double mass)
Samples a momentum from the non-equilibrium distribution 2M_IC from Bazow:2016oky ...
void create(size_t n, PdgCode pdg)
Add n particles of the same type (pdg) to the list.
Definition: particles.cc:66
const double jet_mom_
Initial momentum of the jet particle; only used if insert_jet_ is true.
Definition: spheremodus.h:133
Collection of useful constants that are known at compile time.
double sphere_temperature_
Temperature for momentum distribution (in GeV)
Definition: spheremodus.h:80
const bool account_for_resonance_widths_
In case of thermal initialization: true – account for resonance spectral functions, while computing multiplicities and sampling masses, false – simply use pole masses.
Definition: spheremodus.h:103
Interface to the SMASH configuration files.
const double start_time_
Starting time for the Sphere.
Definition: spheremodus.h:82
static bool is_eos_particle(const ParticleType &ptype)
Check if a particle belongs to the EoS.
Definition: hadgas_eos.h:308
static double partial_density(const ParticleType &ptype, double T, double mub, double mus, bool account_for_resonance_widths=false)
Compute partial density of one hadron sort.
Definition: hadgas_eos.cc:234
T canonical()
Definition: random.h:113
std::map< PdgCode, double > average_multipl_
Average multiplicities in case of thermal initialization.
Definition: spheremodus.h:113
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
SphereModus: Provides a modus for expanding matter calculations.
Definition: spheremodus.h:47
double sample_momenta_IC_ES(const double temperature)
Sample momenta according to the momentum distribution in Bazow:2016oky
ThreeVector threevec() const
Definition: angles.h:268
static const ParticleTypeList & list_all()
Definition: particletype.cc:55
const bool use_thermal_
Whether to use a thermal initialization for all particles instead of specific numbers.
Definition: spheremodus.h:87
const std::string & name() const
Definition: particletype.h:141
Generic algorithms on containers and ranges.
Particle type contains the static properties of a particle species.
Definition: particletype.h:97
double sample_momenta_from_thermal(const double temperature, const double mass)
Samples a momentum from the Maxwell-Boltzmann (thermal) distribution in a faster way, given by Scott Pratt (see Pratt:2014vja) APPENDIX: ALGORITHM FOR GENERATING PARTICLES math trick: for distribution, sample x by: where are uniform random numbers between [0,1) for : , where is used as rejection weight.
static double sample_mass_thermal(const ParticleType &ptype, double beta)
Sample resonance mass in a thermal medium.
Definition: hadgas_eos.cc:325
const bool insert_jet_
Whether to insert a single high energy particle at the center of the expanding sphere (0...
Definition: spheremodus.h:124
const double mus_
Strange chemical potential for thermal initialization; only used if use_thermal_ is true...
Definition: spheremodus.h:97
SphereModus(Configuration modus_config, const ExperimentParameters &parameters)
Constructor.
Definition: spheremodus.cc:164
const double mub_
Baryon chemical potential for thermal initialization; only used if use_thermal_ is true...
Definition: spheremodus.h:92
double sample_momenta_non_eq_mass(const double temperature, const double mass)
Samples a momentum via rejection method from the non-equilibrium distribution .
const std::map< PdgCode, int > init_multipl_
Particle multiplicities at initialization; required if use_thermal_ is false.
Definition: spheremodus.h:108
constexpr int p
Proton.
double sample_momenta_1M_IC(const double temperature, const double mass)
Samples a momentum from the non-equilibrium distribution 1M_IC from Bazow:2016oky ...
const PdgCode jet_pdg_
Pdg of the particle to use as a jet; necessary if insert_jet_ is true, unused otherwise.
Definition: spheremodus.h:129
int poisson(const T &lam)
Returns a Poisson distributed random number.
Definition: random.h:226
int testparticles
Number of test particle.
double initial_conditions(Particles *particles, const ExperimentParameters &parameters)
Generates initial state of the particles in the system according to specified parameters: number of p...
Definition: spheremodus.cc:210
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:654
Angles provides a common interface for generating directions: i.e., two angles that should be interpr...
Definition: angles.h:59
void distribute_isotropically()
Populate the object with a new direction.
Definition: angles.h:188
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
constexpr int n
Neutron.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
Helper structure for Experiment.
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:52
friend std::ostream & operator<<(std::ostream &, const SphereModus &)
Writes the initial state for the Sphere to the output stream.
Definition: spheremodus.cc:188
Definition: action.h:24