Version: SMASH-3.4
stringify.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2025-2026
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 
55  switch (factor) {
57  return "FF1";
59  return "FF2";
61  return "Off";
62  }
63  throw_unhandled_enum("DileptonBremsPionFormFactor", static_cast<int>(factor));
64 }
65 
66 std::string to_string(FermiMotion motion) {
67  switch (motion) {
68  case FermiMotion::Off:
69  return "off";
70  case FermiMotion::On:
71  return "on";
73  return "frozen";
74  }
75  throw_unhandled_enum("FermiMotion", static_cast<int>(motion));
76 }
77 
78 std::string to_string(DensityType type) {
79  switch (type) {
81  return "hadron";
83  return "baryon";
85  return "baryonic isospin";
86  case DensityType::Pion:
87  return "pion";
89  return "total isospin";
90  case DensityType::None:
91  return "none";
93  return "charge";
95  return "strangeness";
96  }
97  throw_unhandled_enum("DensityType", static_cast<int>(type));
98 }
99 
100 std::string to_string(ExpansionMode mode) {
101  switch (mode) {
103  return "NoExpansion";
105  return "MasslessFRW";
107  return "MassiveFRW";
109  return "Exponential";
110  }
111  throw_unhandled_enum("ExpansionMode", static_cast<int>(mode));
112 }
113 
114 std::string to_string(DerivativesMode mode) {
115  switch (mode) {
117  return "Covariant Gaussian";
119  return "Finite difference";
121  return "Off";
122  }
123  throw_unhandled_enum("DerivativesMode", static_cast<int>(mode));
124 }
125 
126 std::string to_string(FieldDerivativesMode mode) {
127  switch (mode) {
129  return "Chain Rule";
131  return "Direct";
132  }
133  throw_unhandled_enum("FieldDerivativesMode", static_cast<int>(mode));
134 }
135 
136 std::string to_string(SmearingMode mode) {
137  switch (mode) {
139  return "Covariant Gaussian";
141  return "Discrete";
143  return "Triangular";
144  }
145  throw_unhandled_enum("SmearingMode", static_cast<int>(mode));
146 }
147 
148 std::string to_string(TimeStepMode mode) {
149  switch (mode) {
150  case TimeStepMode::None:
151  return "None";
152  case TimeStepMode::Fixed:
153  return "Fixed";
154  }
155  throw_unhandled_enum("TimeStepMode", static_cast<int>(mode));
156 }
157 
158 std::string to_string(BoxInitialCondition cond) {
159  switch (cond) {
161  return "thermal momenta";
163  return "thermal momenta quantum";
165  return "peaked momenta";
166  }
167  throw_unhandled_enum("BoxInitialCondition", static_cast<int>(cond));
168 }
169 
171  switch (cond) {
173  return "thermal momenta";
175  return "thermal momenta quantum";
177  return "IC_ES";
179  return "IC_1M";
181  return "IC_2M";
183  return "IC_Massive";
184  }
185  throw_unhandled_enum("SphereInitialCondition", static_cast<int>(cond));
186 }
187 
188 std::string to_string(NNbarTreatment t) {
189  switch (t) {
191  return "no annihilation";
193  return "resonances";
195  return "two to five";
197  return "strings";
198  }
199  throw_unhandled_enum("NNbarTreatment", static_cast<int>(t));
200 }
201 
202 std::string to_string(Sampling s) {
203  switch (s) {
204  case Sampling::Quadratic:
205  return "quadratic";
206  case Sampling::Custom:
207  return "custom";
208  case Sampling::Uniform:
209  return "uniform";
210  }
211  throw_unhandled_enum("Sampling", static_cast<int>(s));
212 }
213 
215  switch (algo) {
217  return "mode sampling";
219  return "biased BF";
221  return "unbiased BF";
222  }
223  throw_unhandled_enum("ThermalizationAlgorithm", static_cast<int>(algo));
224 }
225 
227  switch (c) {
229  return "Geometric";
231  return "Stochastic";
233  return "Covariant";
234  }
235  throw_unhandled_enum("CollisionCriterion", static_cast<int>(c));
236 }
237 
238 std::string to_string(CharmRescattering c) {
239  switch (c) {
241  return "none";
243  return "resonances";
245  return "T-matrix";
246  }
247  throw_unhandled_enum("CharmRescattering", static_cast<int>(c));
248 }
249 
250 std::string to_string(SpinInteractionType type) {
251  switch (type) {
253  return "On";
255  return "Off";
256  }
257  throw_unhandled_enum("SpinInteractionType", static_cast<int>(type));
258 }
259 
261  switch (s) {
263  return "BottomUp";
265  return "TopDown";
267  return "TopDownMeasured";
268  }
269  throw_unhandled_enum("TotalCrossSectionStrategy", static_cast<int>(s));
270 }
271 
273  switch (p) {
275  return "None";
277  return "Largest";
279  return "Closest";
281  return "LargestFromUnstable";
283  return "ClosestFromUnstable";
284  }
285  throw_unhandled_enum("PseudoResonance", static_cast<int>(p));
286 }
287 
288 std::string to_string(FluidizationType f) {
289  switch (f) {
291  return "Constant_Tau";
293  return "Dynamic";
294  }
295  throw_unhandled_enum("FluidizationType", static_cast<int>(f));
296 }
297 
298 std::string to_string(OutputOnlyFinal o) {
299  switch (o) {
301  return "Yes";
302  case OutputOnlyFinal::No:
303  return "No";
305  return "IfNotEmpty";
306  }
307  throw_unhandled_enum("OutputOnlyFinal", static_cast<int>(o));
308 }
309 
310 std::string to_string(einhard::LogLevel level) {
311  switch (level) {
313  return "ALL";
315  return "TRACE";
317  return "DEBUG";
319  return "INFO";
321  return "WARN";
323  return "ERROR";
325  return "FATAL";
327  return "OFF";
328  }
329  throw_unhandled_enum("einhard::LogLevel", static_cast<int>(level));
330 }
331 
332 std::vector<std::string> to_string(const ReactionsBitSet &s) {
333  std::vector<std::string> result{};
334  if (s.test(IncludedReactions::Elastic))
335  result.push_back("Elastic");
336  if (s.test(IncludedReactions::NN_to_NR))
337  result.push_back("NN_to_NR");
338  if (s.test(IncludedReactions::NN_to_DR))
339  result.push_back("NN_to_DR");
340  if (s.test(IncludedReactions::KN_to_KN))
341  result.push_back("KN_to_KN");
343  result.push_back("KN_to_KDelta");
345  result.push_back("Strangeness_exchange");
346  if (s.test(IncludedReactions::NNbar))
347  result.push_back("NNbar");
349  result.push_back("PiDeuteron_to_NN");
351  result.push_back("PiDeuteron_to_pidprime");
353  result.push_back("NDeuteron_to_Ndprime");
355  result.push_back("Charm_T-matrix");
356  return result;
357 }
358 
359 std::vector<std::string> to_string(const MultiParticleReactionsBitSet &s) {
360  std::vector<std::string> result{};
362  result.push_back("Meson_3to1");
364  result.push_back("Deuteron_3to2");
366  result.push_back("NNbar_5to2");
368  result.push_back("A3_Nuclei_4to2");
369  return result;
370 }
371 
372 std::vector<std::string> to_string(const FluidizableProcessesBitSet &s) {
373  std::vector<std::string> result{};
375  result.push_back("Elastic");
377  result.push_back("Decay");
379  result.push_back("Inelastic");
381  result.push_back("SoftString");
383  result.push_back("HardString");
384  return result;
385 }
386 
387 } // namespace smash
SmearingMode
Modes of smearing.
DileptonBremsPionFormFactor
Option to use form factors in dilepton bremsstrahlung as described in Shyam:2010vr .
@ FF2
Photon couples 40% directly to intrinsice quark structure of pion and 60% indirectly via meson.
@ FF1
Photon couples to pion only via meson.
@ Off
Don't use form factors, i.e. multiply by 1.
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.
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.
CharmRescattering
Possible charm scattering options.
@ T_Matrix
Charm interactions via T-matrix approach.
@ Resonances
Charm interactions via resonances.
@ None
Disable charm interactions.
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
@ Charm_T_matrix
@ PiDeuteron_to_NN
@ NN_to_DR
std::bitset< 11 > ReactionsBitSet
Container for the 2 to 2 reactions in the code.
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