Version: SMASH-3.2.2
stringify.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2025
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #include "smash/stringify.h"
11 
12 #include <stdexcept>
13 #include <string_view>
14 #include <vector>
15 
16 namespace smash {
17 
18 // Throw because an enum value was not handled in the \c to_string function.
19 static void throw_unhandled_enum(std::string_view enum_name, int value) {
20  throw std::invalid_argument("Unhandled " + std::string(enum_name) +
21  " enum value " + std::to_string(value) +
22  " passed to conversion function to_string().");
23 }
24 
25 std::string to_string(ThermodynamicQuantity quantity) {
26  switch (quantity) {
28  return "rho_eckart";
30  return "tmn";
32  return "tmn_landau";
34  return "landau_velocity";
36  return "j_QBS";
37  }
38  throw_unhandled_enum("ThermodynamicQuantity", static_cast<int>(quantity));
39 }
40 
41 std::string to_string(CalculationFrame frame) {
42  switch (frame) {
44  return "center of velocity";
46  return "center of mass";
48  return "fixed target";
49  }
50  throw_unhandled_enum("CalculationFrame", static_cast<int>(frame));
51 }
52 
53 std::string to_string(FermiMotion motion) {
54  switch (motion) {
55  case FermiMotion::Off:
56  return "off";
57  case FermiMotion::On:
58  return "on";
60  return "frozen";
61  }
62  throw_unhandled_enum("FermiMotion", static_cast<int>(motion));
63 }
64 
65 std::string to_string(DensityType type) {
66  switch (type) {
68  return "hadron";
70  return "baryon";
72  return "baryonic isospin";
73  case DensityType::Pion:
74  return "pion";
76  return "total isospin";
77  case DensityType::None:
78  return "none";
80  return "charge";
82  return "strangeness";
83  }
84  throw_unhandled_enum("DensityType", static_cast<int>(type));
85 }
86 
87 std::string to_string(ExpansionMode mode) {
88  switch (mode) {
90  return "NoExpansion";
92  return "MasslessFRW";
94  return "MassiveFRW";
96  return "Exponential";
97  }
98  throw_unhandled_enum("ExpansionMode", static_cast<int>(mode));
99 }
100 
101 std::string to_string(DerivativesMode mode) {
102  switch (mode) {
104  return "Covariant Gaussian";
106  return "Finite difference";
108  return "Off";
109  }
110  throw_unhandled_enum("DerivativesMode", static_cast<int>(mode));
111 }
112 
113 std::string to_string(FieldDerivativesMode mode) {
114  switch (mode) {
116  return "Chain Rule";
118  return "Direct";
119  }
120  throw_unhandled_enum("FieldDerivativesMode", static_cast<int>(mode));
121 }
122 
123 std::string to_string(SmearingMode mode) {
124  switch (mode) {
126  return "Covariant Gaussian";
128  return "Discrete";
130  return "Triangular";
131  }
132  throw_unhandled_enum("SmearingMode", static_cast<int>(mode));
133 }
134 
135 std::string to_string(TimeStepMode mode) {
136  switch (mode) {
137  case TimeStepMode::None:
138  return "None";
139  case TimeStepMode::Fixed:
140  return "Fixed";
141  }
142  throw_unhandled_enum("TimeStepMode", static_cast<int>(mode));
143 }
144 
145 std::string to_string(BoxInitialCondition cond) {
146  switch (cond) {
148  return "thermal momenta";
150  return "thermal momenta quantum";
152  return "peaked momenta";
153  }
154  throw_unhandled_enum("BoxInitialCondition", static_cast<int>(cond));
155 }
156 
158  switch (cond) {
160  return "thermal momenta";
162  return "thermal momenta quantum";
164  return "IC_ES";
166  return "IC_1M";
168  return "IC_2M";
170  return "IC_Massive";
171  }
172  throw_unhandled_enum("SphereInitialCondition", static_cast<int>(cond));
173 }
174 
175 std::string to_string(NNbarTreatment t) {
176  switch (t) {
178  return "no annihilation";
180  return "resonances";
182  return "two to five";
184  return "strings";
185  }
186  throw_unhandled_enum("NNbarTreatment", static_cast<int>(t));
187 }
188 
189 std::string to_string(Sampling s) {
190  switch (s) {
191  case Sampling::Quadratic:
192  return "quadratic";
193  case Sampling::Custom:
194  return "custom";
195  case Sampling::Uniform:
196  return "uniform";
197  }
198  throw_unhandled_enum("Sampling", static_cast<int>(s));
199 }
200 
202  switch (algo) {
204  return "mode sampling";
206  return "biased BF";
208  return "unbiased BF";
209  }
210  throw_unhandled_enum("ThermalizationAlgorithm", static_cast<int>(algo));
211 }
212 
214  switch (c) {
216  return "Geometric";
218  return "Stochastic";
220  return "Covariant";
221  }
222  throw_unhandled_enum("CollisionCriterion", static_cast<int>(c));
223 }
224 
226  switch (s) {
228  return "BottomUp";
230  return "TopDown";
232  return "TopDownMeasured";
233  }
234  throw_unhandled_enum("TotalCrossSectionStrategy", static_cast<int>(s));
235 }
236 
238  switch (p) {
240  return "None";
242  return "Largest";
244  return "Closest";
246  return "LargestFromUnstable";
248  return "ClosestFromUnstable";
249  }
250  throw_unhandled_enum("PseudoResonance", static_cast<int>(p));
251 }
252 
253 std::string to_string(FluidizationType f) {
254  switch (f) {
256  return "Constant_Tau";
258  return "Dynamic";
259  }
260  throw_unhandled_enum("FluidizationType", static_cast<int>(f));
261 }
262 
263 std::string to_string(OutputOnlyFinal o) {
264  switch (o) {
266  return "Yes";
267  case OutputOnlyFinal::No:
268  return "No";
270  return "IfNotEmpty";
271  }
272  throw_unhandled_enum("OutputOnlyFinal", static_cast<int>(o));
273 }
274 
275 std::string to_string(einhard::LogLevel level) {
276  switch (level) {
278  return "ALL";
280  return "TRACE";
282  return "DEBUG";
284  return "INFO";
286  return "WARN";
288  return "ERROR";
290  return "FATAL";
292  return "OFF";
293  }
294  throw_unhandled_enum("einhard::LogLevel", static_cast<int>(level));
295 }
296 
297 std::vector<std::string> to_string(const ReactionsBitSet &s) {
298  std::vector<std::string> result{};
299  if (s.test(IncludedReactions::Elastic))
300  result.push_back("Elastic");
301  if (s.test(IncludedReactions::NN_to_NR))
302  result.push_back("NN_to_NR");
303  if (s.test(IncludedReactions::NN_to_DR))
304  result.push_back("NN_to_DR");
305  if (s.test(IncludedReactions::KN_to_KN))
306  result.push_back("KN_to_KN");
308  result.push_back("KN_to_KDelta");
310  result.push_back("Strangeness_exchange");
311  if (s.test(IncludedReactions::NNbar))
312  result.push_back("NNbar");
314  result.push_back("PiDeuteron_to_NN");
316  result.push_back("PiDeuteron_to_pidprime");
318  result.push_back("NDeuteron_to_Ndprime");
319  return result;
320 }
321 
322 std::vector<std::string> to_string(const MultiParticleReactionsBitSet &s) {
323  std::vector<std::string> result{};
325  result.push_back("Meson_3to1");
327  result.push_back("Deuteron_3to2");
329  result.push_back("NNbar_5to2");
331  result.push_back("A3_Nuclei_4to2");
332  return result;
333 }
334 
335 std::vector<std::string> to_string(const FluidizableProcessesBitSet &s) {
336  std::vector<std::string> result{};
338  result.push_back("Elastic");
340  result.push_back("Decay");
342  result.push_back("Inelastic");
344  result.push_back("SoftString");
346  result.push_back("HardString");
347  return result;
348 }
349 
350 } // namespace smash
SmearingMode
Modes of smearing.
FermiMotion
Option to use Fermi Motion.
@ On
Use fermi motion in combination with potentials.
@ Frozen
Use fermi motion without potentials.
@ Off
Don't use fermi motion.
std::bitset< 10 > ReactionsBitSet
Container for the 2 to 2 reactions in the code.
ThermalizationAlgorithm
Defines the algorithm used for the forced thermalization.
FluidizationType
Possible methods to convert SMASH particle into fluid cells.
@ ConstantTau
Hypersurface crossed at a fixed proper time.
@ Dynamic
Dynamic fluidization based on local densities.
NNbarTreatment
Treatment of N Nbar Annihilation.
@ NoAnnihilation
No Annihilation.
@ TwoToFive
Directly create 5 pions, use with multi-particle reactions.
@ Resonances
Use intermediate Resonances.
@ Strings
Use string fragmentation.
TimeStepMode
The time step mode.
@ Fixed
Use fixed time step.
@ None
Don't use time steps; propagate from action to action.
ThermodynamicQuantity
Represents thermodynamic quantities that can be printed out See user guide description for more infor...
@ EckartDensity
Density in the Eckart frame.
@ Tmn
Energy-momentum tensor in lab frame.
@ LandauVelocity
Velocity of the Landau rest frame.
@ j_QBS
Electric (Q), baryonic (B) and strange (S) currents.
@ TmnLandau
Energy-momentum tensor in Landau rest frame.
std::bitset< 5 > FluidizableProcessesBitSet
TotalCrossSectionStrategy
Determine how total cross sections for collision finding should be computed.
@ TopDownMeasured
Mix the two above, using the parametrizations only for measured processes, and summing up partials fo...
@ TopDown
Use parametrizations based on existing data, rescaling with AQM for unmeasured processes.
@ BottomUp
Sum the existing partial contributions.
Sampling
Possible methods of impact parameter sampling.
@ Quadratic
Sample from areal / quadratic distribution.
@ Custom
Sample from custom, user-defined distribution.
@ Uniform
Sample from uniform distribution.
@ From_HardString
@ From_Inelastic
@ From_Elastic
@ From_SoftString
@ From_Decay
std::bitset< 4 > MultiParticleReactionsBitSet
Container for the n to m reactions in the code.
CalculationFrame
The calculation frame.
@ NNbar_5to2
@ A3_Nuclei_4to2
@ Deuteron_3to2
@ Meson_3to1
DerivativesMode
Modes of calculating the gradients.
CollisionCriterion
Criteria used to check collisions.
@ Stochastic
Stochastic Criteiron.
@ Geometric
Geometric criterion.
@ Covariant
Covariant Criterion.
FieldDerivativesMode
Modes of calculating the field gradients: chain rule or direct.
SphereInitialCondition
Initial condition for a particle in a sphere.
@ ThermalMomentaBoltzmann
A thermalized ensemble is generated, with momenta sampled from a Maxwell-Boltzmann distribution.
@ IC_ES
Off-equilibrium distribution used in massless comparisons of SMASH to the extended universe metric.
@ ThermalMomentaQuantum
A thermalized ensemble is generated, with momenta of baryons(mesons) sampled from a Fermi(Bose) distr...
@ IC_Massive
A generalization of IC_ES for the non-zero mass case; note that there is currently no analytical comp...
@ IC_2M
Off-equilibrium distribution used in massless comparisons of SMASH to the extended universe metric.
@ IC_1M
Off-equilibrium distribution used in massless comparisons of SMASH to the extended universe metric.
PseudoResonance
Which pseudo-resonance fills the inelastic gap in the transition to string region of cross sections.
@ Closest
Resonance with the pole mass closest from the invariant mass of incoming particles for all processes.
@ ClosestFromUnstable
Closest resonance for a given mass from processes with at least one resonance in the incoming particl...
@ None
No pseudo-resonance is created.
@ LargestFromUnstable
Heaviest possible resonance from processes with at least one resonance in the incoming particles.
@ Largest
Resonance of largest mass for all processes.
@ KN_to_KDelta
@ KN_to_KN
@ NN_to_NR
@ PiDeuteron_to_pidprime
@ NDeuteron_to_Ndprime
@ Strangeness_exchange
@ PiDeuteron_to_NN
@ NN_to_DR
DensityType
Allows to choose which kind of density to calculate.
OutputOnlyFinal
Whether and when only final state particles should be printed.
@ IfNotEmpty
Print only final-state particles, and those only if the event is not empty.
@ Yes
Print only final-state particles.
@ No
Print initial, intermediate and final-state particles.
BoxInitialCondition
Initial condition for a particle in a box.
@ ThermalMomentaBoltzmann
A thermalized ensemble is generated, with momenta sampled from a Maxwell-Boltzmann distribution.
@ ThermalMomentaQuantum
A thermalized ensemble is generated, with momenta of baryons(mesons) sampled from a Fermi(Bose) distr...
@ PeakedMomenta
All particles have the same momentum with T being the temperature.
ExpansionMode
Defines properties of expansion for the metric (e.g.
LogLevel
Specification of the message severity.
Definition: einhard.hpp:109
@ TRACE
The lowes severity for messages describing the program flow.
Definition: einhard.hpp:111
@ OFF
If selected no messages will be output.
Definition: einhard.hpp:117
@ WARN
Warning messages.
Definition: einhard.hpp:114
@ ALL
Log all message.
Definition: einhard.hpp:110
@ ERROR
Non-fatal errors.
Definition: einhard.hpp:115
@ DEBUG
Debug messages.
Definition: einhard.hpp:112
@ FATAL
Messages that indicate terminal application failure.
Definition: einhard.hpp:116
@ INFO
Messages of informational nature, expected processing time e.g.
Definition: einhard.hpp:113
constexpr int p
Proton.
Definition: action.h:24
static void throw_unhandled_enum(std::string_view enum_name, int value)
Definition: stringify.cc:19
std::string to_string(ThermodynamicQuantity quantity)
Convert a ThermodynamicQuantity enum value to its corresponding string.
Definition: stringify.cc:25