Grid 0.7.0
TwoFlavourEvenOdd.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/TwoFlavourEvenOdd.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_EVEN_ODD_H
31#define QCD_PSEUDOFERMION_TWO_FLAVOUR_EVEN_ODD_H
32
34
35
37// Two flavour pseudofermion action for any EO prec dop
39template <class Impl>
41 : public Action<typename Impl::GaugeField> {
42public:
44
45private:
46 FermionOperator<Impl> &FermOp; // the basic operator
47
50
51 FermionField PhiOdd; // the pseudo fermion field for this trajectory
52 FermionField PhiEven; // the pseudo fermion field for this trajectory
53
54public:
56 // Pass in required objects.
61 : FermOp(Op),
63 ActionSolver(AS),
64 PhiEven(Op.FermionRedBlackGrid()),
65 PhiOdd(Op.FermionRedBlackGrid())
66 {};
67
68 virtual std::string action_name(){return "TwoFlavourEvenOddPseudoFermionAction";}
69
70 virtual std::string LogParameters(){
71 std::stringstream sstream;
72 sstream << GridLogMessage << "["<<action_name()<<"] has no parameters" << std::endl;
73 return sstream.str();
74 }
75
76
78 // Push the gauge field in to the dops. Assume any BC's and smearing already applied
80 virtual void refresh(const GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG& pRNG) {
81
82 // P(phi) = e^{- phi^dag (MpcdagMpc)^-1 phi}
83 // Phi = McpDag eta
84 // P(eta) = e^{- eta^dag eta}
85 //
86 // e^{x^2/2 sig^2} => sig^2 = 0.5.
87
88 RealD scale = std::sqrt(0.5);
89
90 FermionField eta (FermOp.FermionGrid());
91 FermionField etaOdd (FermOp.FermionRedBlackGrid());
92 FermionField etaEven(FermOp.FermionRedBlackGrid());
93
94 gaussian(pRNG,eta);
95 pickCheckerboard(Even,etaEven,eta);
96 pickCheckerboard(Odd,etaOdd,eta);
97
98 FermOp.ImportGauge(U);
100
101
102 PCop.MpcDag(etaOdd,PhiOdd);
103
104 FermOp.MooeeDag(etaEven,PhiEven);
105
106 PhiOdd =PhiOdd*scale;
107 PhiEven=PhiEven*scale;
108
109 };
110
112 // S = phi^dag (Mdag M)^-1 phi (odd)
113 // + phi^dag (Mdag M)^-1 phi (even)
115 virtual RealD S(const GaugeField &U) {
116
117 FermOp.ImportGauge(U);
118
119 FermionField X(FermOp.FermionRedBlackGrid());
120 FermionField Y(FermOp.FermionRedBlackGrid());
121
123
124 X=Zero();
125 ActionSolver(PCop,PhiOdd,X);
126 PCop.Op(X,Y);
127 RealD action = norm2(Y);
128
129 // The EE factorised block; normally can replace with zero if det is constant (gauge field indept)
130 // Only really clover term that creates this.
131 FermOp.MooeeInvDag(PhiEven,Y);
132 action = action + norm2(Y);
133
134 std::cout << GridLogMessage << "Pseudofermion EO action "<<action<<std::endl;
135 return action;
136 };
137
139 //
140 // dS/du = - phi^dag (Mdag M)^-1 [ Mdag dM + dMdag M ] (Mdag M)^-1 phi
141 // = - phi^dag M^-1 dM (MdagM)^-1 phi - phi^dag (MdagM)^-1 dMdag dM (Mdag)^-1 phi
142 //
143 // = - Ydag dM X - Xdag dMdag Y
144 //
146 virtual void deriv(const GaugeField &U,GaugeField & dSdU) {
147 FermOp.ImportGauge(U);
148
149 FermionField X(FermOp.FermionRedBlackGrid());
150 FermionField Y(FermOp.FermionRedBlackGrid());
151 GaugeField tmp(FermOp.GaugeGrid());
152
154
155 // Our conventions really make this UdSdU; We do not differentiate wrt Udag here.
156 // So must take dSdU - adj(dSdU) and left multiply by mom to get dS/dt.
157
158 X=Zero();
160 Mpc.Mpc(X,Y);
161 Mpc.MpcDeriv(tmp , Y, X ); dSdU=tmp;
162 Mpc.MpcDagDeriv(tmp , X, Y); dSdU=dSdU+tmp;
163
164 // Treat the EE case. (MdagM)^-1 = Minv Minvdag
165 // Deriv defaults to zero.
166 // FermOp.MooeeInvDag(PhiOdd,Y);
167 // FermOp.MooeeInv(Y,X);
168 // FermOp.MeeDeriv(tmp , Y, X,DaggerNo ); dSdU=tmp;
169 // FermOp.MeeDeriv(tmp , X, Y,DaggerYes); dSdU=dSdU+tmp;
170
171 assert(FermOp.ConstEE() == 1);
172
173 /*
174 FermOp.MooeeInvDag(PhiOdd,Y);
175 FermOp.MooeeInv(Y,X);
176 FermOp.MeeDeriv(tmp , Y, X,DaggerNo ); dSdU=tmp;
177 FermOp.MeeDeriv(tmp , X, Y,DaggerYes); dSdU=dSdU+tmp;
178 */
179
180 //dSdU = Ta(dSdU);
181
182 };
183
184};
185
187
188#endif
static const int Even
static const int Odd
RealD norm2(const Lattice< vobj > &arg)
void gaussian(GridParallelRNG &rng, Lattice< vobj > &l)
void pickCheckerboard(int cb, Lattice< vobj > &half, const Lattice< vobj > &full)
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
double RealD
Definition Simd.h:61
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
Base class for all actions.
Definition ActionBase.h:64
virtual void MpcDag(const Field &in, Field &out)
virtual void Mpc(const Field &in, Field &out)
void MpcDagDeriv(GaugeField &Force, const FermionField &U, const FermionField &V)
void MpcDeriv(GaugeField &Force, const FermionField &U, const FermionField &V)
void Op(const Field &in, Field &out)
virtual RealD S(const GaugeField &U)
Evaluate this action with the given gauge field.
virtual void refresh(const GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
Refresh pseudofermion fields.
TwoFlavourEvenOddPseudoFermionAction(FermionOperator< Impl > &Op, OperatorFunction< FermionField > &DS, OperatorFunction< FermionField > &AS)
virtual void deriv(const GaugeField &U, GaugeField &dSdU)
virtual std::string LogParameters()
Print the parameters of the action.
OperatorFunction< FermionField > & DerivativeSolver
OperatorFunction< FermionField > & ActionSolver
virtual std::string action_name()
Report the name of the action.
Definition Simd.h:194