Grid 0.7.0
ScalarAction.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/qcd/action/gauge/WilsonGaugeAction.h
6
7 Copyright (C) 2015
8
9 Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
10 Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11 Author: neo <cossu@post.kek.jp>
12 Author: paboyle <paboyle@ph.ed.ac.uk>
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License along
25 with this program; if not, write to the Free Software Foundation, Inc.,
26 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
28 See the full license in the file "LICENSE" in the top level distribution
29directory
30*************************************************************************************/
31/* END LEGAL */
32
33#ifndef SCALAR_ACTION_H
34#define SCALAR_ACTION_H
35
37
38template <class Impl>
39class ScalarAction : public Action<typename Impl::Field> {
40public:
42
43private:
46
47public:
49
50 virtual std::string LogParameters() {
51 std::stringstream sstream;
52 sstream << GridLogMessage << "[ScalarAction] lambda : " << lambda << std::endl;
53 sstream << GridLogMessage << "[ScalarAction] mass_square : " << mass_square << std::endl;
54 return sstream.str();
55 }
56 virtual std::string action_name() {return "ScalarAction";}
57
58 virtual void refresh(const Field &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG) {} // noop as no pseudoferms
59
60 virtual RealD S(const Field &p) {
61 return (mass_square * 0.5 + Nd) * ScalarObs<Impl>::sumphisquared(p) +
64 };
65
66 virtual void deriv(const Field &p,
67 Field &force) {
68 Field tmp(p.Grid());
69 Field p2(p.Grid());
71 tmp = -(Cshift(p, 0, -1) + Cshift(p, 0, 1));
72 for (int mu = 1; mu < Nd; mu++) tmp -= Cshift(p, mu, -1) + Cshift(p, mu, 1);
73
74 force =+(mass_square + 2. * Nd) * p + (lambda / 6.) * p2 * p + tmp;
75 }
76};
77
79
80#endif // SCALAR_ACTION_H
auto Cshift(const Expression &expr, int dim, int shift) -> decltype(closure(expr))
Definition Cshift.h:55
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nd
Definition QCD.h:52
double RealD
Definition Simd.h:61
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
Base class for all actions.
Definition ActionBase.h:64
INHERIT_FIELD_TYPES(Impl)
virtual std::string action_name()
Report the name of the action.
virtual void deriv(const Field &p, Field &force)
virtual RealD S(const Field &p)
virtual std::string LogParameters()
Print the parameters of the action.
virtual void refresh(const Field &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
ScalarAction(RealD ms, RealD l)
static void phisquared(typename Impl::Field &fsq, const typename Impl::Field &f)
Definition ScalarObjs.h:42
static RealD sumphisquared(const typename Impl::Field &f)
Definition ScalarObjs.h:78
static RealD sumphider(const typename Impl::Field &f)
Definition ScalarObjs.h:69
static RealD sumphifourth(const typename Impl::Field &f)
Definition ScalarObjs.h:84