Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
modelData.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
21 #ifndef MODEL_DATA_H_INCLUDED
22 #define MODEL_DATA_H_INCLUDED
23 
24 #include <type_traits>
25 #include <csl.h>
26 #include "quantumField.h"
27 #include "lagrangian.h"
28 
35 namespace mty {
36 
56 class ModelData {
57 
58 public:
59 
61  // Public (static) data members
63 
68  inline static size_t nMomentums = 10;
73  inline static csl::Space const *defaultSpaceTime = &csl::Minkowski;
83  inline static int defaultQuantumNumber = 1;
84 
85 public:
86 
88  // Constructors
90 
96  ModelData();
115  explicit ModelData(std::unique_ptr<Gauge> &&t_gauge);
133  ModelData(
134  std::unique_ptr<Gauge> &&t_gauge,
135  std::unique_ptr<Flavor> &&t_flavor
136  );
159  ModelData(
160  std::unique_ptr<Gauge> &&t_gauge,
161  std::unique_ptr<Flavor> &&t_flavor,
162  std::vector<Particle> &t_particles);
167  ModelData(std::string const& nameFile);
168 
172  virtual ~ModelData();
173 
177  ModelData(ModelData &&other) = default;
181  ModelData &operator=(ModelData &&other) = default;
185  ModelData(ModelData const &other) = delete;
189  ModelData &operator=(ModelData const &other) = delete;
190 
192  // Initialization function
194 
203  void init(bool initGaugeTerms = true);
204 
206  // Check functions
208 
217  void checkHermiticity();
218 
220  // Write function
222 
223  virtual void saveModel(
224  std::ostream &out,
225  int indent = 4
226  );
227 
228  void saveModelFunction(
229  std::string_view name,
230  std::ostream &out,
231  int indent = 0
232  );
233 
234  void saveModelFunctionWithRef(
235  std::string_view name,
236  std::ostream &out,
237  int indent = 0
238  );
239 
240  void saveModelFile(
241  std::string_view name,
242  std::string const &fileName
243  );
244 
246  // Getters
248 
259  Lagrangian const &getLagrangian() const;
260 
264  bool isEnableChecks() const {
265  return enableChecks;
266  }
267 
273  void setEnableChecks(bool t_enable) {
274  enableChecks = t_enable;
275  }
276 
282  csl::Space const *getSpaceTime() const;
283 
290  mty::Gauge *getGauge() const;
291 
298  mty::Flavor *getFlavor() const;
299 
310  std::vector<mty::Particle> const &getParticles() const;
311 
338  std::vector<mty::Particle> getPhysicalParticles(
339  std::function<bool(mty::Particle)> const &predicate
340  = [](mty::Particle) { return true; }
341  ) const;
342 
348  std::vector<mty::QuantumNumber> const &getQuantumNumbers() const;
354  std::vector<mty::QuantumNumber> &getQuantumNumbers();
355 
364  std::vector<csl::Expr> const &getScalarCouplings() const;
365 
374  std::vector<csl::Tensor> const &getTensorCouplings() const;
375 
377  // Setters
379 
387  void setSpaceTime(csl::Space const *t_spaceTime);
388 
407  void setGauge(std::unique_ptr<mty::Gauge> &&t_gauge);
408 
409 
429  void addGaugedGroup(
430  group::Type type,
431  std::string_view name,
432  int dim,
433  csl::Expr const& coupling = nullptr);
434 
457  void addGaugedGroup(
458  group::Type type,
459  std::string_view name,
460  csl::Expr const& coupling = nullptr);
461 
477  void addFlavorGroup(
478  std::string_view name,
479  int nFlavor,
480  bool complexFields = true);
481 
500  void setFlavor(std::unique_ptr<mty::Flavor> &&t_flavor);
501 
517  void addParticle(
518  mty::Particle const &part,
519  bool initializeTerms = true);
535  void addParticles(
536  std::vector<mty::Particle> const &parts,
537  bool initializeTerms = true);
538 
539  void addParticlesIn(csl::Expr const &expr);
540 
552  void removeParticle(mty::Particle const &part);
553 
565  void removeParticles(std::vector<mty::Particle> const &parts);
566 
578  void removeParticle(std::string const &part);
579 
591  void removeParticles(std::vector<std::string> const &parts);
592 
601  void addScalarCoupling(std::string_view t_name);
609  void addScalarCoupling(csl::Expr const &coupling);
610 
619  void addTensorCoupling(csl::Parent const &tensorCoupling);
620 
649  void addQuantumNumber(
650  std::string_view name,
651  std::vector<mty::Particle> const& fields,
652  std::vector<int> const& values,
653  bool conserved = true
654  );
685  template<class FieldType>
686  void addQuantumNumber(
687  std::string_view name,
688  std::vector<FieldType> const& fields,
689  std::vector<int> const& values,
690  bool conserved = true
691  );
722  template<class FieldType>
723  void addQuantumNumber(
724  std::string_view name,
725  std::initializer_list<FieldType> fields,
726  std::vector<int> const &values,
727  bool conserved = true
728  );
729 
739  void setQuantumNumbers(
740  std::vector<mty::QuantumNumber> const &numbers
741  );
742 
743 
745  // Content
747 
758  bool findParticle(std::string_view t_name) const;
769  bool findParticle(mty::Particle const &part) const;
780  bool findParticle(mty::QuantumFieldParent const *part) const;
781 
792  bool findScalarCoupling(std::string_view t_name) const;
803  bool findScalarCoupling(csl::Expr const &coupling) const;
804 
815  bool findTensorCoupling(std::string_view t_name) const;
826  bool findTensorCoupling(csl::Parent const &coupling) const;
837  bool findTensorCoupling(csl::AbstractParent const *coupling) const;
838 
840  // Finders
842 
852  mty::Group const *getGroup(std::string_view t_name) const;
862  mty::Group *getGroup(std::string_view t_name);
863 
873  mty::Group const *getGroup(mty::FlavorGroup const *flavGroup) const;
883  mty::Group *getGroup(mty::FlavorGroup const *flavGroup);
893  mty::GaugedGroup const *getGaugedGroup(std::string_view t_name) const;
903  mty::GaugedGroup *getGaugedGroup(std::string_view t_name);
904 
914  mty::FlavorGroup const *getFlavorGroup(std::string_view t_name) const;
924  mty::FlavorGroup *getFlavorGroup(std::string_view t_name);
925 
926  std::vector<mty::Particle> getParticles(
927  std::initializer_list<std::string_view> names
928  ) const;
940  mty::Particle getParticle(std::string_view t_name) const;
977  mty::Particle getParticle(mty::QuantumField const &field) const;
990  mty::Particle getParticle(csl::Expr const &field) const;
991 
1003  csl::Expr getScalarCoupling(std::string_view t_name) const;
1004 
1016  csl::Tensor getTensorCoupling(std::string_view t_name) const;
1028  csl::Tensor getTensorCoupling(csl::Parent const &t_coupling) const;
1029 
1039  template<class FieldType>
1040  mty::GaugeIrrep getGaugeIrrep(FieldType &&field) const;
1041 
1053  template< class GroupType, class FieldType >
1055  FieldType &&field,
1056  GroupType &&group
1057  ) const;
1058 
1070  template< class GroupType, class FieldType >
1072  FieldType &&field,
1073  GroupType &&group
1074  ) const;
1075 
1085  template<class FieldType>
1086  mty::FlavorIrrep getFlavorIrrep(FieldType &&field) const ;
1087 
1100  template< class FlavorType, class FieldType >
1102  FieldType &&field,
1103  FlavorType &&flavor
1104  ) const;
1105 
1119  template< class GroupType, class FieldType >
1120  csl::Space const *getVectorSpace(
1121  GroupType &&group,
1122  FieldType &&field
1123  ) const;
1124 
1125 
1139  template< class GroupType, class FieldType >
1141  GroupType &&group,
1142  FieldType &&field
1143  ) const;
1144 
1157  template< class GroupType >
1159  GroupType &&group
1160  ) const;
1161 
1176  template< class GroupType, class FieldType >
1177  std::vector<csl::Index> generateIndices(
1178  size_t nIndices,
1179  GroupType &&group,
1180  FieldType &&field
1181  ) const;
1182 
1195  template< class GroupType >
1196  std::vector<csl::Index> generateIndices(
1197  size_t nIndices,
1198  GroupType &&group
1199  ) const;
1200 
1201 
1216  template< class GroupType, class FieldType >
1218  std::string_view nameIndex,
1219  GroupType &&group,
1220  FieldType &&field
1221  ) const;
1222 
1237  template< class GroupType, class FieldType >
1239  GroupType &&group,
1240  FieldType &&field
1241  ) const;
1242 
1253  mty::QuantumNumber const &getQuantumNumber(std::string_view name) const;
1264  mty::QuantumNumber &getQuantumNumber(std::string_view name);
1265 
1267  // Model building
1269 
1279  void checkValidity(mty::Particle const &part) const;
1280 
1293  void checkValidity(mty::Lagrangian::TermType const &term) const;
1294 
1316  void addLagrangianTerm(
1317  csl::Expr const &term,
1318  bool addHermitic = false);
1340  void addLagrangianTerm(
1341  mty::Lagrangian::TermType const &term,
1342  bool addHermitic = false);
1343 
1359  template<class FieldType>
1360  void addBosonicMass(
1361  FieldType &&field,
1362  std::string_view mass
1363  );
1382  template<class FieldType>
1383  void addBosonicMass(
1384  FieldType &&field,
1385  csl::Expr const &mass
1386  );
1387 
1410  template<class FieldType1, class FieldType2>
1411  void addFermionicMass(
1412  FieldType1 &&left,
1413  FieldType2 &&right,
1414  std::string_view mass
1415  );
1438  template<class FieldType1, class FieldType2>
1439  void addFermionicMass(
1440  FieldType1 &&left,
1441  FieldType2 &&right,
1442  csl::Expr const &mass
1443  );
1457  template<class FieldType>
1458  void addFermionicMass(
1459  FieldType &&diracFermion,
1460  std::string_view mass
1461  );
1475  template<class FieldType>
1476  void addFermionicMass(
1477  FieldType &&diracFermion,
1478  csl::Expr const &mass
1479  );
1480 
1490  template<class FieldType>
1491  void renameParticle(
1492  FieldType &&field,
1493  std::string_view newName
1494  );
1495 
1502  void renameCoupling(
1503  std::string_view name,
1504  std::string_view newName
1505  );
1506 
1508  // Display
1510 
1517  void printSubPart(
1518  std::vector<std::string> const &particles,
1519  std::ostream &out = std::cout
1520  ) const;
1527  void printSubPart(
1528  std::initializer_list<std::string> particles,
1529  std::ostream &out = std::cout
1530  ) const;
1537  void printSubPart(
1538  std::string const &particle,
1539  std::ostream &out = std::cout
1540  ) const;
1541 
1553  friend std::ostream &operator<<(
1554  std::ostream &out,
1555  ModelData const &model);
1556 
1557 protected:
1558 
1560  // Protected member functions
1562 
1564  // Init functions
1566 
1574  void initGaugedGroups(bool initGaugeTerms = true);
1575 
1577  // Write functions
1579 
1580  void writeHeader(
1581  std::ostream &out,
1582  int indentSize,
1583  std::vector<csl::Parent> &defined
1584  );
1585  void writeGauge(
1586  std::ostream &out,
1587  int indentSize,
1588  std::vector<csl::Parent> &defined
1589  );
1590  void writeFlavor(
1591  std::ostream &out,
1592  int indentSize,
1593  std::vector<csl::Parent> &defined
1594  );
1595  void writeMassAndWidth(
1596  std::ostream &out,
1597  int indentSize,
1598  std::vector<csl::Parent> &defined
1599  );
1600  void writeParticles(
1601  std::ostream &out,
1602  int indentSize,
1603  std::vector<csl::Parent> &defined
1604  );
1605  void writeDependencies(
1606  std::ostream &out,
1607  int indentSize,
1608  std::vector<csl::Parent> &defined,
1609  std::vector<csl::Expr> &kinetic,
1610  std::vector<csl::Expr> &mass,
1611  std::vector<csl::Expr> &interac
1612  );
1613  void writeLagrangian(
1614  std::ostream &out,
1615  int indentSize,
1616  std::vector<csl::Expr> const &kinetic,
1617  std::vector<csl::Expr> const &mass,
1618  std::vector<csl::Expr> const &interac
1619  );
1620 
1622  // Helper functions for template overloads
1624 
1634  mty::GaugeIrrep doGetGaugeIrrep(mty::Particle const &part) const;
1646  mty::Particle const &part,
1647  mty::Group const *group
1648  ) const;
1661  mty::Particle const &particle,
1662  mty::Group const *group
1663  ) const;
1664 
1674  mty::FlavorIrrep doGetFlavorIrrep(mty::Particle const &part) const;
1686  mty::Particle const &part,
1687  mty::Group const *flavor
1688  ) const;
1689 
1703  mty::Group const *group,
1704  mty::Particle const &irrep
1705  ) const;
1706 
1720  mty::FlavorGroup const *group,
1721  mty::Particle const &irrep
1722  ) const;
1723 
1737  mty::Group const *group,
1738  mty::Particle const &fieldRep
1739  ) const;
1740 
1754  mty::Group const *group
1755  ) const;
1770  std::string_view nameIndex,
1771  mty::Group const *group,
1772  mty::Particle const &fieldRep
1773  ) const;
1774 
1789  mty::Group const *group,
1790  mty::Particle const &fieldRep
1791  ) const;
1792 
1793  /*
1794  * @brief Actually adds a bosonic mass term to the Lagrangian.
1795  *
1796  * @param particle Particle in the mass term.
1797  * @param mass Name of the mass for the particle.
1798  *
1799  * @sa addBosonicMass()
1800  */
1801  void doAddBosonicMass(
1802  mty::Particle const &particle,
1803  std::string_view mass
1804  );
1805  /*
1806  * @brief Actually adds a bosonic mass term to the Lagrangian.
1807  *
1808  * @param particle Particle in the mass term.
1809  * @param mass Mass of the particle.
1810  *
1811  * @sa addBosonicMass()
1812  */
1813  void doAddBosonicMass(
1814  mty::Particle const &particle,
1815  csl::Expr const &mass
1816  );
1817 
1818  /*
1819  * @brief Actually adds a fermionic mass term to the Lagrangian.
1820  *
1821  * @param left Left-handed Weyl fermion.
1822  * @param right Right-handed Weyl fermion.
1823  * @param mass Name of the mass for the particle.
1824  *
1825  * @sa addFermionicMass()
1826  */
1827  void doAddFermionicMass(
1828  mty::Particle const &left,
1829  mty::Particle const &right,
1830  std::string_view mass
1831  );
1832  /*
1833  * @brief Actually adds a fermionic mass term to the Lagrangian.
1834  *
1835  * @param left Left-handed Weyl fermion.
1836  * @param right Right-handed Weyl fermion.
1837  * @param mass Mass of the particle.
1838  *
1839  * @sa addFermionicMass()
1840  */
1841  void doAddFermionicMass(
1842  mty::Particle const &left,
1843  mty::Particle const &right,
1844  csl::Expr const &mass
1845  );
1846  /*
1847  * @brief Actually adds a fermionic mass term to the Lagrangian.
1848  *
1849  * @param diracFermion Dirac fermion.
1850  * @param mass Name of the mass for the particle.
1851  *
1852  * @sa addFermionicMass()
1853  */
1854  void doAddFermionicMass(
1855  mty::Particle const &diracFermion,
1856  std::string_view mass
1857  );
1858  /*
1859  * @brief Actually adds a fermionic mass term to the Lagrangian.
1860  *
1861  * @param diracFermion Dirac fermion.
1862  * @param mass Mass of the particle.
1863  *
1864  * @sa addFermionicMass()
1865  */
1866  void doAddFermionicMass(
1867  mty::Particle const &diracFermion,
1868  csl::Expr const &mass
1869  );
1870 
1879  void doRenameParticle(
1880  mty::Particle const &part,
1881  std::string_view newName
1882  );
1883 
1884 protected:
1885 
1895 
1904 
1908  std::unique_ptr<mty::Gauge> gauge;
1909 
1913  std::unique_ptr<mty::Flavor> flavor;
1914 
1921  std::vector<mty::Particle> particles;
1922 
1931  std::vector<mty::QuantumNumber> quantumNumbers;
1932 
1938  std::vector<csl::Expr> scalarCouplings;
1939 
1945  std::vector<csl::Tensor> tensorCouplings;
1946 
1956  bool gaugeLocked = false;
1957 
1964  bool enableChecks = true;
1965 };
1966 
1967 
1969 // Template functions for ModelData setters
1971 
1972 template<class FieldType>
1974  std::string_view name,
1975  std::vector<FieldType> const& fields,
1976  std::vector<int> const& values,
1977  bool conserved
1978  )
1979  {
1980  std::vector<mty::Particle> parts;
1981  parts.reserve(fields.size());
1982  for (FieldType const &f : fields)
1983  parts.push_back(getParticle(f));
1984  addQuantumNumber(name, parts, values, conserved);
1985  }
1986 template<class FieldType>
1988  std::string_view name,
1989  std::initializer_list<FieldType> fields,
1990  std::vector<int> const &values,
1991  bool conserved
1992  )
1993  {
1995  name,
1996  std::vector<FieldType>(fields),
1997  values,
1998  conserved);
1999  }
2000 
2002 // Template functions for ModelData finders
2004 
2005 
2006 template<class FieldType>
2007  mty::GaugeIrrep ModelData::getGaugeIrrep(FieldType &&field) const
2008  {
2009  constexpr bool field_valid =
2010  std::is_convertible<FieldType, mty::Particle const&>::value;
2011 
2012  if constexpr(field_valid)
2013  return doGetGaugeIrrep(field);
2014  else
2015  return getGaugeIrrep(
2016  getParticle(std::forward<FieldType>(field)));
2017  }
2018 
2019 template< class GroupType, class FieldType >
2021  FieldType &&field,
2022  GroupType &&group
2023  ) const
2024  {
2025  constexpr bool field_valid =
2026  std::is_convertible<
2027  FieldType,
2028  mty::Particle const&>::value;
2029 
2030  constexpr bool group_valid =
2031  std::is_convertible<
2032  GroupType,
2033  mty::Group const*>::value;
2034 
2035  if constexpr(group_valid) {
2036  if constexpr(field_valid)
2037  return doGetCharge(field, group);
2038  else
2039  return getCharge(
2040  getParticle(std::forward<FieldType>(field)),
2041  group);
2042  }
2043  else if constexpr (field_valid)
2044  return getCharge(
2045  field,
2046  getGroup(std::forward<GroupType>(group)));
2047  else
2048  return getCharge(
2049  getParticle(std::forward<FieldType>(field)),
2050  getGroup(std::forward<GroupType>(group)));
2051  }
2052 
2053 template< class GroupType, class FieldType >
2055  FieldType &&field,
2056  GroupType &&group
2057  ) const
2058  {
2059  constexpr bool field_valid =
2060  std::is_convertible<
2061  FieldType,
2062  mty::Particle const&>::value;
2063 
2064  constexpr bool group_valid =
2065  std::is_convertible<
2066  GroupType,
2067  mty::Group const*>::value;
2068 
2069  if constexpr(group_valid) {
2070  if constexpr(field_valid)
2071  return doGetGroupIrrep(field, group);
2072  else
2073  return getGroupIrrep(
2074  getParticle(std::forward<FieldType>(field)),
2075  group);
2076  }
2077  else if constexpr (field_valid)
2078  return getGroupIrrep(
2079  field,
2080  getGroup(std::forward<GroupType>(group)));
2081  else
2082  return getGroupIrrep(
2083  getParticle(std::forward<FieldType>(field)),
2084  getGroup(std::forward<GroupType>(group)));
2085  }
2086 
2087 template<class FieldType>
2089  {
2090  constexpr bool field_valid =
2091  std::is_convertible<FieldType, mty::Particle const&>::value;
2092 
2093  if constexpr(field_valid)
2094  return doGetFlavorIrrep(field);
2095  else
2096  return getFlavorIrrep(
2097  getParticle(std::forward<FieldType>(field)));
2098  }
2099 
2100 template< class FlavorType, class FieldType >
2102  FieldType &&field,
2103  FlavorType &&flavor
2104  ) const
2105  {
2106  constexpr bool field_valid =
2107  std::is_convertible<
2108  FieldType,
2109  mty::Particle const&>::value;
2110 
2111  constexpr bool flavor_valid =
2112  std::is_convertible<
2113  FlavorType,
2114  mty::Group const*>::value;
2115 
2116  if constexpr(flavor_valid) {
2117  if constexpr(field_valid)
2118  return doGetFlavorIrrep(field, flavor);
2119  else
2120  return getFlavorIrrep(
2121  getParticle(std::forward<FieldType>(field)),
2122  flavor);
2123  }
2124  else if constexpr (field_valid)
2125  return getFlavorIrrep(
2126  field,
2127  getGroup(std::forward<FlavorType>(flavor))
2128  );
2129  else
2130  return getFlavorIrrep(
2131  getParticle(std::forward<FieldType>(field)),
2132  getGroup(std::forward<FlavorType>(flavor)));
2133  }
2134 
2135 template< class GroupType, class FieldType >
2137  GroupType &&group,
2138  FieldType &&field
2139  ) const
2140  {
2141  constexpr bool group_valid =
2142  std::is_convertible<
2143  GroupType,
2144  mty::Group const*>::value;
2145 
2146  constexpr bool field_valid =
2147  std::is_convertible<
2148  FieldType,
2149  mty::Particle const&>::value;
2150 
2151  if constexpr(group_valid) {
2152  if constexpr(field_valid)
2153  return doGetVectorSpace(group, field);
2154  else
2155  return getVectorSpace(group,
2156  getParticle(std::forward<FieldType>(field)));
2157  }
2158  else if constexpr (field_valid)
2159  return getVectorSpace(
2160  getGroup(std::forward<GroupType>(group)),
2161  field);
2162  else
2163  return getVectorSpace(
2164  getGroup(std::forward<GroupType>(group)),
2165  getParticle(std::forward<FieldType>(field)));
2166  }
2167 
2168 template< class GroupType, class FieldType >
2170  GroupType &&group,
2171  FieldType &&field
2172  ) const
2173  {
2174  constexpr bool group_valid =
2175  std::is_convertible<
2176  GroupType,
2177  mty::Group const*>::value;
2178 
2179  constexpr bool field_valid =
2180  std::is_convertible<
2181  FieldType,
2182  mty::Particle const&>::value;
2183 
2184  if constexpr(group_valid) {
2185  if constexpr(field_valid)
2186  return doGenerateIndex(group, field);
2187  else
2188  return generateIndex(
2189  group,
2190  getParticle(std::forward<FieldType>(field)));
2191  }
2192  else if constexpr (field_valid)
2193  return generateIndex(
2194  getGroup(std::forward<GroupType>(group)),
2195  field);
2196  else
2197  return generateIndex(
2198  getGroup(std::forward<GroupType>(group)),
2199  getParticle(std::forward<FieldType>(field)));
2200  }
2201 
2202 template< class GroupType >
2204  GroupType &&group
2205  ) const
2206  {
2207  constexpr bool group_valid =
2208  std::is_convertible<
2209  GroupType,
2210  mty::Group const*>::value;
2211 
2212  if constexpr(group_valid) {
2213  return doGenerateIndex(group);
2214  }
2215  else
2216  return generateIndex(
2217  getGroup(std::forward<GroupType>(group))
2218  );
2219  }
2220 
2221  template< class GroupType, class FieldType >
2222  std::vector<csl::Index> ModelData::generateIndices(
2223  size_t nIndices,
2224  GroupType &&group,
2225  FieldType &&field
2226  ) const
2227  {
2228  std::vector<csl::Index> indices(nIndices);
2229  for (size_t i = 0; i != nIndices; ++i)
2230  indices[i] = generateIndex<GroupType, FieldType>(
2231  std::forward<GroupType>(group),
2232  std::forward<FieldType>(field)
2233  );
2234 
2235  return indices;
2236  }
2237 
2238  template< class GroupType >
2239  std::vector<csl::Index> ModelData::generateIndices(
2240  size_t nIndices,
2241  GroupType &&group
2242  ) const
2243  {
2244  std::vector<csl::Index> indices(nIndices);
2245  for (size_t i = 0; i != nIndices; ++i)
2246  indices[i] = generateIndex<GroupType>(
2247  std::forward<GroupType>(group)
2248  );
2249 
2250  return indices;
2251  }
2252 
2253 template< class GroupType, class FieldType >
2255  std::string_view nameIndex,
2256  GroupType &&group,
2257  FieldType &&field
2258  ) const
2259  {
2260  constexpr bool group_valid =
2261  std::is_convertible<
2262  GroupType,
2263  mty::Group const*>::value;
2264 
2265  constexpr bool field_valid =
2266  std::is_convertible<
2267  FieldType,
2268  mty::Particle const&>::value;
2269 
2270  if constexpr(group_valid) {
2271  if constexpr(field_valid)
2272  return doGenerateIndex(nameIndex, group, field);
2273  else
2274  return generateIndex(
2275  nameIndex,
2276  group,
2277  getParticle(std::forward<FieldType>(field)));
2278  }
2279  else if constexpr (field_valid)
2280  return generateIndex(
2281  nameIndex,
2282  getGroup(std::forward<GroupType>(group)),
2283  field);
2284  else
2285  return generateIndex(
2286  nameIndex,
2287  getGroup(std::forward<GroupType>(group)),
2288  getParticle(std::forward<FieldType>(field)));
2289  }
2290 
2291 template< class GroupType, class FieldType >
2293  GroupType &&group,
2294  FieldType &&field
2295  ) const
2296  {
2297  constexpr bool group_valid =
2298  std::is_convertible<
2299  GroupType,
2300  mty::Group const*>::value;
2301 
2302  constexpr bool field_valid =
2303  std::is_convertible<
2304  FieldType,
2305  mty::Particle const&>::value;
2306 
2307  if constexpr(group_valid) {
2308  if constexpr(field_valid)
2309  return doGetGenerator(group, field);
2310  else
2311  return getGenerator(
2312  group,
2313  getParticle(std::forward<FieldType>(field)));
2314  }
2315  else if constexpr (field_valid)
2316  return getGenerator(
2317  getGroup(std::forward<GroupType>(group)),
2318  field);
2319  else
2320  return getGenerator(
2321  getGroup(std::forward<GroupType>(group)),
2322  getParticle(std::forward<FieldType>(field)));
2323  }
2324 
2325 template<class FieldType>
2327  FieldType &&field,
2328  std::string_view mass
2329  )
2330  {
2331  constexpr bool field_valid =
2332  std::is_convertible<
2333  FieldType,
2334  mty::Particle const&>::value;
2335 
2336  if constexpr (field_valid)
2337  doAddBosonicMass(field, mass);
2338  else
2340  getParticle(std::forward<FieldType>(field)),
2341  mass
2342  );
2343  }
2344 template<class FieldType>
2346  FieldType &&field,
2347  csl::Expr const &mass
2348  )
2349  {
2350  constexpr bool field_valid =
2351  std::is_convertible<
2352  FieldType,
2353  mty::Particle const&>::value;
2354 
2355  if constexpr (field_valid)
2356  doAddBosonicMass(field, mass);
2357  else
2359  getParticle(std::forward<FieldType>(field)),
2360  mass
2361  );
2362  }
2363 
2364 template<class FieldType1, class FieldType2>
2366  FieldType1 &&left,
2367  FieldType2 &&right,
2368  std::string_view mass
2369  )
2370  {
2371  constexpr bool field1_valid =
2372  std::is_convertible<
2373  FieldType1,
2374  mty::Particle const&>::value;
2375  constexpr bool field2_valid =
2376  std::is_convertible<
2377  FieldType2,
2378  mty::Particle const&>::value;
2379 
2380  if constexpr(field1_valid) {
2381  if constexpr(field2_valid)
2382  return doAddFermionicMass(left, right, mass);
2383  else
2384  return addFermionicMass(
2385  left,
2386  getParticle(std::forward<FieldType2>(right)),
2387  mass
2388  );
2389  }
2390  else if constexpr (field2_valid)
2391  return addFermionicMass(
2392  getParticle(std::forward<FieldType1>(left)),
2393  right,
2394  mass
2395  );
2396  else
2397  return addFermionicMass(
2398  getParticle(std::forward<FieldType1>(left)),
2399  getParticle(std::forward<FieldType2>(right)),
2400  mass
2401  );
2402  }
2403 template<class FieldType1, class FieldType2>
2405  FieldType1 &&left,
2406  FieldType2 &&right,
2407  csl::Expr const &mass
2408  )
2409  {
2410  constexpr bool field1_valid =
2411  std::is_convertible<
2412  FieldType1,
2413  mty::Particle const&>::value;
2414  constexpr bool field2_valid =
2415  std::is_convertible<
2416  FieldType2,
2417  mty::Particle const&>::value;
2418 
2419  if constexpr(field1_valid) {
2420  if constexpr(field2_valid)
2421  return doAddFermionicMass(left, right, mass);
2422  else
2423  return addFermionicMass(
2424  left,
2425  getParticle(std::forward<FieldType2>(right)),
2426  mass
2427  );
2428  }
2429  else if constexpr (field2_valid)
2430  return addFermionicMass(
2431  getParticle(std::forward<FieldType1>(left)),
2432  right,
2433  mass
2434  );
2435  else
2436  return addFermionicMass(
2437  getParticle(std::forward<FieldType1>(left)),
2438  getParticle(std::forward<FieldType2>(right)),
2439  mass
2440  );
2441  }
2442 template<class FieldType>
2444  FieldType &&diracFermion,
2445  std::string_view mass
2446  )
2447  {
2448  constexpr bool field_valid =
2449  std::is_convertible<
2450  FieldType,
2451  mty::Particle const&>::value;
2452 
2453  if constexpr (field_valid)
2454  doAddFermionicMass(diracFermion, mass);
2455  else
2457  getParticle(std::forward<FieldType>(diracFermion)),
2458  mass
2459  );
2460  }
2461 template<class FieldType>
2463  FieldType &&diracFermion,
2464  csl::Expr const &mass
2465  )
2466  {
2467  constexpr bool field_valid =
2468  std::is_convertible<
2469  FieldType,
2470  mty::Particle const&>::value;
2471 
2472  if constexpr (field_valid)
2473  doAddFermionicMass(diracFermion, mass);
2474  else
2476  getParticle(std::forward<FieldType>(diracFermion)),
2477  mass
2478  );
2479  }
2480 
2481 
2482 template<class FieldType>
2484  FieldType &&field,
2485  std::string_view newName
2486  )
2487  {
2488  constexpr bool field_valid =
2489  std::is_convertible<
2490  FieldType,
2491  mty::Particle const&>::value;
2492 
2493  if constexpr(field_valid)
2494  return doRenameParticle(field, newName);
2495  else
2496  return renameParticle(
2497  getParticle(std::forward<FieldType>(field)),
2498  newName);
2499  }
2500 
2501 } // End of namespace mty
2502 
2503 #endif
Interaction lagrangian of a model, allows to get all diagrams for a particular process by expanding i...
Definition: lagrangian.h:50
Definition: gaugedGroup.h:194
csl::Expr doGetCharge(mty::Particle const &particle, mty::Group const *group) const
Actually returns the charge representation of a particle for a U(1) group.
Definition: modelData.cpp:1157
void setGauge(std::unique_ptr< mty::Gauge > &&t_gauge)
Sets the gauge of the model.
Definition: modelData.cpp:658
std::vector< mty::Particle > particles
Particle content (including gauge bosons, ghosts etc) of the model.
Definition: modelData.h:1921
std::vector< mty::Particle > const & getParticles() const
Returns a const reference to the model&#39;s particles.
Definition: modelData.cpp:595
std::vector< csl::Tensor > const & getTensorCouplings() const
Returns the tensor couplings (Yukawa coupling typically) of the model.
Definition: modelData.cpp:638
mty::FlavorIrrep doGetFlavorIrrep(mty::Particle const &part) const
Actually returns the flavor representation of a particle.
Definition: modelData.cpp:1165
Definition: gauge.h:36
mty::Irrep getGroupIrrep(FieldType &&field, GroupType &&group) const
Returns the group representation of a field.
Definition: modelData.h:2054
static csl::Space const * defaultSpaceTime
Default space-time for the model&#39;s particles. There is actually no support for another space that csl...
Definition: modelData.h:73
mty::Particle getParticle(std::string_view t_name) const
Returns a particle in the model given a name.
Definition: modelData.cpp:1077
void addFermionicMass(FieldType1 &&left, FieldType2 &&right, std::string_view mass)
Adds a fermionic mass to the model.
Definition: modelData.h:2365
std::vector< csl::Index > generateIndices(size_t nIndices, GroupType &&group, FieldType &&field) const
Returns indices coresponding to the representation of a field in a given group.
Definition: modelData.h:2222
ModelData()
Default constructor.
Definition: modelData.cpp:28
void addParticle(mty::Particle const &part, bool initializeTerms=true)
Adds a particle to the model.
Definition: modelData.cpp:720
void checkValidity(mty::Particle const &part) const
Checks the validity of a particle when adding it to the model.
Definition: modelData.cpp:1277
std::unique_ptr< mty::Flavor > flavor
Flavor of the model.
Definition: modelData.h:1913
bool findParticle(std::string_view t_name) const
Searches a particle in the model.
Definition: modelData.cpp:884
void removeParticle(mty::Particle const &part)
Removes a particle from the model.
Definition: modelData.cpp:771
mty::Lagrangian L
Lagrangian of the model.
Definition: modelData.h:1894
bool findScalarCoupling(std::string_view t_name) const
Searches a scalar coupling in the model.
Definition: modelData.cpp:903
mty::Gauge * getGauge() const
Returns a pointer to the model&#39;s gauge.
Definition: modelData.cpp:585
This class inherits from std::shared_ptr<QuantumFieldParent> and should be used instead of direct Qua...
Definition: quantumField.h:1409
Namespace of MARTY.
Definition: 2HDM.h:31
static int defaultQuantumNumber
Default quantum number for particles when not given.
Definition: modelData.h:83
mty::QuantumNumber const & getQuantumNumber(std::string_view name) const
Returns a quantum number (const reference) given its name.
Definition: modelData.cpp:1248
mty::Irrep doGetGroupIrrep(mty::Particle const &part, mty::Group const *group) const
Actually returns the group representation of a particle.
Definition: modelData.cpp:1151
void renameCoupling(std::string_view name, std::string_view newName)
Renames a (scalar or tensor) coupling of the model.
Definition: modelData.cpp:1453
ModelData & operator=(ModelData &&other)=default
Defaulted move assignement operator.
void setEnableChecks(bool t_enable)
Sets enableChecks.
Definition: modelData.h:273
void addBosonicMass(FieldType &&field, std::string_view mass)
Adds a bosonic mass term to the model.
Definition: modelData.h:2326
static size_t nMomentums
Number of momenta instantiated for the model (10). With 5 maximum external legs, this is fairly safe...
Definition: modelData.h:68
class mty::AbstractGroup Group
Abstract base class for groups.
constexpr auto names
Names for topologies.
Definition: topology.h:72
std::vector< csl::Tensor > tensorCouplings
List of tensor couplings of the model.
Definition: modelData.h:1945
mty::Group const * getGroup(std::string_view t_name) const
Returns a Group (pointer to const) given its name.
Definition: modelData.cpp:943
csl::Expr getScalarCoupling(std::string_view t_name) const
Returns a scalar coupling given its name.
Definition: modelData.cpp:1117
void checkHermiticity()
Checks the hermiticity of the Lagrangian, i.e. checks if .
Definition: modelData.cpp:82
mty::GaugedGroup const * getGaugedGroup(std::string_view t_name) const
Returns a GaugedGroup (pointer to const) given its name.
Definition: modelData.cpp:992
mty::Generator getGenerator(GroupType &&group, FieldType &&field) const
Returns the generator coresponding to the representation of a field in a given group.
Definition: modelData.h:2292
mty::GaugeIrrep getGaugeIrrep(FieldType &&field) const
Returns the gauge representation of a field.
Definition: modelData.h:2007
void addQuantumNumber(std::string_view name, std::vector< mty::Particle > const &fields, std::vector< int > const &values, bool conserved=true)
Adds a new quantum number to a model, giving eigenvalues for particles also.
Definition: modelData.cpp:852
Definition: gauge.h:137
void addScalarCoupling(std::string_view t_name)
Adds a scalar coupling constant in the model.
Definition: modelData.cpp:820
bool findTensorCoupling(std::string_view t_name) const
Searches a tensor coupling in the model.
Definition: modelData.cpp:920
This class represents quantum numbers of a theory, like for example baryon number B...
Definition: quantumNumber.h:44
void renameParticle(FieldType &&field, std::string_view newName)
Renames a particle of the model.
Definition: modelData.h:2483
std::vector< mty::QuantumNumber > quantumNumbers
List of quantum numbers in the model.
Definition: modelData.h:1931
void addLagrangianTerm(csl::Expr const &term, bool addHermitic=false)
Adds a lagrangian term to the model.
Definition: modelData.cpp:1311
std::unique_ptr< mty::Gauge > gauge
Gauge of the model.
Definition: modelData.h:1908
csl::Index doGenerateIndex(mty::Group const *group, mty::Particle const &fieldRep) const
Actually returns a csl::Index corresponding to a particle&#39;s representation.
Definition: modelData.cpp:1205
Definition: flavor.h:37
mty::Flavor * getFlavor() const
Returns a pointer to the model&#39;s flavor.
Definition: modelData.cpp:590
void setFlavor(std::unique_ptr< mty::Flavor > &&t_flavor)
Sets the flavor of the model.
Definition: modelData.cpp:709
bool isEnableChecks() const
Definition: modelData.h:264
void addParticles(std::vector< mty::Particle > const &parts, bool initializeTerms=true)
Adds a list of particles to the model.
Definition: modelData.cpp:749
csl::Space const * spaceTime
Space time for the model.
Definition: modelData.h:1903
csl::Expr getCharge(FieldType &&field, GroupType &&group) const
Returns the charge representation of a field in a U(1) group.
Definition: modelData.h:2020
std::vector< csl::Expr > const & getScalarCouplings() const
Returns the scalar couplings (gauge coupling typically) of the model.
Definition: modelData.cpp:633
void initGaugedGroups(bool initGaugeTerms=true)
Initializes gauge terms (gauge bosons, ghosts) and fixes the gauge.
Definition: modelData.cpp:1577
csl::Space const * getSpaceTime() const
Returns a pointer to the space time of the mode (csl::Space).
Definition: modelData.cpp:580
Class deriving from csl::TensorFieldElement, may enter expressions. In contrary to QuantumFieldParent...
Definition: quantumField.h:1614
csl::Space const * getVectorSpace(GroupType &&group, FieldType &&field) const
Returns the vector space coresponding to the representation of a field in a given group...
Definition: modelData.h:2136
bool gaugeLocked
Boolean that tells if the gauge model is initilialized.
Definition: modelData.h:1956
csl::Tensor getTensorCoupling(std::string_view t_name) const
Returns a tensor coupling given its name.
Definition: modelData.cpp:1127
mty::Generator doGetGenerator(mty::Group const *group, mty::Particle const &fieldRep) const
Actually returns a generator corresponding to a particle&#39;s representation.
Definition: modelData.cpp:1238
void addFlavorGroup(std::string_view name, int nFlavor, bool complexFields=true)
Adds a flavor group to the model.
Definition: modelData.cpp:692
Definition: flavor.h:133
csl::Space const * doGetVectorSpace(mty::Group const *group, mty::Particle const &irrep) const
Actually returns the vector space corresponding to a particle&#39;s representation.
Definition: modelData.cpp:1189
void addGaugedGroup(group::Type type, std::string_view name, int dim, csl::Expr const &coupling=nullptr)
Adds a gauge group to the model.
Definition: modelData.cpp:666
Definition: flavor.h:72
void printSubPart(std::vector< std::string > const &particles, std::ostream &out=std::cout) const
Prints a sub part of the Lagrangian including some particles.
Definition: modelData.cpp:1483
void setQuantumNumbers(std::vector< mty::QuantumNumber > const &numbers)
Sets the quantum numbers of the model.
Definition: modelData.cpp:873
bool enableChecks
Boolean telling if checks must be done with lagrangian terms added to the model (gauge representation...
Definition: modelData.h:1964
void setSpaceTime(csl::Space const *t_spaceTime)
Sets the space time of the model.
Definition: modelData.cpp:647
std::vector< csl::Expr > scalarCouplings
Lists of scalar couplings of the model.
Definition: modelData.h:1938
csl::Index generateIndex(GroupType &&group, FieldType &&field) const
Returns an index coresponding to the representation of a field in a given group.
Definition: modelData.h:2169
mty::FlavorIrrep getFlavorIrrep(FieldType &&field) const
Returns the flavor representation of a field.
Definition: modelData.h:2088
Handles the irreducible representation of a given semi-simple algebra.
Definition: representation.h:42
void doRenameParticle(mty::Particle const &part, std::string_view newName)
Actually renames a particle.
Definition: modelData.cpp:1418
mty::GaugeIrrep doGetGaugeIrrep(mty::Particle const &part) const
Actually returns the gauge representation of a particle.
Definition: modelData.cpp:1147
The class ModelData contains all the necessary features to store and manipulate the content of a mode...
Definition: modelData.h:56
std::vector< mty::Particle > getPhysicalParticles(std::function< bool(mty::Particle)> const &predicate=[](mty::Particle) { return true;}) const
Returns a list of the physical particles in a model.
Definition: modelData.cpp:600
Base class for parents of QuantumField objects.
Definition: quantumField.h:152
void removeParticles(std::vector< mty::Particle > const &parts)
Removes particles from the model.
Definition: modelData.cpp:794
Contains the Lagrangian class, that encapsulates all interaction terms for a model.
Definition: generator.h:107
void init(bool initGaugeTerms=true)
Initializes the gauge once and for all. This function must be called after finishing the gauge...
Definition: modelData.cpp:1572
virtual ~ModelData()
Destructor.
Definition: modelData.cpp:66
std::vector< mty::QuantumNumber > const & getQuantumNumbers() const
Returns the list of quantum numbers.
Definition: modelData.cpp:624
Lagrangian const & getLagrangian() const
Returns a const reference to the Lagrangian.
Definition: modelData.cpp:575
Contains QuantumField and QuantumFieldParent, basic objects handling quantum fields as csl expression...
void addTensorCoupling(csl::Parent const &tensorCoupling)
Adds a tensor coupling constant in the model.
Definition: modelData.cpp:838
mty::FlavorGroup const * getFlavorGroup(std::string_view t_name) const
Returns a FlavorGroup (pointer) given its name.
Definition: modelData.cpp:1015
Type
Enumeration of types of semi simple Lie groups. The names being very small, we use a namespace to avo...
Definition: group.h:44
friend std::ostream & operator<<(std::ostream &out, ModelData const &model)
Prints the model.
Definition: modelData.cpp:1522