Grid 0.7.0
TwoFlavour.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/action/pseudofermion/TwoFlavour.h
6
7Copyright (C) 2015
8
9Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11
12This program is free software; you can redistribute it and/or modify
13it under the terms of the GNU General Public License as published by
14the Free Software Foundation; either version 2 of the License, or
15(at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along
23with this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26See the full license in the file "LICENSE" in the top level distribution
27directory
28*************************************************************************************/
29 /* END LEGAL */
30#ifndef QCD_PSEUDOFERMION_TWO_FLAVOUR_H
31#define QCD_PSEUDOFERMION_TWO_FLAVOUR_H
32
34
36// Two flavour pseudofermion action for any dop
38template <class Impl>
39class TwoFlavourPseudoFermionAction : public Action<typename Impl::GaugeField> {
40public:
42
43private:
44 FermionOperator<Impl> &FermOp; // the basic operator
45
47
49
50 FermionField Phi; // the pseudo fermion field for this trajectory
51
52public:
54 // Pass in required objects.
63
64
65 virtual std::string action_name(){return "TwoFlavourPseudoFermionAction";}
66
67 virtual std::string LogParameters(){
68 std::stringstream sstream;
69 sstream << GridLogMessage << "["<<action_name()<<"] has no parameters" << std::endl;
70 return sstream.str();
71 }
72
74 // Push the gauge field in to the dops. Assume any BC's and smearing already applied
76 virtual void refresh(const GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG) {
77 // P(phi) = e^{- phi^dag (MdagM)^-1 phi}
78 // Phi = Mdag eta
79 // P(eta) = e^{- eta^dag eta}
80 //
81 // e^{x^2/2 sig^2} => sig^2 = 0.5.
82 //
83 // So eta should be of width sig = 1/sqrt(2).
84 // and must multiply by 0.707....
85 //
86 // Chroma has this scale factor: two_flavor_monomial_w.h
87 // CPS uses this factor
88 // IroIro: does not use this scale. It is absorbed by a change of vars
89 // in the Phi integral, and thus is only an irrelevant prefactor for
90 // the partition function.
91 //
92
93 const RealD scale = std::sqrt(0.5);
94
95 FermionField eta(FermOp.FermionGrid());
96
97 gaussian(pRNG, eta); eta = scale *eta;
98
99 FermOp.ImportGauge(U);
100 FermOp.Mdag(eta, Phi);
101 };
102
104 // S = phi^dag (Mdag M)^-1 phi
106 virtual RealD S(const GaugeField &U) {
107 FermOp.ImportGauge(U);
108
109 FermionField X(FermOp.FermionGrid());
110 FermionField Y(FermOp.FermionGrid());
111
113 X = Zero();
114 ActionSolver(MdagMOp, Phi, X);
115 MdagMOp.Op(X, Y);
116
117 RealD action = norm2(Y);
118 std::cout << GridLogMessage << "Pseudofermion action " << action << std::endl;
119 return action;
120 };
121
123 // dS/du = - phi^dag (Mdag M)^-1 [ Mdag dM + dMdag M ] (Mdag M)^-1 phi
124 // = - phi^dag M^-1 dM (MdagM)^-1 phi - phi^dag (MdagM)^-1 dMdag dM
125 // (Mdag)^-1 phi
126 //
127 // = - Ydag dM X - Xdag dMdag Y
128 //
129 //
131 virtual void deriv(const GaugeField &U, GaugeField &dSdU) {
132 FermOp.ImportGauge(U);
133
134 FermionField X(FermOp.FermionGrid());
135 FermionField Y(FermOp.FermionGrid());
136 GaugeField tmp(FermOp.GaugeGrid());
137
139
140 X = Zero();
141 DerivativeSolver(MdagMOp, Phi, X); // X = (MdagM)^-1 phi
142 MdagMOp.Op(X, Y); // Y = M X = (Mdag)^-1 phi
143
144 // Our conventions really make this UdSdU; We do not differentiate wrt Udag here.
145 // So must take dSdU - adj(dSdU) and left multiply by mom to get dS/dt.
146
147 FermOp.MDeriv(tmp, Y, X, DaggerNo);
148 dSdU = tmp;
149 FermOp.MDeriv(tmp, X, Y, DaggerYes);
150 dSdU = dSdU + tmp;
151
152 // not taking here the traceless antihermitian component
153 };
154};
155
157
158#endif
RealD norm2(const Lattice< vobj > &arg)
void gaussian(GridParallelRNG &rng, Lattice< vobj > &l)
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 DaggerYes
Definition QCD.h:70
static constexpr int DaggerNo
Definition QCD.h:69
double RealD
Definition Simd.h:61
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
Base class for all actions.
Definition ActionBase.h:64
void Op(const Field &in, Field &out)
virtual RealD S(const GaugeField &U)
Evaluate this action with the given gauge field.
Definition TwoFlavour.h:106
virtual void refresh(const GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
Refresh pseudofermion fields.
Definition TwoFlavour.h:76
virtual void deriv(const GaugeField &U, GaugeField &dSdU)
Definition TwoFlavour.h:131
virtual std::string action_name()
Report the name of the action.
Definition TwoFlavour.h:65
OperatorFunction< FermionField > & DerivativeSolver
Definition TwoFlavour.h:46
OperatorFunction< FermionField > & ActionSolver
Definition TwoFlavour.h:48
TwoFlavourPseudoFermionAction(FermionOperator< Impl > &Op, OperatorFunction< FermionField > &DS, OperatorFunction< FermionField > &AS)
Definition TwoFlavour.h:56
FermionOperator< Impl > & FermOp
Definition TwoFlavour.h:44
virtual std::string LogParameters()
Print the parameters of the action.
Definition TwoFlavour.h:67
Definition Simd.h:194