1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 01:35:36 +00:00
Grid/lib/qcd/action/fermion/WilsonCloverFermion.cc

244 lines
7.3 KiB
C++
Raw Normal View History

2017-03-27 07:12:57 +01:00
/*************************************************************************************
2017-03-24 03:43:28 +00:00
2017-03-27 07:12:57 +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.cc
2017-03-24 03:43:28 +00:00
2017-03-27 07:12:57 +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 07:12:57 +01:00
/* END LEGAL */
2017-03-24 03:43:28 +00:00
#include <Grid/Grid.h>
2017-04-28 15:23:34 +01:00
#include <Grid/Eigen/Dense>
2017-03-27 07:12:57 +01:00
#include <Grid/qcd/spin/Dirac.h>
2017-03-24 03:43:28 +00:00
namespace Grid
{
namespace QCD
{
// *NOT* EO
template <class Impl>
RealD WilsonCloverFermion<Impl>::M(const FermionField &in, FermionField &out)
{
2017-10-24 13:21:17 +01:00
FermionField temp(out._grid);
// Wilson term
out.checkerboard = in.checkerboard;
2017-10-29 12:03:08 +00:00
this->Dhop(in, out, DaggerNo);
2017-10-24 13:21:17 +01:00
// Clover term
Mooee(in, temp);
2017-10-24 13:21:17 +01:00
out += temp;
2017-10-24 13:21:17 +01:00
return norm2(out);
}
2017-04-28 15:23:34 +01:00
template <class Impl>
RealD WilsonCloverFermion<Impl>::Mdag(const FermionField &in, FermionField &out)
{
2017-10-24 13:21:17 +01:00
FermionField temp(out._grid);
// Wilson term
out.checkerboard = in.checkerboard;
2017-10-29 12:03:08 +00:00
this->Dhop(in, out, DaggerYes);
2017-10-24 13:21:17 +01:00
// Clover term
MooeeDag(in, temp);
2017-10-24 13:21:17 +01:00
out += temp;
return norm2(out);
}
2017-03-27 07:12:57 +01:00
template <class Impl>
void WilsonCloverFermion<Impl>::ImportGauge(const GaugeField &_Umu)
{
2017-08-04 16:08:07 +01:00
WilsonFermion<Impl>::ImportGauge(_Umu);
GridBase *grid = _Umu._grid;
typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid);
2017-08-04 16:08:07 +01:00
2017-10-23 18:27:34 +01:00
// Compute the field strength terms mu>nu
WilsonLoops<Impl>::FieldStrength(Bx, _Umu, Zdir, Ydir);
WilsonLoops<Impl>::FieldStrength(By, _Umu, Zdir, Xdir);
2017-10-23 18:27:34 +01:00
WilsonLoops<Impl>::FieldStrength(Bz, _Umu, Ydir, Xdir);
WilsonLoops<Impl>::FieldStrength(Ex, _Umu, Tdir, Xdir);
WilsonLoops<Impl>::FieldStrength(Ey, _Umu, Tdir, Ydir);
WilsonLoops<Impl>::FieldStrength(Ez, _Umu, Tdir, Zdir);
// Compute the Clover Operator acting on Colour and Spin
// multiply here by the clover coefficients for the anisotropy
CloverTerm = fillCloverYZ(Bx) * csw_r;
CloverTerm += fillCloverXZ(By) * csw_r;
CloverTerm += fillCloverXY(Bz) * csw_r;
CloverTerm += fillCloverXT(Ex) * csw_t;
CloverTerm += fillCloverYT(Ey) * csw_t;
CloverTerm += fillCloverZT(Ez) * csw_t;
CloverTerm += diag_mass;
int lvol = _Umu._grid->lSites();
int DimRep = Impl::Dimension;
Eigen::MatrixXcd EigenCloverOp = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep);
Eigen::MatrixXcd EigenInvCloverOp = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep);
std::vector<int> lcoor;
typename SiteCloverType::scalar_object Qx = zero, Qxinv = zero;
for (int site = 0; site < lvol; site++)
{
grid->LocalIndexToLocalCoor(site, lcoor);
EigenCloverOp = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep);
peekLocalSite(Qx, CloverTerm, lcoor);
Qxinv = zero;
2017-10-24 13:21:17 +01:00
//if (csw!=0){
for (int j = 0; j < Ns; j++)
for (int k = 0; k < Ns; k++)
for (int a = 0; a < DimRep; a++)
for (int b = 0; b < DimRep; b++)
EigenCloverOp(a + j * DimRep, b + k * DimRep) = Qx()(j, k)(a, b);
2017-10-24 13:21:17 +01:00
// if (site==0) std::cout << "site =" << site << "\n" << EigenCloverOp << std::endl;
EigenInvCloverOp = EigenCloverOp.inverse();
2017-08-04 16:08:07 +01:00
//std::cout << EigenInvCloverOp << std::endl;
for (int j = 0; j < Ns; j++)
for (int k = 0; k < Ns; k++)
for (int a = 0; a < DimRep; a++)
for (int b = 0; b < DimRep; b++)
Qxinv()(j, k)(a, b) = EigenInvCloverOp(a + j * DimRep, b + k * DimRep);
2017-10-24 13:21:17 +01:00
// if (site==0) std::cout << "site =" << site << "\n" << EigenInvCloverOp << std::endl;
// }
pokeLocalSite(Qxinv, CloverTermInv, lcoor);
2017-03-27 07:12:57 +01:00
}
2017-08-04 16:08:07 +01:00
2017-10-24 13:21:17 +01:00
// Separate the even and odd parts
2017-08-04 16:08:07 +01:00
pickCheckerboard(Even, CloverTermEven, CloverTerm);
2017-10-24 13:21:17 +01:00
pickCheckerboard(Odd, CloverTermOdd, CloverTerm);
2017-09-24 18:32:15 +01:00
pickCheckerboard(Even, CloverTermDagEven, adj(CloverTerm));
2017-10-24 13:21:17 +01:00
pickCheckerboard(Odd, CloverTermDagOdd, adj(CloverTerm));
2017-08-04 16:08:07 +01:00
pickCheckerboard(Even, CloverTermInvEven, CloverTermInv);
2017-10-24 13:21:17 +01:00
pickCheckerboard(Odd, CloverTermInvOdd, CloverTermInv);
2017-08-04 16:08:07 +01:00
2017-09-24 18:32:15 +01:00
pickCheckerboard(Even, CloverTermInvDagEven, adj(CloverTermInv));
2017-10-24 13:21:17 +01:00
pickCheckerboard(Odd, CloverTermInvDagOdd, adj(CloverTermInv));
}
2017-03-27 07:12:57 +01:00
template <class Impl>
void WilsonCloverFermion<Impl>::Mooee(const FermionField &in, FermionField &out)
{
this->MooeeInternal(in, out, DaggerNo, InverseNo);
}
2017-04-28 15:23:34 +01:00
template <class Impl>
void WilsonCloverFermion<Impl>::MooeeDag(const FermionField &in, FermionField &out)
{
2017-09-24 18:32:15 +01:00
this->MooeeInternal(in, out, DaggerYes, InverseNo);
}
2017-04-28 15:23:34 +01:00
template <class Impl>
void WilsonCloverFermion<Impl>::MooeeInv(const FermionField &in, FermionField &out)
{
this->MooeeInternal(in, out, DaggerNo, InverseYes);
}
2017-03-24 03:43:28 +00:00
template <class Impl>
void WilsonCloverFermion<Impl>::MooeeInvDag(const FermionField &in, FermionField &out)
{
this->MooeeInternal(in, out, DaggerYes, InverseYes);
}
2017-04-28 15:23:34 +01:00
template <class Impl>
void WilsonCloverFermion<Impl>::MooeeInternal(const FermionField &in, FermionField &out, int dag, int inv)
{
out.checkerboard = in.checkerboard;
CloverFieldType *Clover;
2017-08-04 16:08:07 +01:00
assert(in.checkerboard == Odd || in.checkerboard == Even);
2017-10-24 13:21:17 +01:00
if (dag)
2017-08-04 16:08:07 +01:00
{
2017-10-24 13:21:17 +01:00
if (in._grid->_isCheckerBoarded)
2017-08-04 16:08:07 +01:00
{
2017-10-24 13:21:17 +01:00
if (in.checkerboard == Odd)
{
Clover = (inv) ? &CloverTermInvDagOdd : &CloverTermDagOdd;
}
else
{
Clover = (inv) ? &CloverTermInvDagEven : &CloverTermDagEven;
}
out = *Clover * in;
2017-08-04 16:08:07 +01:00
}
else
{
2017-10-24 13:21:17 +01:00
Clover = (inv) ? &CloverTermInv : &CloverTerm;
out = adj(*Clover) * in;
2017-08-04 16:08:07 +01:00
}
2017-05-01 11:06:21 +01:00
}
2017-08-04 16:08:07 +01:00
else
{
2017-10-24 13:21:17 +01:00
if (in._grid->_isCheckerBoarded)
{
2017-09-24 18:32:15 +01:00
2017-10-24 13:21:17 +01:00
if (in.checkerboard == Odd)
{
// std::cout << "Calling clover term Odd" << std::endl;
Clover = (inv) ? &CloverTermInvOdd : &CloverTermOdd;
}
else
{
// std::cout << "Calling clover term Even" << std::endl;
Clover = (inv) ? &CloverTermInvEven : &CloverTermEven;
}
out = *Clover * in;
// std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl;
}
else
{
Clover = (inv) ? &CloverTermInv : &CloverTerm;
out = *Clover * in;
}
2017-05-01 11:06:21 +01:00
}
2017-04-28 15:23:34 +01:00
} // MooeeInternal
2017-04-28 15:23:34 +01:00
2017-03-27 08:43:15 +01:00
// Derivative parts
template <class Impl>
void WilsonCloverFermion<Impl>::MooDeriv(GaugeField &mat, const FermionField &X, const FermionField &Y, int dag)
{
assert(0);
}
2017-03-27 08:43:15 +01:00
// Derivative parts
template <class Impl>
void WilsonCloverFermion<Impl>::MeeDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
{
assert(0); // not implemented yet
}
2017-03-27 08:43:15 +01:00
FermOpTemplateInstantiate(WilsonCloverFermion);
AdjointFermOpTemplateInstantiate(WilsonCloverFermion);
TwoIndexFermOpTemplateInstantiate(WilsonCloverFermion);
2017-04-28 15:23:34 +01:00
//GparityFermOpTemplateInstantiate(WilsonCloverFermion);
2017-03-24 03:43:28 +00:00
}
}