Version: SMASH-3.4
clebschgordan.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2018,2020,2022-2023
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 
8 #ifndef SRC_INCLUDE_SMASH_CLEBSCHGORDAN_H_
9 #define SRC_INCLUDE_SMASH_CLEBSCHGORDAN_H_
10 
11 #include <algorithm>
12 
13 #include "clebschgordan_lookup.h"
14 #include "particletype.h"
15 
16 namespace smash {
17 
18 /**
19  * Calculate the squared isospin Clebsch-Gordan coefficient for two particles
20  * p_a and p_b coupling to a resonance Res.
21  * \param[in] p_a Information on spin/isospin of particle a
22  * \param[in] p_b Information on spin/isospin of particle b
23  * \param[in] Res Information on spin/isospin of resonance
24  * \return Clebsch-Gordan squared for 2->1 reaction
25  */
27  const ParticleType &p_b,
28  const ParticleType &Res) {
29  const double cg = ClebschGordan::coefficient(p_a.isospin(), p_b.isospin(),
30  Res.isospin(), p_a.isospin3(),
31  p_b.isospin3(), Res.isospin3());
32  return cg * cg;
33 }
34 
35 /**
36  * Calculate the squared isospin Clebsch-Gordan coefficient for three particles
37  * p_a, p_b and p_c coupling to a resonance Res.
38  * \param[in] p_a Information on spin/isospin of particle a
39  * \param[in] p_b Information on spin/isospin of particle b
40  * \param[in] p_c Information on spin/isospin of particle c
41  * \param[in] Res Information on spin/isospin of resonance
42  * \return Clebsch-Gordan squared for 3->1 reaction
43  */
44 double isospin_clebsch_gordan_sqr_3to1(const ParticleType &p_a,
45  const ParticleType &p_b,
46  const ParticleType &p_c,
47  const ParticleType &Res);
48 
49 /**
50  * Calculate the squared isospin Clebsch-Gordan coefficient for a
51  * 2-to-2 reaction A + B -> C + D. If a total isospin value I is given
52  * (doubled in order to be integer), then only contributions with that total
53  * isospin will be counted.
54  * \param[in] p_a Information on spin/isospin of particle a
55  * \param[in] p_b Information on spin/isospin of particle b
56  * \param[in] p_c Information on spin/isospin of particle c
57  * \param[in] p_d Information on spin/isospin of particle d
58  * \param[in] I total isospin of the reaction
59  * \return Clebsch-Gordan squared for 2->2 reaction
60  */
61 double isospin_clebsch_gordan_sqr_2to2(const ParticleType &p_a,
62  const ParticleType &p_b,
63  const ParticleType &p_c,
64  const ParticleType &p_d,
65  const int I = -1);
66 
67 /// Range of total isospin for reaction of particle a with particle b.
68 class I_tot_range {
69  private:
70  /// Value of minimum total isospin
71  int I_min_;
72  /// Value of maximum total isospin
73  int I_max_;
74 
75  public:
76  /**
77  * Get the allowed range of total isospin for a collision a + b.
78  * \param p_a Particle a.
79  * \param p_b Particle b.
80  * \return Maximum and minimum of allowed values.
81  */
82  I_tot_range(const ParticleType &p_a, const ParticleType &p_b) {
83  // Compute total isospin range with given particles.
84  const int I_z_abs = std::abs(p_a.isospin3() + p_b.isospin3());
85  I_max_ = p_a.isospin() + p_b.isospin();
86  I_min_ = std::max(std::abs(p_a.isospin() - p_b.isospin()), I_z_abs);
87  }
88 
89  /**
90  * Get the allowed range of total isospin for a collision a + b <-> c + d.
91  * \param p_a Particle a.
92  * \param p_b Particle b.
93  * \param p_c Particle c.
94  * \param p_d Particle d.
95  * \return Maximum and minimum of allowed values or empty range, if reaction
96  * is forbidden due to isospin.
97  */
98  I_tot_range(const ParticleType &p_a, const ParticleType &p_b,
99  const ParticleType &p_c, const ParticleType &p_d) {
100  // Compute total isospin range with given initial and final particles.
101  const int I_z = p_a.isospin3() + p_b.isospin3();
102  if (I_z != p_c.isospin3() + p_d.isospin3()) {
103  /* This reaction is forbidden by isospin conservation.
104  * Set impossible values to make sure an empty range is returned. */
105  I_min_ = 1;
106  I_max_ = 0;
107  return;
108  }
109  I_max_ =
110  std::min(p_a.isospin() + p_b.isospin(), p_c.isospin() + p_d.isospin());
111  I_min_ = std::max(std::abs(p_a.isospin() - p_b.isospin()),
112  std::abs(p_c.isospin() - p_d.isospin()));
113  I_min_ = std::max(I_min_, std::abs(I_z));
114  }
115 
116  /**
117  * Iterator class for determination of total isospin.
118  *
119  * See documentation of smash::Particles::GenericIterator class for more
120  * information about exposed types.
121  */
122  class iterator {
123  private:
124  /// Element of the iterator
125  int c_;
126  /// Parent class giving the total isospin range.
128 
129  public:
130  /// <b>Required by STL:</b> expose iterator_category
131  using iterator_category = std::forward_iterator_tag;
132  /// <b>Required by STL:</b> expose value_type
133  using value_type = int;
134  /// <b>Required by STL:</b> expose difference_type
135  using difference_type = int;
136  /// <b>Required by STL:</b> expose pointer
137  using pointer = int *;
138  /// <b>Required by STL:</b> expose reference
139  using reference = int &;
140  /**
141  * Construct an iterator.
142  * \param start Initial value.
143  * \param parent Parent class giving the total isospin range.
144  * \return The constructed iterator.
145  */
146  iterator(int start, I_tot_range &parent) : c_(start), parent_(parent) {}
147  /// \return Current element of the iterator.
148  int operator*() { return c_; }
149  /// \return Next element of the iterator.
150  const iterator *operator++() {
151  c_ -= 2;
152  return this;
153  }
154  /// \return Next element of the iterator.
156  c_ -= 2;
157  return iterator(c_ + 2, parent_);
158  }
159  /**
160  * \param other Other iterator.
161  * \return Whether both iterators are equal.
162  */
163  bool operator==(const iterator &other) { return c_ == other.c_; }
164  /**
165  * \param other Other iterator.
166  * \return Whether both iterators are not equal.
167  */
168  bool operator!=(const iterator &other) { return c_ != other.c_; }
169  };
170 
171  /// \return Beginning of iterator.
172  iterator begin() { return iterator(I_max_, *this); }
173  /// \return End of iterator.
175  if (I_min_ > I_max_) {
176  return begin();
177  }
178  return iterator(I_min_ - 2, *this);
179  }
180 };
181 
182 } // namespace smash
183 
184 #endif // SRC_INCLUDE_SMASH_CLEBSCHGORDAN_H_
static double coefficient(const int j_a, const int j_b, const int j_c, const int m_a, const int m_b, const int m_c)
Check in the Clebsch-Gordan lookup table if the requested coefficient is available.
Iterator class for determination of total isospin.
bool operator==(const iterator &other)
I_tot_range & parent_
Parent class giving the total isospin range.
bool operator!=(const iterator &other)
int difference_type
Required by STL: expose difference_type
int value_type
Required by STL: expose value_type
int & reference
Required by STL: expose reference
int c_
Element of the iterator.
iterator(int start, I_tot_range &parent)
Construct an iterator.
const iterator * operator++()
std::forward_iterator_tag iterator_category
Required by STL: expose iterator_category
int * pointer
Required by STL: expose pointer
Range of total isospin for reaction of particle a with particle b.
Definition: clebschgordan.h:68
int I_min_
Value of minimum total isospin.
Definition: clebschgordan.h:71
I_tot_range(const ParticleType &p_a, const ParticleType &p_b)
Get the allowed range of total isospin for a collision a + b.
Definition: clebschgordan.h:82
I_tot_range(const ParticleType &p_a, const ParticleType &p_b, const ParticleType &p_c, const ParticleType &p_d)
Get the allowed range of total isospin for a collision a + b <-> c + d.
Definition: clebschgordan.h:98
int I_max_
Value of maximum total isospin.
Definition: clebschgordan.h:73
Particle type contains the static properties of a particle species.
Definition: particletype.h:100
int isospin3() const
Definition: particletype.h:179
int isospin() const
Returns twice the isospin vector length .
Definition: action.h:24
double isospin_clebsch_gordan_sqr_3to1(const ParticleType &p_a, const ParticleType &p_b, const ParticleType &p_c, const ParticleType &Res)
Calculate the squared isospin Clebsch-Gordan coefficient for three particles p_a, p_b and p_c couplin...
double isospin_clebsch_gordan_sqr_2to2(const ParticleType &p_a, const ParticleType &p_b, const ParticleType &p_c, const ParticleType &p_d, const int I=-1)
Calculate the squared isospin Clebsch-Gordan coefficient for a 2-to-2 reaction A + B -> C + D.
double isospin_clebsch_gordan_sqr_2to1(const ParticleType &p_a, const ParticleType &p_b, const ParticleType &Res)
Calculate the squared isospin Clebsch-Gordan coefficient for two particles p_a and p_b coupling to a ...
Definition: clebschgordan.h:26