Version: SMASH-2.0
smash::EnergyMomentumTensor Class Reference

#include <energymomentumtensor.h>

The EnergyMomentumTensor class represents a symmetric positive semi-definite energy-momentum tensor \( T^{\mu \nu}\).

Definition at line 29 of file energymomentumtensor.h.

Collaboration diagram for smash::EnergyMomentumTensor:
[legend]

Public Types

typedef std::array< double, 10 > tmn_type
 The energy-momentum tensor is symmetric and has 10 independent components. More...
 
using iterator = tmn_type::iterator
 Iterator over the components. More...
 
using const_iterator = tmn_type::const_iterator
 Constant iterator over the components. More...
 

Public Member Functions

 EnergyMomentumTensor ()
 Default constructor (nulls all components) More...
 
 EnergyMomentumTensor (const tmn_type &Tmn)
 Copy constructor. More...
 
double operator[] (std::size_t i) const
 Return ith component of the tensor. More...
 
EnergyMomentumTensor operator+= (const EnergyMomentumTensor &Tmn0)
 Addition of \(T^{\mu \nu}_0\) to tensor. More...
 
EnergyMomentumTensor operator-= (const EnergyMomentumTensor &Tmn0)
 Subtraction of \(T^{\mu \nu}_0\) of tensor. More...
 
EnergyMomentumTensor operator*= (double a)
 Scaling of the tensor by scalar \(a\). More...
 
EnergyMomentumTensor operator/= (double a)
 Division of the tensor by scalar \(a\). More...
 
FourVector landau_frame_4velocity () const
 Find the Landau frame 4-velocity from energy-momentum tensor. More...
 
EnergyMomentumTensor boosted (const FourVector &u) const
 Boost to a given 4-velocity. More...
 
void add_particle (const FourVector &mom)
 Given momentum of the particle adds \(p^{\mu}p^{\mu}/p^0\) to the energy momentum tensor. More...
 
void add_particle (const ParticleData &p, double factor)
 Same, but \( p^{\mu}p^{\mu}/p^0\) times factor is added. More...
 
void add_particle_for_derivatives (const ParticleData &, double, ThreeVector)
 Dummy function need for update_general_lattice. More...
 
iterator begin ()
 Returns an iterator starting at the (0,0) component. More...
 
iterator end ()
 Returns an iterator pointing after the (3,3)th component. More...
 
const_iterator begin () const
 Const overload of the above. More...
 
const_iterator end () const
 Const overload of the above. More...
 
const_iterator cbegin () const
 
const_iterator cend () const
 

Static Public Member Functions

static std::int8_t tmn_index (std::int8_t mu, std::int8_t nu)
 Access the index of component \( (\mu, \nu) \). More...
 

Private Attributes

tmn_type Tmn_
 The internal storage of the components. More...
 

Member Typedef Documentation

◆ tmn_type

typedef std::array<double, 10> smash::EnergyMomentumTensor::tmn_type

The energy-momentum tensor is symmetric and has 10 independent components.

Definition at line 32 of file energymomentumtensor.h.

◆ iterator

using smash::EnergyMomentumTensor::iterator = tmn_type::iterator

Iterator over the components.

Definition at line 79 of file energymomentumtensor.h.

◆ const_iterator

using smash::EnergyMomentumTensor::const_iterator = tmn_type::const_iterator

Constant iterator over the components.

Definition at line 81 of file energymomentumtensor.h.

Constructor & Destructor Documentation

◆ EnergyMomentumTensor() [1/2]

smash::EnergyMomentumTensor::EnergyMomentumTensor ( )
inline

Default constructor (nulls all components)

Definition at line 34 of file energymomentumtensor.h.

34 { Tmn_.fill(0.); }
Here is the caller graph for this function:

◆ EnergyMomentumTensor() [2/2]

smash::EnergyMomentumTensor::EnergyMomentumTensor ( const tmn_type Tmn)
inlineexplicit

Copy constructor.

Parameters
[in]TmnComponents of the energy-momentum tensor

Definition at line 40 of file energymomentumtensor.h.

40  {
41  for (size_t i = 0; i < 10; i++) {
42  Tmn_[i] = Tmn[i];
43  }
44  }

Member Function Documentation

◆ operator[]()

double smash::EnergyMomentumTensor::operator[] ( std::size_t  i) const
inline

Return ith component of the tensor.

Definition at line 47 of file energymomentumtensor.h.

47 { return Tmn_[i]; }

◆ tmn_index()

static std::int8_t smash::EnergyMomentumTensor::tmn_index ( std::int8_t  mu,
std::int8_t  nu 
)
inlinestatic

Access the index of component \( (\mu, \nu) \).

Parameters
[in]mu\(\mu\) is the row index (0 to 3)
[in]nu\(\nu\) is the line index (0 to 3)

Definition at line 54 of file energymomentumtensor.h.

54  {
55  // clang-format off
56  constexpr std::array<std::int8_t, 16> indices = {0, 1, 2, 3,
57  1, 4, 5, 6,
58  2, 5, 7, 8,
59  3, 6, 8, 9};
60  // clang-format on
61  if (mu < 4 && nu < 4 && mu >= 0 && nu >= 0) {
62  return indices[mu + 4 * nu];
63  } else {
64  throw std::invalid_argument("Invalid indices: " + std::to_string(mu) +
65  ", " + std::to_string(nu));
66  }
67  }
Here is the caller graph for this function:

◆ operator+=()

EnergyMomentumTensor smash::EnergyMomentumTensor::operator+= ( const EnergyMomentumTensor Tmn0)
inline

Addition of \(T^{\mu \nu}_0\) to tensor.

Definition at line 154 of file energymomentumtensor.h.

155  {
156  for (size_t i = 0; i < 10; i++) {
157  Tmn_[i] += Tmn0[i];
158  }
159  return *this;
160 }

◆ operator-=()

EnergyMomentumTensor smash::EnergyMomentumTensor::operator-= ( const EnergyMomentumTensor Tmn0)
inline

Subtraction of \(T^{\mu \nu}_0\) of tensor.

Definition at line 168 of file energymomentumtensor.h.

169  {
170  for (size_t i = 0; i < 10; i++) {
171  Tmn_[i] -= Tmn0[i];
172  }
173  return *this;
174 }

◆ operator*=()

EnergyMomentumTensor smash::EnergyMomentumTensor::operator*= ( double  a)
inline

Scaling of the tensor by scalar \(a\).

Definition at line 182 of file energymomentumtensor.h.

182  {
183  for (size_t i = 0; i < 10; i++) {
184  Tmn_[i] *= a;
185  }
186  return *this;
187 }

◆ operator/=()

EnergyMomentumTensor smash::EnergyMomentumTensor::operator/= ( double  a)
inline

Division of the tensor by scalar \(a\).

Definition at line 199 of file energymomentumtensor.h.

199  {
200  for (size_t i = 0; i < 10; i++) {
201  Tmn_[i] /= a;
202  }
203  return *this;
204 }

◆ landau_frame_4velocity()

FourVector smash::EnergyMomentumTensor::landau_frame_4velocity ( ) const

Find the Landau frame 4-velocity from energy-momentum tensor.

IMPORTANT: resulting 4-velocity is fourvector with LOWER index

Definition at line 23 of file energymomentumtensor.cc.

23  {
24  using Eigen::Matrix4d;
25  using Eigen::Vector4d;
26  /* We want to solve the generalized eigenvalue problem
27  T^{\mu \nu} h_{nu} = \lambda g^{\mu \nu} h_{nu}, or in the other way
28  T_{\mu}^{\nu} h_{nu} = \lambda h_{mu}. The eigenvector
29  corresponding to the largest (and the only positive) eigenvalue is
30  proportional to 4-velocity of the Landau frame.
31  Denote T^{\mu}_{\nu} as A and g^{\mu \nu} as B.
32  A is symmetric and positive semi-definite. B is symmetric.
33  A x = \lambda B x. I have to solve generalized eigenvalue
34  problem, because A can be not positively definite (e.g. if
35  energy-momentum tensor is computed for particles with momenta lying
36  in one plane). For positively definite A a more efficient solution
37  is possible, but I (oliiny) do not consider it, until it becomes
38  important for SMASH performance.
39  */
40  Matrix4d A;
41  // A = T_{\mu}^{\nu} = g_{\mu \mu'} T^{\mu' \nu}
42  // clang-format off
43  A << Tmn_[0], Tmn_[1], Tmn_[2], Tmn_[3],
44  -Tmn_[1], -Tmn_[4], -Tmn_[5], -Tmn_[6],
45  -Tmn_[2], -Tmn_[5], -Tmn_[7], -Tmn_[8],
46  -Tmn_[3], -Tmn_[6], -Tmn_[8], -Tmn_[9];
47  // clang-format on
48 
49  logg[LTmn].debug("Looking for Landau frame for T_{mu}^{nu} ", A);
50  Eigen::EigenSolver<Matrix4d> es(A);
51 
52 // Eigen values should be strictly real and non-negative.
53 
54 /* Here and further I assume that eigenvalues are given in
55  * descending order.
56  *
57  * \todo(oliiny): check Eigen documentation
58  * to make sure this is always true.*/
59 #ifndef NDEBUG
60  Vector4d eig_im = es.eigenvalues().imag();
61  Vector4d eig_re = es.eigenvalues().real();
62  for (size_t i = 0; i < 4; i++) {
63  assert(std::abs(eig_im(i)) < really_small);
64  if (i == 0) {
65  assert(eig_re(i) > -really_small);
66  } else {
67  assert(eig_re(i) < really_small);
68  }
69  }
70  // Make sure that 0th eigenvalue is really the largest one
71  assert(eig_re(0) >= eig_re(1));
72  assert(eig_re(0) >= eig_re(2));
73  assert(eig_re(0) >= eig_re(3));
74  logg[LTmn].debug("eigenvalues: ", eig_re);
75 #endif
76 
77  Vector4d tmp = es.eigenvectors().col(0).real();
78  // Choose sign so that zeroth component is positive
79  if (tmp(0) < 0.0) {
80  tmp = -tmp;
81  }
82 
83  FourVector u(tmp(0), tmp(1), tmp(2), tmp(3));
84  const double u_sqr = u.sqr();
85  if (u_sqr > really_small) {
86  u /= std::sqrt(u_sqr);
87  } else {
88  logg[LTmn].error(
89  "Landau frame is not defined.", " Eigen vector", u, " of ", A,
90  " is not time-like and",
91  " cannot be 4-velocity. This may happen if energy-momentum",
92  " tensor was constructed for a massless particle.");
93  u = FourVector(1., 0., 0., 0.);
94  }
95  return u;
96 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ boosted()

EnergyMomentumTensor smash::EnergyMomentumTensor::boosted ( const FourVector u) const

Boost to a given 4-velocity.

IMPORTANT: boost 4-velocity is fourvector with LOWER index

Parameters
[in]u4-velocity vector

Definition at line 98 of file energymomentumtensor.cc.

98  {
99  using Eigen::Matrix4d;
100  Matrix4d A, L, R;
101  // Energy-momentum tensor
102  // clang-format off
103  A << Tmn_[0], Tmn_[1], Tmn_[2], Tmn_[3],
104  Tmn_[1], Tmn_[4], Tmn_[5], Tmn_[6],
105  Tmn_[2], Tmn_[5], Tmn_[7], Tmn_[8],
106  Tmn_[3], Tmn_[6], Tmn_[8], Tmn_[9];
107  // clang-format on
108  // Compute Lorentz matrix of boost
109  const ThreeVector tmp = u.threevec() / (1.0 + u[0]);
110  // clang-format off
111  L << u[0], u[1], u[2], u[3],
112  u[1], u[1] * tmp.x1() + 1.0, u[2] * tmp.x1(), u[3] * tmp.x1(),
113  u[2], u[1] * tmp.x2(), u[2] * tmp.x2() + 1.0, u[3] * tmp.x2(),
114  u[3], u[1] * tmp.x3(), u[2] * tmp.x3(), u[3] * tmp.x3() + 1.0;
115  // clang-format on
116  // Boost
117  R = L * A * L;
118  // clang-format off
119  return EnergyMomentumTensor({R(0, 0), R(0, 1), R(0, 2), R(0, 3),
120  R(1, 1), R(1, 2), R(1, 3),
121  R(2, 2), R(2, 3),
122  R(3, 3)});
123  // clang-format on
124 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_particle() [1/2]

void smash::EnergyMomentumTensor::add_particle ( const FourVector mom)

Given momentum of the particle adds \(p^{\mu}p^{\mu}/p^0\) to the energy momentum tensor.

Parameters
[in]momMomentum 4-vector with upper index, as all 4-momenta in SMASH

Definition at line 126 of file energymomentumtensor.cc.

126  {
127  const ThreeVector tmp = mom.threevec() / mom[0];
128  Tmn_[0] += mom[0];
129  Tmn_[1] += mom[1];
130  Tmn_[2] += mom[2];
131  Tmn_[3] += mom[3];
132  Tmn_[4] += mom[1] * tmp.x1();
133  Tmn_[5] += mom[1] * tmp.x2();
134  Tmn_[6] += mom[1] * tmp.x3();
135  Tmn_[7] += mom[2] * tmp.x2();
136  Tmn_[8] += mom[2] * tmp.x3();
137  Tmn_[9] += mom[3] * tmp.x3();
138 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_particle() [2/2]

void smash::EnergyMomentumTensor::add_particle ( const ParticleData p,
double  factor 
)

Same, but \( p^{\mu}p^{\mu}/p^0\) times factor is added.

Parameters
[in]pReference to the data information of the particle
See also
ParticleData
Parameters
[in]factorUsually a smearing factor

Definition at line 140 of file energymomentumtensor.cc.

140  {
141  add_particle(p.momentum() * factor);
142 }
Here is the call graph for this function:

◆ add_particle_for_derivatives()

void smash::EnergyMomentumTensor::add_particle_for_derivatives ( const ParticleData ,
double  ,
ThreeVector   
)
inline

Dummy function need for update_general_lattice.

Definition at line 111 of file energymomentumtensor.h.

111  {
112  }

◆ begin() [1/2]

iterator smash::EnergyMomentumTensor::begin ( )
inline

Returns an iterator starting at the (0,0) component.

The iterator implements the randomIterator concept. Thus, you can simply write begin() + 1 to get an iterator that points to the 1st component.

Definition at line 120 of file energymomentumtensor.h.

120 { return Tmn_.begin(); }

◆ end() [1/2]

iterator smash::EnergyMomentumTensor::end ( )
inline

Returns an iterator pointing after the (3,3)th component.

Definition at line 125 of file energymomentumtensor.h.

125 { return Tmn_.end(); }

◆ begin() [2/2]

const_iterator smash::EnergyMomentumTensor::begin ( ) const
inline

Const overload of the above.

Definition at line 128 of file energymomentumtensor.h.

128 { return Tmn_.begin(); }

◆ end() [2/2]

const_iterator smash::EnergyMomentumTensor::end ( ) const
inline

Const overload of the above.

Definition at line 130 of file energymomentumtensor.h.

130 { return Tmn_.end(); }

◆ cbegin()

const_iterator smash::EnergyMomentumTensor::cbegin ( ) const
inline
See also
begin

Definition at line 133 of file energymomentumtensor.h.

133 { return Tmn_.cbegin(); }

◆ cend()

const_iterator smash::EnergyMomentumTensor::cend ( ) const
inline
See also
end

Definition at line 135 of file energymomentumtensor.h.

135 { return Tmn_.cend(); }

Member Data Documentation

◆ Tmn_

tmn_type smash::EnergyMomentumTensor::Tmn_
private

The internal storage of the components.

Tensor has 16 components, but it is symmetric, so number of independent components reduces to 10.

Definition at line 143 of file energymomentumtensor.h.


The documentation for this class was generated from the following files:
smash::EnergyMomentumTensor::Tmn_
tmn_type Tmn_
The internal storage of the components.
Definition: energymomentumtensor.h:143
smash::EnergyMomentumTensor::EnergyMomentumTensor
EnergyMomentumTensor()
Default constructor (nulls all components)
Definition: energymomentumtensor.h:34
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::really_small
constexpr double really_small
Numerical error tolerance.
Definition: constants.h:37
smash::LTmn
static constexpr int LTmn
Definition: energymomentumtensor.cc:21
ThermodynamicQuantity::Tmn
R
#define R(x, n)
Definition: sha256.cc:55
smash::EnergyMomentumTensor::add_particle
void add_particle(const FourVector &mom)
Given momentum of the particle adds to the energy momentum tensor.
Definition: energymomentumtensor.cc:126
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28