Version: SMASH-1.8
action.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2019
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #include "smash/action.h"
11 
12 #include <assert.h>
13 #include <algorithm>
14 #include <sstream>
15 
16 #include "smash/angles.h"
17 #include "smash/constants.h"
18 #include "smash/kinematics.h"
19 #include "smash/logging.h"
20 #include "smash/pauliblocking.h"
22 #include "smash/processbranch.h"
23 #include "smash/quantumnumbers.h"
24 
25 namespace smash {
27 Action::~Action() = default;
28 static constexpr int LPauliBlocking = LogArea::PauliBlocking::id;
29 
30 bool Action::is_valid(const Particles &particles) const {
31  return std::all_of(
33  [&particles](const ParticleData &p) { return particles.is_valid(p); });
34 }
35 
36 bool Action::is_pauli_blocked(const Particles &particles,
37  const PauliBlocker &p_bl) const {
38  // Wall-crossing actions should never be blocked: currently
39  // if the action is blocked, a particle continues to propagate in a straight
40  // line. This would simply bring it out of the box.
42  return false;
43  }
44  for (const auto &p : outgoing_particles_) {
45  if (p.is_baryon()) {
46  const auto f =
47  p_bl.phasespace_dens(p.position().threevec(), p.momentum().threevec(),
48  particles, p.pdgcode(), incoming_particles_);
49  if (f > random::uniform(0., 1.)) {
50  logg[LPauliBlocking].debug("Action ", *this,
51  " is pauli-blocked with f = ", f);
52  return true;
53  }
54  }
55  }
56  return false;
57 }
58 
59 const ParticleList &Action::incoming_particles() const {
60  return incoming_particles_;
61 }
62 
63 void Action::update_incoming(const Particles &particles) {
64  for (auto &p : incoming_particles_) {
65  p = particles.lookup(p);
66  }
67 }
68 
70  // Estimate for the interaction point in the calculational frame
71  FourVector interaction_point = FourVector(0., 0., 0., 0.);
72  for (const auto &part : incoming_particles_) {
73  interaction_point += part.position();
74  }
75  interaction_point /= incoming_particles_.size();
76  return interaction_point;
77 }
78 
79 std::pair<FourVector, FourVector> Action::get_potential_at_interaction_point()
80  const {
82  FourVector UB = FourVector();
83  FourVector UI3 = FourVector();
84  /* Check:
85  * Lattice is turned on. */
86  if (UB_lat_pointer != nullptr) {
87  UB_lat_pointer->value_at(r, UB);
88  }
89  if (UI3_lat_pointer != nullptr) {
90  UI3_lat_pointer->value_at(r, UI3);
91  }
92  return std::make_pair(UB, UI3);
93 }
94 
95 void Action::perform(Particles *particles, uint32_t id_process) {
96  assert(id_process != 0);
97 
99  // store the history info
101  p.set_history(p.get_history().collisions_per_particle + 1, id_process,
103  }
104  }
105 
106  /* For elastic collisions and box wall crossings it is not necessary to remove
107  * particles from the list and insert new ones, it is enough to update their
108  * properties. */
112 
113  logg[LAction].debug("Particle map now has ", particles->size(), " elements.");
114 
115  /* Check the conservation laws if the modifications of the total kinetic
116  * energy of the outgoing particles by the mean field potentials are not
117  * taken into account. */
118  if (UB_lat_pointer == nullptr && UI3_lat_pointer == nullptr) {
119  check_conservation(id_process);
120  }
121 }
122 
124  const auto potentials = get_potential_at_interaction_point();
125  /* scale_B returns the difference of the total force scales of the skyrme
126  * potential between the initial and final states. */
127  double scale_B = 0.0;
128  /* scale_I3 returns the difference of the total force scales of the symmetry
129  * potential between the initial and final states. */
130  double scale_I3 = 0.0;
131  for (const auto &p_in : incoming_particles_) {
132  // Get the force scale of the incoming particle.
133  const auto scale =
134  ((pot_pointer != nullptr) ? pot_pointer->force_scale(p_in.type())
135  : std::make_pair(0.0, 0));
136  scale_B += scale.first;
137  scale_I3 += scale.second * p_in.type().isospin3_rel();
138  }
139  for (const auto &p_out : outgoing_particles_) {
140  // Get the force scale of the outgoing particle.
141  const auto scale = ((pot_pointer != nullptr)
143  : std::make_pair(0.0, 0));
144  scale_B -= scale.first;
145  scale_I3 -= scale.second * type_of_pout(p_out).isospin3_rel();
146  }
147  /* Rescale to get the potential difference between the
148  * initial and final state, and thus get the total momentum
149  * of the outgoing particles*/
150  return total_momentum() + potentials.first * scale_B +
151  potentials.second * scale_I3;
152 }
153 
154 std::pair<double, double> Action::sample_masses(
155  const double kinetic_energy_cm) const {
156  const ParticleType &t_a = outgoing_particles_[0].type();
157  const ParticleType &t_b = outgoing_particles_[1].type();
158  // start with pole masses
159  std::pair<double, double> masses = {t_a.mass(), t_b.mass()};
160 
161  if (kinetic_energy_cm < t_a.min_mass_kinematic() + t_b.min_mass_kinematic()) {
162  const std::string reaction = incoming_particles_[0].type().name() +
163  incoming_particles_[1].type().name() + "→" +
164  t_a.name() + t_b.name();
166  reaction + ": not enough energy, " + std::to_string(kinetic_energy_cm) +
167  " < " + std::to_string(t_a.min_mass_kinematic()) + " + " +
168  std::to_string(t_b.min_mass_kinematic()));
169  }
170 
171  /* If one of the particles is a resonance, sample its mass. */
172  if (!t_a.is_stable() && t_b.is_stable()) {
173  masses.first = t_a.sample_resonance_mass(t_b.mass(), kinetic_energy_cm);
174  } else if (!t_b.is_stable() && t_a.is_stable()) {
175  masses.second = t_b.sample_resonance_mass(t_a.mass(), kinetic_energy_cm);
176  } else if (!t_a.is_stable() && !t_b.is_stable()) {
177  // two resonances in final state
178  masses = t_a.sample_resonance_masses(t_b, kinetic_energy_cm);
179  }
180  return masses;
181 }
182 
183 void Action::sample_angles(std::pair<double, double> masses,
184  const double kinetic_energy_cm) {
187 
188  const double pcm = pCM(kinetic_energy_cm, masses.first, masses.second);
189  if (!(pcm > 0.0)) {
190  logg[LAction].warn("Particle: ", p_a->pdgcode(), " radial momentum: ", pcm);
191  logg[LAction].warn("Ektot: ", kinetic_energy_cm, " m_a: ", masses.first,
192  " m_b: ", masses.second);
193  }
194  /* Here we assume an isotropic angular distribution. */
195  Angles phitheta;
196  phitheta.distribute_isotropically();
197 
198  p_a->set_4momentum(masses.first, phitheta.threevec() * pcm);
199  p_b->set_4momentum(masses.second, -phitheta.threevec() * pcm);
200  /* Debug message is printed before boost, so that p_a and p_b are
201  * the momenta in the center of mass frame and thus opposite to
202  * each other.*/
203  logg[LAction].debug("p_a: ", *p_a, "\np_b: ", *p_b);
204 }
205 
207  /* This function only operates on 2-particle final states. */
208  assert(outgoing_particles_.size() == 2);
210  const double cm_kin_energy = p_tot.abs();
211  // first sample the masses
212  const std::pair<double, double> masses = sample_masses(cm_kin_energy);
213  // after the masses are fixed (and thus also pcm), sample the angles
214  sample_angles(masses, cm_kin_energy);
215 }
216 
218  assert(outgoing_particles_.size() == 3);
219  const double m_a = outgoing_particles_[0].type().mass(),
220  m_b = outgoing_particles_[1].type().mass(),
221  m_c = outgoing_particles_[2].type().mass();
222  const double sqrts = sqrt_s();
223 
224  // sample mab from pCM(sqrt, mab, mc) pCM (mab, ma, mb) <= sqrts^2/4
225  double mab, r, probability, pcm_ab, pcm;
226  do {
227  mab = random::uniform(m_a + m_b, sqrts - m_c);
228  r = random::canonical();
229  pcm = pCM(sqrts, mab, m_c);
230  pcm_ab = pCM(mab, m_a, m_b);
231  probability = pcm * pcm_ab * 4 / (sqrts * sqrts);
232  } while (r > probability);
233  Angles phitheta;
234  phitheta.distribute_isotropically();
235  outgoing_particles_[2].set_4momentum(m_c, pcm * phitheta.threevec());
236  const ThreeVector beta_cm =
237  pcm * phitheta.threevec() / std::sqrt(pcm * pcm + mab * mab);
238 
239  phitheta.distribute_isotropically();
240  outgoing_particles_[0].set_4momentum(m_a, pcm_ab * phitheta.threevec());
241  outgoing_particles_[1].set_4momentum(m_b, -pcm_ab * phitheta.threevec());
242  outgoing_particles_[0].boost_momentum(beta_cm);
243  outgoing_particles_[1].boost_momentum(beta_cm);
244 }
245 
246 void Action::check_conservation(const uint32_t id_process) const {
249  if (before != after) {
250  std::stringstream particle_names;
251  for (const auto &p : incoming_particles_) {
252  particle_names << p.type().name();
253  }
254  particle_names << " vs. ";
255  for (const auto &p : outgoing_particles_) {
256  particle_names << p.type().name();
257  }
258  particle_names << "\n";
259  std::string err_msg = before.report_deviations(after);
260  logg[LAction].error() << particle_names.str() << err_msg;
261  /* Pythia does not conserve energy and momentum at high energy, so we just
262  * print the error and continue. */
265  return;
266  }
267  if (id_process == ID_PROCESS_PHOTON) {
268  throw std::runtime_error("Conservation laws violated in photon process");
269  } else {
270  throw std::runtime_error("Conservation laws violated in process " +
271  std::to_string(id_process));
272  }
273  }
274 }
275 
276 std::ostream &operator<<(std::ostream &out, const ActionList &actions) {
277  out << "ActionList {\n";
278  for (const auto &a : actions) {
279  out << "- " << a << '\n';
280  }
281  return out << '}';
282 }
283 
284 } // namespace smash
smash::Action::sample_angles
virtual void sample_angles(std::pair< double, double > masses, double kinetic_energy_cm)
Sample final-state momenta in general X->2 processes (here: using an isotropical angular distribution...
Definition: action.cc:183
smash
Definition: action.h:24
smash::Action::incoming_particles_
ParticleList incoming_particles_
List with data of incoming particles.
Definition: action.h:304
quantumnumbers.h
smash::ProcessType::StringHard
hard string process involving 2->2 QCD process by PYTHIA.
smash::Action::~Action
virtual ~Action()
Virtual Destructor.
processbranch.h
smash::Action::total_momentum
FourVector total_momentum() const
Sum of 4-momenta of incoming particles.
Definition: action.h:324
smash::Action::time_of_execution_
const double time_of_execution_
Time at which the action is supposed to be performed (absolute time in the lab frame in fm/c).
Definition: action.h:318
smash::Particles::size
size_t size() const
Definition: particles.h:87
smash::ParticleData
Definition: particledata.h:52
smash::Action::sample_2body_phasespace
void sample_2body_phasespace()
Sample the full 2-body phase-space (masses, momenta, angles) in the center-of-mass frame for the fina...
Definition: action.cc:206
smash::LPauliBlocking
static constexpr int LPauliBlocking
Definition: action.cc:28
smash::Potentials::force_scale
static std::pair< double, int > force_scale(const ParticleType &data)
Evaluates the scaling factor of the forces acting on the particles.
Definition: potentials.cc:164
smash::Action::is_pauli_blocked
bool is_pauli_blocked(const Particles &particles, const PauliBlocker &p_bl) const
Check if the action is Pauli-blocked.
Definition: action.cc:36
smash::Action::check_conservation
virtual void check_conservation(const uint32_t id_process) const
Check various conservation laws.
Definition: action.cc:246
smash::is_string_soft_process
bool is_string_soft_process(ProcessType p)
Check if a given process type is a soft string excitation.
Definition: processbranch.cc:18
smash::operator<<
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Definition: action.h:463
smash::ParticleType::mass
double mass() const
Definition: particletype.h:144
smash::Angles::distribute_isotropically
void distribute_isotropically()
Populate the object with a new direction.
Definition: angles.h:188
smash::ParticleData::pdgcode
PdgCode pdgcode() const
Get the pdgcode of the particle.
Definition: particledata.h:81
smash::PauliBlocker::phasespace_dens
double phasespace_dens(const ThreeVector &r, const ThreeVector &p, const Particles &particles, const PdgCode pdg, const ParticleList &disregard) const
Calculate phase-space density of a particle species at the point (r,p).
Definition: pauliblocking.cc:56
smash::Action::update_incoming
void update_incoming(const Particles &particles)
Update the incoming particles that are stored in this action to the state they have in the global par...
Definition: action.cc:63
action.h
smash::ParticleData::set_4momentum
void set_4momentum(const FourVector &momentum_vector)
Set the particle's 4-momentum directly.
Definition: particledata.h:148
smash::logg
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > logg
An array that stores all pre-configured Logger objects.
Definition: logging.cc:39
smash::all_of
bool all_of(Container &&c, UnaryPredicate &&p)
Convenience wrapper for std::all_of that operates on a complete container.
Definition: algorithms.h:80
smash::pCM
T pCM(const T sqrts, const T mass_a, const T mass_b) noexcept
Definition: kinematics.h:79
pauliblocking.h
angles.h
smash::UI3_lat_pointer
RectangularLattice< FourVector > * UI3_lat_pointer
Pointer to the symmmetry potential on the lattice.
Definition: potential_globals.cc:16
smash::ThreeVector
Definition: threevector.h:31
smash::ProcessType::Wall
box wall crossing
smash::PauliBlocker
A class that stores parameters needed for Pauli blocking, tabulates necessary integrals and computes ...
Definition: pauliblocking.h:36
smash::ParticleType::sample_resonance_masses
std::pair< double, double > sample_resonance_masses(const ParticleType &t2, const double cms_energy, int L=0) const
Resonance mass sampling for 2-particle final state with two resonances.
Definition: particletype.cc:679
smash::UB_lat_pointer
RectangularLattice< FourVector > * UB_lat_pointer
Pointer to the skyrme potential on the lattice.
Definition: potential_globals.cc:15
smash::ParticleType::is_stable
bool is_stable() const
Definition: particletype.h:236
smash::Particles::update
void update(const ParticleList &old_state, ParticleList &new_state, bool do_replace)
Updates the Particles object, replacing the particles in old_state with the particles in new_state.
Definition: particles.h:200
smash::Action::type_of_pout
const ParticleType & type_of_pout(const ParticleData &p_out) const
Get the type of a given particle.
Definition: action.h:425
smash::ParticleType::sample_resonance_mass
double sample_resonance_mass(const double mass_stable, const double cms_energy, int L=0) const
Resonance mass sampling for 2-particle final state with one resonance (type given by 'this') and one ...
Definition: particletype.cc:622
smash::ParticleType::isospin3_rel
double isospin3_rel() const
Definition: particletype.h:179
smash::QuantumNumbers::report_deviations
std::string report_deviations(const Particles &particles) const
Checks if the current particle list has still the same values and reports about differences.
Definition: quantumnumbers.h:248
smash::Action::process_type_
ProcessType process_type_
type of process
Definition: action.h:321
smash::ParticleType
Definition: particletype.h:97
smash::Action::is_valid
bool is_valid(const Particles &particles) const
Check whether the action still applies.
Definition: action.cc:30
smash::ParticleType::name
const std::string & name() const
Definition: particletype.h:141
smash::LAction
static constexpr int LAction
Definition: action.h:25
smash::Action::get_potential_at_interaction_point
std::pair< FourVector, FourVector > get_potential_at_interaction_point() const
Get the skyrme and asymmetry potential at the interaction point.
Definition: action.cc:79
smash::Action::perform
virtual void perform(Particles *particles, uint32_t id_process)
Actually perform the action, e.g.
Definition: action.cc:95
smash::Action::total_momentum_of_outgoing_particles
FourVector total_momentum_of_outgoing_particles() const
Calculate the total kinetic momentum of the outgoing particles.
Definition: action.cc:123
smash::Particles::lookup
const ParticleData & lookup(const ParticleData &old_state) const
Returns the particle that is currently stored in this object given an old copy of that particle.
Definition: particles.h:222
smash::Action::outgoing_particles_
ParticleList outgoing_particles_
Initially this stores only the PDG codes of final-state particles.
Definition: action.h:312
smash::Action::sample_3body_phasespace
virtual void sample_3body_phasespace()
Sample the full 3-body phase-space (masses, momenta, angles) in the center-of-mass frame for the fina...
Definition: action.cc:217
smash::Angles::threevec
ThreeVector threevec() const
Definition: angles.h:268
kinematics.h
smash::Action::sqrt_s
double sqrt_s() const
Determine the total energy in the center-of-mass frame [GeV].
Definition: action.h:266
smash::Particles::is_valid
bool is_valid(const ParticleData &copy) const
Check whether the ParticleData copy is still a valid copy of the one stored in the Particles object.
Definition: particles.h:120
smash::Particles
Definition: particles.h:33
constants.h
logging.h
smash::ProcessType::Elastic
elastic scattering: particles remain the same, only momenta change
smash::FourVector
Definition: fourvector.h:33
smash::Action::get_interaction_point
FourVector get_interaction_point() const
Get the interaction point.
Definition: action.cc:69
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::Angles
Angles provides a common interface for generating directions: i.e., two angles that should be interpr...
Definition: angles.h:59
smash::random::uniform
T uniform(T min, T max)
Definition: random.h:88
smash::ID_PROCESS_PHOTON
constexpr std::uint32_t ID_PROCESS_PHOTON
Process ID for any photon process.
Definition: constants.h:131
smash::ParticleType::min_mass_kinematic
double min_mass_kinematic() const
The minimum mass of the resonance that is kinematically allowed.
Definition: particletype.cc:360
smash::pot_pointer
Potentials * pot_pointer
Pointer to a Potential class.
Definition: potential_globals.cc:17
smash::Action::incoming_particles
const ParticleList & incoming_particles() const
Get the list of particles that go into the action.
Definition: action.cc:59
potential_globals.h
smash::Action::sample_masses
virtual std::pair< double, double > sample_masses(double kinetic_energy_cm) const
Sample final-state masses in general X->2 processes (thus also fixing the absolute c....
Definition: action.cc:154
smash::QuantumNumbers
Definition: quantumnumbers.h:53
smash::Action::InvalidResonanceFormation
Definition: action.h:298
smash::random::canonical
T canonical()
Definition: random.h:113
smash::FourVector::threevec
ThreeVector threevec() const
Definition: fourvector.h:319