Version: SMASH-3.3
setup.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2015,2017-2025
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_TESTS_SETUP_H_
11 #define SRC_TESTS_SETUP_H_
12 
13 #include <filesystem>
14 
15 #include "smash/decaymodes.h"
16 #include "smash/experiment.h"
17 #include "smash/outputinterface.h"
18 #include "smash/particledata.h"
19 #include "smash/particles.h"
20 #include "smash/particletype.h"
21 #include "smash/random.h"
23 
24 namespace smash {
25 namespace Test {
26 
37 #ifndef DOXYGEN
39 #include <particles.txt.h>
40 #endif
42 }
43 
48 inline void create_actual_decaymodes() {
49 #ifndef DOXYGEN
51 #include <decaymodes.txt.h>
52 #endif
54 }
55 
57 static constexpr double smashon_mass = 0.123;
59 static constexpr double smashon_width = 1.2;
61 static constexpr const char smashon_pdg_string[] = "661";
62 
68  "# NAME MASS[GEV] WIDTH[GEV] PARITY PDG\n"
69  "σ " +
71  " + 661\n");
72 }
73 
80  "# NAME MASS[GEV] WIDTH[GEV] PARITY PDG\n"
81  "σ " +
82  std::to_string(smashon_mass) + " 0.0 + 661\n");
83 }
84 
86 struct Position : public FourVector {
88 };
90 struct Momentum : public FourVector {
92 };
93 
98 inline ParticleData smashon(int id = -1) {
99  ParticleData p{ParticleType::find(0x661), id};
100  return p;
101 }
106 inline ParticleData smashon(const Position &position, int id = -1) {
107  ParticleData p{ParticleType::find(0x661), id};
108  p.set_4position(position);
109  p.set_formation_time(position[0]);
110  return p;
111 }
116 inline ParticleData smashon(const Momentum &momentum, int id = -1) {
117  ParticleData p{ParticleType::find(0x661), id};
118  p.set_4momentum(momentum);
119  return p;
120 }
125 inline ParticleData smashon(const Position &position, const Momentum &momentum,
126  int id = -1) {
127  ParticleData p{ParticleType::find(0x661), id};
128  p.set_4position(position);
129  p.set_4momentum(momentum);
130  p.set_formation_time(position[0]);
131  p.set_unpolarized_spin_vector();
132  return p;
133 }
141 inline ParticleData smashon(const Momentum &momentum, const Position &position,
142  int id = -1) {
143  ParticleData p{ParticleType::find(0x661), id};
144  p.set_4position(position);
145  p.set_4momentum(momentum);
146  p.set_formation_time(position[0]);
147  p.set_unpolarized_spin_vector();
148  return p;
149 }
154 inline ParticleData smashon_random(int id = -1) {
155  auto random_value = random::make_uniform_distribution(-15.0, +15.0);
156  ParticleData p{ParticleType::find(0x661), id};
157  auto random_time = random_value();
158  p.set_formation_time(random_time);
159  p.set_4position(
160  {random_time, random_value(), random_value(), random_value()});
161  p.set_4momentum(smashon_mass,
162  {random_value(), random_value(), random_value()});
163  return p;
164 }
165 
169 inline std::unique_ptr<ExperimentBase> experiment(Configuration c) {
170  return ExperimentBase::create(c, ".");
171 }
172 
176 template <typename G>
177 inline ParticleList create_particle_list(std::size_t n, G &&generator) {
178  ParticleList list;
179  list.reserve(n);
180  for (auto i = n; i; --i) {
181  list.emplace_back(generator());
182  }
183  return list;
184 }
185 
187 using ParticlesPtr = std::unique_ptr<Particles>;
188 
193 template <typename G>
194 inline ParticlesPtr create_particles(int n, G &&generator) {
195  ParticlesPtr p = std::make_unique<Particles>();
196  for (auto i = n; i; --i) {
197  p->insert(generator());
198  }
199  return p;
200 }
201 
207  const std::initializer_list<ParticleData> &init) {
208  ParticlesPtr p = std::make_unique<Particles>();
209  for (const auto &data : init) {
210  p->insert(data);
211  }
212  return p;
213 }
214 
217  return ReactionsBitSet().set();
218 }
219 
222  return MultiParticleReactionsBitSet().reset();
223 }
224 
233  int testparticles = 1, double dt = 0.1,
235  bool strings = false,
237  ReactionsBitSet included_2to2 = all_reactions_included()) {
238  return ExperimentParameters{
239  std::make_unique<UniformClock>(0., dt, 300.0), // labclock
240  std::make_unique<UniformClock>(0., 1., 300.0), // outputclock
241  1, // ensembles
242  testparticles, // testparticles
243  DerivativesMode::CovariantGaussian, // derivatives mode
244  RestFrameDensityDerivativesMode::Off, // rest frame derivatives mode
245  FieldDerivativesMode::ChainRule, // field derivatives mode
246  SmearingMode::CovariantGaussian, // smearing mode
247  1.0, // Gaussian smearing width
248  4.0, // Gaussian smearing cut-off
249  0.333333, // discrete smearing weight
250  2.0, // triangular smearing range
251  criterion, // collision criterion
252  true, // two_to_one
253  included_2to2,
255  strings,
256  1.0,
257  nnbar_treatment,
258  0., // low energy sigma_NN cut-off
259  false, // potential_affect_threshold
260  -1.0, // box_length
261  200.0, // max. cross section
262  2.5, // fixed min. cell length
263  1.0, // cross section scaling
264  false, // in thermodynamics outputs spectators are included
265  false, // do weak decays
266  true, // decay initial particles
267  SpinInteractionType::Off, // no spin interactions
268  std::nullopt // use monash tune, not known
269  };
270 }
271 
281  double elastic_parameter = 10,
283  ReactionsBitSet included_2to2 = all_reactions_included(),
284  bool strings_switch = true, bool use_AQM = false,
285  bool strings_with_probability = false,
286  TotalCrossSectionStrategy xs_strategy =
288  Configuration config{
289  R"(
290  Collision_Term:
291  Only_Warn_For_High_Probability: true
292  Pseudoresonance: None
293  )"};
294  config.set_value(InputKeys::collTerm_elasticCrossSection, elastic_parameter);
295  config.set_value(InputKeys::collTerm_useAQM, use_AQM);
297  strings_with_probability);
298 
299  if (xs_strategy == TotalCrossSectionStrategy::BottomUp) {
300  config.merge_yaml(InputKeys::collTerm_totXsStrategy.as_yaml("BottomUp"));
301  } else if (xs_strategy == TotalCrossSectionStrategy::TopDown) {
302  config.merge_yaml(InputKeys::collTerm_totXsStrategy.as_yaml("TopDown"));
303  } else if (xs_strategy == TotalCrossSectionStrategy::TopDownMeasured) {
304  config.merge_yaml(
305  InputKeys::collTerm_totXsStrategy.as_yaml("TopDownMeasured"));
306  }
308  config,
309  default_parameters(1, 0.1, CollisionCriterion::Geometric, strings_switch,
310  nnbar_treatment, included_2to2));
311 }
312 
314 inline EventInfo default_event_info(double impact_parameter = 0.0,
315  bool empty_event = false) {
316  return EventInfo{impact_parameter, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1,
317  empty_event, false};
318 }
319 
321 inline std::unique_ptr<StringProcess> default_string_process_interface() {
322  return std::make_unique<StringProcess>(
323  1.0, // String_Tension
324  1.0, // String_Formation_Time
325  0.5, // Gluon_Beta
326  0.001, // Gluon_Pmin
327  2.0, // Quark_Alpha
328  7.0, // Quark_Beta
329  0.16, // Strange_Supp
330  0.036, // Diquark_Supp
331  0.42, // Sigma_Perp
332  0.2, // StringZ_A_Leading
333  2.0, // StringZ_B_Leading
334  2.0, // StringZ_A
335  0.55, // StringZ_B
336  0.5, // String_Sigma_T
337  1.0, // Form_Time_Factor
338  false, // Mass_Dependent_Formation_Times
339  1. / 3., // Prob_proton_to_d_uu
340  true, // Separate_Fragment_Baryon
341  0.15, // Popcorn_Rate
342  false); // Use_Monash_Tune
343 }
344 
347  InitialConditionParameters parameters{};
348  parameters.type = FluidizationType::Dynamic;
349  parameters.fluidizable_processes = FluidizableProcessesBitSet{}.set();
350  parameters.energy_density_threshold = 0.5;
351  parameters.min_time = 0;
352  parameters.max_time = 100;
353  parameters.num_fluid_cells = 50;
354  parameters.formation_time_fraction = 1;
355  parameters.smearing_kernel_at_0 = std::pow(2 * M_PI, -1.5);
356  parameters.delay_initial_elastic = false;
357  return parameters;
358 }
359 
363 } // namespace Test
364 } // namespace smash
365 
366 #endif // SRC_TESTS_SETUP_H_
Interface to the SMASH configuration files.
void set_value(Key< U > key, T &&value)
Overwrite the value of the YAML node corresponding to the specified key.
static void load_decaymodes(const std::string &input)
Loads the DecayModes map as described in the input string.
Definition: decaymodes.cc:163
static std::unique_ptr< ExperimentBase > create(Configuration &config, const std::filesystem::path &output_path)
Factory method that creates and initializes a new Experiment<Modus>.
Definition: experiment.cc:22
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
FourVector()
default constructor nulls the fourvector components
Definition: fourvector.h:36
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:59
static const ParticleType & find(PdgCode pdgcode)
Returns the ParticleType object for the given pdgcode.
Definition: particletype.cc:99
static void create_type_list(const std::string &particles)
Initialize the global ParticleType list (list_all) from the given input data.
Helper class for ScatterActionsFinder.
std::bitset< 10 > ReactionsBitSet
Container for the 2 to 2 reactions in the code.
@ Dynamic
Dynamic fluidization based on local densities.
NNbarTreatment
Treatment of N Nbar Annihilation.
@ NoAnnihilation
No Annihilation.
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.
std::bitset< 4 > MultiParticleReactionsBitSet
Container for the n to m reactions in the code.
CollisionCriterion
Criteria used to check collisions.
@ Geometric
Geometric criterion.
@ Off
No spin interactions.
ParticleList create_particle_list(std::size_t n, G &&generator)
Generate a list of particles from the given generator function.
Definition: setup.h:177
static constexpr double smashon_mass
The mass of the smashon particle.
Definition: setup.h:57
void create_actual_particletypes()
Creates the ParticleType list containing the actual particles that SMASH uses.
Definition: setup.h:36
static constexpr const char smashon_pdg_string[]
The PDG code of the smashon particle.
Definition: setup.h:61
ParticlesPtr create_particles(int n, G &&generator)
Creates a Particles object and fills it with n particles generated by the generator function.
Definition: setup.h:194
std::unique_ptr< StringProcess > default_string_process_interface()
Creates a default StringProcessInterface object for testing.
Definition: setup.h:317
static constexpr double smashon_width
The decay width of the smashon particle.
Definition: setup.h:59
void create_actual_decaymodes()
Creates the DecayModes list containing the actual decay modes that SMASH uses.
Definition: setup.h:48
std::unique_ptr< Particles > ParticlesPtr
A type alias for a unique_ptr of Particles.
Definition: setup.h:187
std::unique_ptr< ExperimentBase > experiment(Configuration c)
Create an experiment given an input configuration.
Definition: setup.h:169
void create_smashon_particletypes()
Creates a ParticleType list containing only the smashon test particle.
Definition: setup.h:66
ParticleData smashon(int id=-1)
Create a particle with 0 position and momentum vectors and optionally a given id.
Definition: setup.h:98
MultiParticleReactionsBitSet no_multiparticle_reactions()
returns BitSet for multi-particle reactions, where everything is off
Definition: setup.h:221
ScatterActionsFinderParameters default_finder_parameters(double elastic_parameter=10, NNbarTreatment nnbar_treatment=NNbarTreatment::NoAnnihilation, ReactionsBitSet included_2to2=all_reactions_included(), bool strings_switch=true, bool use_AQM=false, bool strings_with_probability=false, TotalCrossSectionStrategy xs_strategy=TotalCrossSectionStrategy::BottomUp)
Creates a standard ScatterActionsFinderParameters object which works for almost all testing purposes.
Definition: setup.h:280
EventInfo default_event_info(double impact_parameter=0.0, bool empty_event=false)
Creates default EventInfo object for testing purposes.
Definition: setup.h:310
void create_stable_smashon_particletypes()
Creates a ParticleType list containing only the smashon test particle with width 0 (stable).
Definition: setup.h:78
ExperimentParameters default_parameters(int testparticles=1, double dt=0.1, CollisionCriterion criterion=CollisionCriterion::Geometric, bool strings=false, NNbarTreatment nnbar_treatment=NNbarTreatment::NoAnnihilation, ReactionsBitSet included_2to2=all_reactions_included())
Creates a standard ExperimentParameters object which works for almost all testing purposes.
Definition: setup.h:232
ParticleData smashon_random(int id=-1)
Create a particle with random position and momentum vectors and optionally a given id.
Definition: setup.h:154
InitialConditionParameters default_dynamic_IC_parameters()
Creates default parameters for dynamic IC.
Definition: setup.h:342
ReactionsBitSet all_reactions_included()
returns BitSet of 2->2 reactions, where everything is on
Definition: setup.h:216
constexpr int p
Proton.
constexpr int n
Neutron.
uniform_dist< T > make_uniform_distribution(T min, T max)
Definition: random.h:135
Definition: action.h:24
std::string to_string(ThermodynamicQuantity quantity)
Convert a ThermodynamicQuantity enum value to its corresponding string.
Definition: stringify.cc:26
Structure to contain custom data for output.
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
FluidizationType type
Type of initialization.
Definition: icparameters.h:21
static const Key< bool > collTerm_stringsWithProbability
See user guide description for more information.
Definition: input_keys.h:2597
static const Key< bool > collTerm_useAQM
See user guide description for more information.
Definition: input_keys.h:2673
static const Key< TotalCrossSectionStrategy > collTerm_totXsStrategy
See user guide description for more information.
Definition: input_keys.h:2629
static const Key< double > collTerm_elasticCrossSection
See user guide description for more information.
Definition: input_keys.h:2188
A FourVector that is marked as a momentum vector.
Definition: setup.h:90
A FourVector that is marked as a position vector.
Definition: setup.h:86