Version: SMASH-3.1
setup.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2015,2017-2023
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  "σ " +
70  std::to_string(smashon_mass) + " " + std::to_string(smashon_width) +
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  return p;
110 }
115 inline ParticleData smashon(const Momentum &momentum, int id = -1) {
116  ParticleData p{ParticleType::find(0x661), id};
117  p.set_4momentum(momentum);
118  return p;
119 }
124 inline ParticleData smashon(const Position &position, const Momentum &momentum,
125  int id = -1) {
126  ParticleData p{ParticleType::find(0x661), id};
127  p.set_4position(position);
128  p.set_4momentum(momentum);
129  return p;
130 }
138 inline ParticleData smashon(const Momentum &momentum, const Position &position,
139  int id = -1) {
140  ParticleData p{ParticleType::find(0x661), id};
141  p.set_4position(position);
142  p.set_4momentum(momentum);
143  return p;
144 }
149 inline ParticleData smashon_random(int id = -1) {
150  auto random_value = random::make_uniform_distribution(-15.0, +15.0);
151  ParticleData p{ParticleType::find(0x661), id};
152  p.set_4position(
153  {random_value(), random_value(), random_value(), random_value()});
154  p.set_4momentum(smashon_mass,
155  {random_value(), random_value(), random_value()});
156  return p;
157 }
158 
162 inline std::unique_ptr<ExperimentBase> experiment(Configuration c) {
163  return ExperimentBase::create(c, ".");
164 }
165 
169 template <typename G>
170 inline ParticleList create_particle_list(std::size_t n, G &&generator) {
171  ParticleList list;
172  list.reserve(n);
173  for (auto i = n; i; --i) {
174  list.emplace_back(generator());
175  }
176  return list;
177 }
178 
180 using ParticlesPtr = std::unique_ptr<Particles>;
181 
186 template <typename G>
187 inline ParticlesPtr create_particles(int n, G &&generator) {
188  ParticlesPtr p = std::make_unique<Particles>();
189  for (auto i = n; i; --i) {
190  p->insert(generator());
191  }
192  return p;
193 }
194 
200  const std::initializer_list<ParticleData> &init) {
201  ParticlesPtr p = std::make_unique<Particles>();
202  for (const auto &data : init) {
203  p->insert(data);
204  }
205  return p;
206 }
207 
210  return ReactionsBitSet().set();
211 }
212 
215  return MultiParticleReactionsBitSet().reset();
216 }
217 
226  int testparticles = 1, double dt = 0.1,
228  return ExperimentParameters{
229  std::make_unique<UniformClock>(0., dt, 300.0), // labclock
230  std::make_unique<UniformClock>(0., 1., 300.0), // outputclock
231  1, // ensembles
232  testparticles, // testparticles
233  DerivativesMode::CovariantGaussian, // derivatives mode
234  RestFrameDensityDerivativesMode::Off, // rest frame derivatives mode
235  FieldDerivativesMode::ChainRule, // field derivatives mode
236  SmearingMode::CovariantGaussian, // smearing mode
237  1.0, // Gaussian smearing width
238  4.0, // Gaussian smearing cut-off
239  0.333333, // discrete smearing weight
240  2.0, // triangular smearing range
241  crit,
242  true, // two_to_one
245  false, // strings switch
246  1.0,
248  0., // low energy sigma_NN cut-off
249  false, // potential_affect_threshold
250  -1.0, // box_length
251  200.0, // max. cross section
252  2.5, // fixed min. cell length
253  1.0, // cross section scaling
254  false, // in thermodynamics outputs spectators are included
255  false, // do weak decays
256  true, // decay initial particles
257  std::nullopt // use monash tune, not known
258  };
259 }
260 
268  double elastic_parameter = 10,
270  ReactionsBitSet included_2to2 = all_reactions_included(),
271  bool strings_switch = true, bool use_AQM = false,
272  bool strings_with_probability = false,
273  TotalCrossSectionStrategy xs_strategy =
275  StringTransitionParameters default_transition_params{};
276  return {elastic_parameter,
277  0., // low_snn_cut
278  1., // scale_xs
279  0., // additional_el_xs
280  200., // maximum_cross_section
282  nnbar_treatment,
283  included_2to2,
285  1, // testparticles
286  true, // two_to_one
287  false, // allow_first_collisions_within_nucleus
288  strings_switch,
289  use_AQM,
290  strings_with_probability,
291  true, // only_warn_for_high_prob
292  default_transition_params,
293  xs_strategy,
295 }
296 
298 inline EventInfo default_event_info(double impact_parameter = 0.0,
299  bool empty_event = false) {
300  return EventInfo{impact_parameter, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1,
301  empty_event, false};
302 }
303 
305 inline std::unique_ptr<StringProcess> default_string_process_interface() {
306  return std::make_unique<StringProcess>(
307  1.0, // String_Tension
308  1.0, // String_Formation_Time
309  0.5, // Gluon_Beta
310  0.001, // Gluon_Pmin
311  2.0, // Quark_Alpha
312  7.0, // Quark_Beta
313  0.16, // Strange_Supp
314  0.036, // Diquark_Supp
315  0.42, // Sigma_Perp
316  0.2, // StringZ_A_Leading
317  2.0, // StringZ_B_Leading
318  2.0, // StringZ_A
319  0.55, // StringZ_B
320  0.5, // String_Sigma_T
321  1.0, // Form_Time_Factor
322  false, // Mass_Dependent_Formation_Times
323  1. / 3., // Prob_proton_to_d_uu
324  true, // Separate_Fragment_Baryon
325  0.15, // Popcorn_Rate
326  false); // Use_Monash_Tune
327 }
328 
332 } // namespace Test
333 } // namespace smash
334 
335 #endif // SRC_TESTS_SETUP_H_
Interface to the SMASH configuration files.
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:58
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.
std::bitset< 10 > ReactionsBitSet
Container for the 2 to 2 reactions in the code.
NNbarTreatment
Treatment of N Nbar Annihilation.
@ NoAnnihilation
No Annihilation.
TotalCrossSectionStrategy
Determine how total cross sections for collision finding should be computed.
@ 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.
@ None
No pseudo-resonance is created.
ParticleList create_particle_list(std::size_t n, G &&generator)
Generate a list of particles from the given generator function.
Definition: setup.h:170
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:187
std::unique_ptr< StringProcess > default_string_process_interface()
Creates a default StringProcessInterface object for testing.
Definition: setup.h:305
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:180
std::unique_ptr< ExperimentBase > experiment(Configuration c)
Create an experiment given an input configuration.
Definition: setup.h:162
ExperimentParameters default_parameters(int testparticles=1, double dt=0.1, CollisionCriterion crit=CollisionCriterion::Geometric)
Creates a standard ExperimentParameters object which works for almost all testing purposes.
Definition: setup.h:225
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:214
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:267
EventInfo default_event_info(double impact_parameter=0.0, bool empty_event=false)
Creates default EventInfo object for testing purposes.
Definition: setup.h:298
void create_stable_smashon_particletypes()
Creates a ParticleType list containing only the smashon test particle with width 0 (stable).
Definition: setup.h:78
ParticleData smashon_random(int id=-1)
Create a particle with random position and momentum vectors and optionally a given id.
Definition: setup.h:149
ReactionsBitSet all_reactions_included()
returns BitSet of 2->2 reactions, where everything is on
Definition: setup.h:209
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
Structure to contain custom data for output.
Helper structure for Experiment.
Helper structure for ScatterActionsFinder.
Constants related to transition between low and high collision energies.
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