Version: SMASH-3.4
freeforallaction.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2022-2023
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_FREEFORALLACTION_H_
11 #define SRC_INCLUDE_SMASH_FREEFORALLACTION_H_
12 
13 #include "action.h"
14 
15 namespace smash {
16 
17 /**
18  * \ingroup action
19  * \brief Action class to create any incoming/outgoing particle combination
20  * freely. This class is in particular designed to add and remove particles from
21  * the evolution. This introduces violations of the conservation laws, but it is
22  * needed for a concurrent running of transport and hydrodynamics.
23  */
24 class FreeforallAction : public Action {
25  public:
26  /**
27  * The FreeforallAction is able to add particles by providing an empty
28  * particle list for \c in_part and a list with particles which are supposed
29  * to be added to the evolution as \c out_part . If particles should be
30  * removed a filled particle list with the corresponding particles should be
31  * provided as \c in_part and an empty list as \c out_part .
32  *
33  * \param[in] in_part List of incoming particles
34  * \param[in] out_part List of outgoing particles
35  * \param[in] absolute_labframe_time Absolute time at which the action is
36  * supposed to take place
37  *
38  * \note This action takes advantage of how the parent class works in order to
39  * fake 0 → 1 and 1 → 0 processes. If particles need to be both
40  * added and removed one needs to create and perform this action twice. Said
41  * differently, the provided lists cannot be non-empty at the same time.
42  */
43  FreeforallAction(const ParticleList &in_part, const ParticleList &out_part,
44  double absolute_labframe_time)
45  : Action(in_part, out_part, absolute_labframe_time,
47  if (!in_part.empty() && !out_part.empty()) {
48  throw std::invalid_argument(
49  "The FreeforallAction was used with two non-empty lists. This is not "
50  "allowed. Please use the action twice, if particles should be added "
51  "and removed.");
52  }
53  }
54 
55  double get_total_weight() const override { return 0.0; }
56  double get_partial_weight() const override { return 0.0; }
57 
58  /**
59  * Generate a final state for the FreeforallAction in the sense that the
60  * time and position of the particles in the list is scrolled back to the
61  * action time. The outgoing particles are set in the constructor.
62  */
63  void generate_final_state() override {
64  // Set time for arbitrary outgoing particles to time of action
65  for (auto &particle : outgoing_particles_) {
66  const double t = particle.position().x0();
67  const FourVector u(1.0, particle.velocity());
68  particle.set_formation_time(t);
69  particle.set_4position(particle.position() +
70  u * (time_of_execution() - t));
71  }
72  }
73 
74  /**
75  * Function for debug output of incoming and outgoing particles from
76  * freeforall action
77  * \param[in] out Location of the output stream
78  */
79  void format_debug_output(std::ostream &out) const override {
80  out << "Freeforall action of " << incoming_particles_.size() << " to "
81  << outgoing_particles_.size() << " particles.";
82  }
83 };
84 
85 } // namespace smash
86 
87 #endif // SRC_INCLUDE_SMASH_FREEFORALLACTION_H_
Action is the base class for a generic process that takes a number of incoming particles and transfor...
Definition: action.h:35
ParticleList outgoing_particles_
Initially this stores only the PDG codes of final-state particles.
Definition: action.h:363
double time_of_execution() const
Get the time at which the action is supposed to be performed.
Definition: action.h:254
ParticleList incoming_particles_
List with data of incoming particles.
Definition: action.h:355
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
Action class to create any incoming/outgoing particle combination freely.
double get_total_weight() const override
Return the total weight value, which is mainly used for the weight output entry.
FreeforallAction(const ParticleList &in_part, const ParticleList &out_part, double absolute_labframe_time)
The FreeforallAction is able to add particles by providing an empty particle list for in_part and a l...
void format_debug_output(std::ostream &out) const override
Function for debug output of incoming and outgoing particles from freeforall action.
void generate_final_state() override
Generate a final state for the FreeforallAction in the sense that the time and position of the partic...
double get_partial_weight() const override
Return the specific weight for the chosen outgoing channel, which is mainly used for the partial weig...
Definition: action.h:24
ProcessType
ProcessTypes are used to identify the type of the process.
Definition: processbranch.h:39
@ Freeforall
See here for a short description.