flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
fields.hpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#ifndef CXXQFT_FIELDS_H
20#define CXXQFT_FIELDS_H
21
22#include <array>
24#include <boost/array.hpp>
25#include <boost/version.hpp>
26
27#include <boost/mpl/erase.hpp>
28#include <boost/mpl/joint_view.hpp>
29#include <boost/mpl/pair.hpp>
30#include <boost/mpl/vector.hpp>
31#include <boost/mpl/vector_c.hpp>
32
33#include <boost/fusion/adapted/boost_array.hpp>
34#include <boost/fusion/adapted/mpl.hpp>
35
36#include <boost/hana/config.hpp>
37#include <boost/hana/equal.hpp>
38#include <boost/hana/fwd/transform.hpp>
39
40#if BOOST_VERSION >= 105800
41#include <boost/fusion/include/move.hpp>
42#else
43#include <boost/fusion/include/copy.hpp>
44#endif
45
51 template <class Field>
59 using type = std::array<int, Field::numberOfFieldIndices>;
60 };
61
62 namespace detail {
68 template <class Field>
70 static constexpr int value =
71 std::tuple_size<typename field_indices<Field>::type>::value;
72 using type = boost::mpl::int_<value>;
73 };
74 /*
75 * @param FieldSequence a Forward Sequence, e.g vector<type1,typ2,...>
76 * (see https://www.boost.org/doc/libs/1_69_0/libs/mpl/doc/refmanual/forward-sequence.html).
77 * @returns `::type` which accomodates `mpl::int_<N>` with `int N` being the
78 * sum of @b number of indices of fields inside FieldSequence.
79 * @returns `::value` which represents `N` where `N` being the `int`
80 * sum of @b number of indices of fields inside FieldSequence
81 */
82 template <class FieldSequence>
84 using type = typename boost::mpl::fold<
85 FieldSequence,
86 boost::mpl::int_<0>,
87 boost::mpl::plus<boost::mpl::_1,
89 >
90 >::type;
91 static constexpr int value = type::value;
92 };
93 } // namespace detail
94
95 /* @note Is defined by compiler only if the number of generation for a field
96 * is not 1.
97 */
98 template <class Field>
99 std::enable_if_t<Field::numberOfGenerations != 1, bool>
100 isSMField(const typename field_indices<Field>::type& indices) {
101 boost::array<bool, Field::numberOfGenerations> sm_flags;
102
103 #if BOOST_VERSION >= 105800
104 boost::fusion::move(typename Field::sm_flags(), sm_flags);
105 #else
106 boost::fusion::copy(typename Field::sm_flags(), sm_flags);
107 #endif
108
109 return sm_flags[indices.front()];
110 }
111
112 template <class Field>
113 std::enable_if_t<Field::numberOfGenerations == 1, bool>
115 return boost::mpl::at_c<typename Field::sm_flags, 0>::type::value;
116 }
117
118 namespace fields
119 {
120 enum class ParticleType {
121 scalar,
122 fermion,
123 vector,
124 ghost
125 };
126
127 template<typename Field>
128 struct is_massless {
129 static constexpr bool value = Field::massless;
130 };
131 template<typename Field>
133
134 enum class ParticleColorRep {
135 singlet,
136 triplet,
138 sextet,
139 octet
140 };
141
142 template<typename Field>
143 struct is_singlet {
144 static constexpr bool value =
145 Field::colorRep == ParticleColorRep::singlet;
146 };
147 template<typename Field>
149
150 template<typename Field>
151 struct is_triplet {
152 static constexpr bool value = Field::colorRep == ParticleColorRep::triplet;
153 };
154 template<typename Field>
156
157 template<typename Field>
159 static constexpr bool value =
160 Field::colorRep == ParticleColorRep::anti_triplet;
161 };
162 template<typename Field>
164
165 template<typename Field>
166 struct is_octet {
167 static constexpr bool value = Field::colorRep == ParticleColorRep::octet;
168 };
169 template<typename Field>
171
172 template<typename Field>
173 constexpr std::enable_if_t<
175 >
179 template<typename Field>
180 constexpr std::enable_if_t<
182 >
186 template<typename Field>
187 constexpr std::enable_if_t<
189 >
191 return Field::colorRep;
192 }
193
194 template<class Field>
195 struct bar {
196 using index_bounds = typename Field::index_bounds;
197 using sm_flags = typename Field::sm_flags;
200
201 static constexpr int numberOfGenerations = Field::numberOfGenerations;
202 static constexpr int numberOfFieldIndices = Field::numberOfFieldIndices;
203 static constexpr double electricCharge = -Field::electricCharge;
204 static constexpr auto particleType = Field::particleType;
205 static constexpr auto colorRep = color_conj<Field>();
206 static constexpr auto massless = Field::massless;
207 static constexpr auto pdgids = boost::hana::transform(Field::pdgids, [](int x) {return -x;});
208 };
209
210 template<class Field>
211 struct conj {
212 using index_bounds = typename Field::index_bounds;
213 using sm_flags = typename Field::sm_flags;
216
217 static constexpr int numberOfGenerations = Field::numberOfGenerations;
218 static constexpr int numberOfFieldIndices = Field::numberOfFieldIndices;
219 static constexpr double electricCharge = -Field::electricCharge;
220 static constexpr auto particleType = Field::particleType;
221 static constexpr auto colorRep = color_conj<Field>();
222 static constexpr auto massless = Field::massless;
223 static constexpr auto pdgids = boost::hana::transform(Field::pdgids, [](int x) {return -x;});
224 };
225
226 // Double Lorentz conjugation
227 template <class Field>
228 struct bar<bar<Field>> {
229 using type = Field;
230 };
231 template <class Field>
232 struct conj<conj<Field>> {
233 using type = Field;
234 };
235
236 // Remove Lorentz conjugation
237 template <class Field>
239 using type = Field;
240 };
241
242 template <class Field>
246
247 template <class Field>
251
252 template <class Field>
253 struct is_scalar : public std::false_type {};
254
255 template <class Field>
256 struct is_scalar<bar<Field> > : public is_scalar<Field> {};
257
258 template <class Field>
259 struct is_scalar<conj<Field> > : public is_scalar<Field> {};
260
261 template <class Field>
262 struct is_fermion : public std::false_type {};
263
264 template <class Field>
265 struct is_fermion<bar<Field> > : public is_fermion<Field> {};
266
267 template <class Field>
268 struct is_fermion<conj<Field> > : public is_fermion<Field> {};
269
270 template <class Field>
271 struct is_vector : public std::false_type {};
272
273 template <class Field>
274 struct is_vector<bar<Field> > : public is_vector<Field> {};
275
276 template <class Field>
277 struct is_vector<conj<Field> > : public is_vector<Field> {};
278
279 template <class Field>
280 struct is_ghost : public std::false_type {};
281
282 template <class Field>
283 struct is_ghost<bar<Field> > : public is_ghost<Field> {};
284
285 template <class Field>
286 struct is_ghost<conj<Field> > : public is_ghost<Field> {};
287
288 } // namespace generic_fields
289
290 using fields::bar;
291 using fields::conj;
293
294} // namespace flexiblesusy::cxx_diagrams
295
296#endif
constexpr std::enable_if_t< is_triplet< Field >::value, ParticleColorRep > color_conj()
Definition fields.hpp:176
std::enable_if_t< Field::numberOfGenerations !=1, bool > isSMField(const typename field_indices< Field >::type &indices)
Definition fields.hpp:100
Declare a metafunction that gives the int value for Field during compilation time or int_<int N> type...
Definition fields.hpp:69
typename boost::mpl::fold< FieldSequence, boost::mpl::int_< 0 >, boost::mpl::plus< boost::mpl::_1, number_of_field_indices< boost::mpl::_2 > > >::type type
Definition fields.hpp:90
Declare a type that can hold the field indices for any given field.
Definition fields.hpp:52
std::array< int, Field::numberOfFieldIndices > type
Definition fields.hpp:59
static constexpr int numberOfGenerations
Definition fields.hpp:201
typename Field::index_bounds index_bounds
Definition fields.hpp:196
static constexpr double electricCharge
Definition fields.hpp:203
typename Field::sm_flags sm_flags
Definition fields.hpp:197
static constexpr auto particleType
Definition fields.hpp:204
static constexpr int numberOfFieldIndices
Definition fields.hpp:202
static constexpr double electricCharge
Definition fields.hpp:219
static constexpr int numberOfGenerations
Definition fields.hpp:217
typename Field::index_bounds index_bounds
Definition fields.hpp:212
typename Field::sm_flags sm_flags
Definition fields.hpp:213
static constexpr int numberOfFieldIndices
Definition fields.hpp:218