Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
mtylibrary.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 
23 #pragma once
24 
25 #include <csl.h>
26 #include "model.h"
27 
28 namespace mty {
29 
31  public:
32  template<class ...Args>
33  Library(Args &&...args)
34  :csl::LibraryGenerator(std::forward<Args>(args)...)
35  {
36  addInclude("clooptools.h");
37  addInclude("marty/looptools_init.h");
38 #if !(defined __APPLE__ || defined __MACH__)
39  // If we are not on MacOS, add -lgfortran
40  addLibrary("-lgfortran");
41  setGccCompiler();
42 #else
43  setClangCompiler();
44 #endif
45  if (csl::LibraryGenerator::isQuadruplePrecision()) {
46  addLibrary("-looptools-quad");
47  addInclude("marty/looptools_quad_extension.h");
48  addLibrary("-lquadmath");
49  }
50  else {
51  addLibrary("-looptools");
52  }
53  }
54 
55  void applyDiagonalizationData(Model &model) {
56  model.applyDiagonalizationData(*this);
57  }
58 
59  void generateSpectrum(Model &model) {
60  model.applyDiagonalizationData(*this);
61  for (const auto &m : model.getAbbreviatedMassExpressions()) {
62  if (csl::Abbrev::find_opt(m)) {
63  addMassExpression(m->getName());
64  addFunction(m->getName(), m, "G");
65  }
66  }
67  }
68 
69  void importLHAModule(
70  std::string const &t_pathToMarty
71  )
72  {
73  lhaEnabled = true;
74  pathToMarty = t_pathToMarty;
75  }
76 
77  void addFunction(
78  std::string const &name,
79  csl::Expr expr,
80  std::string const &groupName = "G"
81  )
82  {
83  csl::ScopedProperty p(&csl::option::checkCommutations, false);
84  auto &f = csl::LibraryGenerator::addFunction(name, expr, groupName);
85  f.addInitInstruction("clearcache();");
86  }
87 
88  void print()
89  {
90  if (lhaEnabled) doImportLHAModule();
91  csl::LibraryGenerator::print();
92  }
93 
94  void build(unsigned int nJobs = 1)
95  {
96  if (lhaEnabled) doImportLHAModule();
97  csl::LibraryGenerator::build(nJobs);
98  }
99 
100  private:
101 
102  void doImportLHAModule()
103  {
104  csl::LibraryGenerator::setupDirectory();
105  const auto martySrc = pathToMarty + "/src";
106  const auto martyInc = pathToMarty + "/include";
107  const auto targetSrc = path + "/src";
108  const auto targetInc = path + "/include";
109  [[maybe_unused]] int sysres
110  = system(("mkdir -p " + martySrc + " " + martyInc).c_str());
111  sysres = system(("cp " + martySrc + "/lha.cpp " + targetSrc).c_str());
112  sysres = system(("cp " + martySrc + "/lhaData.cpp " + targetSrc).c_str());
113  sysres = system(("cp " + martyInc + "/lha.h " + targetInc).c_str());
114  sysres = system(("cp " + martyInc + "/lhaData.h " + targetInc).c_str());
115  sysres = system(("cp " + martyInc + "/lhaBlocks.h " + targetInc).c_str());
116  sysres = system(("cp " + pathToMarty + "/../csl/include/std_vector*.h " + targetInc).c_str());
117  }
118 
119  bool lhaEnabled { false };
120  std::string pathToMarty;
121  };
122 }
Namespace of MARTY.
Definition: 2HDM.h:31
Contains the mty::Model class. It contains all objects in the theory. In particular QuantumField obje...
Definition: mtylibrary.h:30
std::vector< csl::Expr > const & getAbbreviatedMassExpressions() const
Definition: modelBuilder.h:120
Contains all objects in the theory. In particular QuantumField objects, Gauge, Flavor, Particle...
Definition: model.h:68