Version: SMASH-2.2
scatteractionsfinder.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2021
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_SCATTERACTIONSFINDER_H_
11 #define SRC_INCLUDE_SMASH_SCATTERACTIONSFINDER_H_
12 
13 #include <memory>
14 #include <set>
15 #include <vector>
16 
17 #include "action.h"
18 #include "actionfinderfactory.h"
19 #include "configuration.h"
20 #include "scatteraction.h"
21 
22 namespace smash {
23 
31  public:
47  const ExperimentParameters &parameters);
48 
65  inline double collision_time(
66  const ParticleData &p1, const ParticleData &p2, double dt,
67  const std::vector<FourVector> &beam_momentum) const {
69  return dt * random::uniform(0., 1.);
70  } else {
71  /*
72  * For frozen Fermi motion:
73  * If particles have not yet interacted and are the initial nucleons,
74  * perform action finding with beam momentum instead of Fermi motion
75  * corrected momentum. That is because the particles are propagated with
76  * the beam momentum until they interact.
77  */
78  if (p1.id() < 0 || p2.id() < 0) {
79  throw std::runtime_error("Invalid particle ID for Fermi motion");
80  }
81  const bool p1_has_no_prior_interactions =
82  (static_cast<uint64_t>(p1.id()) < // particle from
83  static_cast<uint64_t>(beam_momentum.size())) && // initial nucleus
85 
86  const bool p2_has_no_prior_interactions =
87  (static_cast<uint64_t>(p2.id()) < // particle from
88  static_cast<uint64_t>(beam_momentum.size())) && // initial nucleus
90 
91  const FourVector p1_mom = (p1_has_no_prior_interactions)
92  ? beam_momentum[p1.id()]
93  : p1.momentum();
94  const FourVector p2_mom = (p2_has_no_prior_interactions)
95  ? beam_momentum[p2.id()]
96  : p2.momentum();
104  const FourVector delta_x = p1.position() - p2.position();
105  const double p1_sqr = p1_mom.sqr();
106  const double p2_sqr = p2_mom.sqr();
107  const double p1_dot_x = p1_mom.Dot(delta_x);
108  const double p2_dot_x = p2_mom.Dot(delta_x);
109  const double p1_dot_p2 = p1_mom.Dot(p2_mom);
110  const double denominator = std::pow(p1_dot_p2, 2) - p1_sqr * p2_sqr;
111  if (unlikely(std::abs(denominator) < really_small * really_small)) {
112  return -1.0;
113  }
114 
115  const double time_1 = (p2_sqr * p1_dot_x - p1_dot_p2 * p2_dot_x) *
116  p1_mom.x0() / denominator;
117  const double time_2 = -(p1_sqr * p2_dot_x - p1_dot_p2 * p1_dot_x) *
118  p2_mom.x0() / denominator;
119  return (time_1 + time_2) / 2;
120  } else {
130  const ThreeVector dv_times_e1e2 =
131  p1_mom.threevec() * p2_mom.x0() - p2_mom.threevec() * p1_mom.x0();
132  const double dv_times_e1e2_sqr = dv_times_e1e2.sqr();
133  if (dv_times_e1e2_sqr < really_small) {
134  return -1.0;
135  }
136  const ThreeVector dr =
137  p1.position().threevec() - p2.position().threevec();
138  return -(dr * dv_times_e1e2) *
139  (p1_mom.x0() * p2_mom.x0() / dv_times_e1e2_sqr);
140  }
141  }
142  }
143 
158  ActionList find_actions_in_cell(
159  const ParticleList &search_list, double dt, const double gcell_vol,
160  const std::vector<FourVector> &beam_momentum) const override;
161 
174  ActionList find_actions_with_neighbors(
175  const ParticleList &search_list, const ParticleList &neighbors_list,
176  double dt, const std::vector<FourVector> &beam_momentum) const override;
177 
190  const ParticleList &search_list, const Particles &surrounding_list,
191  double dt, const std::vector<FourVector> &beam_momentum) const override;
192 
197  ActionList find_final_actions(const Particles & /*search_list*/,
198  bool /*only_res*/ = false) const override {
199  return ActionList();
200  }
201 
212  inline bool is_constant_elastic_isotropic() const {
213  return ParticleType::list_all().size() == 1 && !two_to_one_ && isotropic_ &&
214  elastic_parameter_ > 0.;
215  }
216 
229  double max_transverse_distance_sqr(int testparticles) const {
232  testparticles * fm2_mb * M_1_PI;
233  }
234 
239  void dump_reactions() const;
240 
254  void dump_cross_sections(const ParticleType &a, const ParticleType &b,
255  double m_a, double m_b, bool final_state,
256  std::vector<double> &plab) const;
257 
263  if (strings_switch_) {
264  return string_process_interface_.get();
265  } else {
266  return NULL;
267  }
268  }
269 
270  private:
293  ActionPtr check_collision_two_part(
294  const ParticleData &data_a, const ParticleData &data_b, double dt,
295  const std::vector<FourVector> &beam_momentum = {},
296  const double gcell_vol = 0.0) const;
297 
313  ActionPtr check_collision_multi_part(const ParticleList &plist, double dt,
314  const double gcell_vol) const;
315 
317  std::unique_ptr<StringProcess> string_process_interface_;
321  const double elastic_parameter_;
323  const int testparticles_;
325  const bool isotropic_;
327  const bool two_to_one_;
333  const double scale_xs_;
335  const double additional_el_xs_;
340  const double low_snn_cut_;
342  const bool strings_switch_;
344  const bool use_AQM_;
354  const double box_length_;
367 };
368 
369 } // namespace smash
370 
371 #endif // SRC_INCLUDE_SMASH_SCATTERACTIONSFINDER_H_
ActionFinderInterface is the abstract base class for all action finders, i.e.
Interface to the SMASH configuration files.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
double sqr() const
calculate the square of the vector (which is a scalar)
Definition: fourvector.h:455
ThreeVector threevec() const
Definition: fourvector.h:324
double Dot(const FourVector &a) const
calculate the scalar product with another four-vector
Definition: fourvector.h:451
double x0() const
Definition: fourvector.h:308
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:58
const FourVector & momentum() const
Get the particle's 4-momentum.
Definition: particledata.h:158
int32_t id() const
Get the id of the particle.
Definition: particledata.h:76
HistoryData get_history() const
Get history information.
Definition: particledata.h:139
const FourVector & position() const
Get the particle's position in Minkowski space.
Definition: particledata.h:204
Particle type contains the static properties of a particle species.
Definition: particletype.h:97
static const ParticleTypeList & list_all()
Definition: particletype.cc:51
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
A simple scatter finder: Just loops through all particles and checks each pair for a collision.
const int testparticles_
Number of test particles.
ActionList find_final_actions(const Particles &, bool=false) const override
Find some final collisions at the end of the simulation.
const MultiParticleReactionsBitSet incl_multi_set_
List of included multi-particle reactions.
ActionList find_actions_in_cell(const ParticleList &search_list, double dt, const double gcell_vol, const std::vector< FourVector > &beam_momentum) const override
Search for all the possible collisions within one cell.
const double elastic_parameter_
Elastic cross section parameter (in mb).
void dump_cross_sections(const ParticleType &a, const ParticleType &b, double m_a, double m_b, bool final_state, std::vector< double > &plab) const
Print out partial cross-sections of all processes that can occur in the collision of a(mass = m_a) an...
const bool strings_switch_
Switch to turn off string excitation.
const double additional_el_xs_
Additional constant elastic cross section.
const double scale_xs_
Factor by which all (partial) cross sections are scaled.
const bool allow_first_collisions_within_nucleus_
If particles within nucleus are allowed to collide for their first time.
const NNbarTreatment nnbar_treatment_
Switch for NNbar reactions.
const double low_snn_cut_
Elastic collsions between two nucleons with sqrt_s below low_snn_cut_ are excluded.
StringProcess * get_process_string_ptr()
const bool use_AQM_
Switch to control whether to use AQM or not.
const bool isotropic_
Do all collisions isotropically.
double max_transverse_distance_sqr(int testparticles) const
The maximal distance over which particles can interact in case of the geometric criterion,...
const bool only_warn_for_high_prob_
Switch to turn off throwing an exception for collision probabilities larger than 1.
const CollisionCriterion coll_crit_
Specifies which collision criterion is used.
ScatterActionsFinder(Configuration config, const ExperimentParameters &parameters)
Constructor of the finder with the given parameters.
const ReactionsBitSet incl_set_
List of included 2<->2 reactions.
const bool two_to_one_
Enable 2->1 processes.
ActionPtr check_collision_two_part(const ParticleData &data_a, const ParticleData &data_b, double dt, const std::vector< FourVector > &beam_momentum={}, const double gcell_vol=0.0) const
Check for a single pair of particles (id_a, id_b) if a collision will happen in the next timestep and...
const double string_formation_time_
Parameter for formation time.
std::unique_ptr< StringProcess > string_process_interface_
Class that deals with strings, interfacing Pythia.
void dump_reactions() const
Prints out all the 2-> n (n > 1) reactions with non-zero cross-sections between all possible pairs of...
bool is_constant_elastic_isotropic() const
If there is only one particle sort, no decays (only elastic scatterings are possible),...
ActionPtr check_collision_multi_part(const ParticleList &plist, double dt, const double gcell_vol) const
Check for multiple i.e.
const double box_length_
Box length: needed to determine coordinates of collision correctly in case of collision through the w...
ActionList find_actions_with_surrounding_particles(const ParticleList &search_list, const Particles &surrounding_list, double dt, const std::vector< FourVector > &beam_momentum) const override
Search for all the possible secondary collisions between the outgoing particles and the rest.
const bool strings_with_probability_
Decide whether to implement string fragmentation based on a probability.
ActionList find_actions_with_neighbors(const ParticleList &search_list, const ParticleList &neighbors_list, double dt, const std::vector< FourVector > &beam_momentum) const override
Search for all the possible collisions among the neighboring cells.
double collision_time(const ParticleData &p1, const ParticleData &p2, double dt, const std::vector< FourVector > &beam_momentum) const
Determine the collision time of the two particles.
String excitation processes used in SMASH.
Definition: stringprocess.h:45
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
double sqr() const
Definition: threevector.h:259
std::bitset< 10 > ReactionsBitSet
Container for the 2 to 2 reactions in the code.
NNbarTreatment
Treatment of N Nbar Annihilation.
std::bitset< 4 > MultiParticleReactionsBitSet
Container for the n to m reactions in the code.
CollisionCriterion
Criteria used to check collisions.
@ Stochastic
Stochastic Criteiron.
@ Covariant
Covariant Criterion.
#define unlikely(x)
Tell the branch predictor that this expression is likely false.
Definition: macros.h:16
T uniform(T min, T max)
Definition: random.h:88
Definition: action.h:24
constexpr double really_small
Numerical error tolerance.
Definition: constants.h:37
constexpr double fm2_mb
mb <-> fm^2 conversion factor.
Definition: constants.h:28
Helper structure for Experiment.
int32_t collisions_per_particle
Collision counter per particle, zero only for initially present particles.
Definition: particledata.h:32