1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Added support for anisotropy to the WilsonFermion class

This commit is contained in:
Guido Cossu 2017-10-31 18:20:38 +00:00
parent 749189fd72
commit fa5e4add47
3 changed files with 76 additions and 15 deletions

View File

@ -47,7 +47,8 @@ int WilsonFermionStatic::HandOptDslash;
template <class Impl> template <class Impl>
WilsonFermion<Impl>::WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid, WilsonFermion<Impl>::WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid,
GridRedBlackCartesian &Hgrid, RealD _mass, GridRedBlackCartesian &Hgrid, RealD _mass,
const ImplParams &p) const ImplParams &p,
const WilsonAnisotropyCoefficients &anis)
: Kernels(p), : Kernels(p),
_grid(&Fgrid), _grid(&Fgrid),
_cbgrid(&Hgrid), _cbgrid(&Hgrid),
@ -60,16 +61,41 @@ WilsonFermion<Impl>::WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid,
Umu(&Fgrid), Umu(&Fgrid),
UmuEven(&Hgrid), UmuEven(&Hgrid),
UmuOdd(&Hgrid), UmuOdd(&Hgrid),
_tmp(&Hgrid) _tmp(&Hgrid),
anisotropyCoeff(anis)
{ {
// Allocate the required comms buffer // Allocate the required comms buffer
ImportGauge(_Umu); ImportGauge(_Umu);
if (anisotropyCoeff.isAnisotropic){
diag_mass = mass + 1.0 + (Nd-1)*(anisotropyCoeff.nu / anisotropyCoeff.xi_0);
} else {
diag_mass = 4.0 + mass;
}
} }
template <class Impl> template <class Impl>
void WilsonFermion<Impl>::ImportGauge(const GaugeField &_Umu) { void WilsonFermion<Impl>::ImportGauge(const GaugeField &_Umu) {
GaugeField HUmu(_Umu._grid); GaugeField HUmu(_Umu._grid);
HUmu = _Umu * (-0.5);
//Here multiply the anisotropy coefficients
if (anisotropyCoeff.isAnisotropic)
{
for (int mu = 0; mu < Nd; mu++)
{
GaugeLinkField U_dir = (-0.5)*PeekIndex<LorentzIndex>(_Umu, mu);
if (mu != anisotropyCoeff.t_direction)
U_dir *= (anisotropyCoeff.nu / anisotropyCoeff.xi_0);
PokeIndex<LorentzIndex>(HUmu, U_dir, mu);
}
}
else
{
HUmu = _Umu * (-0.5);
}
Impl::DoubleStore(GaugeGrid(), Umu, HUmu); Impl::DoubleStore(GaugeGrid(), Umu, HUmu);
pickCheckerboard(Even, UmuEven, Umu); pickCheckerboard(Even, UmuEven, Umu);
pickCheckerboard(Odd, UmuOdd, Umu); pickCheckerboard(Odd, UmuOdd, Umu);
@ -83,14 +109,14 @@ template <class Impl>
RealD WilsonFermion<Impl>::M(const FermionField &in, FermionField &out) { RealD WilsonFermion<Impl>::M(const FermionField &in, FermionField &out) {
out.checkerboard = in.checkerboard; out.checkerboard = in.checkerboard;
Dhop(in, out, DaggerNo); Dhop(in, out, DaggerNo);
return axpy_norm(out, 4 + mass, in, out); return axpy_norm(out, diag_mass, in, out);
} }
template <class Impl> template <class Impl>
RealD WilsonFermion<Impl>::Mdag(const FermionField &in, FermionField &out) { RealD WilsonFermion<Impl>::Mdag(const FermionField &in, FermionField &out) {
out.checkerboard = in.checkerboard; out.checkerboard = in.checkerboard;
Dhop(in, out, DaggerYes); Dhop(in, out, DaggerYes);
return axpy_norm(out, 4 + mass, in, out); return axpy_norm(out, diag_mass, in, out);
} }
template <class Impl> template <class Impl>
@ -114,7 +140,7 @@ void WilsonFermion<Impl>::MeooeDag(const FermionField &in, FermionField &out) {
template <class Impl> template <class Impl>
void WilsonFermion<Impl>::Mooee(const FermionField &in, FermionField &out) { void WilsonFermion<Impl>::Mooee(const FermionField &in, FermionField &out) {
out.checkerboard = in.checkerboard; out.checkerboard = in.checkerboard;
typename FermionField::scalar_type scal(4.0 + mass); typename FermionField::scalar_type scal(diag_mass);
out = scal * in; out = scal * in;
} }
@ -127,7 +153,7 @@ void WilsonFermion<Impl>::MooeeDag(const FermionField &in, FermionField &out) {
template<class Impl> template<class Impl>
void WilsonFermion<Impl>::MooeeInv(const FermionField &in, FermionField &out) { void WilsonFermion<Impl>::MooeeInv(const FermionField &in, FermionField &out) {
out.checkerboard = in.checkerboard; out.checkerboard = in.checkerboard;
out = (1.0/(4.0+mass))*in; out = (1.0/(diag_mass))*in;
} }
template<class Impl> template<class Impl>
@ -204,7 +230,7 @@ void WilsonFermion<Impl>::DerivInternal(StencilImpl &st, DoubledGaugeField &U,
FermionField Btilde(B._grid); FermionField Btilde(B._grid);
FermionField Atilde(B._grid); FermionField Atilde(B._grid);
Atilde = A; Atilde = A;//redundant
st.HaloExchange(B, compressor); st.HaloExchange(B, compressor);

View File

@ -44,6 +44,19 @@ class WilsonFermionStatic {
static const int npoint = 8; static const int npoint = 8;
}; };
struct WilsonAnisotropyCoefficients{
bool isAnisotropic;
int t_direction;
double xi_0;
double nu;
WilsonAnisotropyCoefficients():
isAnisotropic(false),
t_direction(Nd-1),
xi_0(1.0),
nu(1.0){}
};
template <class Impl> template <class Impl>
class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic { class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic {
public: public:
@ -118,7 +131,8 @@ class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic {
// Constructor // Constructor
WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid, WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid,
GridRedBlackCartesian &Hgrid, RealD _mass, GridRedBlackCartesian &Hgrid, RealD _mass,
const ImplParams &p = ImplParams()); const ImplParams &p = ImplParams(),
const WilsonAnisotropyCoefficients &anis = WilsonAnisotropyCoefficients() );
// DoubleStore impl dependent // DoubleStore impl dependent
void ImportGauge(const GaugeField &_Umu); void ImportGauge(const GaugeField &_Umu);
@ -130,6 +144,7 @@ class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic {
// protected: // protected:
public: public:
RealD mass; RealD mass;
RealD diag_mass;
GridBase *_grid; GridBase *_grid;
GridBase *_cbgrid; GridBase *_cbgrid;
@ -146,6 +161,8 @@ class WilsonFermion : public WilsonKernels<Impl>, public WilsonFermionStatic {
LebesgueOrder Lebesgue; LebesgueOrder Lebesgue;
LebesgueOrder LebesgueEvenOdd; LebesgueOrder LebesgueEvenOdd;
WilsonAnisotropyCoefficients anisotropyCoeff;
}; };
typedef WilsonFermion<WilsonImplF> WilsonFermionF; typedef WilsonFermion<WilsonImplF> WilsonFermionF;

View File

@ -32,7 +32,7 @@
#include <actions/ferm/invert/syssolver_linop_aggregate.h> #include <actions/ferm/invert/syssolver_linop_aggregate.h>
// Mass // Mass
double mq = 0.02; double mq = 0.1;
// Define Wilson Types // Define Wilson Types
typedef Grid::QCD::WilsonImplR::FermionField FermionField; typedef Grid::QCD::WilsonImplR::FermionField FermionField;
@ -255,6 +255,12 @@ public:
Chroma::WilsonFermActParams p; Chroma::WilsonFermActParams p;
p.Mass = _mq; p.Mass = _mq;
AnisoParam_t _apar;
_apar.anisoP = true;
_apar.t_dir = 3; // in 4d
_apar.xi_0 = 2.0;
_apar.nu = 1.0;
p.anisoParam = _apar;
Chroma::Handle<Chroma::FermBC<T4, U, U>> fbc(new Chroma::SimpleFermBC<T4, U, U>(bcs)); Chroma::Handle<Chroma::FermBC<T4, U, U>> fbc(new Chroma::SimpleFermBC<T4, U, U>(bcs));
Chroma::Handle<Chroma::CreateFermState<T4, U, U>> cfs(new Chroma::CreateSimpleFermState<T4, U, U>(fbc)); Chroma::Handle<Chroma::CreateFermState<T4, U, U>> cfs(new Chroma::CreateSimpleFermState<T4, U, U>(fbc));
@ -269,7 +275,13 @@ public:
p.Mass = _mq; p.Mass = _mq;
p.clovCoeffR = QDP::Real(1.0); p.clovCoeffR = QDP::Real(1.0);
p.clovCoeffT = QDP::Real(1.0); p.clovCoeffT = QDP::Real(1.0);
Real u0 = QDP::Real(1.0); p.u0 = QDP::Real(1.0);
AnisoParam_t _apar;
_apar.anisoP = false;
_apar.t_dir = 3; // in 4d
_apar.xi_0 = 2.0;
_apar.nu = 1.0;
p.anisoParam = _apar;
Chroma::Handle<Chroma::FermBC<T4, U, U>> fbc(new Chroma::SimpleFermBC<T4, U, U>(bcs)); Chroma::Handle<Chroma::FermBC<T4, U, U>> fbc(new Chroma::SimpleFermBC<T4, U, U>(bcs));
Chroma::Handle<Chroma::CreateFermState<T4, U, U>> cfs(new Chroma::CreateSimpleFermState<T4, U, U>(fbc)); Chroma::Handle<Chroma::CreateFermState<T4, U, U>> cfs(new Chroma::CreateSimpleFermState<T4, U, U>(fbc));
@ -391,8 +403,13 @@ void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD
if (action == Wilson) if (action == Wilson)
{ {
WilsonAnisotropyCoefficients anis;
Grid::QCD::WilsonFermionR Wf(Umu, *UGrid, *UrbGrid, _mass); anis.isAnisotropic = true;
anis.t_direction = 3;
anis.xi_0 = 2.0;
anis.nu = 1.0;
WilsonImplParams iParam;
Grid::QCD::WilsonFermionR Wf(Umu, *UGrid, *UrbGrid, _mass, iParam, anis);
std::cout << Grid::GridLogMessage << " Calling Grid Wilson Fermion multiply " << std::endl; std::cout << Grid::GridLogMessage << " Calling Grid Wilson Fermion multiply " << std::endl;
@ -406,7 +423,8 @@ void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD
if (action == WilsonClover) if (action == WilsonClover)
{ {
Grid::RealD _csw = 1.0; Grid::RealD _csw = 1.0;
WilsonAnisotropyCoefficients anis;
WilsonImplParams implParam;
Grid::QCD::WilsonCloverFermionR Wf(Umu, *UGrid, *UrbGrid, _mass, _csw); Grid::QCD::WilsonCloverFermionR Wf(Umu, *UGrid, *UrbGrid, _mass, _csw);
Wf.ImportGauge(Umu); Wf.ImportGauge(Umu);