Version: SMASH-3.1
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 
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 
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 
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 
68 class I_tot_range {
69  private:
71  int I_min_;
73  int I_max_;
74 
75  public:
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 
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 
122  class iterator {
123  private:
125  int c_;
128 
129  public:
131  using iterator_category = std::forward_iterator_tag;
133  using value_type = int;
135  using difference_type = int;
137  using pointer = int *;
139  using reference = int &;
146  iterator(int start, I_tot_range &parent) : c_(start), parent_(parent) {}
148  int operator*() { return c_; }
150  const iterator *operator++() {
151  c_ -= 2;
152  return this;
153  }
156  c_ -= 2;
157  return iterator(c_ + 2, parent_);
158  }
163  bool operator==(const iterator &other) { return c_ == other.c_; }
168  bool operator!=(const iterator &other) { return c_ != other.c_; }
169  };
170 
172  iterator begin() { return iterator(I_max_, *this); }
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:98
int isospin3() const
Definition: particletype.h:177
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