1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 15:55:37 +00:00
Grid/lib/qcd/action/fermion/WilsonCloverFermion.h

327 lines
11 KiB
C
Raw Normal View History

2017-03-27 02:54:16 +01:00
/*************************************************************************************
2017-03-24 03:43:28 +00:00
2017-03-27 02:54:16 +01:00
Grid physics library, www.github.com/paboyle/Grid
2017-03-24 03:43:28 +00:00
2017-03-27 07:12:57 +01:00
Source file: ./lib/qcd/action/fermion/WilsonCloverFermion.h
2017-03-24 03:43:28 +00:00
2017-03-27 02:54:16 +01:00
Copyright (C) 2017
2017-03-24 03:43:28 +00:00
2017-03-27 07:12:57 +01:00
Author: paboyle <paboyle@ph.ed.ac.uk>
Author: Guido Cossu <guido.cossu@ed.ac.uk>
2017-03-24 03:43:28 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/
2017-03-27 02:54:16 +01:00
/* END LEGAL */
2017-10-24 13:21:17 +01:00
2017-03-27 02:54:16 +01:00
#ifndef GRID_QCD_WILSON_CLOVER_FERMION_H
#define GRID_QCD_WILSON_CLOVER_FERMION_H
2017-03-24 03:43:28 +00:00
#include <Grid/Grid.h>
2017-04-28 15:23:34 +01:00
namespace Grid
{
namespace QCD
{
2017-03-27 02:54:16 +01:00
template <class Impl>
2017-04-28 15:23:34 +01:00
class WilsonCloverFermion : public WilsonFermion<Impl>
{
2017-03-27 02:54:16 +01:00
public:
2017-04-28 15:23:34 +01:00
// Types definitions
2017-03-27 02:54:16 +01:00
INHERIT_IMPL_TYPES(Impl);
2017-10-24 13:21:17 +01:00
template <typename vtype>
using iImplClover = iScalar<iMatrix<iMatrix<vtype, Impl::Dimension>, Ns>>;
typedef iImplClover<Simd> SiteCloverType;
typedef Lattice<SiteCloverType> CloverFieldType;
2017-03-27 02:54:16 +01:00
public:
2017-03-27 07:12:57 +01:00
typedef WilsonFermion<Impl> WilsonBase;
2017-03-27 02:54:16 +01:00
virtual void Instantiatable(void){};
// Constructors
WilsonCloverFermion(GaugeField &_Umu, GridCartesian &Fgrid,
GridRedBlackCartesian &Hgrid,
RealD _mass,
RealD _csw,
const ImplParams &p = ImplParams()) : WilsonFermion<Impl>(_Umu,
Fgrid,
Hgrid,
2017-04-28 15:23:34 +01:00
_mass, p),
2017-10-24 13:21:17 +01:00
CloverTerm(&Fgrid),
CloverTermInv(&Fgrid),
CloverTermEven(&Hgrid),
CloverTermOdd(&Hgrid),
CloverTermInvEven(&Hgrid),
CloverTermInvOdd(&Hgrid),
2017-10-26 18:23:55 +01:00
CloverTermDagEven(&Hgrid),
CloverTermDagOdd(&Hgrid),
CloverTermInvDagEven(&Hgrid),
CloverTermInvDagOdd(&Hgrid)
2017-03-27 02:54:16 +01:00
{
csw = _csw;
2017-03-27 07:12:57 +01:00
assert(Nd == 4); // require 4 dimensions
2017-10-24 13:21:17 +01:00
2017-10-26 18:23:55 +01:00
if (csw == 0)
std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw = 0" << std::endl;
ImportGauge(_Umu);
2017-03-27 02:54:16 +01:00
}
2017-04-28 15:23:34 +01:00
virtual RealD M(const FermionField &in, FermionField &out);
virtual RealD Mdag(const FermionField &in, FermionField &out);
2017-03-27 02:54:16 +01:00
virtual void Mooee(const FermionField &in, FermionField &out);
virtual void MooeeDag(const FermionField &in, FermionField &out);
virtual void MooeeInv(const FermionField &in, FermionField &out);
virtual void MooeeInvDag(const FermionField &in, FermionField &out);
2017-04-28 15:23:34 +01:00
virtual void MooeeInternal(const FermionField &in, FermionField &out, int dag, int inv);
2017-03-27 02:54:16 +01:00
2017-10-26 18:23:55 +01:00
//virtual void MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag);
2017-04-28 15:23:34 +01:00
virtual void MooDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag);
virtual void MeeDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag);
2017-03-27 08:43:15 +01:00
2017-03-27 07:12:57 +01:00
void ImportGauge(const GaugeField &_Umu);
2017-04-28 15:23:34 +01:00
2017-10-26 18:23:55 +01:00
// Derivative parts unpreconditioned pseudofermions
void MDeriv(GaugeField &force, const FermionField &X, const FermionField &Y, int dag)
{
conformable(X._grid, Y._grid);
conformable(X._grid, force._grid);
GaugeLinkField force_mu(force._grid), lambda(force._grid);
GaugeField clover_force(force._grid);
PropagatorField Lambda(force._grid);
// Here we are hitting some performance issues:
// need to extract the components of the DoubledGaugeField
// for each call
// Possible solution
// Create a vector object to store them? (cons: wasting space)
std::vector<GaugeLinkField> U(Nd, this->Umu._grid);
Impl::extractLinkField(U, this->Umu);
force = zero;
// Derivative of the Wilson hopping term
2017-10-29 12:03:08 +00:00
this->DhopDeriv(force, X, Y, dag);
2017-10-26 18:23:55 +01:00
///////////////////////////////////////////////////////////
// Clover term derivative
///////////////////////////////////////////////////////////
Impl::outerProductImpl(Lambda, X, Y);
2017-10-29 11:43:33 +00:00
//std::cout << "Lambda:" << Lambda << std::endl;
2017-10-26 18:23:55 +01:00
Gamma::Algebra sigma[] = {
Gamma::Algebra::SigmaXY,
Gamma::Algebra::SigmaXZ,
Gamma::Algebra::SigmaXT,
Gamma::Algebra::MinusSigmaXY,
Gamma::Algebra::SigmaYZ,
Gamma::Algebra::SigmaYT,
Gamma::Algebra::MinusSigmaXZ,
Gamma::Algebra::MinusSigmaYZ,
Gamma::Algebra::SigmaZT,
Gamma::Algebra::MinusSigmaXT,
Gamma::Algebra::MinusSigmaYT,
Gamma::Algebra::MinusSigmaZT};
/*
sigma_{\mu \nu}=
| 0 sigma[0] sigma[1] sigma[2] |
| sigma[3] 0 sigma[4] sigma[5] |
| sigma[6] sigma[7] 0 sigma[8] |
| sigma[9] sigma[10] sigma[11] 0 |
*/
int count = 0;
clover_force = zero;
for (int mu = 0; mu < 4; mu++)
{
force_mu = zero;
for (int nu = 0; nu < 4; nu++)
{
if (mu == nu) continue;
2017-10-29 11:43:33 +00:00
PropagatorField Slambda = Gamma(sigma[count]) * Lambda; // sigma checked
Impl::TraceSpinImpl(lambda, Slambda); // traceSpin ok
force_mu -= Cmunu(U, lambda, mu, nu); // checked
2017-10-26 18:23:55 +01:00
count++;
}
pokeLorentz(clover_force, U[mu] * force_mu, mu);
}
2017-10-29 11:43:33 +00:00
clover_force *= csw;
2017-10-26 18:23:55 +01:00
force += clover_force;
2017-10-29 11:43:33 +00:00
2017-10-26 18:23:55 +01:00
}
// Computing C_{\mu \nu}(x) as in Eq.(B.39) in Zbigniew Sroczynski's PhD thesis
GaugeLinkField Cmunu(std::vector<GaugeLinkField> &U, GaugeLinkField &lambda, int mu, int nu)
{
conformable(lambda._grid, U[0]._grid);
GaugeLinkField out(lambda._grid), tmp(lambda._grid);
// insertion in upper staple
// please check redundancy of shift operations
2017-10-29 11:43:33 +00:00
2017-10-26 18:23:55 +01:00
// C1+
tmp = lambda * U[nu];
out = Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu);
2017-10-29 11:43:33 +00:00
2017-10-26 18:23:55 +01:00
// C2+
2017-10-29 11:43:33 +00:00
tmp = U[mu] * Impl::ShiftStaple(adj(lambda), mu);
2017-10-26 18:23:55 +01:00
out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu);
2017-10-29 11:43:33 +00:00
2017-10-26 18:23:55 +01:00
// C3+
2017-10-29 11:43:33 +00:00
tmp = U[nu] * Impl::ShiftStaple(adj(lambda), nu);
2017-10-26 18:23:55 +01:00
out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu);
// C4+
out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu) * lambda;
// insertion in lower staple
// C1-
out -= Impl::ShiftStaple(lambda, mu) * Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu);
// C2-
tmp = adj(lambda) * U[nu];
out -= Impl::ShiftStaple(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu);
// C3-
tmp = lambda * U[nu];
out -= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu);
// C4-
out -= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu) * lambda;
return out;
}
2017-03-27 02:54:16 +01:00
private:
2017-03-27 07:12:57 +01:00
// here fixing the 4 dimensions, make it more general?
2017-10-26 18:23:55 +01:00
RealD csw; // Clover coefficient
2017-10-24 13:21:17 +01:00
CloverFieldType CloverTerm, CloverTermInv; // Clover term
CloverFieldType CloverTermEven, CloverTermOdd; // Clover term EO
CloverFieldType CloverTermInvEven, CloverTermInvOdd; // Clover term Inv EO
CloverFieldType CloverTermDagEven, CloverTermDagOdd; // Clover term Dag EO
CloverFieldType CloverTermInvDagEven, CloverTermInvDagOdd; // Clover term Inv Dag EO
2017-09-24 18:32:15 +01:00
2017-04-28 15:23:34 +01:00
// eventually these two can be compressed into 6x6 blocks instead of the 12x12
// using the DeGrand-Rossi basis for the gamma matrices
2017-08-04 16:08:07 +01:00
CloverFieldType fillCloverYZ(const GaugeLinkField &F)
{
2017-04-28 15:23:34 +01:00
CloverFieldType T(F._grid);
2017-08-04 16:08:07 +01:00
T = zero;
2017-04-28 15:23:34 +01:00
PARALLEL_FOR_LOOP
2017-08-04 16:08:07 +01:00
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
T._odata[i]()(0, 1) = timesMinusI(F._odata[i]()());
T._odata[i]()(1, 0) = timesMinusI(F._odata[i]()());
T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()());
2017-04-28 15:23:34 +01:00
}
2017-10-24 13:21:17 +01:00
return T;
}
2017-08-04 16:08:07 +01:00
CloverFieldType fillCloverXZ(const GaugeLinkField &F)
{
CloverFieldType T(F._grid);
T = zero;
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
T._odata[i]()(0, 1) = -F._odata[i]()();
T._odata[i]()(1, 0) = F._odata[i]()();
T._odata[i]()(2, 3) = -F._odata[i]()();
T._odata[i]()(3, 2) = F._odata[i]()();
}
2017-10-24 13:21:17 +01:00
return T;
}
2017-08-04 16:08:07 +01:00
CloverFieldType fillCloverXY(const GaugeLinkField &F)
{
CloverFieldType T(F._grid);
T = zero;
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
2017-10-29 11:43:33 +00:00
2017-08-04 16:08:07 +01:00
T._odata[i]()(0, 0) = timesMinusI(F._odata[i]()());
T._odata[i]()(1, 1) = timesI(F._odata[i]()());
T._odata[i]()(2, 2) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 3) = timesI(F._odata[i]()());
}
2017-10-24 13:21:17 +01:00
return T;
}
2017-08-04 16:08:07 +01:00
CloverFieldType fillCloverXT(const GaugeLinkField &F)
{
CloverFieldType T(F._grid);
T = zero;
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
2017-10-24 13:21:17 +01:00
T._odata[i]()(0, 1) = timesI(F._odata[i]()());
T._odata[i]()(1, 0) = timesI(F._odata[i]()());
T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()());
2017-08-04 16:08:07 +01:00
}
2017-10-24 13:21:17 +01:00
return T;
}
2017-08-04 16:08:07 +01:00
CloverFieldType fillCloverYT(const GaugeLinkField &F)
{
CloverFieldType T(F._grid);
T = zero;
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
2017-10-24 13:21:17 +01:00
T._odata[i]()(0, 1) = -(F._odata[i]()());
T._odata[i]()(1, 0) = (F._odata[i]()());
T._odata[i]()(2, 3) = (F._odata[i]()());
T._odata[i]()(3, 2) = -(F._odata[i]()());
2017-08-04 16:08:07 +01:00
}
2017-10-24 13:21:17 +01:00
return T;
}
2017-08-04 16:08:07 +01:00
CloverFieldType fillCloverZT(const GaugeLinkField &F)
{
CloverFieldType T(F._grid);
T = zero;
PARALLEL_FOR_LOOP
for (int i = 0; i < CloverTerm._grid->oSites(); i++)
{
2017-10-24 13:21:17 +01:00
T._odata[i]()(0, 0) = timesI(F._odata[i]()());
T._odata[i]()(1, 1) = timesMinusI(F._odata[i]()());
T._odata[i]()(2, 2) = timesMinusI(F._odata[i]()());
T._odata[i]()(3, 3) = timesI(F._odata[i]()());
2017-08-04 16:08:07 +01:00
}
2017-10-24 13:21:17 +01:00
return T;
}
2017-03-27 02:54:16 +01:00
};
}
}
2017-10-24 13:21:17 +01:00
#endif // GRID_QCD_WILSON_CLOVER_FERMION_H