Version: SMASH-3.4
boxmodus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2023
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_BOXMODUS_H_
8 #define SRC_INCLUDE_SMASH_BOXMODUS_H_
9 
10 #include <map>
11 #include <memory>
12 
13 #include "forwarddeclarations.h"
14 #include "modusdefault.h"
15 
16 namespace smash {
17 
18 /**
19  * \ingroup modus
20  * BoxModus: Provides a modus for infinite matter calculations
21  *
22  * Matter is confined in a cubical box. Depending on the initial
23  * condition, particles are either reflected on the boundaries
24  * (not implemented now) or inserted on opposite positions.
25  *
26  * To use this modus, choose
27  Modus: Box
28  * \code
29  * General:
30  * Modus: Box
31  * \endcode
32  * in the configuration file.
33  *
34  * Options for BoxModus go in the "Modi"→"Box" section of the
35  * configuration:
36  *
37  * \code
38  * Modi:
39  * Box:
40  * # definitions here
41  * \endcode
42  *
43  * The following configuration options are understood:
44  * \ref doxypage_input_conf_modi_box
45  */
46 class BoxModus : public ModusDefault {
47  public:
48  /**
49  * Constructor
50  *
51  * Gathers all configuration variables for the Box.
52  *
53  * \param[in] modus_config The configuration object that sets all
54  * initial conditions of the experiment.
55  * \param[in] parameters Unused, but necessary because of templated
56  * initialization
57  */
58  explicit BoxModus(Configuration modus_config,
59  const ExperimentParameters &parameters);
60 
61  /**
62  * Generates initial state of the particles in the system according to
63  * specified parameters: number of particles of each species, momentum
64  * and coordinate space distributions. Subsequently makes the total
65  * 3-momentum 0.
66  *
67  * \param[out] particles An empty list that gets filled up by this function
68  * \param[in] parameters The initialization parameters of the box
69  * \return The starting time of the simulation
70  */
71  double initial_conditions(Particles *particles,
72  const ExperimentParameters &parameters);
73 
74  /**
75  * Enforces that all particles are inside the box at the beginning of
76  * an event. It checks if the particles were placed correctly inside the box
77  * at initialization and places them inside if they are not.
78  *
79  * \param[in] particles particles to check their position and possibly
80  * move it
81  * \param[in] output_list output objects
82  * \return The number of particles that were put back into the box
83  *
84  * In BoxModus if a particle crosses the wall of the box, it is
85  * inserted from the opposite side. However these wall crossings are not
86  * performed by this function but in the Experiment constructor when the
87  * WallCrossActionsFinder are created. Wall crossings are written to
88  * collision output: this is where OutputsList is used.
89  */
91  const OutputsList &output_list = {});
92 
93  /// \copydoc smash::ModusDefault::create_grid
95  const Particles &particles, double min_cell_length,
96  double timestep_duration, CollisionCriterion crit,
97  const bool include_unformed_particles,
100  if (crit == CollisionCriterion::Stochastic) {
102  }
103  return {{{0, 0, 0}, {length_, length_, length_}},
104  particles,
105  min_cell_length,
106  timestep_duration,
107  limit,
108  include_unformed_particles,
109  strategy};
110  }
111 
112  /**
113  * Creates GrandCanThermalizer. (Special Box implementation.)
114  *
115  * \param[in] conf configuration object
116  * \return unique pointer to created thermalizer class
117  */
118  std::unique_ptr<GrandCanThermalizer> create_grandcan_thermalizer(
119  Configuration &conf) const {
120  const std::array<double, 3> lat_size = {length_, length_, length_};
121  const std::array<double, 3> origin = {0., 0., 0.};
122  const bool periodicity = true;
123  return std::make_unique<GrandCanThermalizer>(conf, lat_size, origin,
124  periodicity);
125  }
126 
127  /// \copydoc smash::ModusDefault::max_timestep()
128  double max_timestep(double max_transverse_distance_sqr) const {
129  return 0.5 * std::sqrt(length_ * length_ - max_transverse_distance_sqr);
130  }
131 
132  /// \return equilibration time of the box
133  double equilibration_time() const { return equilibration_time_; }
134  /// \return whether the modus is box (also, trivially true)
135  bool is_box() const { return true; }
136  /// \return length of the box
137  double length() const { return length_; }
138 
139  private:
140  /// Initial momenta distribution: thermal or peaked momenta
142  /// Length of the cube's edge in fm
143  const double length_;
144  /// time after which output is written
145  const double equilibration_time_;
146  /// Temperature of the Box in GeV
147  const double temperature_;
148  /// Initial time of the box
149  const double start_time_ = 0.;
150  /**
151  * Whether to use a thermal initialization for all particles
152  * instead of specific numbers
153  */
154  const bool use_thermal_ = false;
155  /**
156  * Baryon chemical potential for thermal initialization;
157  * only used if use_thermal_ is true
158  */
159  const double mub_;
160  /**
161  * Strange chemical potential for thermal initialization;
162  * only used if use_thermal_ is true
163  */
164  const double mus_;
165  /**
166  * Charge chemical potential for thermal initialization;
167  * only used if use_thermal_ is true
168  */
169  const double muq_;
170  /**
171  * In case of thermal initialization: true -- account for resonance
172  * spectral functions, while computing multiplicities and sampling masses,
173  * false -- simply use pole masses.
174  */
176  /**
177  * Particle multiplicities at initialization;
178  * required if use_thermal_ is false
179  */
180  const std::map<PdgCode, int> init_multipl_;
181  /**
182  * Average multiplicities in case of thermal initialization.
183  * Saved to avoid recalculating at every event
184  */
185  std::map<PdgCode, double> average_multipl_;
186  /**
187  * Optional PDG code of the particle to use as a jet. Same setup as in the
188  * sphere modus case.
189  */
190  const std::optional<PdgCode> jet_pdg_;
191  /**
192  * Initial momentum of the jet particle; only used if insert_jet_ is true
193  */
194  const double jet_mom_;
195 
196  /**
197  * \ingroup logging
198  * Console output on startup of box specific parameters;
199  * writes the initial state for the box to the output stream.
200  *
201  * \param[in] out The ostream into which to output
202  * \param[in] m The BoxModus object to write into out
203  */
204  friend std::ostream &operator<<(std::ostream &out, const BoxModus &m);
205 };
206 
207 } // namespace smash
208 
209 #endif // SRC_INCLUDE_SMASH_BOXMODUS_H_
BoxModus: Provides a modus for infinite matter calculations.
Definition: boxmodus.h:46
std::unique_ptr< GrandCanThermalizer > create_grandcan_thermalizer(Configuration &conf) const
Creates GrandCanThermalizer.
Definition: boxmodus.h:118
const std::optional< PdgCode > jet_pdg_
Optional PDG code of the particle to use as a jet.
Definition: boxmodus.h:190
double equilibration_time() const
Definition: boxmodus.h:133
double max_timestep(double max_transverse_distance_sqr) const
Definition: boxmodus.h:128
const double muq_
Charge chemical potential for thermal initialization; only used if use_thermal_ is true.
Definition: boxmodus.h:169
const double jet_mom_
Initial momentum of the jet particle; only used if insert_jet_ is true.
Definition: boxmodus.h:194
int impose_boundary_conditions(Particles *particles, const OutputsList &output_list={})
Enforces that all particles are inside the box at the beginning of an event.
Definition: boxmodus.cc:226
BoxModus(Configuration modus_config, const ExperimentParameters &parameters)
Constructor.
Definition: boxmodus.cc:66
const bool use_thermal_
Whether to use a thermal initialization for all particles instead of specific numbers.
Definition: boxmodus.h:154
bool is_box() const
Definition: boxmodus.h:135
const double mub_
Baryon chemical potential for thermal initialization; only used if use_thermal_ is true.
Definition: boxmodus.h:159
Grid< GridOptions::PeriodicBoundaries > create_grid(const Particles &particles, double min_cell_length, double timestep_duration, CollisionCriterion crit, const bool include_unformed_particles, CellSizeStrategy strategy=CellSizeStrategy::Optimal) const
Creates the Grid with normal boundary conditions.
Definition: boxmodus.h:94
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: boxmodus.cc:104
double length() const
Definition: boxmodus.h:137
const BoxInitialCondition initial_condition_
Initial momenta distribution: thermal or peaked momenta.
Definition: boxmodus.h:141
const std::map< PdgCode, int > init_multipl_
Particle multiplicities at initialization; required if use_thermal_ is false.
Definition: boxmodus.h:180
const bool account_for_resonance_widths_
In case of thermal initialization: true – account for resonance spectral functions,...
Definition: boxmodus.h:175
const double temperature_
Temperature of the Box in GeV.
Definition: boxmodus.h:147
const double mus_
Strange chemical potential for thermal initialization; only used if use_thermal_ is true.
Definition: boxmodus.h:164
std::map< PdgCode, double > average_multipl_
Average multiplicities in case of thermal initialization.
Definition: boxmodus.h:185
const double start_time_
Initial time of the box.
Definition: boxmodus.h:149
const double equilibration_time_
time after which output is written
Definition: boxmodus.h:145
const double length_
Length of the cube's edge in fm.
Definition: boxmodus.h:143
Interface to the SMASH configuration files.
Base class for Modus classes that provides default function implementations.
Definition: modusdefault.h:45
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
CollisionCriterion
Criteria used to check collisions.
@ Stochastic
Stochastic Criteiron.
BoxInitialCondition
Initial condition for a particle in a box.
friend std::ostream & operator<<(std::ostream &out, const BoxModus &m)
Console output on startup of box specific parameters; writes the initial state for the box to the out...
Definition: boxmodus.cc:33
Definition: action.h:24
CellNumberLimitation
Identifies whether the number of cells should be limited.
Definition: grid.h:55
@ ParticleNumber
Limit the number of cells to the number of particles.
@ None
No cell number limitation.
CellSizeStrategy
Indentifies the strategy of determining the cell size.
Definition: grid.h:33
@ Optimal
Look for optimal cell size.
Helper structure for Experiment.