flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
lattice_model.hpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#ifndef LATTICE_MODEL_H
20#define LATTICE_MODEL_H
21
22#include <string>
23#include <ostream>
24#include <functional>
25#include "mathdefs.hpp"
26
27namespace flexiblesusy {
28
29class Lattice;
30template<class Method> class RGFlow;
31
32struct Wilson {
33 Wilson(size_t nvars) : width(nvars) {}
34 virtual ~Wilson() = default;
35 size_t width; // 1 + number of Wilson coefficients
36 // derivative wrt t == x[0]
37 virtual Real dx(const Real *x, size_t i) const = 0;
38 // d dx[i] / d x[j] == d dx[i] / d y[j] / unit[j]
39 virtual void ddx(const Real *x, size_t i, Real *ddx) const = 0;
40};
41
42struct ParWilson {
43 ParWilson(size_t width_) : width(width_) {}
44 virtual ~ParWilson() = default;
45 size_t width; // 1 + number of Wilson coefficients
46 // derivative wrt t == x[0]
47 virtual Real dx(const Real a, const Real *x, size_t i) const = 0;
48 // d dx[i] / d x[j] == d dx[i] / d y[j] / unit[j]
49 virtual void ddx(const Real a, const Real *x, size_t i, Real *ddx) const=0;
50};
51
52class Lattice_model: public ParWilson {
53public:
55 virtual ~Lattice_model() = default;
56 virtual void init(RGFlow<Lattice> *flow, size_t theory)
57 { f = flow; T = theory; }
58 virtual void calculate_spectrum() = 0;
59 virtual std::string name() const { return "unnamed"; }
60 virtual int run_to(double, double eps = -1.0);
61 virtual void print(std::ostream& out) const { out << "Model: " << name(); }
62 friend std::ostream& operator<<
63 (std::ostream& out, const Lattice_model& model) {
64 model.print(out);
65 return out;
66 }
67
68protected:
70 size_t T;
71};
72
74public:
75 template<class T>
76 struct Var {
77 Var(std::function<T()> get, std::function<void(T)> set) :
78 get_(get), set_(set) {}
79 operator T() { return get_(); }
80 T operator=(T value) { set_(value); return get_(); }
81 T operator=(Var<T>& var) { return operator=(T(var)); }
82 std::function<T()> get_;
83 std::function<void(T)> set_;
84 };
85
86 Lattice_translator(RGFlow<Lattice> *flow, size_t theory, size_t site) :
87 f(flow), T(theory), m(site)
88 {}
89 Real u(size_t i);
90 Real& y(size_t i);
91
92private:
94 size_t T;
95 size_t m;
96};
97
98} // namespace flexiblesusy
99
100#endif
virtual void print(std::ostream &out) const
virtual std::string name() const
virtual ~Lattice_model()=default
virtual void calculate_spectrum()=0
virtual void init(RGFlow< Lattice > *flow, size_t theory)
virtual int run_to(double, double eps=-1.0)
Lattice_translator(RGFlow< Lattice > *flow, size_t theory, size_t site)
double Real
Definition: mathdefs.hpp:12
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:5342
Var(std::function< T()> get, std::function< void(T)> set)
virtual ~ParWilson()=default
ParWilson(size_t width_)
virtual Real dx(const Real a, const Real *x, size_t i) const =0
virtual void ddx(const Real a, const Real *x, size_t i, Real *ddx) const =0
virtual void ddx(const Real *x, size_t i, Real *ddx) const =0
virtual Real dx(const Real *x, size_t i) const =0
virtual ~Wilson()=default
Wilson(size_t nvars)