Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
lagrangian.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 
24 #ifndef LAGRANGIAN_H_INCLUDED
25 #define LAGRANGIAN_H_INCLUDED
26 
27 #include "quantumField.h"
28 #include "interactionTerm.h"
29 
30 namespace mty::interaction {
31 
32 enum Type {
33  Kinetic,
34  Mass,
35  Interaction,
36 };
37 
38 }
39 
40 namespace mty {
41 
42 class Expander;
43 
44 mty::interaction::Type determineTermType(const InteractionTerm& term);
45 
50 class Lagrangian {
51 
52  public:
53 
55 
56  protected:
57 
58  mutable bool expressionComputed = false;
59 
60  mutable csl::Expr expression;
61 
62  public:
63 
64  std::vector<TermType> kinetic;
65 
66  std::vector<TermType> mass;
67 
68  std::vector<TermType> interaction;
69 
70  public:
71 
72  Lagrangian();
73 
74  Lagrangian(const Lagrangian& other) = default;
75 
76  ~Lagrangian(){};
77 
78  bool contains(const TermType& searchTerm) const;
79  bool contains(const InteractionTerm& searchTerm) const;
80 
81  csl::Expr getExpression() const;
82 
83  csl::Tensor getPoint() const;
84 
85  void mergeTerms();
86 
87  void removeParticle(Particle const &particle);
88 
89  csl::Expr operator()(const csl::Expr& point);
90 
91  size_t size() const;
92 
93  size_t fullSize() const;
94 
95  bool empty() const;
96 
97  bool totalEmpty() const;
98 
99  TermType operator[](size_t pos) const;
100 
101  TermType& operator[](size_t pos);
102 
103  std::vector<TermType>::iterator begin();
104 
105  std::vector<TermType>::iterator end();
106 
107  std::vector<TermType>::const_iterator begin() const;
108 
109  std::vector<TermType>::const_iterator end() const;
110 
111  void push_back(const csl::Expr& newTerm);
112 
113  void push_back(InteractionTerm const &newTerm);
114 
115  void push_back(TermType const &newTerm);
116 
117  friend
118  std::ostream& operator<<(std::ostream& fout, const Lagrangian& L);
119 
120  static
121  void mergeTerms(std::vector<TermType>& terms);
122 
123  protected:
124 
125  void ensurePoint(csl::Expr &expr);
126 
127  void ensurePoint(InteractionTerm &term);
128 };
129 
130 inline
131 size_t Lagrangian::size() const
132 {
133  return interaction.size();
134 }
135 
136 inline
137 size_t Lagrangian::fullSize() const
138 {
139  return kinetic.size()
140  + mass.size()
141  + interaction.size();
142 }
143 
144 inline
145 bool Lagrangian::empty() const
146 {
147  return begin() == end();
148 }
149 
150 inline
151 bool Lagrangian::totalEmpty() const
152 {
153  return kinetic.empty() and mass.empty() and interaction.empty();
154 }
155 
156 inline
157 Lagrangian::TermType Lagrangian::operator[](size_t pos) const
158 {
159  return interaction[pos];
160 }
161 
162 inline
163 Lagrangian::TermType& Lagrangian::operator[](size_t pos)
164 {
165  return interaction[pos];
166 }
167 
168 inline
169 std::vector<Lagrangian::TermType>::iterator Lagrangian::begin()
170 {
171  return interaction.begin();
172 }
173 
174 inline
175 std::vector<Lagrangian::TermType>::iterator Lagrangian::end()
176 {
177  return interaction.end();
178 }
179 
180 inline
181 std::vector<Lagrangian::TermType>::const_iterator Lagrangian::begin() const
182 {
183  return interaction.begin();
184 }
185 
186 inline
187 std::vector<Lagrangian::TermType>::const_iterator Lagrangian::end() const
188 {
189  return interaction.end();
190 }
191 
192 } // End of namespace mty
193 
194 #endif /* LAGRANGIAN_H */
Interaction lagrangian of a model, allows to get all diagrams for a particular process by expanding i...
Definition: lagrangian.h:50
Type
std::ostream & operator<<(std::ostream &fout, csl::Type type)
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
Definition: lagrangian.h:30
Interaction term (in the Lagrangian) in MARTY.
Definition: interactionTerm.h:50
Contains QuantumField and QuantumFieldParent, basic objects handling quantum fields as csl expression...
Class mty::InteractionTerm, general purpose container for Lagrangian terms in MARTY.