Version: SMASH-1.8
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 static constexpr int LSphere = LogArea::Sphere::id;
35 
166  const ExperimentParameters &)
167  : radius_(modus_config.take({"Sphere", "Radius"})),
168  sphere_temperature_(modus_config.take({"Sphere", "Temperature"})),
169  start_time_(modus_config.take({"Sphere", "Start_Time"}, 0.)),
170  use_thermal_(
171  modus_config.take({"Sphere", "Use_Thermal_Multiplicities"}, false)),
172  mub_(modus_config.take({"Sphere", "Baryon_Chemical_Potential"}, 0.)),
173  mus_(modus_config.take({"Sphere", "Strange_Chemical_Potential"}, 0.)),
174  account_for_resonance_widths_(
175  modus_config.take({"Sphere", "Account_Resonance_Widths"}, true)),
176  init_multipl_(use_thermal_
177  ? std::map<PdgCode, int>()
178  : modus_config.take({"Sphere", "Init_Multiplicities"})
179  .convert_for(init_multipl_)),
180  init_distr_(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  out << "Boltzmann momentum distribution with T = " << m.sphere_temperature_
201  << " GeV.\n";
202  if (m.insert_jet_) {
204  out << "Adding a " << ptype->name() << " as a jet in the middle "
205  << "of the sphere with " << m.jet_mom_ << " GeV initial momentum.\n";
206  }
207  return out;
208 }
209 
210 /* initial_conditions - sets particle data for @particles */
212  const ExperimentParameters &parameters) {
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  logg[LSphere].debug(mult.first, " initial multiplicity ",
234  thermal_mult_int);
235  }
236  logg[LSphere].info("Initial hadron gas baryon density ", nb_init);
237  logg[LSphere].info("Initial hadron gas strange density ", ns_init);
238  } else {
239  for (const auto &p : init_multipl_) {
240  particles->create(p.second * parameters.testparticles, p.first);
241  logg[LSphere].debug("Particle ", p.first, " initial multiplicity ",
242  p.second);
243  }
244  }
245  /* loop over particle data to fill in momentum and position information */
246  for (ParticleData &data : *particles) {
247  Angles phitheta;
248  /* thermal momentum according Maxwell-Boltzmann distribution */
249  double momentum_radial, mass = data.pole_mass();
250  /* assign momentum_radial according to requested distribution */
251  switch (init_distr_) {
253  momentum_radial = sample_momenta_IC_ES(T);
254  break;
256  momentum_radial = sample_momenta_1M_IC(T, mass);
257  break;
259  momentum_radial = sample_momenta_2M_IC(T, mass);
260  break;
262  momentum_radial = sample_momenta_non_eq_mass(T, mass);
263  break;
265  default:
267  ? data.type().mass()
268  : HadronGasEos::sample_mass_thermal(data.type(), 1.0 / T);
269  momentum_radial = sample_momenta_from_thermal(T, mass);
270  break;
271  }
272  phitheta.distribute_isotropically();
273  logg[LSphere].debug(data.type().name(), "(id ", data.id(),
274  ") radial momentum ", momentum_radial, ", direction",
275  phitheta);
276  data.set_4momentum(mass, phitheta.threevec() * momentum_radial);
277  momentum_total += data.momentum();
278  /* uniform sampling in a sphere with radius r */
279  double position_radial;
280  position_radial = std::cbrt(random::canonical()) * radius_;
281  Angles pos_phitheta;
282  pos_phitheta.distribute_isotropically();
283  data.set_4position(
284  FourVector(start_time_, pos_phitheta.threevec() * position_radial));
285  data.set_formation_time(start_time_);
286  }
287  /* Make total 3-momentum 0 */
288  for (ParticleData &data : *particles) {
289  data.set_4momentum(data.momentum().abs(),
290  data.momentum().threevec() -
291  momentum_total.threevec() / particles->size());
292  }
293 
294  /* Add a single highly energetic particle in the center of the sphere (jet) */
295  if (insert_jet_) {
296  auto &jet_particle = particles->create(jet_pdg_);
297  jet_particle.set_formation_time(start_time_);
298  jet_particle.set_4position(FourVector(start_time_, 0., 0., 0.));
299  jet_particle.set_4momentum(ParticleType::find(jet_pdg_).mass(),
300  ThreeVector(jet_mom_, 0., 0.));
301  }
302 
303  /* Recalculate total momentum */
304  momentum_total = FourVector(0, 0, 0, 0);
305  for (ParticleData &data : *particles) {
306  momentum_total += data.momentum();
307  /* IC: debug checks */
308  logg[LSphere].debug() << data;
309  }
310  /* allows to check energy conservation */
311  logg[LSphere].debug() << "Sphere initial total 4-momentum [GeV]: "
312  << momentum_total;
313  return start_time_;
314 }
315 } // 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:116
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:211
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
algorithms.h
SphereInitialCondition::IC_2M
smash::ParticleData
Definition: particledata.h:52
smash::HadronGasEos::partial_density
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
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
macros.h
smash::operator<<
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Definition: action.h:463
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:82
smash::SphereModus::start_time_
const double start_time_
Starting time for the Sphere.
Definition: spheremodus.h:82
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:105
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:663
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:325
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
SphereInitialCondition::IC_1M
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
distributions.h
SphereInitialCondition::ThermalMomenta
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:153
smash::LSphere
static constexpr int LSphere
Definition: spheremodus.cc:34
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:239
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:308
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:165
configuration.h
smash::ExperimentParameters
Helper structure for Experiment.
Definition: experimentparameters.h:23
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:190
smash::ExperimentParameters::testparticles
int testparticles
Number of test particle.
Definition: experimentparameters.h:31
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:57