Version: SMASH-2.2
setup.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2015-2022
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 "../include/smash/cxx14compat.h"
14 #include "../include/smash/decaymodes.h"
15 #include "../include/smash/experiment.h"
16 #include "../include/smash/outputinterface.h"
17 #include "../include/smash/particledata.h"
18 #include "../include/smash/particles.h"
19 #include "../include/smash/particletype.h"
20 #include "../include/smash/random.h"
21 
22 #include <boost/filesystem.hpp>
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 
173 inline Configuration configuration(std::string overrides = {}) {
174  Configuration c{bf::path{TEST_CONFIG_PATH} / "input"};
175  if (!overrides.empty()) {
176  c.merge_yaml(overrides);
177  }
178  return c;
179 }
180 
187 inline std::unique_ptr<ExperimentBase> experiment(
188  const Configuration &c = configuration()) {
189  return ExperimentBase::create(c, ".");
190 }
191 
196 inline std::unique_ptr<ExperimentBase> experiment(const char *configOverrides) {
197  return ExperimentBase::create(configuration(configOverrides), ".");
198 }
199 
203 template <typename G>
204 inline ParticleList create_particle_list(std::size_t n, G &&generator) {
205  ParticleList list;
206  list.reserve(n);
207  for (auto i = n; i; --i) {
208  list.emplace_back(generator());
209  }
210  return list;
211 }
212 
214 using ParticlesPtr = std::unique_ptr<Particles>;
215 
220 template <typename G>
221 inline ParticlesPtr create_particles(int n, G &&generator) {
222  ParticlesPtr p = make_unique<Particles>();
223  for (auto i = n; i; --i) {
224  p->insert(generator());
225  }
226  return p;
227 }
228 
234  const std::initializer_list<ParticleData> &init) {
235  ParticlesPtr p = make_unique<Particles>();
236  for (const auto &data : init) {
237  p->insert(data);
238  }
239  return p;
240 }
241 
244  return ReactionsBitSet().set();
245 }
246 
249  return MultiParticleReactionsBitSet().reset();
250 }
251 
260  int testparticles = 1, double dt = 0.1,
262  return ExperimentParameters{
263  make_unique<UniformClock>(0., dt), // labclock
264  make_unique<UniformClock>(0., 1.), // outputclock
265  1, // ensembles
266  testparticles, // testparticles
267  DerivativesMode::CovariantGaussian, // derivatives mode
268  RestFrameDensityDerivativesMode::Off, // rest frame derivatives mode
269  FieldDerivativesMode::ChainRule, // field derivatives mode
270  SmearingMode::CovariantGaussian, // smearing mode
271  1.0, // Gaussian smearing width
272  4.0, // Gaussian smearing cut-off
273  0.333333, // discrete smearing weight
274  2.0, // triangular smearing range
275  crit,
276  true, // two_to_one
279  false, // strings switch
280  false, // use_AQM
281  1.0,
282  false, // string_with_probability
284  0., // low energy sigma_NN cut-off
285  false, // potential_affect_threshold
286  -1.0, // box_length
287  200.0, // max. cross section
288  2.5, // fixed min. cell length
289  false, // allow collisions within nucleus
290  1.0, // cross section scaling
291  0.0, // additional elastic cross section
292  false, // in thermodynamics outputs spectators are included
293  false // do weak decays
294  };
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 
307 } // namespace Test
308 } // namespace smash
309 
310 #endif // SRC_TESTS_SETUP_H_
Interface to the SMASH configuration files.
void merge_yaml(const std::string &yaml)
Merge the configuration in yaml into the existing tree.
static void load_decaymodes(const std::string &input)
Loads the DecayModes map as described in the input string.
Definition: decaymodes.cc:164
static std::unique_ptr< ExperimentBase > create(Configuration config, const bf::path &output_path)
Factory method that creates and initializes a new Experiment<Modus>.
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.
@ NoAnnihilation
No Annihilation.
std::bitset< 4 > MultiParticleReactionsBitSet
Container for the n to m reactions in the code.
CollisionCriterion
Criteria used to check collisions.
@ Geometric
(Default) geometric criterion.
ParticleList create_particle_list(std::size_t n, G &&generator)
Generate a list of particles from the given generator function.
Definition: setup.h:204
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:221
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:214
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:259
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:248
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
Configuration configuration(std::string overrides={})
Return a configuration object filled with data from src/config.yaml.
Definition: setup.h:173
ParticleData smashon_random(int id=-1)
Create a particle with random position and momentum vectors and optionally a given id.
Definition: setup.h:149
std::unique_ptr< ExperimentBase > experiment(const Configuration &c=configuration())
Create an experiment.
Definition: setup.h:187
ReactionsBitSet all_reactions_included()
returns BitSet of 2->2 reactions, where everything is on
Definition: setup.h:243
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.
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