Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
sglfield.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 #pragma once
25 
26 #include "multifunction.h"
27 
28 namespace sgl {
29 
30  struct PartnerShip {
31  int self { -1 };
32  int other { -1 };
33  bool isLeft { false };
34  };
35 
36  class Field: public AbstractLiteral {
37 
38  public:
39 
40  enum Order {
41  None,
42  Left,
43  Right
44  };
45 
46  Field(
47  csl::Expr const &field,
48  bool particle,
49  bool incoming,
50  bool onShell,
51  PartnerShip const &partnerShip,
52  Order order = None
53  );
54 
55  bool contains(csl::Index const &) const override {
56  return false;
57  }
58  void replace(csl::Index const&, csl::Index const&) override {}
59 
60  csl::Index getIndex() const {
61  return index;
62  }
63 
64  bool isOnShell() const { return onshell; }
65  bool isIncomingParticle() const { return incoming && particle; }
66  bool isIncomingAntiParticle() const { return incoming && !particle; }
67  bool isOutgoingParticle() const { return !incoming && particle; }
68  bool isOutgoingAntiParticle() const { return !incoming && !particle; }
69 
70  bool isComplexConjugated() const {
71  return isIncomingAntiParticle() || isOutgoingParticle();
72  }
73 
74  bool isZero() const override { return false; }
75 
76  bool isHappyWith(Field const &other) const {
77  return partnerShip.self == -1
78  || other.partnerShip.self == partnerShip.other;
79  }
80 
81  bool isLeftField() const {
82  return partnerShip.isLeft;
83  }
84 
85  void conjugate();
86 
87  csl::Expr toCSL(TensorSet const &tensors) const override;
88 
89  csl::Expr toCSL(TensorSet const &tensors, csl::Index index) const;
90 
91  GExpr copy() const override;
92  GExpr refresh() const override;
93 
94  void print(std::ostream &out = std::cout) const override;
95 
96  bool isSame(Field const &other) const;
97 
98  public:
99 
100  csl::Expr initField;
101  csl::Index index;
102  csl::TensorField psi;
103  csl::Tensor p;
104  bool particle;
105  bool incoming;
106  bool onshell;
107  Order order;
108  PartnerShip partnerShip;
109  };
110 
111  template<class ...Args>
112  std::shared_ptr<Field> field_s(Args &&...args)
113  {
114  return std::make_shared<Field>(std::forward<Args>(args)...);
115  }
116 }
Definition: tensorset.h:30
Definition: abstractgammasym.h:87
Definition: sglfield.h:30
Definition: abstractgammasym.h:32
Base class for expressions with arguments in SGL.
Definition: multifunction.h:54
Definition: sglfield.h:36