Version: SMASH-2.0
spheremodus.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2013-2020
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/angles.h"
20 #include "smash/configuration.h"
21 #include "smash/constants.h"
23 #include "smash/fourvector.h"
24 #include "smash/hadgas_eos.h"
25 #include "smash/logging.h"
26 #include "smash/particles.h"
27 #include "smash/quantumsampling.h"
28 #include "smash/random.h"
29 #include "smash/spheremodus.h"
30 #include "smash/threevector.h"
31 
32 namespace smash {
33 static constexpr int LSphere = LogArea::Sphere::id;
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.)),
173  account_for_resonance_widths_(
174  modus_config.take({"Sphere", "Account_Resonance_Widths"}, true)),
175  init_multipl_(use_thermal_
176  ? std::map<PdgCode, int>()
177  : modus_config.take({"Sphere", "Init_Multiplicities"})
178  .convert_for(init_multipl_)),
179  init_distr_(
180  modus_config.take({"Sphere", "Initial_Condition"},
182  insert_jet_(modus_config.has_value({"Sphere", "Jet", "Jet_PDG"})),
183  jet_pdg_(insert_jet_ ? modus_config.take({"Sphere", "Jet", "Jet_PDG"})
184  .convert_for(jet_pdg_)
185  : pdg::p), // dummy default; never used
186  jet_mom_(modus_config.take({"Sphere", "Jet", "Jet_Momentum"}, 20.)) {}
187 
188 /* console output on startup of sphere specific parameters */
189 std::ostream &operator<<(std::ostream &out, const SphereModus &m) {
190  out << "-- Sphere Modus:\nRadius of the sphere: " << m.radius_ << " fm\n";
191  if (m.use_thermal_) {
192  out << "Thermal multiplicities (T = " << m.sphere_temperature_
193  << " GeV, muB = " << m.mub_ << " GeV, muS = " << m.mus_ << " GeV)\n";
194  } else {
195  for (const auto &p : m.init_multipl_) {
196  ParticleTypePtr ptype = &ParticleType::find(p.first);
197  out << ptype->name() << " initial multiplicity " << p.second << '\n';
198  }
199  }
200  switch (m.init_distr_) {
202  out << "Boltzmann momentum distribution with T = "
203  << m.sphere_temperature_ << " GeV.\n";
204  break;
206  out << "Fermi/Bose momentum distribution with T = "
207  << m.sphere_temperature_ << " GeV.\n";
208  break;
210  out << "Sphere Initial Condition is IC_ES";
211  break;
213  out << "Sphere Initial Condition is IC_1M";
214  break;
216  out << "Sphere Initial Condition is IC_2M";
217  break;
219  out << "Sphere Initial Condition is IC_Massive";
220  break;
221  }
222  if (m.insert_jet_) {
224  out << "Adding a " << ptype->name() << " as a jet in the middle "
225  << "of the sphere with " << m.jet_mom_ << " GeV initial momentum.\n";
226  }
227  return out;
228 }
229 
230 /* initial_conditions - sets particle data for @particles */
232  const ExperimentParameters &parameters) {
233  FourVector momentum_total(0, 0, 0, 0);
234  const double T = this->sphere_temperature_;
235  const double V = 4.0 / 3.0 * M_PI * radius_ * radius_ * radius_;
236  /* Create NUMBER OF PARTICLES according to configuration */
237  if (use_thermal_) {
238  if (average_multipl_.empty()) {
239  for (const ParticleType &ptype : ParticleType::list_all()) {
240  if (HadronGasEos::is_eos_particle(ptype)) {
241  const double n = HadronGasEos::partial_density(
243  average_multipl_[ptype.pdgcode()] = n * V * parameters.testparticles;
244  }
245  }
246  }
247  double nb_init = 0.0, ns_init = 0.0;
248  for (const auto &mult : average_multipl_) {
249  const int thermal_mult_int = random::poisson(mult.second);
250  particles->create(thermal_mult_int, mult.first);
251  nb_init += mult.second * mult.first.baryon_number();
252  ns_init += mult.second * mult.first.strangeness();
253  logg[LSphere].debug(mult.first, " initial multiplicity ",
254  thermal_mult_int);
255  }
256  logg[LSphere].info("Initial hadron gas baryon density ", nb_init);
257  logg[LSphere].info("Initial hadron gas strange density ", ns_init);
258  } else {
259  for (const auto &p : init_multipl_) {
260  particles->create(p.second * parameters.testparticles, p.first);
261  logg[LSphere].debug("Particle ", p.first, " initial multiplicity ",
262  p.second);
263  }
264  }
265  std::unique_ptr<QuantumSampling> quantum_sampling;
267  quantum_sampling = make_unique<QuantumSampling>(init_multipl_, V, T);
268  }
269  /* loop over particle data to fill in momentum and position information */
270  for (ParticleData &data : *particles) {
271  Angles phitheta;
272  /* thermal momentum according Maxwell-Boltzmann distribution */
273  double momentum_radial = 0.0, mass = data.pole_mass();
274  /* assign momentum_radial according to requested distribution */
275  switch (init_distr_) {
277  momentum_radial = sample_momenta_IC_ES(T);
278  break;
280  momentum_radial = sample_momenta_1M_IC(T, mass);
281  break;
283  momentum_radial = sample_momenta_2M_IC(T, mass);
284  break;
286  momentum_radial = sample_momenta_non_eq_mass(T, mass);
287  break;
289  default:
291  ? data.type().mass()
292  : HadronGasEos::sample_mass_thermal(data.type(), 1.0 / T);
293  momentum_radial = sample_momenta_from_thermal(T, mass);
294  break;
296  /*
297  * **********************************************************************
298  * Sampling the thermal momentum according Bose/Fermi/Boltzmann
299  * distribution.
300  * We take the pole mass as the mass.
301  * **********************************************************************
302  */
303  mass = data.type().mass();
304  momentum_radial = quantum_sampling->sample(data.pdgcode());
305  break;
306  }
307  phitheta.distribute_isotropically();
308  logg[LSphere].debug(data.type().name(), "(id ", data.id(),
309  ") radial momentum ", momentum_radial, ", direction",
310  phitheta);
311  data.set_4momentum(mass, phitheta.threevec() * momentum_radial);
312  momentum_total += data.momentum();
313  /* uniform sampling in a sphere with radius r */
314  double position_radial;
315  position_radial = std::cbrt(random::canonical()) * radius_;
316  Angles pos_phitheta;
317  pos_phitheta.distribute_isotropically();
318  data.set_4position(
319  FourVector(start_time_, pos_phitheta.threevec() * position_radial));
320  data.set_formation_time(start_time_);
321  }
322  /* Make total 3-momentum 0 */
323  for (ParticleData &data : *particles) {
324  data.set_4momentum(data.momentum().abs(),
325  data.momentum().threevec() -
326  momentum_total.threevec() / particles->size());
327  }
328 
329  /* Add a single highly energetic particle in the center of the sphere (jet) */
330  if (insert_jet_) {
331  auto &jet_particle = particles->create(jet_pdg_);
332  jet_particle.set_formation_time(start_time_);
333  jet_particle.set_4position(FourVector(start_time_, 0., 0., 0.));
334  jet_particle.set_4momentum(ParticleType::find(jet_pdg_).mass(),
335  ThreeVector(jet_mom_, 0., 0.));
336  }
337 
338  /* Recalculate total momentum */
339  momentum_total = FourVector(0, 0, 0, 0);
340  for (ParticleData &data : *particles) {
341  momentum_total += data.momentum();
342  /* IC: debug checks */
343  logg[LSphere].debug() << data;
344  }
345  /* allows to check energy conservation */
346  logg[LSphere].debug() << "Sphere initial total 4-momentum [GeV]: "
347  << momentum_total;
348  return start_time_;
349 }
350 } // namespace smash
SphereInitialCondition::IC_Massive
smash
Definition: action.h:24
smash::SphereModus::mus_
const double mus_
Strange chemical potential for thermal initialization; only used if use_thermal_ is true.
Definition: spheremodus.h:97
smash::sample_momenta_1M_IC
double sample_momenta_1M_IC(const double temperature, const double mass)
Samples a momentum from the non-equilibrium distribution 1M_IC from Bazow:2016oky .
Definition: distributions.cc:125
smash::SphereModus::initial_conditions
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:231
smash::SphereModus
Definition: spheremodus.h:47
smash::SphereModus::init_multipl_
const std::map< PdgCode, int > init_multipl_
Particle multiplicities at initialization; required if use_thermal_ is false.
Definition: spheremodus.h:108
smash::SphereModus::insert_jet_
const bool insert_jet_
Whether to insert a single high energy particle at the center of the expanding sphere (0,...
Definition: spheremodus.h:124
SphereInitialCondition::IC_2M
smash::ParticleData
Definition: particledata.h:52
smash::SphereModus::account_for_resonance_widths_
const bool account_for_resonance_widths_
In case of thermal initialization: true – account for resonance spectral functions,...
Definition: spheremodus.h:103
smash::SphereModus::radius_
double radius_
Sphere radius (in fm/c)
Definition: spheremodus.h:78
SphereInitialCondition::ThermalMomentaBoltzmann
smash::operator<<
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Definition: action.h:518
smash::Angles::distribute_isotropically
void distribute_isotropically()
Populate the object with a new direction.
Definition: angles.h:188
experimentparameters.h
smash::sample_momenta_non_eq_mass
double sample_momenta_non_eq_mass(const double temperature, const double mass)
Samples a momentum via rejection method from the non-equilibrium distribution.
Definition: distributions.cc:91
smash::SphereModus::start_time_
const double start_time_
Starting time for the Sphere.
Definition: spheremodus.h:82
smash::HadronGasEos::partial_density
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:270
fourvector.h
smash::SphereModus::init_distr_
const SphereInitialCondition init_distr_
Initialization scheme for momenta in the sphere; used for expanding metric setup.
Definition: spheremodus.h:118
smash::logg
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
smash::ParticleType::find
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
Definition: particletype.cc:99
random.h
angles.h
smash::Configuration
Interface to the SMASH configuration files.
Definition: configuration.h:464
smash::Particles::create
void create(size_t n, PdgCode pdg)
Add n particles of the same type (pdg) to the list.
Definition: particles.cc:66
smash::ParticleTypePtr
Definition: particletype.h:665
smash::ThreeVector
Definition: threevector.h:31
spheremodus.h
smash::HadronGasEos::sample_mass_thermal
static double sample_mass_thermal(const ParticleType &ptype, double beta)
Sample resonance mass in a thermal medium.
Definition: hadgas_eos.cc:385
SphereInitialCondition::ThermalMomentaQuantum
smash::SphereModus::mub_
const double mub_
Baryon chemical potential for thermal initialization; only used if use_thermal_ is true.
Definition: spheremodus.h:92
threevector.h
quantumsampling.h
SphereInitialCondition::IC_1M
chemicalpotential.h
smash::ParticleType
Definition: particletype.h:97
smash::ParticleType::name
const std::string & name() const
Definition: particletype.h:141
smash::SphereModus::sphere_temperature_
double sphere_temperature_
Temperature for momentum distribution (in GeV)
Definition: spheremodus.h:80
smash::sample_momenta_2M_IC
double sample_momenta_2M_IC(const double temperature, const double mass)
Samples a momentum from the non-equilibrium distribution 2M_IC from Bazow:2016oky .
Definition: distributions.cc:162
smash::LSphere
static constexpr int LSphere
Definition: spheremodus.cc:33
smash::SphereModus::jet_pdg_
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
smash::random::poisson
int poisson(const T &lam)
Returns a Poisson distributed random number.
Definition: random.h:226
SphereInitialCondition::IC_ES
particles.h
smash::Angles::threevec
ThreeVector threevec() const
Definition: angles.h:268
smash::Particles
Definition: particles.h:33
smash::sample_momenta_IC_ES
double sample_momenta_IC_ES(const double temperature)
Sample momenta according to the momentum distribution in Bazow:2016oky .
Definition: distributions.cc:248
smash::HadronGasEos::is_eos_particle
static bool is_eos_particle(const ParticleType &ptype)
Check if a particle belongs to the EoS.
Definition: hadgas_eos.h:355
constants.h
smash::SphereModus::average_multipl_
std::map< PdgCode, double > average_multipl_
Average multiplicities in case of thermal initialization.
Definition: spheremodus.h:113
smash::SphereModus::jet_mom_
const double jet_mom_
Initial momentum of the jet particle; only used if insert_jet_ is true.
Definition: spheremodus.h:133
logging.h
smash::SphereModus::SphereModus
SphereModus(Configuration modus_config, const ExperimentParameters &parameters)
Constructor.
Definition: spheremodus.cc:164
configuration.h
smash::ExperimentParameters
Helper structure for Experiment.
Definition: experimentparameters.h:24
smash::FourVector
Definition: fourvector.h:33
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::Angles
Angles provides a common interface for generating directions: i.e., two angles that should be interpr...
Definition: angles.h:59
hadgas_eos.h
smash::pdg::n
constexpr int n
Neutron.
Definition: pdgcode_constants.h:30
smash::sample_momenta_from_thermal
double sample_momenta_from_thermal(const double temperature, const double mass)
Samples a momentum from the Maxwell-Boltzmann (thermal) distribution in a faster way,...
Definition: distributions.cc:199
smash::ExperimentParameters::testparticles
int testparticles
Number of test particle.
Definition: experimentparameters.h:32
smash::SphereModus::use_thermal_
const bool use_thermal_
Whether to use a thermal initialization for all particles instead of specific numbers.
Definition: spheremodus.h:87
smash::random::canonical
T canonical()
Definition: random.h:113
smash::FourVector::threevec
ThreeVector threevec() const
Definition: fourvector.h:319
smash::ParticleType::list_all
static const ParticleTypeList & list_all()
Definition: particletype.cc:51