Version: SMASH-3.3
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 [[noreturn]] static void throw_unhandled_enum(std::string_view enum_name,
20  int value) {
21  throw std::invalid_argument("Unhandled " + std::string(enum_name) +
22  " enum value " + std::to_string(value) +
23  " passed to conversion function to_string().");
24 }
25 
26 std::string to_string(ThermodynamicQuantity quantity) {
27  switch (quantity) {
29  return "rho_eckart";
31  return "tmn";
33  return "tmn_landau";
35  return "landau_velocity";
37  return "j_QBS";
38  }
39  throw_unhandled_enum("ThermodynamicQuantity", static_cast<int>(quantity));
40 }
41 
42 std::string to_string(CalculationFrame frame) {
43  switch (frame) {
45  return "center of velocity";
47  return "center of mass";
49  return "fixed target";
50  }
51  throw_unhandled_enum("CalculationFrame", static_cast<int>(frame));
52 }
53 
54 std::string to_string(FermiMotion motion) {
55  switch (motion) {
56  case FermiMotion::Off:
57  return "off";
58  case FermiMotion::On:
59  return "on";
61  return "frozen";
62  }
63  throw_unhandled_enum("FermiMotion", static_cast<int>(motion));
64 }
65 
66 std::string to_string(DensityType type) {
67  switch (type) {
69  return "hadron";
71  return "baryon";
73  return "baryonic isospin";
74  case DensityType::Pion:
75  return "pion";
77  return "total isospin";
78  case DensityType::None:
79  return "none";
81  return "charge";
83  return "strangeness";
84  }
85  throw_unhandled_enum("DensityType", static_cast<int>(type));
86 }
87 
88 std::string to_string(ExpansionMode mode) {
89  switch (mode) {
91  return "NoExpansion";
93  return "MasslessFRW";
95  return "MassiveFRW";
97  return "Exponential";
98  }
99  throw_unhandled_enum("ExpansionMode", static_cast<int>(mode));
100 }
101 
102 std::string to_string(DerivativesMode mode) {
103  switch (mode) {
105  return "Covariant Gaussian";
107  return "Finite difference";
109  return "Off";
110  }
111  throw_unhandled_enum("DerivativesMode", static_cast<int>(mode));
112 }
113 
114 std::string to_string(FieldDerivativesMode mode) {
115  switch (mode) {
117  return "Chain Rule";
119  return "Direct";
120  }
121  throw_unhandled_enum("FieldDerivativesMode", static_cast<int>(mode));
122 }
123 
124 std::string to_string(SmearingMode mode) {
125  switch (mode) {
127  return "Covariant Gaussian";
129  return "Discrete";
131  return "Triangular";
132  }
133  throw_unhandled_enum("SmearingMode", static_cast<int>(mode));
134 }
135 
136 std::string to_string(TimeStepMode mode) {
137  switch (mode) {
138  case TimeStepMode::None:
139  return "None";
140  case TimeStepMode::Fixed:
141  return "Fixed";
142  }
143  throw_unhandled_enum("TimeStepMode", static_cast<int>(mode));
144 }
145 
146 std::string to_string(BoxInitialCondition cond) {
147  switch (cond) {
149  return "thermal momenta";
151  return "thermal momenta quantum";
153  return "peaked momenta";
154  }
155  throw_unhandled_enum("BoxInitialCondition", static_cast<int>(cond));
156 }
157 
159  switch (cond) {
161  return "thermal momenta";
163  return "thermal momenta quantum";
165  return "IC_ES";
167  return "IC_1M";
169  return "IC_2M";
171  return "IC_Massive";
172  }
173  throw_unhandled_enum("SphereInitialCondition", static_cast<int>(cond));
174 }
175 
176 std::string to_string(NNbarTreatment t) {
177  switch (t) {
179  return "no annihilation";
181  return "resonances";
183  return "two to five";
185  return "strings";
186  }
187  throw_unhandled_enum("NNbarTreatment", static_cast<int>(t));
188 }
189 
190 std::string to_string(Sampling s) {
191  switch (s) {
192  case Sampling::Quadratic:
193  return "quadratic";
194  case Sampling::Custom:
195  return "custom";
196  case Sampling::Uniform:
197  return "uniform";
198  }
199  throw_unhandled_enum("Sampling", static_cast<int>(s));
200 }
201 
203  switch (algo) {
205  return "mode sampling";
207  return "biased BF";
209  return "unbiased BF";
210  }
211  throw_unhandled_enum("ThermalizationAlgorithm", static_cast<int>(algo));
212 }
213 
215  switch (c) {
217  return "Geometric";
219  return "Stochastic";
221  return "Covariant";
222  }
223  throw_unhandled_enum("CollisionCriterion", static_cast<int>(c));
224 }
225 
226 std::string to_string(SpinInteractionType type) {
227  switch (type) {
229  return "On";
231  return "Off";
232  }
233  throw_unhandled_enum("SpinInteractionType", static_cast<int>(type));
234 }
235 
237  switch (s) {
239  return "BottomUp";
241  return "TopDown";
243  return "TopDownMeasured";
244  }
245  throw_unhandled_enum("TotalCrossSectionStrategy", static_cast<int>(s));
246 }
247 
249  switch (p) {
251  return "None";
253  return "Largest";
255  return "Closest";
257  return "LargestFromUnstable";
259  return "ClosestFromUnstable";
260  }
261  throw_unhandled_enum("PseudoResonance", static_cast<int>(p));
262 }
263 
264 std::string to_string(FluidizationType f) {
265  switch (f) {
267  return "Constant_Tau";
269  return "Dynamic";
270  }
271  throw_unhandled_enum("FluidizationType", static_cast<int>(f));
272 }
273 
274 std::string to_string(OutputOnlyFinal o) {
275  switch (o) {
277  return "Yes";
278  case OutputOnlyFinal::No:
279  return "No";
281  return "IfNotEmpty";
282  }
283  throw_unhandled_enum("OutputOnlyFinal", static_cast<int>(o));
284 }
285 
286 std::string to_string(einhard::LogLevel level) {
287  switch (level) {
289  return "ALL";
291  return "TRACE";
293  return "DEBUG";
295  return "INFO";
297  return "WARN";
299  return "ERROR";
301  return "FATAL";
303  return "OFF";
304  }
305  throw_unhandled_enum("einhard::LogLevel", static_cast<int>(level));
306 }
307 
308 std::vector<std::string> to_string(const ReactionsBitSet &s) {
309  std::vector<std::string> result{};
310  if (s.test(IncludedReactions::Elastic))
311  result.push_back("Elastic");
312  if (s.test(IncludedReactions::NN_to_NR))
313  result.push_back("NN_to_NR");
314  if (s.test(IncludedReactions::NN_to_DR))
315  result.push_back("NN_to_DR");
316  if (s.test(IncludedReactions::KN_to_KN))
317  result.push_back("KN_to_KN");
319  result.push_back("KN_to_KDelta");
321  result.push_back("Strangeness_exchange");
322  if (s.test(IncludedReactions::NNbar))
323  result.push_back("NNbar");
325  result.push_back("PiDeuteron_to_NN");
327  result.push_back("PiDeuteron_to_pidprime");
329  result.push_back("NDeuteron_to_Ndprime");
330  return result;
331 }
332 
333 std::vector<std::string> to_string(const MultiParticleReactionsBitSet &s) {
334  std::vector<std::string> result{};
336  result.push_back("Meson_3to1");
338  result.push_back("Deuteron_3to2");
340  result.push_back("NNbar_5to2");
342  result.push_back("A3_Nuclei_4to2");
343  return result;
344 }
345 
346 std::vector<std::string> to_string(const FluidizableProcessesBitSet &s) {
347  std::vector<std::string> result{};
349  result.push_back("Elastic");
351  result.push_back("Decay");
353  result.push_back("Inelastic");
355  result.push_back("SoftString");
357  result.push_back("HardString");
358  return result;
359 }
360 
361 } // 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.
SpinInteractionType
Possible spin interaction types.
@ On
All spin interactions.
@ Off
No spin interactions.
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:26