Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
feynOptions.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 
26 #pragma once
27 
28 #include <functional>
29 #include "lagrangian.h"
30 #include "mrtOptions.h"
31 #include "topology.h"
32 #include "operatorBasis.h"
33 
34 namespace mty {
35 
36  class InteractionTerm;
37  class FeynmanDiagram;
38  class FeynmanRule;
39 
44  class FeynOptions {
45 
46  public:
47 
55  using LagrangianFilter
56  = std::function<bool(mty::InteractionTerm const&)>;
64  using DiagramFilter
65  = std::function<bool(mty::FeynmanDiagram const&)>;
66 
74  FeynOptions();
75 
80 
84  int getLoopOrder() const { return *loopOrder; }
85 
89  int getExpansionOrder() const { return expansionOrder; }
90 
94  int getTopology() const { return topology; }
95 
99  std::vector<int> const &getFermionOrder() const {
100  return fermionOrder;
101  }
102 
106  std::vector<LagrangianFilter> const &getLagrangianFilters() const {
107  return lfilters;
108  }
109 
113  std::vector<DiagramFilter> const &getDiagramFilters() const {
114  return dfilters;
115  }
116 
122  }
123 
128  return wilsonOperatorBasis;
129  }
130 
138  void setFeynmanRuleMode();
139 
151  void setLoopOrder(int t_nLoops, int nExternalLegs);
152 
160  void setTopology(int t_topology);
161 
170  void setFermionOrder(std::vector<int> const &order);
171 
178  void setWilsonOperatorCoefficient(csl::Expr const &factor);
179 
187  bool passFilters(FeynmanDiagram const &diagram) const;
188 
201  void applyFilters(
202  std::vector<Lagrangian::TermType> &lagrangian
203  ) const;
204 
224  std::vector<FeynmanRule const*> applyFilters(
225  std::vector<FeynmanRule> const &lagrangian
226  ) const;
227 
241  void applyFilters(
242  std::vector<FeynmanDiagram> &diagrams,
243  bool forceFilters = false
244  ) const;
245 
260  template<class Filter>
261  void addFilter(Filter &&filter) {
262  if constexpr (std::is_constructible_v<LagrangianFilter, Filter>)
263  {
264  addLagrangianFilter(std::forward<Filter>(filter));
265  }
266  else
267  {
268  addDiagramFilter(std::forward<Filter>(filter));
269  }
270  }
271 
278  void addFilters() {}
279 
305  template<class First, class ...Next>
306  void addFilters(First &&first, Next &&...next)
307  {
308  addFilter(std::forward<First>(first));
309  addFilters(std::forward<Next>(next)...);
310  }
311 
316  void resetFilters();
317 
318  protected:
319 
328  void addLagrangianFilter(LagrangianFilter const &filter) {
329  addLagrangianFilters({filter});
330  }
339  void addDiagramFilter(DiagramFilter const &filter) {
340  addDiagramFilters({filter});
341  }
348  std::initializer_list<LagrangianFilter> filters
349  );
355  void addDiagramFilters(
356  std::initializer_list<DiagramFilter> filters
357  );
358 
359  private:
360 
370  template<class Container, class Predicate>
372  Container &container,
373  Predicate const &predicate
374  ) const
375  {
376  auto last = std::remove_if(
377  begin(container), end(container), predicate);
378  container.erase(last, end(container));
379  }
380 
384  void initDefaultFilters();
385 
395 
396  public:
397 
405  bool orderInsertions { mty::option::applyInsertionOrdering };
406 
416  bool orderExternalFermions { mty::option::orderExternalFermions };
417 
425  bool simplifyAmplitudes { mty::option::simplifyAmplitudes };
426 
431  bool discardLowerOrders { mty::option::discardLowerOrders };
432 
437  bool verboseAmplitude { mty::option::verboseAmplitude };
438 
443  bool partialCalculation { false };
444 
445  private:
446 
456  bool feynRuleCalculation { false };
457 
466 
472 
478 
498  std::vector<int> fermionOrder;
499 
509  std::vector<LagrangianFilter> lfilters;
510 
521  std::vector<DiagramFilter> dfilters;
522 
537 
545 
546  constexpr static size_t nDefaultDiagramFilters = 1;
547  };
548 
549 } // namespace mty
void addDiagramFilter(DiagramFilter const &filter)
Adds one diagram filter to the options.
Definition: feynOptions.h:339
void applyFilters(Container &container, Predicate const &predicate) const
Helper private class applying a set of filters on a range.
Definition: feynOptions.h:371
bool discardLowerOrders
Set this option to false if you want the tree-level diagrams to appear in the same amplitude as the o...
Definition: feynOptions.h:431
bool partialCalculation
Set this option to true to disable the DiagramFilters if the calculation is only a part of the full c...
Definition: feynOptions.h:443
int getExpansionOrder() const
Definition: feynOptions.h:89
bool verboseAmplitude
Set this options to false to disable all prints during calculations.
Definition: feynOptions.h:437
void setTopology(int t_topology)
Sets the topology for the calculation.
Definition: feynOptions.cpp:35
void addFilters(First &&first, Next &&...next)
Adds an arbitrary number of filters (Lagrangian or diagram filters) to the options.
Definition: feynOptions.h:306
Contains utilities to handle topologies for Feynman diagrams.
Namespace of MARTY.
Definition: 2HDM.h:31
void addDiagramFilters(std::initializer_list< DiagramFilter > filters)
Adds a list of diagram filters to the options.
Definition: feynOptions.cpp:131
int getTopology() const
Definition: feynOptions.h:94
csl::Expr getWilsonOperatorCoefficient() const
Definition: feynOptions.h:120
std::vector< LagrangianFilter > lfilters
List of lagrangian filters.
Definition: feynOptions.h:509
std::function< bool(mty::FeynmanDiagram const &)> DiagramFilter
Type definition for a Feynman diagram.
Definition: feynOptions.h:65
FeynOptions()
Default constructor, only constructor of this class (expect copy and move).
Definition: feynOptions.cpp:23
Instances of this class can be given to mty::Model when launching a calculation to customize the outp...
Definition: feynOptions.h:44
void initDefaultFilters()
Initializes the default filters.
Definition: feynOptions.cpp:140
void addLagrangianFilter(LagrangianFilter const &filter)
Adds one Lagrangian filter to the options.
Definition: feynOptions.h:328
Uses projectors .
std::vector< DiagramFilter > dfilters
List of diagram filters.
Definition: feynOptions.h:521
bool feynRuleCalculation
Mode of an amplitude calculation.
Definition: feynOptions.h:456
void setLoopOrder(int t_nLoops, int nExternalLegs)
Sets the number of loops for the calculation.
Definition: feynOptions.cpp:29
void addFilter(Filter &&filter)
Adds one filter (LagrangianFilter or DiagramFilter) to the options.
Definition: feynOptions.h:261
void resetFilters()
Resets the filters (for lagrangian and diagrams) to the default ones, i.e. removing all user-defined ...
Definition: feynOptions.cpp:115
Class containing a Feynman diagram, symbolic expression and graph included.
Definition: feynmanDiagram.h:50
std::shared_ptr< int > loopOrder
Loop order (0 for tree-level, 1 for one-loop).
Definition: feynOptions.h:465
std::vector< LagrangianFilter > const & getLagrangianFilters() const
Definition: feynOptions.h:106
bool passFilters(FeynmanDiagram const &diagram) const
Tells if a diagram passes all diagram filters.
int getLoopOrder() const
Definition: feynOptions.h:84
int expansionOrder
Taylor expansion order for an amplitude calculation (expansion of the lagrangian exponential).
Definition: feynOptions.h:471
void setWilsonOperatorBasis(OperatorBasis basis)
Sets the Wilson operator basis wilsonOperatorBasis.
Definition: feynOptions.cpp:50
void setWilsonOperatorCoefficient(csl::Expr const &factor)
Sets the Wilson operator coefficient wilsonOperatorCoefficient.
Definition: feynOptions.cpp:45
void setFermionOrder(std::vector< int > const &order)
Sets the fermion order used to express the amplitude.
Definition: feynOptions.cpp:40
bool orderExternalFermions
Boolean telling if external fermions must be ordered in the result.
Definition: feynOptions.h:416
bool getFeynRuleCalculation() const
Definition: feynOptions.h:79
std::function< bool(mty::InteractionTerm const &)> LagrangianFilter
Type definition for a Lagrangian filter.
Definition: feynOptions.h:56
bool orderInsertions
This option (default = true) implies that fermionic insertions are ordered using a given rule...
Definition: feynOptions.h:405
OperatorBasis getWilsonOperatorBasis() const
Definition: feynOptions.h:127
OperatorBasis
Operator basis for Wilson coefficients.
Definition: operatorBasis.h:8
void addLagrangianFilters(std::initializer_list< LagrangianFilter > filters)
Adds a list of Lagrangian filters to the options.
Definition: feynOptions.cpp:122
void setFeynmanRuleMode()
Sets the value of feynRuleCalculation to true (the default value of this member is false)...
Definition: feynOptions.cpp:55
Contains the Lagrangian class, that encapsulates all interaction terms for a model.
std::vector< int > fermionOrder
Order for fermions in bilinears.
Definition: feynOptions.h:498
void applyFilters(std::vector< Lagrangian::TermType > &lagrangian) const
Applies the Lagrangian filters on a vector of vertices.
Definition: feynOptions.cpp:82
Any topologies i.e. combination of all 5 possible topologies.
Definition: topology.h:59
csl::Expr wilsonOperatorCoefficient
Prefactor used for Wilson coefficients.
Definition: feynOptions.h:536
std::vector< int > const & getFermionOrder() const
Definition: feynOptions.h:99
int topology
Topology allowed for the calculation. The default is mty::Topology::Any.
Definition: feynOptions.h:477
bool simplifyAmplitudes
Set this option to false if you want to disable all simplifications of amplitudes.
Definition: feynOptions.h:425
void addFilters()
Overloads to add 0 filter (this function does nothing).
Definition: feynOptions.h:278
std::vector< DiagramFilter > const & getDiagramFilters() const
Definition: feynOptions.h:113
OperatorBasis wilsonOperatorBasis
Operator basis for Wilson coefficients.
Definition: feynOptions.h:544