Version: SMASH-3.4
collidermodus.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020,2022-2026
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_COLLIDERMODUS_H_
8 #define SRC_INCLUDE_SMASH_COLLIDERMODUS_H_
9 
10 #include <cstring>
11 #include <map>
12 #include <memory>
13 #include <string>
14 #include <utility>
15 #include <vector>
16 
18 #include "smash/deformednucleus.h"
20 #include "smash/fourvector.h"
21 #include "smash/icparameters.h"
22 #include "smash/interpolation.h"
23 #include "smash/modusdefault.h"
24 #include "smash/nucleus.h"
25 #include "smash/pdgcode.h"
26 
27 namespace smash {
28 
29 struct ExperimentParameters;
30 
31 /**
32  * \ingroup modus
33  * ColliderModus: Provides a modus for colliding nuclei.
34  *
35  * To use this modus, choose
36  * \code
37  * General:
38  * Modus: Collider
39  * \endcode
40  * in the configuration file.
41  *
42  * Options for ColliderModus go in the "Modi"→"Collider" section of the
43  * configuration.
44  *
45  * The following configuration options are understood: \ref
46  * doxypage_input_conf_modi_collider
47  */
48 class ColliderModus : public ModusDefault {
49  public:
50  /**
51  * Constructor
52  *
53  * Takes all there is to take from the (truncated!) configuration
54  * object (only contains configuration for this modus).
55  *
56  * \param[in] modus_config The configuration object that sets all
57  * initial conditions of the experiment.
58  * \param[in] parameters Unused, but necessary because of templated
59  * initialization
60  * \throw ColliderEmpty if projectile or nucleus are empty (i.e. do
61  * not contain particles)
62  * \throw InvalidEnergy if sqrts from config is not large enough to support
63  * the colliding masses of the nuclei, or if E_kin or
64  * P_lab are negative
65  * \throw domain_error if more or less than exactly one of the
66  * input energy options is specified, or if custom
67  * impact parameter Values and Yields are improperly
68  * supplied
69  */
70  explicit ColliderModus(Configuration modus_config,
71  const ExperimentParameters &parameters);
72  /**
73  * Creates full path string consisting of file_directory and file_name
74  * Needed to initialize a customnucleus.
75  * \param[in] file_directory is the path to the external file
76  * \param[in] file_name is the name of the external file
77  */
78  std::string custom_file_path(const std::string &file_directory,
79  const std::string &file_name);
80  /**
81  * Generates initial state of the particles in the system.
82  * In particular, it initializes the momenta and positions of nucleons
83  * withing the colliding nuclei.
84  *
85  * \param[out] particles An empty list that gets filled up by this function
86  * \param[in] parameters The initialization parameters of the system
87  * \return The starting time of the simulation (negative, so that nuclei
88  * collide exactly at t=0)
89  * \throw domain_error if the velocities of each nucleus are >= 1, or if
90  * input for Fermi motion is invalid
91  */
92  double initial_conditions(Particles *particles,
93  const ExperimentParameters &parameters);
94 
95  /** Sample impact parameter.
96  *
97  * Samples the impact parameter from values between imp_min_ and imp_max_, if
98  * linear or quadratic sampling is used. By specifying impact parameters and
99  * corresponding yields, custom sampling can be used.
100  * This depends on the value of sampling_.
101  *
102  * Note that imp_max_ less than imp_min_ also works fine.
103  *
104  */
105  void sample_impact();
106 
107  /// Time until nuclei have passed through each other
108  double nuclei_passing_time() const {
109  const double passing_distance =
110  projectile_->get_nuclear_radius() + target_->get_nuclear_radius();
111  const double passing_time =
112  passing_distance /
113  std::sqrt(sqrt_s_NN_ * sqrt_s_NN_ /
114  ((2 * nucleon_mass) * (2 * nucleon_mass)) -
115  1);
116  return passing_time;
117  }
118  /**
119  * \return the beam velocity of the projectile, which will be used to
120  * calculate the beam momenta in experiment.cc if Fermi motion is
121  * frozen.
122  */
123  double velocity_projectile() const { return velocity_projectile_; }
124  /**
125  * \return the beam velocity of the target, which will be used to calculate
126  * the beam momenta in experiment.cc if Fermi motion is frozen.
127  */
128  double velocity_target() const { return velocity_target_; }
129  /// \return The Fermi motion type
131  /// \return whether the modus is collider (which is, yes, trivially true)
132  bool is_collider() const { return true; }
133  /// \return center of mass energy per nucleon pair
134  double sqrt_s_NN() const { return sqrt_s_NN_; }
135  /// \return impact parameter of the collision
136  double impact_parameter() const { return impact_; }
137  /// \return Whether the calculation frame is the fixed target frame
139  return frame_ == CalculationFrame::FixedTarget ? true : false;
140  }
141  /// \return Whether this is an initial condition for hydrodynamics
142  bool is_IC_for_hybrid() const { return IC_for_hybrid_; }
143  /// \return Parameters used in initial conditions for hydrodynamics
145  return *IC_parameters_;
146  }
147  /// \return The background energy density map
148  const std::map<int32_t, double> &fluid_background() const {
149  return *fluid_background_;
150  }
151  /// \return Lattice where fluidization is evaluated
153  return *fluid_lattice_;
154  }
155  /**
156  * Build lattice of energy momentum tensor. After t>25 fm, the lattice
157  * grows at every 5 \unit{fm} to accommodate for the system expansion.
158  *
159  * \param[in] t Current time.
160  * \param[in] ensembles Only the first Particles element is actually used.
161  * \param[in] dens_par Contains parameters for density smearing.
162  */
163  void build_fluidization_lattice(double t,
164  const std::vector<Particles> &ensembles,
165  const DensityParameters &dens_par);
166 
167  /**
168  * Update the background energy density due to hydrodynamics, to be
169  * called by an external manager.
170  *
171  * \param[in] background Map with particle indices as keys and their
172  * corresponding background energy density as values.
173  */
174  void update_fluidization_background(std::map<int32_t, double> &&background) {
175  *fluid_background_ = std::move(background);
176  }
177 
178  /**
179  * \ingroup exception
180  * Thrown when either \a projectile_ or \a target_ nuclei are empty.
181  */
183  using ModusDefault::BadInput::BadInput;
184  };
185 
186  private:
187  /**
188  * Projectile.
189  *
190  * The object that goes from negative z-values to positive z-values
191  * with positive velocity.
192  */
193  std::unique_ptr<Nucleus> projectile_;
194  /**
195  * Target.
196  *
197  * The object that goes from positive z-values to negative z-values
198  * with negative velocity. In fixed target experiments, the target is
199  * at rest.
200  */
201  std::unique_ptr<Nucleus> target_;
202  /**
203  * Center-of-mass energy squared of the nucleus-nucleus collision.
204  *
205  * Needs to be double to allow for calculations at LHC energies
206  */
207  double total_s_;
208  /**
209  * Center-of-mass energy of a nucleon-nucleon collision.
210  *
211  * Needs to be double to allow for calculations at LHC energies
212  */
213  double sqrt_s_NN_;
214  /** Configure Deformed Nucleus
215  *
216  * Sets up a deformed nucleus object based on the input parameters in the
217  * configuration file.
218  * \param[in] nucleus_cfg Subset of configuration, projectile or target
219  * section.
220  * \param[in] ntest Number of test particles
221  * \param[in] nucleus_type String 'projectile' or 'target'. To display an
222  * appropriate error message.
223  * \return Pointer to the created deformed nucleus object.
224  */
225  static std::unique_ptr<DeformedNucleus> create_deformed_nucleus(
226  Configuration &nucleus_cfg, const int ntest,
227  const std::string &nucleus_type);
228  /** Configure Alpha-Clustered Nucleus
229  *
230  * Sets up an alpha-clustered nucleus object based on the input parameters in
231  * the configuration file. \param[in] nucleus_cfg Subset of configuration,
232  * projectile or target section. \param[in] ntest Number of test particles
233  * \param[in] nucleus_type String 'projectile' or 'target'. To display an
234  * appropriate error message.
235  * \return Pointer to the created deformed nucleus object.
236  */
237  static std::unique_ptr<AlphaClusteredNucleus> create_alphaclustered_nucleus(
238  Configuration &nucleus_cfg, const int ntest,
239  const std::string &nucleus_type);
240  /**
241  * Checks if target and projectile are read from the same external file if
242  * they are both initialized as a customnucleus. Function is only called if,
243  * projectile is customnucleus.
244  * \param[in] proj_config Configuration of projectile nucleus
245  * \param[in] targ_config Configuration of target nucleus
246  */
247  bool same_inputfile(Configuration &proj_config, Configuration &targ_config);
248 
249  /**
250  * Print information about the input kinematic range for the Initial
251  * Conditions output.
252  */
253  void log_IC_kinematic_range() noexcept;
254 
255  /**
256  * Impact parameter.
257  *
258  * The nuclei projectile_ and target_ will be shifted along the x-axis
259  * so that their centers move on antiparallel lines that are this
260  * distance apart from each other.
261  */
262  double impact_ = 0.;
263  /// Whether the reaction plane should be randomized
265  /// Whether the particles will serve as initial conditions for hydrodynamics
266  bool IC_for_hybrid_ = false;
267  /// Method used for sampling of impact parameter.
268  Sampling sampling_ = InputKeys::modi_collider_impact_sample.default_value();
269  /// Minimum value of impact parameter.
270  double imp_min_ = InputKeys::modi_collider_impact_value.default_value();
271  /// Maximum value of impact parameter.
272  double imp_max_ = InputKeys::modi_collider_impact_value.default_value();
273  /// Maximum value of yield. Needed for custom impact parameter sampling.
274  double yield_max_ = 0.0;
275  /// Pointer to the impact parameter interpolation.
276  std::unique_ptr<InterpolateDataLinear<double>> impact_interpolation_ =
277  nullptr;
278 
279  /**
280  * Rotate the reaction plane about the angle phi
281  *
282  * \param[in] phi Angle about which to rotate
283  * \param[in] particles Particles, whose position is rotated
284  */
285  void rotate_reaction_plane(double phi, Particles *particles);
286 
287  /** Initial z-displacement of nuclei.
288  *
289  * Projectile is shifted on -(this value) in z-direction
290  * and target on +(this value)*v_target/v_projectile. In this way
291  * projectile and target touch at t=0 in z=0.
292  */
294  /**
295  * Reference frame for the system, as specified from config
296  */
298  /**
299  * An option to include Fermi motion ("off", "on", "frozen")
300  */
302  /**
303  * Beam velocity of the projectile
304  */
305  double velocity_projectile_ = 0.0;
306  /**
307  * Beam velocity of the target
308  */
309  double velocity_target_ = 0.0;
310  /// Plain Old Data type to hold parameters for initial conditions
312  /// Energy-momentum tensor lattice for dynamic fluidization
314  nullptr;
315  /**
316  * Energy density background from hydrodynamic evolution, with particle
317  * indices as keys. Useful when using SMASH as a library.
318  */
319  std::unique_ptr<std::map<int32_t, double>> fluid_background_ = nullptr;
320 
321  /**
322  * Get the frame dependent velocity for each nucleus, using
323  * the current reference frame. \see frame_
324  *
325  * \param[in] mandelstam_s The total center-of-mass energy of the system.
326  * \param[in] m_a The (positive) mass of the projectile.
327  * \param[in] m_b The (positive) mass of the target.
328  * \return A pair < v_a, v_b > containing the velocities of the nuclei.
329  * \throw domain_error if the reference frame is not properly specified
330  */
331  std::pair<double, double> get_velocities(double mandelstam_s, double m_a,
332  double m_b);
333 
334  /**\ingroup logging
335  * Writes the initial state for the ColliderModus to the output stream.
336  *
337  * \param[in] out The ostream into which to output
338  * \param[in] m The ColliderModus object to write into out
339  */
340  friend std::ostream &operator<<(std::ostream &, const ColliderModus &);
341 };
342 
343 } // namespace smash
344 
345 #endif // SRC_INCLUDE_SMASH_COLLIDERMODUS_H_
ColliderModus: Provides a modus for colliding nuclei.
Definition: collidermodus.h:48
CalculationFrame frame_
Reference frame for the system, as specified from config.
const RectangularLattice< EnergyMomentumTensor > & fluid_lattice() const
double imp_min_
Minimum value of impact parameter.
double initial_z_displacement_
Initial z-displacement of nuclei.
bool IC_for_hybrid_
Whether the particles will serve as initial conditions for hydrodynamics.
bool calculation_frame_is_fixed_target() const
double yield_max_
Maximum value of yield. Needed for custom impact parameter sampling.
void log_IC_kinematic_range() noexcept
Print information about the input kinematic range for the Initial Conditions output.
bool random_reaction_plane_
Whether the reaction plane should be randomized.
void rotate_reaction_plane(double phi, Particles *particles)
Rotate the reaction plane about the angle phi.
std::pair< double, double > get_velocities(double mandelstam_s, double m_a, double m_b)
Get the frame dependent velocity for each nucleus, using the current reference frame.
void sample_impact()
Sample impact parameter.
double impact_parameter() const
std::unique_ptr< Nucleus > projectile_
Projectile.
double nuclei_passing_time() const
Time until nuclei have passed through each other.
std::unique_ptr< InterpolateDataLinear< double > > impact_interpolation_
Pointer to the impact parameter interpolation.
void update_fluidization_background(std::map< int32_t, double > &&background)
Update the background energy density due to hydrodynamics, to be called by an external manager.
bool is_IC_for_hybrid() const
FermiMotion fermi_motion()
FermiMotion fermi_motion_
An option to include Fermi motion ("off", "on", "frozen")
const std::map< int32_t, double > & fluid_background() const
double velocity_target() const
static std::unique_ptr< AlphaClusteredNucleus > create_alphaclustered_nucleus(Configuration &nucleus_cfg, const int ntest, const std::string &nucleus_type)
Configure Alpha-Clustered Nucleus.
double velocity_projectile_
Beam velocity of the projectile.
Sampling sampling_
Method used for sampling of impact parameter.
std::unique_ptr< RectangularLattice< EnergyMomentumTensor > > fluid_lattice_
Energy-momentum tensor lattice for dynamic fluidization.
std::string custom_file_path(const std::string &file_directory, const std::string &file_name)
Creates full path string consisting of file_directory and file_name Needed to initialize a customnucl...
double total_s_
Center-of-mass energy squared of the nucleus-nucleus collision.
std::unique_ptr< Nucleus > target_
Target.
ColliderModus(Configuration modus_config, const ExperimentParameters &parameters)
Constructor.
double impact_
Impact parameter.
double sqrt_s_NN_
Center-of-mass energy of a nucleon-nucleon collision.
double initial_conditions(Particles *particles, const ExperimentParameters &parameters)
Generates initial state of the particles in the system.
void build_fluidization_lattice(double t, const std::vector< Particles > &ensembles, const DensityParameters &dens_par)
Build lattice of energy momentum tensor.
bool same_inputfile(Configuration &proj_config, Configuration &targ_config)
Checks if target and projectile are read from the same external file if they are both initialized as ...
std::unique_ptr< std::map< int32_t, double > > fluid_background_
Energy density background from hydrodynamic evolution, with particle indices as keys.
double sqrt_s_NN() const
double velocity_projectile() const
static std::unique_ptr< DeformedNucleus > create_deformed_nucleus(Configuration &nucleus_cfg, const int ntest, const std::string &nucleus_type)
Configure Deformed Nucleus.
const InitialConditionParameters & IC_parameters() const
double velocity_target_
Beam velocity of the target.
bool is_collider() const
std::unique_ptr< InitialConditionParameters > IC_parameters_
Plain Old Data type to hold parameters for initial conditions.
double imp_max_
Maximum value of impact parameter.
Interface to the SMASH configuration files.
A class to pre-calculate and store parameters relevant for density calculation.
Definition: density.h:92
The EnergyMomentumTensor class represents a symmetric positive semi-definite energy-momentum tensor .
Represent a piecewise linear interpolation.
Definition: interpolation.h:67
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
A container class to hold all the arrays on the lattice and access them.
Definition: lattice.h:49
FermiMotion
Option to use Fermi Motion.
Sampling
Possible methods of impact parameter sampling.
CalculationFrame
The calculation frame.
Definition: action.h:24
constexpr double nucleon_mass
Nucleon mass in GeV.
Definition: constants.h:69
Thrown when either projectile_ or target_ nuclei are empty.
Helper structure for Experiment.
The variables in this POD struct are of type std::optional<double> so that only the relevant paramete...
Definition: icparameters.h:19
A container to keep track of all ever existed input keys.
Definition: input_keys.h:1255
BadInput is an error to throw if the configuration options are invalid.
Definition: modusdefault.h:195