Grid 0.7.0
DomainDecomposedBoundaryTwoFlavourPseudoFermion.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/pseudofermion/DomainDecomposedTwoFlavourBoundary.h
6
7 Copyright (C) 2021
8
9Author: Peter Boyle <paboyle@ph.ed.ac.uk>
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License along
22 with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25 See the full license in the file "LICENSE" in the top level distribution directory
26*************************************************************************************/
27/* END LEGAL */
28#pragma once
29
31
33// Two flavour ratio
35template<class ImplD,class ImplF>
36class DomainDecomposedBoundaryTwoFlavourPseudoFermion : public Action<typename ImplD::GaugeField> {
37public:
39
40private:
41 SchurFactoredFermionOperator<ImplD,ImplF> & DenOp;// the basic operator
45
46 FermionField Phi; // the pseudo fermion field for this trajectory
47
49public:
50 DomainDecomposedBoundaryTwoFlavourPseudoFermion(SchurFactoredFermionOperator<ImplD,ImplF> &_DenOp,RealD _DerivativeTol, RealD _ActionTol, RealD _InnerTol = 1.0e-6 )
51 : DenOp(_DenOp),
52 DerivativeStoppingCondition(_DerivativeTol),
53 ActionStoppingCondition(_ActionTol),
54 InnerStoppingCondition(_InnerTol),
55 Phi(_DenOp.FermionGrid()) {};
56
57 virtual std::string action_name(){return "DomainDecomposedBoundaryTwoFlavourPseudoFermion";}
58
59
60 virtual std::string LogParameters(){
61 std::stringstream sstream;
62 return sstream.str();
63 }
64
65 virtual void refresh(const GaugeField &U, GridSerialRNG& sRNG, GridParallelRNG& pRNG)
66 {
67 // P(phi) = e^{- phi^dag Rdag^-1 R^-1 phi}
68 //
69 // DenOp == R
70 //
71 // Take phi = R eta ; eta = R^-1 Phi
72 //
73 // P(eta) = e^{- eta^dag eta}
74 //
75 // e^{x^2/2 sig^2} => sig^2 = 0.5.
76 //
77 // So eta should be of width sig = 1/sqrt(2) and must multiply by 0.707....
78 //
79 RealD scale = std::sqrt(0.5);
80
83 DenOp.ImportGauge(U);
84
85 FermionField eta(DenOp.FermionGrid());
86
87 gaussian(pRNG,eta); eta=eta*scale;
88
89 DenOp.ProjectBoundaryBar(eta);
90 DenOp.R(eta,Phi);
91 //DumpSliceNorm("Phi",Phi);
92 refresh_action = norm2(eta);
93 };
94
96 // S = phi^dag Rdag^-1 R^-1 phi
98 virtual RealD S(const GaugeField &U) {
99
102 DenOp.ImportGauge(U);
103
104 FermionField X(DenOp.FermionGrid());
105
106 DenOp.RInv(Phi,X);
107
108 RealD action = norm2(X);
109
110 return action;
111 };
112
113 virtual void deriv(const GaugeField &U,GaugeField & dSdU)
114 {
117 DenOp.ImportGauge(U);
118
119 GridBase *fgrid = DenOp.FermionGrid();
120 GridBase *ugrid = DenOp.GaugeGrid();
121
122 FermionField X(fgrid);
123 FermionField Y(fgrid);
124 FermionField tmp(fgrid);
125
126 GaugeField force(ugrid);
127
128 FermionField DiDdb_Phi(fgrid); // Vector C in my notes
129 FermionField DidRinv_Phi(fgrid); // Vector D in my notes
130 FermionField Rinv_Phi(fgrid);
131
132// FermionField RinvDagRinv_Phi(fgrid);
133// FermionField DdbdDidRinv_Phi(fgrid);
134
135 // R^-1 term
136 DenOp.dBoundaryBar(Phi,tmp);
137 DenOp.Dinverse(tmp,DiDdb_Phi); // Vector C
138 Rinv_Phi = Phi - DiDdb_Phi;
139 DenOp.ProjectBoundaryBar(Rinv_Phi);
140
141 // R^-dagger R^-1 term
142 DenOp.DinverseDag(Rinv_Phi,DidRinv_Phi); // Vector D
143/*
144 DenOp.dBoundaryBarDag(DidRinv_Phi,DdbdDidRinv_Phi);
145 RinvDagRinv_Phi = Rinv_Phi - DdbdDidRinv_Phi;
146 DenOp.ProjectBoundaryBar(RinvDagRinv_Phi);
147*/
148 X = DiDdb_Phi;
149 Y = DidRinv_Phi;
150 DenOp.PeriodicFermOpD.MDeriv(force,Y,X,DaggerNo); dSdU=force;
151 DenOp.PeriodicFermOpD.MDeriv(force,X,Y,DaggerYes); dSdU=dSdU+force;
152 DumpSliceNorm("force",dSdU);
153 dSdU *= -1.0;
154 };
155};
156
158
void DumpSliceNorm(std::string s, const Lattice< vobj > &f, int mu=-1)
Definition Lattice_crc.h:32
RealD norm2(const Lattice< vobj > &arg)
void gaussian(GridParallelRNG &rng, Lattice< vobj > &l)
#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
virtual RealD S(const GaugeField &U)
Evaluate this action with the given gauge field.
DomainDecomposedBoundaryTwoFlavourPseudoFermion(SchurFactoredFermionOperator< ImplD, ImplF > &_DenOp, RealD _DerivativeTol, RealD _ActionTol, RealD _InnerTol=1.0e-6)
virtual std::string LogParameters()
Print the parameters of the action.
virtual void refresh(const GaugeField &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
Refresh pseudofermion fields.