From a04eb7df5d53e72ce501d5e13c8ef051d3a28442 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Fri, 24 Mar 2017 12:43:28 +0900 Subject: [PATCH 01/43] Starting Clover term --- .vscode/settings.json | 3 + lib/qcd/action/fermion/WilsonCloverFermion.cc | 98 +++++++++++++++++++ lib/qcd/action/fermion/WilsonCloverFermion.h | 76 ++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 lib/qcd/action/fermion/WilsonCloverFermion.cc create mode 100644 lib/qcd/action/fermion/WilsonCloverFermion.h diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..20af2f68 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +// Place your settings in this file to overwrite default and user settings. +{ +} \ No newline at end of file diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc new file mode 100644 index 00000000..1d59474e --- /dev/null +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -0,0 +1,98 @@ + /************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./lib/qcd/action/fermion/WilsonTMFermion.cc + + Copyright (C) 2015 + +Author: paboyle + + 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 + *************************************************************************************/ + /* END LEGAL */ +#include + +namespace Grid { +namespace QCD { + + /* + * BF sequence + * + void bfmbase::MooeeInv(Fermion_t psi, + Fermion_t chi, + int dag, int cb) + + double m = this->mass; + double tm = this->twistedmass; + double mtil = 4.0+this->mass; + + double sq = mtil*mtil + tm*tm; + + double a = mtil/sq; + double b = -tm /sq; + if(dag) b=-b; + axpibg5x(chi,psi,a,b); + + void bfmbase::Mooee(Fermion_t psi, + Fermion_t chi, + int dag,int cb) + double a = 4.0+this->mass; + double b = this->twistedmass; + if(dag) b=-b; + axpibg5x(chi,psi,a,b); + */ + + template + void WilsonTMFermion::Mooee(const FermionField &in, FermionField &out) { + RealD a = 4.0+this->mass; + RealD b = this->mu; + out.checkerboard = in.checkerboard; + axpibg5x(out,in,a,b); + } + template + void WilsonTMFermion::MooeeDag(const FermionField &in, FermionField &out) { + RealD a = 4.0+this->mass; + RealD b = -this->mu; + out.checkerboard = in.checkerboard; + axpibg5x(out,in,a,b); + } + template + void WilsonTMFermion::MooeeInv(const FermionField &in, FermionField &out) { + RealD m = this->mass; + RealD tm = this->mu; + RealD mtil = 4.0+this->mass; + RealD sq = mtil*mtil+tm*tm; + RealD a = mtil/sq; + RealD b = -tm /sq; + axpibg5x(out,in,a,b); + } + template + void WilsonTMFermion::MooeeInvDag(const FermionField &in, FermionField &out) { + RealD m = this->mass; + RealD tm = this->mu; + RealD mtil = 4.0+this->mass; + RealD sq = mtil*mtil+tm*tm; + RealD a = mtil/sq; + RealD b = tm /sq; + axpibg5x(out,in,a,b); + } + + FermOpTemplateInstantiate(WilsonTMFermion); + +} +} diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h new file mode 100644 index 00000000..5901cb2f --- /dev/null +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -0,0 +1,76 @@ + /************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./lib/qcd/action/fermion/WilsonTMFermion.h + + Copyright (C) 2015 + +Author: paboyle + + 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 + *************************************************************************************/ + /* END LEGAL */ +#ifndef GRID_QCD_WILSON_TM_FERMION_H +#define GRID_QCD_WILSON_TM_FERMION_H + +#include + +namespace Grid { + + namespace QCD { + + template + class WilsonTMFermion : public WilsonFermion + { + public: + INHERIT_IMPL_TYPES(Impl); + public: + + virtual void Instantiatable(void) {}; + // Constructors + WilsonTMFermion(GaugeField &_Umu, + GridCartesian &Fgrid, + GridRedBlackCartesian &Hgrid, + RealD _mass, + RealD _mu, + const ImplParams &p= ImplParams() + ) : + WilsonFermion(_Umu, + Fgrid, + Hgrid, + _mass,p) + + { + mu = _mu; + } + + + // allow override for twisted mass and clover + 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) ; + + private: + RealD mu; // TwistedMass parameter + + }; + +}} + +#endif From 5fdc05782b4578b21ba66421ec58753c32ec9350 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 27 Mar 2017 10:54:16 +0900 Subject: [PATCH 02/43] More in the clover fermion class --- lib/qcd/action/fermion/WilsonCloverFermion.h | 81 +++++++++----------- lib/qcd/action/fermion/WilsonFermion.h | 4 +- 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index 5901cb2f..41131e5d 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -1,12 +1,13 @@ - /************************************************************************************* +/************************************************************************************* - Grid physics library, www.github.com/paboyle/Grid + Grid physics library, www.github.com/paboyle/Grid Source file: ./lib/qcd/action/fermion/WilsonTMFermion.h - Copyright (C) 2015 + Copyright (C) 2017 Author: paboyle +Author: Guido Cossu 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 @@ -24,53 +25,47 @@ Author: paboyle See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ - /* END LEGAL */ -#ifndef GRID_QCD_WILSON_TM_FERMION_H -#define GRID_QCD_WILSON_TM_FERMION_H +/* END LEGAL */ +#ifndef GRID_QCD_WILSON_CLOVER_FERMION_H +#define GRID_QCD_WILSON_CLOVER_FERMION_H #include namespace Grid { +namespace QCD { - namespace QCD { +template +class WilsonCloverFermion : public WilsonFermion { +public: + INHERIT_IMPL_TYPES(Impl); - template - class WilsonTMFermion : public WilsonFermion - { - public: - INHERIT_IMPL_TYPES(Impl); - public: +public: + virtual void Instantiatable(void){}; + // Constructors + WilsonCloverFermion(GaugeField &_Umu, GridCartesian &Fgrid, + GridRedBlackCartesian &Hgrid, + RealD _mass, + RealD _csw, + const ImplParams &p = ImplParams()) : WilsonFermion(_Umu, + Fgrid, + Hgrid, + _mass, p) + { + csw = _csw; + } - virtual void Instantiatable(void) {}; - // Constructors - WilsonTMFermion(GaugeField &_Umu, - GridCartesian &Fgrid, - GridRedBlackCartesian &Hgrid, - RealD _mass, - RealD _mu, - const ImplParams &p= ImplParams() - ) : - WilsonFermion(_Umu, - Fgrid, - Hgrid, - _mass,p) + virtual RealD M(const FermionField& in, FermionField& out); + virtual RealD Mdag(const FermionField& in, FermionField& out); - { - mu = _mu; - } + 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); +private: + RealD csw; // Clover coefficient +}; +} +} - // allow override for twisted mass and clover - 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) ; - - private: - RealD mu; // TwistedMass parameter - - }; - -}} - -#endif +#endif // GRID_QCD_WILSON_CLOVER_FERMION_H diff --git a/lib/qcd/action/fermion/WilsonFermion.h b/lib/qcd/action/fermion/WilsonFermion.h index 933be732..50f4f884 100644 --- a/lib/qcd/action/fermion/WilsonFermion.h +++ b/lib/qcd/action/fermion/WilsonFermion.h @@ -65,8 +65,8 @@ class WilsonFermion : public WilsonKernels, public WilsonFermionStatic { // override multiply; cut number routines if pass dagger argument // and also make interface more uniformly consistent ////////////////////////////////////////////////////////////////// - RealD M(const FermionField &in, FermionField &out); - RealD Mdag(const FermionField &in, FermionField &out); + virtual RealD M(const FermionField &in, FermionField &out); + virtual RealD Mdag(const FermionField &in, FermionField &out); ///////////////////////////////////////////////////////// // half checkerboard operations From fff484eca5a88b01c61b1a638faf75d4b00e5304 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 27 Mar 2017 15:12:57 +0900 Subject: [PATCH 03/43] Populating Clover fermions methods --- lib/qcd/action/Actions.h | 11 +- lib/qcd/action/fermion/WilsonCloverFermion.cc | 134 ++++++++++-------- lib/qcd/action/fermion/WilsonCloverFermion.h | 28 +++- 3 files changed, 103 insertions(+), 70 deletions(-) diff --git a/lib/qcd/action/Actions.h b/lib/qcd/action/Actions.h index 4a30f8c3..b825ac49 100644 --- a/lib/qcd/action/Actions.h +++ b/lib/qcd/action/Actions.h @@ -142,11 +142,10 @@ typedef SymanzikGaugeAction ConjugateSymanzikGaugeAction //////////////////////////////////////////// #include // 4d wilson like -#include // 4d wilson like +#include // 4d wilson like +#include // 4d wilson like #include // 5d base used by all 5d overlap types -//#include - #include // Cayley types #include #include @@ -188,10 +187,16 @@ typedef WilsonFermion WilsonTwoIndexSymmetricFermi typedef WilsonFermion WilsonTwoIndexSymmetricFermionF; typedef WilsonFermion WilsonTwoIndexSymmetricFermionD; +// Twisted mass fermion typedef WilsonTMFermion WilsonTMFermionR; typedef WilsonTMFermion WilsonTMFermionF; typedef WilsonTMFermion WilsonTMFermionD; +// Clover fermions +typedef WilsonCloverFermion WilsonCloverFermionR; +typedef WilsonCloverFermion WilsonCloverFermionF; +typedef WilsonCloverFermion WilsonCloverFermionD; + typedef DomainWallFermion DomainWallFermionR; typedef DomainWallFermion DomainWallFermionF; typedef DomainWallFermion DomainWallFermionD; diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 1d59474e..0cc82f62 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -1,12 +1,13 @@ - /************************************************************************************* +/************************************************************************************* - Grid physics library, www.github.com/paboyle/Grid + Grid physics library, www.github.com/paboyle/Grid - Source file: ./lib/qcd/action/fermion/WilsonTMFermion.cc + Source file: ./lib/qcd/action/fermion/WilsonCloverFermion.cc - Copyright (C) 2015 + Copyright (C) 2017 -Author: paboyle + Author: paboyle + Author: Guido Cossu 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 @@ -24,75 +25,82 @@ Author: paboyle See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ - /* END LEGAL */ +/* END LEGAL */ #include +#include namespace Grid { namespace QCD { - /* - * BF sequence - * - void bfmbase::MooeeInv(Fermion_t psi, - Fermion_t chi, - int dag, int cb) + template + void WilsonCloverFermion::AddCloverTerm(const FermionField& in, + FermionField& out){ + FermionField tmp(out._grid); + tmp = zero; + // the product sigma_munu Fmunu is hermitian + tmp += Bx*(Gamma(Gamma::Algebra::SigmaYZ)*in); + tmp += By*(Gamma(Gamma::Algebra::MinusSigmaXZ)*in); + tmp += Bz*(Gamma(Gamma::Algebra::SigmaXY)*in); + tmp += Ex*(Gamma(Gamma::Algebra::MinusSigmaXT)*in); + tmp += Ey*(Gamma(Gamma::Algebra::MinusSigmaYT)*in); + tmp += Ez*(Gamma(Gamma::Algebra::MinusSigmaZT)*in); + out += tmp*csw; // check signs - double m = this->mass; - double tm = this->twistedmass; - double mtil = 4.0+this->mass; + } - double sq = mtil*mtil + tm*tm; - double a = mtil/sq; - double b = -tm /sq; - if(dag) b=-b; - axpibg5x(chi,psi,a,b); - - void bfmbase::Mooee(Fermion_t psi, - Fermion_t chi, - int dag,int cb) - double a = 4.0+this->mass; - double b = this->twistedmass; - if(dag) b=-b; - axpibg5x(chi,psi,a,b); - */ - - template - void WilsonTMFermion::Mooee(const FermionField &in, FermionField &out) { - RealD a = 4.0+this->mass; - RealD b = this->mu; + template + RealD WilsonCloverFermion::M(const FermionField& in, FermionField& out) { + // Wilson term out.checkerboard = in.checkerboard; - axpibg5x(out,in,a,b); - } - template - void WilsonTMFermion::MooeeDag(const FermionField &in, FermionField &out) { - RealD a = 4.0+this->mass; - RealD b = -this->mu; - out.checkerboard = in.checkerboard; - axpibg5x(out,in,a,b); - } - template - void WilsonTMFermion::MooeeInv(const FermionField &in, FermionField &out) { - RealD m = this->mass; - RealD tm = this->mu; - RealD mtil = 4.0+this->mass; - RealD sq = mtil*mtil+tm*tm; - RealD a = mtil/sq; - RealD b = -tm /sq; - axpibg5x(out,in,a,b); - } - template - void WilsonTMFermion::MooeeInvDag(const FermionField &in, FermionField &out) { - RealD m = this->mass; - RealD tm = this->mu; - RealD mtil = 4.0+this->mass; - RealD sq = mtil*mtil+tm*tm; - RealD a = mtil/sq; - RealD b = tm /sq; - axpibg5x(out,in,a,b); + this->Dhop(in, out, DaggerNo); + // Clover term + // apply the sigma and Fmunu + AddCloverTerm(in, out); + // overall factor + return axpy_norm(out, 4 + this->mass, in, out); } - FermOpTemplateInstantiate(WilsonTMFermion); + template + RealD WilsonCloverFermion::Mdag(const FermionField& in, FermionField& out) { + // Wilson term + out.checkerboard = in.checkerboard; + this->Dhop(in, out, DaggerYes); + // Clover term + // apply the sigma and Fmunu + AddCloverTerm(in, out); + return axpy_norm(out, 4 + this->mass, in, out); + } + + template + void WilsonCloverFermion::ImportGauge(const GaugeField& _Umu) { + this->ImportGauge(_Umu); + // Compute the field strength terms + + // Invert the Moo, Mee terms (?) + } + + + template + void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) { + out.checkerboard = in.checkerboard; + + } + + template + void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &out) { + assert(0); // not implemented yet + } + template + void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &out) { + assert(0); // not implemented yet + } + template + void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out) { + assert(0); // not implemented yet + } + + FermOpTemplateInstantiate(WilsonCloverFermion); } } diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index 41131e5d..d3785cac 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -2,12 +2,12 @@ Grid physics library, www.github.com/paboyle/Grid - Source file: ./lib/qcd/action/fermion/WilsonTMFermion.h + Source file: ./lib/qcd/action/fermion/WilsonCloverFermion.h Copyright (C) 2017 -Author: paboyle -Author: Guido Cossu + Author: paboyle + Author: Guido Cossu 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 @@ -40,6 +40,8 @@ public: INHERIT_IMPL_TYPES(Impl); public: + typedef WilsonFermion WilsonBase; + virtual void Instantiatable(void){}; // Constructors WilsonCloverFermion(GaugeField &_Umu, GridCartesian &Fgrid, @@ -49,9 +51,17 @@ public: const ImplParams &p = ImplParams()) : WilsonFermion(_Umu, Fgrid, Hgrid, - _mass, p) + _mass, p), + Bx(_Umu._grid), + By(_Umu._grid), + Bz(_Umu._grid), + Ex(_Umu._grid), + Ey(_Umu._grid), + Ez(_Umu._grid) { csw = _csw; + assert(Nd == 4); // require 4 dimensions + } virtual RealD M(const FermionField& in, FermionField& out); @@ -62,8 +72,18 @@ public: virtual void MooeeInv(const FermionField &in, FermionField &out); virtual void MooeeInvDag(const FermionField &in, FermionField &out); + void ImportGauge(const GaugeField &_Umu); private: + // here fixing the 4 dimensions, make it more general? + + // Field strengths + GaugeLinkField Bx, By, Bz, Ex, Ey, Ez; + RealD csw; // Clover coefficient + + + // Methods + void AddCloverTerm(const FermionField& in, FermionField& out); }; } } From 5e549ebd8b645ba6b7c39548b1ded42b629c6011 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 27 Mar 2017 16:43:15 +0900 Subject: [PATCH 04/43] Adding force terms --- lib/qcd/QCD.h | 6 ++- lib/qcd/action/fermion/WilsonCloverFermion.cc | 29 ++++++++++- lib/qcd/action/fermion/WilsonCloverFermion.h | 6 ++- lib/qcd/utils/WilsonLoops.h | 50 +++++++++++++++++++ 4 files changed, 88 insertions(+), 3 deletions(-) diff --git a/lib/qcd/QCD.h b/lib/qcd/QCD.h index f434bdd9..1c24ecdd 100644 --- a/lib/qcd/QCD.h +++ b/lib/qcd/QCD.h @@ -35,7 +35,11 @@ namespace Grid{ namespace QCD { - + static const int Xdir = 0; + static const int Ydir = 1; + static const int Zdir = 2; + static const int Tdir = 3; + static const int Xp = 0; static const int Yp = 1; static const int Zp = 2; diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 0cc82f62..b94c72c0 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -76,6 +76,12 @@ namespace QCD { void WilsonCloverFermion::ImportGauge(const GaugeField& _Umu) { this->ImportGauge(_Umu); // Compute the field strength terms + WilsonLoops::FieldStrength(Bx, _Umu, Ydir, Zdir); + WilsonLoops::FieldStrength(By, _Umu, Zdir, Xdir); + WilsonLoops::FieldStrength(Bz, _Umu, Xdir, Ydir); + WilsonLoops::FieldStrength(Ex, _Umu, Tdir, Xdir); + WilsonLoops::FieldStrength(Ey, _Umu, Tdir, Ydir); + WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); // Invert the Moo, Mee terms (?) } @@ -84,7 +90,7 @@ namespace QCD { template void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) { out.checkerboard = in.checkerboard; - + assert(0); // to be completed } template @@ -100,6 +106,27 @@ namespace QCD { assert(0); // not implemented yet } + // Derivative parts + template + void WilsonCloverFermion::MDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ + GaugeField tmp(mat._grid); + this->DhopDeriv(mat, U, V, dag); + MooDeriv(tmp, U, V, dag); + mat += tmp; + } + + // Derivative parts + template + void WilsonCloverFermion::MooDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ + assert(0); // not implemented yet + } + + // Derivative parts + template + void WilsonCloverFermion::MeeDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ + assert(0); // not implemented yet + } + FermOpTemplateInstantiate(WilsonCloverFermion); } diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index d3785cac..e942de1f 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -61,7 +61,6 @@ public: { csw = _csw; assert(Nd == 4); // require 4 dimensions - } virtual RealD M(const FermionField& in, FermionField& out); @@ -72,6 +71,11 @@ public: virtual void MooeeInv(const FermionField &in, FermionField &out); virtual void MooeeInvDag(const FermionField &in, FermionField &out); + virtual void MDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag); + 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); + + void ImportGauge(const GaugeField &_Umu); private: // here fixing the 4 dimensions, make it more general? diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index 03d45c07..ca2b2b8d 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -256,6 +256,56 @@ public: } } + //////////////////////////////////////////////////////////////////////// + // the sum over all staples on each site in direction mu,nu, lower part + //////////////////////////////////////////////////////////////////////// + static void StapleLower(GaugeMat &staple, const GaugeLorentz &Umu, int mu, + int nu) { + if (nu != mu) { + GridBase *grid = Umu._grid; + + std::vector U(Nd, grid); + for (int d = 0; d < Nd; d++) { + U[d] = PeekIndex(Umu, d);// some redundant copies + } + + // mu + // ^ + // |__> nu + + // __ + // | + // |__ + // + // + staple = Gimpl::ShiftStaple( + Gimpl::CovShiftBackward(U[nu], nu, + Gimpl::CovShiftBackward(U[mu], mu, U[nu])), + mu); + } + } + + ////////////////////////////////////////////////////// + // Field Strength + ////////////////////////////////////////////////////// + static void FieldStrength(GaugeMat &FS, const GaugeLorentz &Umu, int mu, int nu){ + // Fmn +--<--+ Ut +--<--+ + // | | | | + // (x)+-->--+ +-->--+(x) + // | | | | + // +--<--+ +--<--+ + + GaugeMat Vup(Umu._grid), Vdn(Umu._grid); + StapleUpper(Vup, Umu, mu, nu);// coalesce these two (up low) + StapleLower(Vdn, Umu, mu, nu); + GaugeMat v = adj(Vup) - adj(Vdn); + GaugeMat u = PeekIndex(Umu, mu); // some redundant copies + GaugeMat vu = v*u; + FS = 0.25*Ta(u*v - Cshift(vu, mu, +1)); + } + + + ////////////////////////////////////////////////////// // Similar to above for rectangle is required ////////////////////////////////////////////////////// From 3750b9ffeefb31e8bfb9b30b2266b83acdc7d4ff Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 27 Mar 2017 16:53:32 +0900 Subject: [PATCH 05/43] Deleting MPI test for OSX in Travis --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae3efda8..055adee1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,5 +102,3 @@ script: - ../configure --enable-precision=single --enable-simd=SSE4 --enable-comms=mpi-auto - make -j4 - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mpirun.openmpi -n 2 ./benchmarks/Benchmark_dwf --threads 1 --mpi 2.1.1.1; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mpirun -n 2 ./benchmarks/Benchmark_dwf --threads 1 --mpi 2.1.1.1; fi - From 1ed69816b9ecb9838c0a9d613e08fc2fc042afa2 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Thu, 30 Mar 2017 11:14:27 +0100 Subject: [PATCH 06/43] First steps for the force term --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 13 ++++++++++++- lib/qcd/utils/WilsonLoops.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index b94c72c0..7e51dcfe 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -82,8 +82,10 @@ namespace QCD { WilsonLoops::FieldStrength(Ex, _Umu, Tdir, Xdir); WilsonLoops::FieldStrength(Ey, _Umu, Tdir, Ydir); WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); + // Save the contracted term with sigma + // into a dense matrix site by site - // Invert the Moo, Mee terms (?) + // Invert the Moo, Mee terms (using Eigen) } @@ -110,6 +112,14 @@ namespace QCD { template void WilsonCloverFermion::MDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ GaugeField tmp(mat._grid); + + conformable(U._grid, _grid); + conformable(U._grid, V._grid); + conformable(U._grid, mat._grid); + + mat.checkerboard = U.checkerboard; + tmp.checkerboard = U.checkerboard; + this->DhopDeriv(mat, U, V, dag); MooDeriv(tmp, U, V, dag); mat += tmp; @@ -118,6 +128,7 @@ namespace QCD { // Derivative parts template void WilsonCloverFermion::MooDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ + assert(0); // not implemented yet } diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index ca2b2b8d..1984d2b8 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -301,7 +301,7 @@ public: GaugeMat v = adj(Vup) - adj(Vdn); GaugeMat u = PeekIndex(Umu, mu); // some redundant copies GaugeMat vu = v*u; - FS = 0.25*Ta(u*v - Cshift(vu, mu, +1)); + FS = 0.25*Ta(u*v + Cshift(vu, mu, +1));// need jsut the antihermite part } From b8ae787b5e3e50646085b5ea0dc74dd825dd9489 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Thu, 30 Mar 2017 11:33:15 +0100 Subject: [PATCH 07/43] Correcting a simple typo --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 1 - lib/qcd/utils/WilsonLoops.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 7e51dcfe..5d5d6622 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -113,7 +113,6 @@ namespace QCD { void WilsonCloverFermion::MDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ GaugeField tmp(mat._grid); - conformable(U._grid, _grid); conformable(U._grid, V._grid); conformable(U._grid, mat._grid); diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index 1984d2b8..143b283a 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -301,7 +301,7 @@ public: GaugeMat v = adj(Vup) - adj(Vdn); GaugeMat u = PeekIndex(Umu, mu); // some redundant copies GaugeMat vu = v*u; - FS = 0.25*Ta(u*v + Cshift(vu, mu, +1));// need jsut the antihermite part + FS = 0.25*Ta(u*v + Cshift(vu, mu, +1)); } From 6fd82228bfcc949e60ba229600d44c251caffd38 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Wed, 5 Apr 2017 10:51:44 +0100 Subject: [PATCH 08/43] Working on the derivative --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 5d5d6622..e588de42 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -127,7 +127,7 @@ namespace QCD { // Derivative parts template void WilsonCloverFermion::MooDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ - + // Compute the 8 terms of the derivative assert(0); // not implemented yet } From b69499630276813e217ac211e765d13c9a4e16a0 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Fri, 14 Apr 2017 13:30:14 +0100 Subject: [PATCH 09/43] adding comments --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index e588de42..c7fd211d 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -128,6 +128,17 @@ namespace QCD { template void WilsonCloverFermion::MooDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ // Compute the 8 terms of the derivative + + // Pseudocode + // Using Chroma as a template + + // for loop on mu and nu, but upper matrix + // take the outer product factor * U x (sigma_mu_nu V) + + // derivative of loops + // end of loop + + assert(0); // not implemented yet } From 5553b8d2b86a1fa4b44a304e4fab9ab3e8001f16 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Fri, 28 Apr 2017 15:23:34 +0100 Subject: [PATCH 10/43] Clover term compiles, not tested --- lib/qcd/action/fermion/Fermion.h | 2 +- lib/qcd/action/fermion/WilsonCloverFermion.cc | 144 ++++++---- lib/qcd/action/fermion/WilsonCloverFermion.h | 59 ++-- tests/core/Test_wilson_clover.cc | 251 ++++++++++++++++++ 4 files changed, 383 insertions(+), 73 deletions(-) create mode 100644 tests/core/Test_wilson_clover.cc diff --git a/lib/qcd/action/fermion/Fermion.h b/lib/qcd/action/fermion/Fermion.h index 2eaf42fa..9d999c6d 100644 --- a/lib/qcd/action/fermion/Fermion.h +++ b/lib/qcd/action/fermion/Fermion.h @@ -49,7 +49,7 @@ Author: Peter Boyle #include // 4d wilson like #include // 4d wilson like -#include // 4d wilson like +#include // 4d wilson clover fermions #include // 5d base used by all 5d overlap types #include diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index c7fd211d..ebea565b 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -27,28 +27,35 @@ *************************************************************************************/ /* END LEGAL */ #include +#include #include namespace Grid { namespace QCD { - template - void WilsonCloverFermion::AddCloverTerm(const FermionField& in, - FermionField& out){ - FermionField tmp(out._grid); - tmp = zero; - // the product sigma_munu Fmunu is hermitian - tmp += Bx*(Gamma(Gamma::Algebra::SigmaYZ)*in); - tmp += By*(Gamma(Gamma::Algebra::MinusSigmaXZ)*in); - tmp += Bz*(Gamma(Gamma::Algebra::SigmaXY)*in); - tmp += Ex*(Gamma(Gamma::Algebra::MinusSigmaXT)*in); - tmp += Ey*(Gamma(Gamma::Algebra::MinusSigmaYT)*in); - tmp += Ez*(Gamma(Gamma::Algebra::MinusSigmaZT)*in); - out += tmp*csw; // check signs - - } +//WilsonLoop::CloverPlaquette +///////////////////////////////////////////////////// +//// Clover plaquette combination in mu,nu plane with Double Stored U +//////////////////////////////////////////////////// +//static void CloverPlaquette(GaugeMat &Q, const std::vector &U, +// const int mu, const int nu){ +// Q = zero; +// Q += Gimpl::CovShiftBackward( +// U[mu], mu, Gimpl::CovShiftBackward( +// U[nu], nu, Gimpl::CovShiftForward(U[mu], mu, U[nu] ))); +// Q += Gimpl::CovShiftForward( +// U[mu], mu, Gimpl::CovShiftForward( +// U[nu], nu, Gimpl::CovShiftBackward(U[mu], mu, U[nu+Nd] ))); +// Q += Gimpl::CovShiftBackward( +// U[nu], nu, Gimpl::CovShiftForward( +// U[mu], mu, Gimpl::CovShiftForward(U[nu], nu, U[mu+Nd] ))); +// Q += Gimpl::CovShiftForward( +// U[mu], mu, Gimpl::CovShiftBackward( +// U[nu], nu, Gimpl::CovShiftBackward(U[mu], mu, U[nu] ))); +// } +// *NOT* EO template RealD WilsonCloverFermion::M(const FermionField& in, FermionField& out) { // Wilson term @@ -56,7 +63,7 @@ namespace QCD { this->Dhop(in, out, DaggerNo); // Clover term // apply the sigma and Fmunu - AddCloverTerm(in, out); + Mooee(in, out); // overall factor return axpy_norm(out, 4 + this->mass, in, out); } @@ -68,13 +75,16 @@ namespace QCD { this->Dhop(in, out, DaggerYes); // Clover term // apply the sigma and Fmunu - AddCloverTerm(in, out); + MooeeDag(in, out); return axpy_norm(out, 4 + this->mass, in, out); } template void WilsonCloverFermion::ImportGauge(const GaugeField& _Umu) { this->ImportGauge(_Umu); + GridBase* grid = _Umu._grid; + assert(Nd==4); //only works in 4 dim + typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid); // Compute the field strength terms WilsonLoops::FieldStrength(Bx, _Umu, Ydir, Zdir); WilsonLoops::FieldStrength(By, _Umu, Zdir, Xdir); @@ -82,31 +92,77 @@ namespace QCD { WilsonLoops::FieldStrength(Ex, _Umu, Tdir, Xdir); WilsonLoops::FieldStrength(Ey, _Umu, Tdir, Ydir); WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); - // Save the contracted term with sigma - // into a dense matrix site by site - // Invert the Moo, Mee terms (using Eigen) + // Compute the Clover Operator acting on Colour and Spin + CloverTerm = fillClover(Bx)*(Gamma(Gamma::Algebra::SigmaYZ)); + CloverTerm += fillClover(By)*(Gamma(Gamma::Algebra::MinusSigmaXZ)); + CloverTerm += fillClover(Bz)*(Gamma(Gamma::Algebra::SigmaXY)); + CloverTerm += fillClover(Ex)*(Gamma(Gamma::Algebra::MinusSigmaXT)); + CloverTerm += fillClover(Ey)*(Gamma(Gamma::Algebra::MinusSigmaYT)); + CloverTerm += fillClover(Ez)*(Gamma(Gamma::Algebra::MinusSigmaZT)); + CloverTerm *= csw; + + + 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 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; + 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); + + EigenInvCloverOp = EigenCloverOp.inverse(); + 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); + + pokeLocalSite(Qxinv,CloverTermInv,lcoor); + } + } + + template + void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out){ + this -> MooeeInternal(in, out, DaggerNo, InverseNo); + } + + template + void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &out){ + this -> MooeeInternal(in, out, DaggerNo, InverseYes); + } + + template + void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &out){ + this -> MooeeInternal(in, out, DaggerNo, InverseYes); + } + + template + void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out){ + this -> MooeeInternal(in, out, DaggerNo, InverseYes); } template - void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) { - out.checkerboard = in.checkerboard; - assert(0); // to be completed - } + void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionField &out, int dag, int inv){ + out.checkerboard = in.checkerboard; + CloverFieldType *Clover; - template - void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &out) { - assert(0); // not implemented yet - } - template - void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &out) { - assert(0); // not implemented yet - } - template - void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out) { - assert(0); // not implemented yet - } + Clover = (inv) ? &CloverTermInv : &CloverTerm; + if(dag){ out = adj(*Clover)*in;} else {out = *Clover*in;} + } // MooeeInternal // Derivative parts template @@ -128,17 +184,6 @@ namespace QCD { template void WilsonCloverFermion::MooDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ // Compute the 8 terms of the derivative - - // Pseudocode - // Using Chroma as a template - - // for loop on mu and nu, but upper matrix - // take the outer product factor * U x (sigma_mu_nu V) - - // derivative of loops - // end of loop - - assert(0); // not implemented yet } @@ -148,7 +193,10 @@ namespace QCD { assert(0); // not implemented yet } - FermOpTemplateInstantiate(WilsonCloverFermion); +FermOpTemplateInstantiate(WilsonCloverFermion); // now only for the fundamental representation +//AdjointFermOpTemplateInstantiate(WilsonCloverFermion); +//TwoIndexFermOpTemplateInstantiate(WilsonCloverFermion); +//GparityFermOpTemplateInstantiate(WilsonCloverFermion); } } diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index e942de1f..0fa0d57d 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -31,14 +31,20 @@ #include -namespace Grid { -namespace QCD { +namespace Grid +{ +namespace QCD +{ template -class WilsonCloverFermion : public WilsonFermion { +class WilsonCloverFermion : public WilsonFermion +{ public: + // Types definitions INHERIT_IMPL_TYPES(Impl); - + template using iImplClover = iScalar, Ns> >; + typedef iImplClover SiteCloverType; + typedef Lattice CloverFieldType; public: typedef WilsonFermion WilsonBase; @@ -51,43 +57,48 @@ public: const ImplParams &p = ImplParams()) : WilsonFermion(_Umu, Fgrid, Hgrid, - _mass, p), - Bx(_Umu._grid), - By(_Umu._grid), - Bz(_Umu._grid), - Ex(_Umu._grid), - Ey(_Umu._grid), - Ez(_Umu._grid) + _mass, p), + CloverTerm(&Fgrid), + CloverTermInv(&Fgrid) { csw = _csw; assert(Nd == 4); // require 4 dimensions } - virtual RealD M(const FermionField& in, FermionField& out); - virtual RealD Mdag(const FermionField& in, FermionField& out); + virtual RealD M(const FermionField &in, FermionField &out); + virtual RealD Mdag(const FermionField &in, FermionField &out); 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); + virtual void MooeeInternal(const FermionField &in, FermionField &out, int dag, int inv); - virtual void MDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag); - 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); - + virtual void MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag); + 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); void ImportGauge(const GaugeField &_Umu); + private: // here fixing the 4 dimensions, make it more general? - // Field strengths - GaugeLinkField Bx, By, Bz, Ex, Ey, Ez; + RealD csw; // Clover coefficient + CloverFieldType CloverTerm, CloverTermInv; // Clover term + // eventually these two can be compressed into 6x6 blocks instead of the 12x12 + // using the DeGrand-Rossi basis for the gamma matrices - RealD csw; // Clover coefficient - - - // Methods - void AddCloverTerm(const FermionField& in, FermionField& out); + CloverFieldType fillClover(const GaugeLinkField& F){ + CloverFieldType T(F._grid); + PARALLEL_FOR_LOOP + for (int i = 0; i < CloverTerm._grid->oSites(); i++){ + for (int s1 = 0; s1 < Nc; s1++) + for (int s2 = 0; s2 < Nc; s2++) + T._odata[i]()(s1,s2) = F._odata[i]()(); + } + return T; + } + }; } } diff --git a/tests/core/Test_wilson_clover.cc b/tests/core/Test_wilson_clover.cc new file mode 100644 index 00000000..08516d80 --- /dev/null +++ b/tests/core/Test_wilson_clover.cc @@ -0,0 +1,251 @@ + /************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./benchmarks/Benchmark_wilson.cc + + Copyright (C) 2015 + + Author: Guido Cossu + + 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 + *************************************************************************************/ + /* END LEGAL */ +#include + +using namespace std; +using namespace Grid; +using namespace Grid::QCD; + +int main (int argc, char ** argv) +{ + Grid_init(&argc,&argv); + + std::vector latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); + std::vector mpi_layout = GridDefaultMpi(); + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); + + int threads = GridThread::GetThreads(); + std::cout< seeds({1,2,3,4}); + GridParallelRNG pRNG(&Grid); + pRNG.SeedFixedIntegers(seeds); + // pRNG.SeedFixedIntegers(std::vector({45,12,81,9}); + + typedef typename WilsonCloverFermionR::FermionField FermionField; + typename WilsonCloverFermionR::ImplParams params; + + FermionField src (&Grid); random(pRNG,src); + FermionField result(&Grid); result=zero; + FermionField ref(&Grid); ref=zero; + FermionField tmp(&Grid); tmp=zero; + FermionField err(&Grid); tmp=zero; + FermionField phi (&Grid); random(pRNG,phi); + FermionField chi (&Grid); random(pRNG,chi); + LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu); + std::vector U(4,&Grid); + + + double volume=1; + for(int mu=0;mu(Umu,mu); + /* Debug force unit + U[mu] = 1.0; + PokeIndex(Umu,U[mu],mu); + */ + } + + ref = zero; + + RealD mass=0.1; + RealD csw = 1.0; + + { // Simple clover implementation + + // ref = ref + mass * src; + } + + WilsonCloverFermionR Dwc(Umu,Grid,RBGrid,mass,csw,params); + + + std::cout< * = < chi | Deo^dag| phi> "< HermOpEO(Dwc); + HermOpEO.MpcDagMpc(chi_e,dchi_e,t1,t2); + HermOpEO.MpcDagMpc(chi_o,dchi_o,t1,t2); + + HermOpEO.MpcDagMpc(phi_e,dphi_e,t1,t2); + HermOpEO.MpcDagMpc(phi_o,dphi_o,t1,t2); + + pDce = innerProduct(phi_e,dchi_e); + pDco = innerProduct(phi_o,dchi_o); + cDpe = innerProduct(chi_e,dphi_e); + cDpo = innerProduct(chi_o,dphi_o); + + std::cout< Date: Fri, 28 Apr 2017 15:51:05 +0100 Subject: [PATCH 11/43] Correcting the M and Mdag in the clover term --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 277 +++++++++--------- 1 file changed, 146 insertions(+), 131 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index ebea565b..3ab481ce 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -30,13 +30,15 @@ #include #include -namespace Grid { -namespace QCD { +namespace Grid +{ +namespace QCD +{ -//WilsonLoop::CloverPlaquette -///////////////////////////////////////////////////// -//// Clover plaquette combination in mu,nu plane with Double Stored U -//////////////////////////////////////////////////// +//WilsonLoop::CloverPlaquette +///////////////////////////////////////////////////// +//// Clover plaquette combination in mu,nu plane with Double Stored U +//////////////////////////////////////////////////// //static void CloverPlaquette(GaugeMat &Q, const std::vector &U, // const int mu, const int nu){ // Q = zero; @@ -54,149 +56,162 @@ namespace QCD { // U[nu], nu, Gimpl::CovShiftBackward(U[mu], mu, U[nu] ))); // } +// *NOT* EO +template +RealD WilsonCloverFermion::M(const FermionField &in, FermionField &out) +{ + // Wilson term + out.checkerboard = in.checkerboard; + this->Dhop(in, out, DaggerNo); + // Clover term + // apply the sigma and Fmunu + FermionField temp(out._grid); + Mooee(in, temp); + // overall factor + out += temp; + return axpy_norm(out, 4 + this->mass, in, out); +} -// *NOT* EO - template - RealD WilsonCloverFermion::M(const FermionField& in, FermionField& out) { - // Wilson term - out.checkerboard = in.checkerboard; - this->Dhop(in, out, DaggerNo); - // Clover term - // apply the sigma and Fmunu - Mooee(in, out); - // overall factor - return axpy_norm(out, 4 + this->mass, in, out); +template +RealD WilsonCloverFermion::Mdag(const FermionField &in, FermionField &out) +{ + // Wilson term + out.checkerboard = in.checkerboard; + this->Dhop(in, out, DaggerYes); + // Clover term + // apply the sigma and Fmunu + FermionField temp(out._grid); + MooeeDag(in, temp); + out+=temp; + return axpy_norm(out, 4 + this->mass, in, out); +} + +template +void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) +{ + this->ImportGauge(_Umu); + GridBase *grid = _Umu._grid; + assert(Nd == 4); // only works in 4 dim + typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid); + + // Compute the field strength terms + WilsonLoops::FieldStrength(Bx, _Umu, Ydir, Zdir); + WilsonLoops::FieldStrength(By, _Umu, Zdir, Xdir); + WilsonLoops::FieldStrength(Bz, _Umu, Xdir, Ydir); + WilsonLoops::FieldStrength(Ex, _Umu, Tdir, Xdir); + WilsonLoops::FieldStrength(Ey, _Umu, Tdir, Ydir); + WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); + + // Compute the Clover Operator acting on Colour and Spin + CloverTerm = fillClover(Bx) * (Gamma(Gamma::Algebra::SigmaYZ)); + CloverTerm += fillClover(By) * (Gamma(Gamma::Algebra::MinusSigmaXZ)); + CloverTerm += fillClover(Bz) * (Gamma(Gamma::Algebra::SigmaXY)); + CloverTerm += fillClover(Ex) * (Gamma(Gamma::Algebra::MinusSigmaXT)); + CloverTerm += fillClover(Ey) * (Gamma(Gamma::Algebra::MinusSigmaYT)); + CloverTerm += fillClover(Ez) * (Gamma(Gamma::Algebra::MinusSigmaZT)); + CloverTerm *= csw; + + 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 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; + 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); + + EigenInvCloverOp = EigenCloverOp.inverse(); + 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); + + pokeLocalSite(Qxinv, CloverTermInv, lcoor); } +} - template - RealD WilsonCloverFermion::Mdag(const FermionField& in, FermionField& out) { - // Wilson term - out.checkerboard = in.checkerboard; - this->Dhop(in, out, DaggerYes); - // Clover term - // apply the sigma and Fmunu - MooeeDag(in, out); - return axpy_norm(out, 4 + this->mass, in, out); - } +template +void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) +{ + this->MooeeInternal(in, out, DaggerNo, InverseNo); +} - template - void WilsonCloverFermion::ImportGauge(const GaugeField& _Umu) { - this->ImportGauge(_Umu); - GridBase* grid = _Umu._grid; - assert(Nd==4); //only works in 4 dim - typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid); - // Compute the field strength terms - WilsonLoops::FieldStrength(Bx, _Umu, Ydir, Zdir); - WilsonLoops::FieldStrength(By, _Umu, Zdir, Xdir); - WilsonLoops::FieldStrength(Bz, _Umu, Xdir, Ydir); - WilsonLoops::FieldStrength(Ex, _Umu, Tdir, Xdir); - WilsonLoops::FieldStrength(Ey, _Umu, Tdir, Ydir); - WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); +template +void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &out) +{ + this->MooeeInternal(in, out, DaggerNo, InverseYes); +} - // Compute the Clover Operator acting on Colour and Spin - CloverTerm = fillClover(Bx)*(Gamma(Gamma::Algebra::SigmaYZ)); - CloverTerm += fillClover(By)*(Gamma(Gamma::Algebra::MinusSigmaXZ)); - CloverTerm += fillClover(Bz)*(Gamma(Gamma::Algebra::SigmaXY)); - CloverTerm += fillClover(Ex)*(Gamma(Gamma::Algebra::MinusSigmaXT)); - CloverTerm += fillClover(Ey)*(Gamma(Gamma::Algebra::MinusSigmaYT)); - CloverTerm += fillClover(Ez)*(Gamma(Gamma::Algebra::MinusSigmaZT)); - CloverTerm *= csw; +template +void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &out) +{ + this->MooeeInternal(in, out, DaggerNo, InverseYes); +} +template +void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out) +{ + this->MooeeInternal(in, out, DaggerNo, InverseYes); +} - int lvol = _Umu._grid->lSites(); - int DimRep = Impl::Dimension; +template +void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionField &out, int dag, int inv) +{ + out.checkerboard = in.checkerboard; + CloverFieldType *Clover; - Eigen::MatrixXcd EigenCloverOp = Eigen::MatrixXcd::Zero(Ns*DimRep,Ns*DimRep); - Eigen::MatrixXcd EigenInvCloverOp = Eigen::MatrixXcd::Zero(Ns*DimRep,Ns*DimRep); - - std::vector lcoor; - typename SiteCloverType::scalar_object Qx = zero, Qxinv = zero; + Clover = (inv) ? &CloverTermInv : &CloverTerm; + if (dag){ out = adj(*Clover) * in;} else { out = *Clover * in;} +} // MooeeInternal - 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; - 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); +// Derivative parts +template +void WilsonCloverFermion::MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) +{ + GaugeField tmp(mat._grid); - EigenInvCloverOp = EigenCloverOp.inverse(); - 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); + conformable(U._grid, V._grid); + conformable(U._grid, mat._grid); - pokeLocalSite(Qxinv,CloverTermInv,lcoor); - } - } + mat.checkerboard = U.checkerboard; + tmp.checkerboard = U.checkerboard; - template - void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out){ - this -> MooeeInternal(in, out, DaggerNo, InverseNo); - } + this->DhopDeriv(mat, U, V, dag); + MooDeriv(tmp, U, V, dag); + mat += tmp; +} - template - void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &out){ - this -> MooeeInternal(in, out, DaggerNo, InverseYes); - } +// Derivative parts +template +void WilsonCloverFermion::MooDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) +{ + // Compute the 8 terms of the derivative + assert(0); // not implemented yet +} - template - void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &out){ - this -> MooeeInternal(in, out, DaggerNo, InverseYes); - } - - template - void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out){ - this -> MooeeInternal(in, out, DaggerNo, InverseYes); - } - - - template - void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionField &out, int dag, int inv){ - out.checkerboard = in.checkerboard; - CloverFieldType *Clover; - - Clover = (inv) ? &CloverTermInv : &CloverTerm; - if(dag){ out = adj(*Clover)*in;} else {out = *Clover*in;} - } // MooeeInternal - - // Derivative parts - template - void WilsonCloverFermion::MDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ - GaugeField tmp(mat._grid); - - conformable(U._grid, V._grid); - conformable(U._grid, mat._grid); - - mat.checkerboard = U.checkerboard; - tmp.checkerboard = U.checkerboard; - - this->DhopDeriv(mat, U, V, dag); - MooDeriv(tmp, U, V, dag); - mat += tmp; - } - - // Derivative parts - template - void WilsonCloverFermion::MooDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ - // Compute the 8 terms of the derivative - assert(0); // not implemented yet - } - - // Derivative parts - template - void WilsonCloverFermion::MeeDeriv(GaugeField&mat, const FermionField&U, const FermionField&V, int dag){ - assert(0); // not implemented yet - } +// Derivative parts +template +void WilsonCloverFermion::MeeDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) +{ + assert(0); // not implemented yet +} FermOpTemplateInstantiate(WilsonCloverFermion); // now only for the fundamental representation //AdjointFermOpTemplateInstantiate(WilsonCloverFermion); //TwoIndexFermOpTemplateInstantiate(WilsonCloverFermion); //GparityFermOpTemplateInstantiate(WilsonCloverFermion); - } } From 62a64d9108cf260cb0f5d3dd18aa0695568cc432 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 1 May 2017 11:06:21 +0100 Subject: [PATCH 12/43] EO support, wip --- .vscode/settings.json | 38 +++++++++++++++++++ lib/qcd/action/fermion/WilsonCloverFermion.cc | 15 +++++++- lib/qcd/action/fermion/WilsonCloverFermion.h | 8 +++- tests/core/Test_wilson_clover.cc | 3 +- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 20af2f68..dd8f0473 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,41 @@ // Place your settings in this file to overwrite default and user settings. { + "files.associations": { + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "array": "cpp", + "atomic": "cpp", + "*.tcc": "cpp", + "chrono": "cpp", + "codecvt": "cpp", + "condition_variable": "cpp", + "cstdint": "cpp", + "exception": "cpp", + "slist": "cpp", + "functional": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "limits": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "ratio": "cpp", + "stdexcept": "cpp", + "system_error": "cpp", + "thread": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "utility": "cpp" + } } \ No newline at end of file diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 3ab481ce..e1900830 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -91,7 +91,6 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) { this->ImportGauge(_Umu); GridBase *grid = _Umu._grid; - assert(Nd == 4); // only works in 4 dim typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid); // Compute the field strength terms @@ -140,6 +139,11 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) Qxinv()(j, k)(a, b) = EigenInvCloverOp(a + j * DimRep, b + k * DimRep); pokeLocalSite(Qxinv, CloverTermInv, lcoor); + // Separate the even and odd parts. + pickCheckerboard(Even, CloverTermEven, CloverTerm); + pickCheckerboard( Odd, CloverTermOdd, CloverTerm); + pickCheckerboard(Even, CloverTermInvEven, CloverTermInv); + pickCheckerboard( Odd, CloverTermInvOdd, CloverTermInv); } } @@ -172,8 +176,15 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie { out.checkerboard = in.checkerboard; CloverFieldType *Clover; + if (in.checkerboard == Odd){ + std::cout << "Calling clover term Odd" << std::endl; + Clover = (inv) ? &CloverTermInvOdd : &CloverTermOdd; + } + if (in.checkerboard == Even){ + std::cout << "Calling clover term Even" << std::endl; + Clover = (inv) ? &CloverTermInvEven : &CloverTermEven; + } - Clover = (inv) ? &CloverTermInv : &CloverTerm; if (dag){ out = adj(*Clover) * in;} else { out = *Clover * in;} } // MooeeInternal diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index 0fa0d57d..c9e7be39 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -59,7 +59,11 @@ public: Hgrid, _mass, p), CloverTerm(&Fgrid), - CloverTermInv(&Fgrid) + CloverTermInv(&Fgrid), + CloverTermEven(&Hgrid), + CloverTermOdd(&Hgrid), + CloverTermInvEven(&Hgrid), + CloverTermInvOdd(&Hgrid) { csw = _csw; assert(Nd == 4); // require 4 dimensions @@ -85,6 +89,8 @@ private: RealD csw; // Clover coefficient CloverFieldType CloverTerm, CloverTermInv; // Clover term + CloverFieldType CloverTermEven, CloverTermOdd; + CloverFieldType CloverTermInvEven, CloverTermInvOdd; // Clover term // eventually these two can be compressed into 6x6 blocks instead of the 12x12 // using the DeGrand-Rossi basis for the gamma matrices diff --git a/tests/core/Test_wilson_clover.cc b/tests/core/Test_wilson_clover.cc index 08516d80..3df69e3b 100644 --- a/tests/core/Test_wilson_clover.cc +++ b/tests/core/Test_wilson_clover.cc @@ -191,8 +191,9 @@ int main (int argc, char ** argv) Dwc.MooeeInv(src_e,phi_e); Dwc.Mooee(chi_o,src_o); +exit(1); Dwc.MooeeInv(src_o,phi_o); - + setCheckerboard(phi,phi_e); setCheckerboard(phi,phi_o); From 75ee6cfc86e2365baf0a50cd4bf317e7c6fb097a Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Fri, 4 Aug 2017 16:08:07 +0100 Subject: [PATCH 13/43] Debugging the Clover term --- .gitignore | 2 + .vscode/settings.json | 11 ++- lib/cartesian/Cartesian_base.h | 2 + lib/cartesian/Cartesian_full.h | 5 +- lib/cartesian/Cartesian_red_black.h | 1 + lib/qcd/action/fermion/WilsonCloverFermion.cc | 78 +++++++-------- lib/qcd/action/fermion/WilsonCloverFermion.h | 99 +++++++++++++++++-- tests/core/Test_wilson_clover.cc | 3 +- 8 files changed, 149 insertions(+), 52 deletions(-) diff --git a/.gitignore b/.gitignore index d743ee06..6b92b1a4 100644 --- a/.gitignore +++ b/.gitignore @@ -123,3 +123,5 @@ make-bin-BUCK.sh lib/qcd/spin/gamma-gen/*.h lib/qcd/spin/gamma-gen/*.cc +.vscode/settings.json +settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json index dd8f0473..3e49029b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -36,6 +36,15 @@ "tuple": "cpp", "type_traits": "cpp", "typeinfo": "cpp", - "utility": "cpp" + "utility": "cpp", + "iostream": "cpp", + "strstream": "cpp", + "complex": "cpp", + "fstream": "cpp", + "iomanip": "cpp", + "istream": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "streambuf": "cpp" } } \ No newline at end of file diff --git a/lib/cartesian/Cartesian_base.h b/lib/cartesian/Cartesian_base.h index 0db6ce0d..e435bbba 100644 --- a/lib/cartesian/Cartesian_base.h +++ b/lib/cartesian/Cartesian_base.h @@ -69,6 +69,8 @@ public: std::vector _lstart; // local start of array in gcoors _processor_coor[d]*_ldimensions[d] std::vector _lend ; // local end of array in gcoors _processor_coor[d]*_ldimensions[d]+_ldimensions_[d]-1 + bool _isCheckerBoarded; + public: //////////////////////////////////////////////////////////////// diff --git a/lib/cartesian/Cartesian_full.h b/lib/cartesian/Cartesian_full.h index b0e47fa4..3be3e8cd 100644 --- a/lib/cartesian/Cartesian_full.h +++ b/lib/cartesian/Cartesian_full.h @@ -69,6 +69,7 @@ public: /////////////////////// // Grid information /////////////////////// + _isCheckerBoarded = false; _ndimension = dimensions.size(); _fdimensions.resize(_ndimension); @@ -76,8 +77,8 @@ public: _ldimensions.resize(_ndimension); _rdimensions.resize(_ndimension); _simd_layout.resize(_ndimension); - _lstart.resize(_ndimension); - _lend.resize(_ndimension); + _lstart.resize(_ndimension); + _lend.resize(_ndimension); _ostride.resize(_ndimension); _istride.resize(_ndimension); diff --git a/lib/cartesian/Cartesian_red_black.h b/lib/cartesian/Cartesian_red_black.h index 3037de00..a440538a 100644 --- a/lib/cartesian/Cartesian_red_black.h +++ b/lib/cartesian/Cartesian_red_black.h @@ -139,6 +139,7 @@ public: /////////////////////// // Grid information /////////////////////// + _isCheckerBoarded = true; _checker_dim = checker_dim; assert(checker_dim_mask[checker_dim]==1); _ndimension = dimensions.size(); diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index e1900830..f8b62ba4 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -35,27 +35,6 @@ namespace Grid namespace QCD { -//WilsonLoop::CloverPlaquette -///////////////////////////////////////////////////// -//// Clover plaquette combination in mu,nu plane with Double Stored U -//////////////////////////////////////////////////// -//static void CloverPlaquette(GaugeMat &Q, const std::vector &U, -// const int mu, const int nu){ -// Q = zero; -// Q += Gimpl::CovShiftBackward( -// U[mu], mu, Gimpl::CovShiftBackward( -// U[nu], nu, Gimpl::CovShiftForward(U[mu], mu, U[nu] ))); -// Q += Gimpl::CovShiftForward( -// U[mu], mu, Gimpl::CovShiftForward( -// U[nu], nu, Gimpl::CovShiftBackward(U[mu], mu, U[nu+Nd] ))); -// Q += Gimpl::CovShiftBackward( -// U[nu], nu, Gimpl::CovShiftForward( -// U[mu], mu, Gimpl::CovShiftForward(U[nu], nu, U[mu+Nd] ))); -// Q += Gimpl::CovShiftForward( -// U[mu], mu, Gimpl::CovShiftBackward( -// U[nu], nu, Gimpl::CovShiftBackward(U[mu], mu, U[nu] ))); -// } - // *NOT* EO template RealD WilsonCloverFermion::M(const FermionField &in, FermionField &out) @@ -89,10 +68,10 @@ RealD WilsonCloverFermion::Mdag(const FermionField &in, FermionField &out) template void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) { - this->ImportGauge(_Umu); + WilsonFermion::ImportGauge(_Umu); GridBase *grid = _Umu._grid; typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid); - + // Compute the field strength terms WilsonLoops::FieldStrength(Bx, _Umu, Ydir, Zdir); WilsonLoops::FieldStrength(By, _Umu, Zdir, Xdir); @@ -102,12 +81,12 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); // Compute the Clover Operator acting on Colour and Spin - CloverTerm = fillClover(Bx) * (Gamma(Gamma::Algebra::SigmaYZ)); - CloverTerm += fillClover(By) * (Gamma(Gamma::Algebra::MinusSigmaXZ)); - CloverTerm += fillClover(Bz) * (Gamma(Gamma::Algebra::SigmaXY)); - CloverTerm += fillClover(Ex) * (Gamma(Gamma::Algebra::MinusSigmaXT)); - CloverTerm += fillClover(Ey) * (Gamma(Gamma::Algebra::MinusSigmaYT)); - CloverTerm += fillClover(Ez) * (Gamma(Gamma::Algebra::MinusSigmaZT)); + CloverTerm = fillCloverYZ(Bx); + CloverTerm += fillCloverXZ(By); + CloverTerm += fillCloverXY(Bz); + CloverTerm += fillCloverXT(Ex); + CloverTerm += fillCloverYT(Ey); + CloverTerm += fillCloverZT(Ez) ; CloverTerm *= csw; int lvol = _Umu._grid->lSites(); @@ -130,8 +109,11 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) 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); + //std::cout << EigenCloverOp << std::endl; + EigenInvCloverOp = EigenCloverOp.inverse(); + //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++) @@ -139,17 +121,21 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) Qxinv()(j, k)(a, b) = EigenInvCloverOp(a + j * DimRep, b + k * DimRep); pokeLocalSite(Qxinv, CloverTermInv, lcoor); - // Separate the even and odd parts. - pickCheckerboard(Even, CloverTermEven, CloverTerm); - pickCheckerboard( Odd, CloverTermOdd, CloverTerm); - pickCheckerboard(Even, CloverTermInvEven, CloverTermInv); - pickCheckerboard( Odd, CloverTermInvOdd, CloverTermInv); } + + // Separate the even and odd parts. + pickCheckerboard(Even, CloverTermEven, CloverTerm); + pickCheckerboard( Odd, CloverTermOdd, CloverTerm); + + pickCheckerboard(Even, CloverTermInvEven, CloverTermInv); + pickCheckerboard( Odd, CloverTermInvOdd, CloverTermInv); + } template void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) { + conformable(in,out); this->MooeeInternal(in, out, DaggerNo, InverseNo); } @@ -176,15 +162,27 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie { out.checkerboard = in.checkerboard; CloverFieldType *Clover; - if (in.checkerboard == Odd){ - std::cout << "Calling clover term Odd" << std::endl; - Clover = (inv) ? &CloverTermInvOdd : &CloverTermOdd; + assert(in.checkerboard == Odd || in.checkerboard == Even); + + if (in._grid->_isCheckerBoarded) + { + 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; + } } - if (in.checkerboard == Even){ - std::cout << "Calling clover term Even" << std::endl; - Clover = (inv) ? &CloverTermInvEven : &CloverTermEven; + else + { + Clover = (inv) ? &CloverTermInv : &CloverTerm; } + std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; if (dag){ out = adj(*Clover) * in;} else { out = *Clover * in;} } // MooeeInternal diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index c9e7be39..fd9d1f60 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -94,17 +94,102 @@ private: // eventually these two can be compressed into 6x6 blocks instead of the 12x12 // using the DeGrand-Rossi basis for the gamma matrices - CloverFieldType fillClover(const GaugeLinkField& F){ + CloverFieldType fillCloverYZ(const GaugeLinkField &F) + { CloverFieldType T(F._grid); + T = zero; PARALLEL_FOR_LOOP - for (int i = 0; i < CloverTerm._grid->oSites(); i++){ - for (int s1 = 0; s1 < Nc; s1++) - for (int s2 = 0; s2 < Nc; s2++) - T._odata[i]()(s1,s2) = F._odata[i]()(); + 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]()()); } - return T; - } + return T; +} + + 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]()(); + } + + return T; +} + + CloverFieldType fillCloverXY(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, 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]()()); + } + + return T; +} + + CloverFieldType fillCloverXT(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) = timesMinusI(F._odata[i]()()); + T._odata[i]()(1, 0) = timesMinusI(F._odata[i]()()); + T._odata[i]()(2, 3) = timesI(F._odata[i]()()); + T._odata[i]()(3, 2) = timesI(F._odata[i]()()); + } + + return T; +} + + CloverFieldType fillCloverYT(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]()()); + } + + return T; +} + + CloverFieldType fillCloverZT(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, 0) = timesMinusI(F._odata[i]()()); + T._odata[i]()(1, 1) = timesI(F._odata[i]()()); + T._odata[i]()(2, 2) = timesI(F._odata[i]()()); + T._odata[i]()(3, 3) = timesMinusI(F._odata[i]()()); + } + + return T; +} + }; } } diff --git a/tests/core/Test_wilson_clover.cc b/tests/core/Test_wilson_clover.cc index 3df69e3b..1b208e2d 100644 --- a/tests/core/Test_wilson_clover.cc +++ b/tests/core/Test_wilson_clover.cc @@ -91,7 +91,7 @@ int main (int argc, char ** argv) } WilsonCloverFermionR Dwc(Umu,Grid,RBGrid,mass,csw,params); - + Dwc.ImportGauge(Umu); std::cout< Date: Tue, 15 Aug 2017 10:50:44 +0100 Subject: [PATCH 14/43] Correction of the dagger version of the Clover --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index f8b62ba4..ce120846 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -142,19 +142,22 @@ void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) template void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &out) { - this->MooeeInternal(in, out, DaggerNo, InverseYes); + conformable(in,out); + this->MooeeInternal(in, out, DaggerYes, InverseYes); } template void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &out) { + conformable(in,out); this->MooeeInternal(in, out, DaggerNo, InverseYes); } template void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out) { - this->MooeeInternal(in, out, DaggerNo, InverseYes); + conformable(in,out); + this->MooeeInternal(in, out, DaggerYes, InverseYes); } template @@ -183,7 +186,10 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie } std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; - if (dag){ out = adj(*Clover) * in;} else { out = *Clover * in;} + std::cout << GridLogMessage << "in.checkerboard " << in.checkerboard << std::endl; + std::cout << GridLogMessage << "out.checkerboard " << out.checkerboard << std::endl; + out = *Clover * in; + //if (dag){ out = adj(*Clover) * in;} else { out = *Clover * in;} } // MooeeInternal // Derivative parts From 56478d63a5589e0ece63d7394b3c5167d5ef11bd Mon Sep 17 00:00:00 2001 From: David Preti Date: Sun, 24 Sep 2017 19:32:15 +0200 Subject: [PATCH 15/43] clover + test (valence) --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 126 +++++++++++++++--- lib/qcd/action/fermion/WilsonCloverFermion.h | 35 +++-- tests/core/Test_wilson_clover.cc | 44 +++--- 3 files changed, 142 insertions(+), 63 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index f8b62ba4..54e72353 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -86,8 +86,8 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) CloverTerm += fillCloverXY(Bz); CloverTerm += fillCloverXT(Ex); CloverTerm += fillCloverYT(Ey); - CloverTerm += fillCloverZT(Ez) ; - CloverTerm *= csw; + CloverTerm += fillCloverZT(Ez); + CloverTerm *= 0.5 * csw; // FieldStrength normalization? should be ( -i/8 ). Is it the anti-symmetric combination? int lvol = _Umu._grid->lSites(); int DimRep = Impl::Dimension; @@ -109,7 +109,7 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) 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); - //std::cout << EigenCloverOp << std::endl; + // if (site==0) std::cout << "site =" << site << "\n" << EigenCloverOp << std::endl; EigenInvCloverOp = EigenCloverOp.inverse(); @@ -119,6 +119,7 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) 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); + // if (site==0) std::cout << "site =" << site << "\n" << EigenInvCloverOp << std::endl; pokeLocalSite(Qxinv, CloverTermInv, lcoor); } @@ -127,8 +128,17 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) pickCheckerboard(Even, CloverTermEven, CloverTerm); pickCheckerboard( Odd, CloverTermOdd, CloverTerm); + + pickCheckerboard(Even, CloverTermDagEven, adj(CloverTerm)); + pickCheckerboard( Odd, CloverTermDagOdd, adj(CloverTerm)); + + pickCheckerboard(Even, CloverTermInvEven, CloverTermInv); pickCheckerboard( Odd, CloverTermInvOdd, CloverTermInv); + + + pickCheckerboard(Even, CloverTermInvDagEven, adj(CloverTermInv)); + pickCheckerboard( Odd, CloverTermInvDagOdd, adj(CloverTermInv)); } @@ -142,7 +152,7 @@ void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) template void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &out) { - this->MooeeInternal(in, out, DaggerNo, InverseYes); + this->MooeeInternal(in, out, DaggerYes, InverseNo); } template @@ -154,7 +164,7 @@ void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &o template void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out) { - this->MooeeInternal(in, out, DaggerNo, InverseYes); + this->MooeeInternal(in, out, DaggerYes, InverseYes); } template @@ -164,26 +174,98 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie CloverFieldType *Clover; assert(in.checkerboard == Odd || in.checkerboard == Even); - if (in._grid->_isCheckerBoarded) - { - if (in.checkerboard == Odd) - { - std::cout << "Calling clover term Odd" << std::endl; - Clover = (inv) ? &CloverTermInvOdd : &CloverTermOdd; + + + + if (dag){ + if (in._grid->_isCheckerBoarded){ + if (in.checkerboard == Odd){ + std::cout << "Calling clover term adj Odd" << std::endl; + Clover = (inv) ? &CloverTermInvDagOdd : &CloverTermDagOdd; + +/* test + int DimRep = Impl::Dimension; + Eigen::MatrixXcd A = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep); + std::vector lcoor; + typename SiteCloverType::scalar_object Qx2 = zero; + GridBase *grid = in._grid; + int site = 0 ; + grid->LocalIndexToLocalCoor(site, lcoor); + peekLocalSite(Qx2, *Clover, lcoor); + 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++) + A(a + j * DimRep, b + k * DimRep) = Qx2()(j, k)(a, b); + std::cout << "adj Odd =" << site << "\n" << A << std::endl; + end test */ + + + + } else { + std::cout << "Calling clover term adj Even" << std::endl; + Clover = (inv) ? &CloverTermInvDagEven : &CloverTermDagEven; + +/* test + int DimRep = Impl::Dimension; + Eigen::MatrixXcd A = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep); + std::vector lcoor; + typename SiteCloverType::scalar_object Qx2 = zero; + GridBase *grid = in._grid; + int site = 0 ; + grid->LocalIndexToLocalCoor(site, lcoor); + peekLocalSite(Qx2, *Clover, lcoor); + 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++) + A(a + j * DimRep, b + k * DimRep) = Qx2()(j, k)(a, b); + std::cout << "adj Odd =" << site << "\n" << A << std::endl; + end test */ + + } - else - { - std::cout << "Calling clover term Even" << std::endl; - Clover = (inv) ? &CloverTermInvEven : &CloverTermEven; - } - } - else - { - Clover = (inv) ? &CloverTermInv : &CloverTerm; + std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; + out = *Clover * in; + } else { + Clover = (inv) ? &CloverTermInv : &CloverTerm; + out = adj(*Clover) * in; } - std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; - if (dag){ out = adj(*Clover) * in;} else { out = *Clover * in;} + + + + } else { + if (in._grid->_isCheckerBoarded){ + + 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; + } + } + + + + + + + +/* + } else { + out = *Clover * in; + } + */ + + } // MooeeInternal // Derivative parts diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index fd9d1f60..e8654513 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -63,7 +63,11 @@ public: CloverTermEven(&Hgrid), CloverTermOdd(&Hgrid), CloverTermInvEven(&Hgrid), - CloverTermInvOdd(&Hgrid) + CloverTermInvOdd(&Hgrid), + CloverTermDagEven(&Hgrid), //test + CloverTermDagOdd(&Hgrid), //test + CloverTermInvDagEven(&Hgrid), //test + CloverTermInvDagOdd(&Hgrid) //test { csw = _csw; assert(Nd == 4); // require 4 dimensions @@ -91,6 +95,11 @@ private: CloverFieldType CloverTerm, CloverTermInv; // Clover term CloverFieldType CloverTermEven, CloverTermOdd; CloverFieldType CloverTermInvEven, CloverTermInvOdd; // Clover term + + CloverFieldType CloverTermInvDagEven, CloverTermInvDagOdd; //test + CloverFieldType CloverTermDagEven, CloverTermDagOdd; //test + + // eventually these two can be compressed into 6x6 blocks instead of the 12x12 // using the DeGrand-Rossi basis for the gamma matrices @@ -149,10 +158,10 @@ private: PARALLEL_FOR_LOOP 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) = timesI(F._odata[i]()()); - T._odata[i]()(3, 2) = timesI(F._odata[i]()()); + T._odata[i]()(0, 1) = timesI(F._odata[i]()()); //fixed + T._odata[i]()(1, 0) = timesI(F._odata[i]()()); //fixed + T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()()); //fixed + T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()()); //fixed } return T; @@ -165,10 +174,10 @@ private: 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]()()); + T._odata[i]()(0, 1) = -(F._odata[i]()()); //fixed + T._odata[i]()(1, 0) = (F._odata[i]()()); //fixed + T._odata[i]()(2, 3) = (F._odata[i]()()); //fixed + T._odata[i]()(3, 2) = -(F._odata[i]()()); //fixed } return T; @@ -181,10 +190,10 @@ private: PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { - T._odata[i]()(0, 0) = timesMinusI(F._odata[i]()()); - T._odata[i]()(1, 1) = timesI(F._odata[i]()()); - T._odata[i]()(2, 2) = timesI(F._odata[i]()()); - T._odata[i]()(3, 3) = timesMinusI(F._odata[i]()()); + T._odata[i]()(0, 0) = timesI(F._odata[i]()()); //fixed + T._odata[i]()(1, 1) = timesMinusI(F._odata[i]()()); //fixed + T._odata[i]()(2, 2) = timesMinusI(F._odata[i]()()); //fixed + T._odata[i]()(3, 3) = timesI(F._odata[i]()()); //fixed } return T; diff --git a/tests/core/Test_wilson_clover.cc b/tests/core/Test_wilson_clover.cc index 1b208e2d..9e5b246e 100644 --- a/tests/core/Test_wilson_clover.cc +++ b/tests/core/Test_wilson_clover.cc @@ -172,11 +172,6 @@ int main (int argc, char ** argv) std::cout< HermOpEO(Dwc); - HermOpEO.MpcDagMpc(chi_e,dchi_e,t1,t2); - HermOpEO.MpcDagMpc(chi_o,dchi_o,t1,t2); + Dwc.MooeeDag(chi_e,src_e); + Dwc.MooeeInv(src_e,phi_e); - HermOpEO.MpcDagMpc(phi_e,dphi_e,t1,t2); - HermOpEO.MpcDagMpc(phi_o,dphi_o,t1,t2); + Dwc.MooeeDag(chi_o,src_o); + Dwc.MooeeInv(src_o,phi_o); - pDce = innerProduct(phi_e,dchi_e); - pDco = innerProduct(phi_o,dchi_o); - cDpe = innerProduct(chi_e,dphi_e); - cDpo = innerProduct(chi_o,dphi_o); - - std::cout< Date: Thu, 5 Oct 2017 10:13:53 +0200 Subject: [PATCH 16/43] first attempt to write C terms in clover derivative. Some shifts to be fixed --- lib/perfmon/PerfCount.h | 3 +- lib/perfmon/Stat.cc | 30 ++++---- lib/qcd/action/fermion/WilsonCloverFermion.cc | 75 +++++++++++++++---- 3 files changed, 77 insertions(+), 31 deletions(-) diff --git a/lib/perfmon/PerfCount.h b/lib/perfmon/PerfCount.h index 73d2c70f..cb27c283 100644 --- a/lib/perfmon/PerfCount.h +++ b/lib/perfmon/PerfCount.h @@ -90,9 +90,10 @@ inline uint64_t cyclecount(void){ } #elif defined __x86_64__ inline uint64_t cyclecount(void){ - return __rdtsc(); + //return __rdtsc(); // unsigned int dummy; // return __rdtscp(&dummy); +return 0; // <- remove this; } #else diff --git a/lib/perfmon/Stat.cc b/lib/perfmon/Stat.cc index 3f47fd83..75679412 100644 --- a/lib/perfmon/Stat.cc +++ b/lib/perfmon/Stat.cc @@ -57,35 +57,37 @@ void PmuStat::start(void) pmu_start(); ++count; xmemctrs(&mrstart, &mwstart); - tstart = __rdtsc(); + //tstart = __rdtsc(); +tstart=0; #endif } void PmuStat::enter(int t) { #ifdef __x86_64__ - counters[0][t] = __rdpmc(0); - counters[1][t] = __rdpmc(1); - counters[2][t] = __rdpmc((1<<30)|0); - counters[3][t] = __rdpmc((1<<30)|1); - counters[4][t] = __rdpmc((1<<30)|2); - counters[5][t] = __rdtsc(); + counters[0][t] = 0;//__rdpmc(0); + counters[1][t] = 0;//__rdpmc(1); + counters[2][t] = 0;//__rdpmc((1<<30)|0); + counters[3][t] = 0;//__rdpmc((1<<30)|1); + counters[4][t] = 0;//__rdpmc((1<<30)|2); + counters[5][t] = 0;//__rdtsc(); #endif } void PmuStat::exit(int t) { #ifdef __x86_64__ - counters[0][t] = __rdpmc(0) - counters[0][t]; - counters[1][t] = __rdpmc(1) - counters[1][t]; - counters[2][t] = __rdpmc((1<<30)|0) - counters[2][t]; - counters[3][t] = __rdpmc((1<<30)|1) - counters[3][t]; - counters[4][t] = __rdpmc((1<<30)|2) - counters[4][t]; - counters[5][t] = __rdtsc() - counters[5][t]; + counters[0][t] = 0;//__rdpmc(0) - counters[0][t]; + counters[1][t] = 0;// __rdpmc(1) - counters[1][t]; + counters[2][t] = 0;// __rdpmc((1<<30)|0) - counters[2][t]; + counters[3][t] = 0;// __rdpmc((1<<30)|1) - counters[3][t]; + counters[4][t] = 0;// __rdpmc((1<<30)|2) - counters[4][t]; + counters[5][t] = 0;// __rdtsc() - counters[5][t]; #endif } void PmuStat::accum(int nthreads) { #ifdef __x86_64__ - tend = __rdtsc(); + // tend = __rdtsc(); + tend =0 ; xmemctrs(&mrend, &mwend); pmu_stop(); for (int t = 0; t < nthreads; ++t) { diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 54e72353..bc996ccb 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -253,25 +253,14 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie } } - - - - - - -/* - } else { - out = *Clover * in; - } - */ - - } // MooeeInternal // Derivative parts template void WilsonCloverFermion::MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) { + + GaugeField tmp(mat._grid); conformable(U._grid, V._grid); @@ -287,10 +276,64 @@ void WilsonCloverFermion::MDeriv(GaugeField &mat, const FermionField &U, c // Derivative parts template -void WilsonCloverFermion::MooDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) +void WilsonCloverFermion::MooDeriv(GaugeField &mat, const FermionField &X, const FermionField &Y, int dag) { - // Compute the 8 terms of the derivative - assert(0); // not implemented yet + +GridBase *grid = mat._grid; + +GaugeLinkField Lambda(grid), tmp(grid); +Lambda = zero; //Y*dag(X)+X*dag(Y); // I have to peek spin and decide the color structure + +conformable(mat._grid, X._grid); +conformable(Y._grid, X._grid); + +std::vector C1p(Nd,grid), C2p(Nd,grid), C3p(Nd,grid), C4p(Nd,grid); +std::vector C1m(Nd,grid), C2m(Nd,grid), C3m(Nd,grid), C4m(Nd,grid); +std::vector U(Nd, mat._grid); + +for (int mu = 0; mu < Nd; mu++) { + U[mu] = PeekIndex(mat, mu); + C1p[mu]=zero; C2p[mu]=zero; C3p[mu]=zero; C4p[mu]=zero; + C1m[mu]=zero; C2m[mu]=zero; C3m[mu]=zero; C4m[mu]=zero; +} + + +for (int mu=0;mu<4;mu++){ + for (int nu=0;nu<4;nu++){ +// insertion in upper staple + tmp = Impl::CovShiftIdentityBackward(Lambda, nu) * U[nu]; + C1p[mu]+= Cshift(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Cshift(U[nu], nu, -1))), mu, 1); + + tmp = Impl::CovShiftIdentityForward(Lambda, mu) * U[mu]; + C2p[mu]+= Cshift(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Cshift(U[nu], nu, -1))), mu, 1); + + tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu]; + C3p[mu]+= Cshift(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Cshift(tmp, nu, -1))), mu, 1); + + tmp = Lambda; + C4p[mu]+= Cshift(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Cshift(U[nu], nu, -1))),mu,1) * tmp; + +// insertion in lower staple + tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu]; + C1m[mu]+= Cshift(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu, 1); + + tmp = Cshift(Cshift(Lambda, nu, 2),mu, 1) * U[mu]; + C2m[mu]+= Cshift(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, U[nu])), mu ,1); + + tmp = Cshift(Lambda, nu, 2) * U[nu]; + C3m[mu]+= Cshift(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu, 1); + + tmp = Lambda; + C4m[mu]+= Cshift(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu, 1)* tmp; + } +} + + +//Still implementing. Have to be tested, and understood how to project EO + + + + } // Derivative parts From 317ddfedee2104de5bfb96d9174dc31542af9797 Mon Sep 17 00:00:00 2001 From: pretidav Date: Mon, 16 Oct 2017 02:47:33 +0200 Subject: [PATCH 17/43] updated test clover + first attempt derivative clove term (still missing spin part) --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 79 +++++---- lib/qcd/action/fermion/WilsonCloverFermion.h | 16 +- tests/core/Test_wilson_clover.cc | 156 ++++++++++++++---- 3 files changed, 180 insertions(+), 71 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index bc996ccb..7f58f277 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -46,7 +46,6 @@ RealD WilsonCloverFermion::M(const FermionField &in, FermionField &out) // apply the sigma and Fmunu FermionField temp(out._grid); Mooee(in, temp); - // overall factor out += temp; return axpy_norm(out, 4 + this->mass, in, out); } @@ -89,6 +88,7 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) CloverTerm += fillCloverZT(Ez); CloverTerm *= 0.5 * csw; // FieldStrength normalization? should be ( -i/8 ). Is it the anti-symmetric combination? + int lvol = _Umu._grid->lSites(); int DimRep = Impl::Dimension; @@ -98,20 +98,21 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) std::vector 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; +//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); - // if (site==0) std::cout << "site =" << site << "\n" << EigenCloverOp << std::endl; - - + // if (site==0) std::cout << "site =" << site << "\n" << EigenCloverOp << std::endl; + EigenInvCloverOp = EigenCloverOp.inverse(); //std::cout << EigenInvCloverOp << std::endl; for (int j = 0; j < Ns; j++) @@ -120,9 +121,11 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) for (int b = 0; b < DimRep; b++) Qxinv()(j, k)(a, b) = EigenInvCloverOp(a + j * DimRep, b + k * DimRep); // if (site==0) std::cout << "site =" << site << "\n" << EigenInvCloverOp << std::endl; - +// } pokeLocalSite(Qxinv, CloverTermInv, lcoor); - } + } + + // Separate the even and odd parts. pickCheckerboard(Even, CloverTermEven, CloverTerm); @@ -180,7 +183,7 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie if (dag){ if (in._grid->_isCheckerBoarded){ if (in.checkerboard == Odd){ - std::cout << "Calling clover term adj Odd" << std::endl; +// std::cout << "Calling clover term adj Odd" << std::endl; Clover = (inv) ? &CloverTermInvDagOdd : &CloverTermDagOdd; /* test @@ -203,7 +206,7 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie } else { - std::cout << "Calling clover term adj Even" << std::endl; +// std::cout << "Calling clover term adj Even" << std::endl; Clover = (inv) ? &CloverTermInvDagEven : &CloverTermDagEven; /* test @@ -225,7 +228,7 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie } - std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; + // std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; out = *Clover * in; } else { Clover = (inv) ? &CloverTermInv : &CloverTerm; @@ -239,14 +242,14 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie if (in._grid->_isCheckerBoarded){ if (in.checkerboard == Odd){ - std::cout << "Calling clover term Odd" << std::endl; + // std::cout << "Calling clover term Odd" << std::endl; Clover = (inv) ? &CloverTermInvOdd : &CloverTermOdd; } else { - std::cout << "Calling clover term Even" << std::endl; + // std::cout << "Calling clover term Even" << std::endl; Clover = (inv) ? &CloverTermInvEven : &CloverTermEven; } out = *Clover * in; - std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; + // std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; } else { Clover = (inv) ? &CloverTermInv : &CloverTerm; out = *Clover * in; @@ -281,8 +284,12 @@ void WilsonCloverFermion::MooDeriv(GaugeField &mat, const FermionField &X, GridBase *grid = mat._grid; +//GaugeLinkField Lambdaodd(grid), Lambdaeven(grid), tmp(grid); +//Lambdaodd = zero; //Yodd*dag(Xodd)+Xodd*dag(Yodd); // I have to peek spin and decide the color structure +//Lambdaeven = zero; //Teven*dag(Xeven)+Xeven*dag(Yeven) + 2*(Dee^-1) + GaugeLinkField Lambda(grid), tmp(grid); -Lambda = zero; //Y*dag(X)+X*dag(Y); // I have to peek spin and decide the color structure +Lambda=zero; conformable(mat._grid, X._grid); conformable(Y._grid, X._grid); @@ -297,37 +304,53 @@ for (int mu = 0; mu < Nd; mu++) { C1m[mu]=zero; C2m[mu]=zero; C3m[mu]=zero; C4m[mu]=zero; } +/* + PARALLEL_FOR_LOOP + 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]()()); + } +*/ + +for (int i=0;i<4;i++){ //spin + for(int j=0;j<4;j++){ //spin + +for (int mu=0;mu<4;mu++){ //color + for (int nu=0;nu<4;nu++){ //color -for (int mu=0;mu<4;mu++){ - for (int nu=0;nu<4;nu++){ // insertion in upper staple - tmp = Impl::CovShiftIdentityBackward(Lambda, nu) * U[nu]; - C1p[mu]+= Cshift(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Cshift(U[nu], nu, -1))), mu, 1); + tmp = Lambda * U[nu]; + C1p[mu]+=Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - tmp = Impl::CovShiftIdentityForward(Lambda, mu) * U[mu]; - C2p[mu]+= Cshift(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Cshift(U[nu], nu, -1))), mu, 1); + tmp = Lambda * U[mu]; + C2p[mu]+= Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu]; - C3p[mu]+= Cshift(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Cshift(tmp, nu, -1))), mu, 1); + C3p[mu]+= Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu); tmp = Lambda; - C4p[mu]+= Cshift(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Cshift(U[nu], nu, -1))),mu,1) * tmp; + C4p[mu]+= Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))),mu) * tmp; // insertion in lower staple - tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu]; - C1m[mu]+= Cshift(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu, 1); + tmp = Lambda * U[nu]; + C1m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu); - tmp = Cshift(Cshift(Lambda, nu, 2),mu, 1) * U[mu]; - C2m[mu]+= Cshift(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, U[nu])), mu ,1); + tmp = Lambda * U[mu]; + C2m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, U[nu])), mu); - tmp = Cshift(Lambda, nu, 2) * U[nu]; - C3m[mu]+= Cshift(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu, 1); + tmp = Lambda * U[nu]; + C3m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu); tmp = Lambda; - C4m[mu]+= Cshift(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu, 1)* tmp; + C4m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu)* tmp; } } +} +} //Still implementing. Have to be tested, and understood how to project EO diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index e8654513..7840af90 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -44,7 +44,7 @@ public: INHERIT_IMPL_TYPES(Impl); template using iImplClover = iScalar, Ns> >; typedef iImplClover SiteCloverType; - typedef Lattice CloverFieldType; + typedef Lattice CloverFieldType; public: typedef WilsonFermion WilsonBase; @@ -91,14 +91,12 @@ public: private: // here fixing the 4 dimensions, make it more general? - RealD csw; // Clover coefficient - CloverFieldType CloverTerm, CloverTermInv; // Clover term - CloverFieldType CloverTermEven, CloverTermOdd; - CloverFieldType CloverTermInvEven, CloverTermInvOdd; // Clover term - - CloverFieldType CloverTermInvDagEven, CloverTermInvDagOdd; //test - CloverFieldType CloverTermDagEven, CloverTermDagOdd; //test - + RealD csw; // Clover coefficient + CloverFieldType CloverTerm=zero, CloverTermInv=zero; // Clover term + CloverFieldType CloverTermEven=zero, CloverTermOdd=zero; // Clover term EO + CloverFieldType CloverTermInvEven=zero, CloverTermInvOdd=zero; // Clover term Inv EO + CloverFieldType CloverTermDagEven=zero, CloverTermDagOdd=zero; // Clover term Dag EO + CloverFieldType CloverTermInvDagEven=zero, CloverTermInvDagOdd=zero; // Clover term Inv Dag EO // eventually these two can be compressed into 6x6 blocks instead of the 12x12 // using the DeGrand-Rossi basis for the gamma matrices diff --git a/tests/core/Test_wilson_clover.cc b/tests/core/Test_wilson_clover.cc index 9e5b246e..9a5fffe2 100644 --- a/tests/core/Test_wilson_clover.cc +++ b/tests/core/Test_wilson_clover.cc @@ -55,13 +55,15 @@ int main (int argc, char ** argv) typedef typename WilsonCloverFermionR::FermionField FermionField; typename WilsonCloverFermionR::ImplParams params; - FermionField src (&Grid); random(pRNG,src); - FermionField result(&Grid); result=zero; - FermionField ref(&Grid); ref=zero; - FermionField tmp(&Grid); tmp=zero; - FermionField err(&Grid); tmp=zero; - FermionField phi (&Grid); random(pRNG,phi); - FermionField chi (&Grid); random(pRNG,chi); + FermionField src (&Grid); random(pRNG,src); + FermionField result(&Grid); result=zero; + FermionField result2(&Grid); result2=zero; + FermionField ref(&Grid); ref=zero; + FermionField tmp(&Grid); tmp=zero; + FermionField err(&Grid); err=zero; + FermionField err2(&Grid); err2=zero; + FermionField phi (&Grid); random(pRNG,phi); + FermionField chi (&Grid); random(pRNG,chi); LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu); std::vector U(4,&Grid); @@ -71,24 +73,9 @@ int main (int argc, char ** argv) volume=volume*latt_size[mu]; } - // Only one non-zero (y) - for(int mu=0;mu(Umu,mu); - /* Debug force unit - U[mu] = 1.0; - PokeIndex(Umu,U[mu],mu); - */ - } - - ref = zero; - - RealD mass=0.1; + RealD mass= 0.1; RealD csw = 1.0; - { // Simple clover implementation - - // ref = ref + mass * src; - } WilsonCloverFermionR Dwc(Umu,Grid,RBGrid,mass,csw,params); Dwc.ImportGauge(Umu); @@ -176,27 +163,26 @@ int main (int argc, char ** argv) std::cout< seeds2({5,6,7,8}); + GridParallelRNG pRNG2(&Grid); pRNG2.SeedFixedIntegers(seeds2); + LatticeColourMatrix Omega(&Grid); + LatticeColourMatrix ShiftedOmega(&Grid); + LatticeGaugeField U_prime(&Grid); U_prime=zero; + LatticeColourMatrix U_prime_mu(&Grid); U_prime_mu=zero; + SU::LieRandomize(pRNG2, Omega, 1.0); + for (int mu=0;mu Date: Mon, 23 Oct 2017 13:32:26 +0100 Subject: [PATCH 18/43] Changes in the Makefile to compile against Chroma on Linux --- tests/qdpxx/Makefile.am | 3 ++- tests/qdpxx/Makefile.am.qdpxx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/qdpxx/Makefile.am b/tests/qdpxx/Makefile.am index f7f30b85..bbcd0412 100644 --- a/tests/qdpxx/Makefile.am +++ b/tests/qdpxx/Makefile.am @@ -1,4 +1,5 @@ AM_CXXFLAGS += `chroma-config --cxxflags` -AM_LDFLAGS += `chroma-config --ldflags` `chroma-config --libs` +AM_LDFLAGS += `chroma-config --ldflags` +LIBS += `chroma-config --libs` include Make.inc diff --git a/tests/qdpxx/Makefile.am.qdpxx b/tests/qdpxx/Makefile.am.qdpxx index 3ccfa4b8..f212413f 100644 --- a/tests/qdpxx/Makefile.am.qdpxx +++ b/tests/qdpxx/Makefile.am.qdpxx @@ -1,6 +1,7 @@ # additional include paths necessary to compile the C++ library AM_CXXFLAGS = -I$(top_srcdir)/include `chroma-config --cxxflags` -AM_LDFLAGS = -L$(top_builddir)/lib `chroma-config --ldflags` `chroma-config --libs` +AM_LDFLAGS = -L$(top_builddir)/lib `chroma-config --ldflags` +AM_LIBS = `chroma-config --libs` include Make.inc From 6391b2a1d0ae8128dafa25349be754a198b978d3 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 23 Oct 2017 14:42:35 +0100 Subject: [PATCH 19/43] Added test for Wilson and Clover fermions --- .vscode/settings.json | 3 +- tests/qdpxx/Test_qdpxx_wilson.cc | 463 +++++++++++++++++++++++++++++++ 2 files changed, 465 insertions(+), 1 deletion(-) create mode 100644 tests/qdpxx/Test_qdpxx_wilson.cc diff --git a/.vscode/settings.json b/.vscode/settings.json index 3e49029b..f13d503b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -45,6 +45,7 @@ "istream": "cpp", "ostream": "cpp", "sstream": "cpp", - "streambuf": "cpp" + "streambuf": "cpp", + "algorithm": "cpp" } } \ No newline at end of file diff --git a/tests/qdpxx/Test_qdpxx_wilson.cc b/tests/qdpxx/Test_qdpxx_wilson.cc new file mode 100644 index 00000000..70a8b1bf --- /dev/null +++ b/tests/qdpxx/Test_qdpxx_wilson.cc @@ -0,0 +1,463 @@ +/************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./tests/qdpxx/Test_qdpxx_wilson.cc + + Copyright (C) 2017 + + Author: Guido Cossu + + 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 + *************************************************************************************/ +/* END LEGAL */ + +#include + +// Mass +double mq = 0.1; + +// Define Wilson Types +typedef Grid::QCD::WilsonImplR::FermionField FermionField; +typedef Grid::QCD::LatticeGaugeField GaugeField; + +#include +#include +#include + +enum ChromaAction +{ + Wilson, // Wilson + WilsonClover // CloverFermions +}; + +void make_gauge(GaugeField &lat, FermionField &src); +void calc_grid(ChromaAction CA, GaugeField &lat, FermionField &src, FermionField &res, int dag); +void calc_chroma(ChromaAction CA, GaugeField &lat, FermionField &src, FermionField &res, int dag); + +namespace Chroma +{ + +class ChromaWrapper +{ +public: + typedef multi1d U; + typedef LatticeFermion T4; + + static void ImportGauge(GaugeField &gr, + QDP::multi1d &ch) + { + Grid::QCD::LorentzColourMatrix LCM; + Grid::Complex cc; + QDP::ColorMatrix cm; + QDP::Complex c; + + std::vector x(4); + QDP::multi1d cx(4); + std::vector gd = gr._grid->GlobalDimensions(); + + for (x[0] = 0; x[0] < gd[0]; x[0]++) + { + for (x[1] = 0; x[1] < gd[1]; x[1]++) + { + for (x[2] = 0; x[2] < gd[2]; x[2]++) + { + for (x[3] = 0; x[3] < gd[3]; x[3]++) + { + cx[0] = x[0]; + cx[1] = x[1]; + cx[2] = x[2]; + cx[3] = x[3]; + Grid::peekSite(LCM, gr, x); + + for (int mu = 0; mu < 4; mu++) + { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + cc = LCM(mu)()(i, j); + c = QDP::cmplx(QDP::Real(real(cc)), QDP::Real(imag(cc))); + QDP::pokeColor(cm, c, i, j); + } + } + QDP::pokeSite(ch[mu], cm, cx); + } + } + } + } + } + } + + static void ExportGauge(GaugeField &gr, + QDP::multi1d &ch) + { + Grid::QCD::LorentzColourMatrix LCM; + Grid::Complex cc; + QDP::ColorMatrix cm; + QDP::Complex c; + + std::vector x(4); + QDP::multi1d cx(4); + std::vector gd = gr._grid->GlobalDimensions(); + + for (x[0] = 0; x[0] < gd[0]; x[0]++) + { + for (x[1] = 0; x[1] < gd[1]; x[1]++) + { + for (x[2] = 0; x[2] < gd[2]; x[2]++) + { + for (x[3] = 0; x[3] < gd[3]; x[3]++) + { + cx[0] = x[0]; + cx[1] = x[1]; + cx[2] = x[2]; + cx[3] = x[3]; + + for (int mu = 0; mu < 4; mu++) + { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + cm = QDP::peekSite(ch[mu], cx); + c = QDP::peekColor(cm, i, j); + cc = Grid::Complex(toDouble(real(c)), toDouble(imag(c))); + LCM(mu) + ()(i, j) = cc; + } + } + } + Grid::pokeSite(LCM, gr, x); + } + } + } + } + } + + // Specific for Wilson Fermions + static void ImportFermion(Grid::QCD::LatticeFermion &gr, + QDP::LatticeFermion &ch) + { + Grid::QCD::SpinColourVector F; + Grid::Complex c; + + QDP::Fermion cF; + QDP::SpinVector cS; + QDP::Complex cc; + + std::vector x(4); // explicit 4d fermions in Grid + QDP::multi1d cx(4); + std::vector gd = gr._grid->GlobalDimensions(); + + for (x[0] = 0; x[0] < gd[0]; x[0]++) + { + for (x[1] = 0; x[1] < gd[1]; x[1]++) + { + for (x[2] = 0; x[2] < gd[2]; x[2]++) + { + for (x[3] = 0; x[3] < gd[3]; x[3]++) + { + cx[0] = x[0]; + cx[1] = x[1]; + cx[2] = x[2]; + cx[3] = x[3]; + + Grid::peekSite(F, gr, x); + + for (int j = 0; j < 3; j++) + { + for (int sp = 0; sp < 4; sp++) + { + + c = F()(sp)(j); + + cc = QDP::cmplx(QDP::Real(real(c)), QDP::Real(imag(c))); + + QDP::pokeSpin(cS, cc, sp); + } + QDP::pokeColor(cF, cS, j); + } + QDP::pokeSite(ch, cF, cx); + } + } + } + } + } + + // Specific for 4d Wilson fermions + static void ExportFermion(Grid::QCD::LatticeFermion &gr, + QDP::LatticeFermion &ch) + { + Grid::QCD::SpinColourVector F; + Grid::Complex c; + + QDP::Fermion cF; + QDP::SpinVector cS; + QDP::Complex cc; + + std::vector x(4); // 4d fermions + QDP::multi1d cx(4); + std::vector gd = gr._grid->GlobalDimensions(); + + for (x[0] = 0; x[0] < gd[0]; x[0]++) + { + for (x[1] = 0; x[1] < gd[1]; x[1]++) + { + for (x[2] = 0; x[2] < gd[2]; x[2]++) + { + for (x[3] = 0; x[3] < gd[3]; x[3]++) + { + cx[0] = x[0]; + cx[1] = x[1]; + cx[2] = x[2]; + cx[3] = x[3]; + + cF = QDP::peekSite(ch, cx); + for (int sp = 0; sp < 4; sp++) + { + for (int j = 0; j < 3; j++) + { + cS = QDP::peekColor(cF, j); + cc = QDP::peekSpin(cS, sp); + c = Grid::Complex(QDP::toDouble(QDP::real(cc)), + QDP::toDouble(QDP::imag(cc))); + F() + (sp)(j) = c; + } + } + Grid::pokeSite(F, gr, x); + } + } + } + } + } + + static Handle> GetLinOp(U &u, ChromaAction params) + { + QDP::Real _mq(mq); + QDP::multi1d bcs(QDP::Nd); + + // Boundary conditions + bcs[0] = bcs[1] = bcs[2] = bcs[3] = 1; + + if (params == Wilson) + { + + Chroma::WilsonFermActParams p; + p.Mass = _mq; + + Chroma::Handle> fbc(new Chroma::SimpleFermBC(bcs)); + Chroma::Handle> cfs(new Chroma::CreateSimpleFermState(fbc)); + Chroma::UnprecWilsonFermAct S_f(cfs, p); + Chroma::Handle> ffs(S_f.createState(u)); + return S_f.linOp(ffs); + } + + if (params == WilsonClover) + { + Chroma::CloverFermActParams p; + p.Mass = _mq; + p.clovCoeffR = QDP::Real(1.0); + p.clovCoeffT = QDP::Real(1.0); + Real u0 = QDP::Real(0.0); + + + Chroma::Handle> fbc(new Chroma::SimpleFermBC(bcs)); + Chroma::Handle> cfs(new Chroma::CreateSimpleFermState(fbc)); + Chroma::UnprecCloverFermAct S_f(cfs, p); + Chroma::Handle> ffs(S_f.createState(u)); + return S_f.linOp(ffs); + } + } +}; +} // namespace Chroma + +int main(int argc, char **argv) +{ + + /******************************************************** + * Setup QDP + *********************************************************/ + Chroma::initialize(&argc, &argv); + Chroma::WilsonTypeFermActs4DEnv::registerAll(); + + /******************************************************** + * Setup Grid + *********************************************************/ + Grid::Grid_init(&argc, &argv); + Grid::GridCartesian *UGrid = Grid::QCD::SpaceTimeGrid::makeFourDimGrid(Grid::GridDefaultLatt(), + Grid::GridDefaultSimd(Grid::QCD::Nd, Grid::vComplex::Nsimd()), + Grid::GridDefaultMpi()); + + std::vector gd = UGrid->GlobalDimensions(); + QDP::multi1d nrow(QDP::Nd); + for (int mu = 0; mu < 4; mu++) + nrow[mu] = gd[mu]; + + QDP::Layout::setLattSize(nrow); + QDP::Layout::create(); + + GaugeField Ug(UGrid); + FermionField src(UGrid); + FermionField res_chroma(UGrid); + FermionField res_grid(UGrid); + + std::vector ActionList({Wilson, WilsonClover}); + std::vector ActionName({"Wilson", "WilsonClover"}); + + { + + for (int i = 0; i < ActionList.size(); i++) + { + std::cout << "*****************************" << std::endl; + std::cout << "Action " << ActionName[i] << std::endl; + std::cout << "*****************************" << std::endl; + make_gauge(Ug, src); // fills the gauge field and the fermion field with random numbers + + for (int dag = 0; dag < 2; dag++) + { + + { + + std::cout << "Dag = " << dag << std::endl; + + calc_chroma(ActionList[i], Ug, src, res_chroma, dag); + + // Remove the normalisation of Chroma Gauge links ???????? + std::cout << "Norm of Chroma " << ActionName[i] << " multiply " << Grid::norm2(res_chroma) << std::endl; + calc_grid(ActionList[i], Ug, src, res_grid, dag); + + std::cout << "Norm of gauge " << Grid::norm2(Ug) << std::endl; + + std::cout << "Norm of Grid " << ActionName[i] << " multiply " << Grid::norm2(res_grid) << std::endl; + + res_chroma = res_chroma - res_grid; + std::cout << "Norm of difference " << Grid::norm2(res_chroma) << std::endl; + } + } + + std::cout << "Finished test " << std::endl; + + Chroma::finalize(); + } + } +} + + +void calc_chroma(ChromaAction action, GaugeField &lat, FermionField &src, FermionField &res, int dag) +{ + QDP::multi1d u(4); + Chroma::ChromaWrapper::ImportGauge(lat, u); + + QDP::LatticeFermion check; + QDP::LatticeFermion result; + QDP::LatticeFermion psi; + + Chroma::ChromaWrapper::ImportFermion(src, psi); + + for (int mu = 0; mu < 4; mu++) + { + std::cout << "Imported Gauge norm [" << mu << "] " << QDP::norm2(u[mu]) << std::endl; + } + std::cout << "Imported Fermion norm " << QDP::norm2(psi) << std::endl; + + typedef QDP::LatticeFermion T; + typedef QDP::multi1d U; + + auto linop = Chroma::ChromaWrapper::GetLinOp(u, action); + + printf("Calling Chroma Linop\n"); + fflush(stdout); + + if (dag) + (*linop)(check, psi, Chroma::MINUS); + else + (*linop)(check, psi, Chroma::PLUS); + + printf("Called Chroma Linop\n"); + fflush(stdout); + + // std::cout << "Calling Chroma Linop " << std::endl; + // linop->evenEvenLinOp(tmp, psi, isign); + // check[rb[0]] = tmp; + // linop->oddOddLinOp(tmp, psi, isign); + // check[rb[1]] = tmp; + // linop->evenOddLinOp(tmp, psi, isign); + // check[rb[0]] += tmp; + // linop->oddEvenLinOp(tmp, psi, isign); + // check[rb[1]] += tmp; + + Chroma::ChromaWrapper::ExportFermion(res, check); +} + +void make_gauge(GaugeField &Umu, FermionField &src) +{ + using namespace Grid; + using namespace Grid::QCD; + + std::vector seeds4({1, 2, 3, 4}); + + Grid::GridCartesian *UGrid = (Grid::GridCartesian *)Umu._grid; + Grid::GridParallelRNG RNG4(UGrid); + RNG4.SeedFixedIntegers(seeds4); + Grid::QCD::SU3::HotConfiguration(RNG4, Umu); + Grid::gaussian(RNG4, src); +} + +void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD::LatticeFermion &src, Grid::QCD::LatticeFermion &res, int dag) +{ + using namespace Grid; + using namespace Grid::QCD; + + Grid::GridCartesian *UGrid = (Grid::GridCartesian *)Umu._grid; + Grid::GridRedBlackCartesian *UrbGrid = Grid::QCD::SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); + + Grid::RealD _mass = mq; + + if (action == Wilson) + { + + Grid::QCD::WilsonFermionR Wf(Umu, *UGrid, *UrbGrid, _mass); + + std::cout << Grid::GridLogMessage << " Calling Grid Wilson Fermion multiply " << std::endl; + + if (dag) + Wf.Mdag(src, res); + else + Wf.M(src, res); + return; + } + + if (action == WilsonClover) + { + Grid::RealD _csw = 1.0; + + Grid::QCD::WilsonCloverFermionR Wf(Umu, *UGrid, *UrbGrid, _mass, _csw); + Wf.ImportGauge(Umu); + + std::cout << Grid::GridLogMessage << " Calling Grid Wilson Clover Fermion multiply " << std::endl; + + if (dag) + Wf.Mdag(src, res); + else + Wf.M(src, res); + return; + } + + assert(0); +} From 031c94e02e0644701f4eb2337a2dd684615f29c0 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 23 Oct 2017 18:27:34 +0100 Subject: [PATCH 20/43] Debugging process for the clover term --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 11 ++-- lib/qcd/action/fermion/WilsonCloverFermion.h | 24 ++++----- tests/qdpxx/Test_qdpxx_wilson.cc | 52 +++++++++++++++++-- 3 files changed, 65 insertions(+), 22 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 7f58f277..5e7e0034 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -71,10 +71,10 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) GridBase *grid = _Umu._grid; typename Impl::GaugeLinkField Bx(grid), By(grid), Bz(grid), Ex(grid), Ey(grid), Ez(grid); - // Compute the field strength terms - WilsonLoops::FieldStrength(Bx, _Umu, Ydir, Zdir); + // Compute the field strength terms mu>nu + WilsonLoops::FieldStrength(Bx, _Umu, Zdir, Ydir); WilsonLoops::FieldStrength(By, _Umu, Zdir, Xdir); - WilsonLoops::FieldStrength(Bz, _Umu, Xdir, Ydir); + WilsonLoops::FieldStrength(Bz, _Umu, Ydir, Xdir); WilsonLoops::FieldStrength(Ex, _Umu, Tdir, Xdir); WilsonLoops::FieldStrength(Ey, _Umu, Tdir, Ydir); WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); @@ -86,7 +86,7 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) CloverTerm += fillCloverXT(Ex); CloverTerm += fillCloverYT(Ey); CloverTerm += fillCloverZT(Ez); - CloverTerm *= 0.5 * csw; // FieldStrength normalization? should be ( -i/8 ). Is it the anti-symmetric combination? + CloverTerm *= (0.5) * csw; int lvol = _Umu._grid->lSites(); @@ -232,7 +232,8 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie out = *Clover * in; } else { Clover = (inv) ? &CloverTermInv : &CloverTerm; - out = adj(*Clover) * in; + //out = adj(*Clover) * in; + out = adj(CloverTerm) * in; } diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index 7840af90..18386485 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -156,10 +156,10 @@ private: PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { - T._odata[i]()(0, 1) = timesI(F._odata[i]()()); //fixed - T._odata[i]()(1, 0) = timesI(F._odata[i]()()); //fixed - T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()()); //fixed - T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()()); //fixed + 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]()()); } return T; @@ -172,10 +172,10 @@ private: PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { - T._odata[i]()(0, 1) = -(F._odata[i]()()); //fixed - T._odata[i]()(1, 0) = (F._odata[i]()()); //fixed - T._odata[i]()(2, 3) = (F._odata[i]()()); //fixed - T._odata[i]()(3, 2) = -(F._odata[i]()()); //fixed + 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]()()); } return T; @@ -188,10 +188,10 @@ private: PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { - T._odata[i]()(0, 0) = timesI(F._odata[i]()()); //fixed - T._odata[i]()(1, 1) = timesMinusI(F._odata[i]()()); //fixed - T._odata[i]()(2, 2) = timesMinusI(F._odata[i]()()); //fixed - T._odata[i]()(3, 3) = timesI(F._odata[i]()()); //fixed + 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]()()); } return T; diff --git a/tests/qdpxx/Test_qdpxx_wilson.cc b/tests/qdpxx/Test_qdpxx_wilson.cc index 70a8b1bf..1e1f6a23 100644 --- a/tests/qdpxx/Test_qdpxx_wilson.cc +++ b/tests/qdpxx/Test_qdpxx_wilson.cc @@ -29,7 +29,7 @@ #include // Mass -double mq = 0.1; +double mq = 0.0; // Define Wilson Types typedef Grid::QCD::WilsonImplR::FermionField FermionField; @@ -274,7 +274,7 @@ public: p.Mass = _mq; p.clovCoeffR = QDP::Real(1.0); p.clovCoeffT = QDP::Real(1.0); - Real u0 = QDP::Real(0.0); + Real u0 = QDP::Real(1.0); Chroma::Handle> fbc(new Chroma::SimpleFermBC(bcs)); @@ -316,6 +316,8 @@ int main(int argc, char **argv) FermionField src(UGrid); FermionField res_chroma(UGrid); FermionField res_grid(UGrid); + FermionField only_wilson(UGrid); + FermionField difference(UGrid); std::vector ActionList({Wilson, WilsonClover}); std::vector ActionName({"Wilson", "WilsonClover"}); @@ -346,8 +348,19 @@ int main(int argc, char **argv) std::cout << "Norm of Grid " << ActionName[i] << " multiply " << Grid::norm2(res_grid) << std::endl; - res_chroma = res_chroma - res_grid; - std::cout << "Norm of difference " << Grid::norm2(res_chroma) << std::endl; + difference = res_chroma - res_grid; + std::cout << "Norm of difference " << Grid::norm2(difference) << std::endl; + + // Isolate Clover term + calc_grid(Wilson, Ug, src, only_wilson, dag);// Wilson term + res_grid -= only_wilson; + res_chroma -= only_wilson; + + std::cout << "Chroma:" << res_chroma << std::endl; + std::cout << "Grid :" << res_grid << std::endl; + + + } } @@ -416,7 +429,36 @@ void make_gauge(GaugeField &Umu, FermionField &src) Grid::GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); Grid::QCD::SU3::HotConfiguration(RNG4, Umu); - Grid::gaussian(RNG4, src); + + // Fermion field + //Grid::gaussian(RNG4, src); + Grid::QCD::SpinColourVector F; + Grid::Complex c; + + std::vector x(4); // 4d fermions + std::vector gd = src._grid->GlobalDimensions(); + + for (x[0] = 0; x[0] < gd[0]; x[0]++) + { + for (x[1] = 0; x[1] < gd[1]; x[1]++) + { + for (x[2] = 0; x[2] < gd[2]; x[2]++) + { + for (x[3] = 0; x[3] < gd[3]; x[3]++) + { + for (int sp = 0; sp < 1; sp++) + { + for (int j = 1; j < 2; j++)// colours + { + c = Grid::Complex(1.0, 0.0); + F()(sp)(j) = c; + } + } + Grid::pokeSite(F, src, x); + } + } + } + } } void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD::LatticeFermion &src, Grid::QCD::LatticeFermion &res, int dag) From 6579dd30ff6fd12378c0386d2ca317980586faff Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Mon, 23 Oct 2017 18:47:00 +0100 Subject: [PATCH 21/43] More debug test --- tests/qdpxx/Test_qdpxx_wilson.cc | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/qdpxx/Test_qdpxx_wilson.cc b/tests/qdpxx/Test_qdpxx_wilson.cc index 1e1f6a23..8046c00d 100644 --- a/tests/qdpxx/Test_qdpxx_wilson.cc +++ b/tests/qdpxx/Test_qdpxx_wilson.cc @@ -276,7 +276,6 @@ public: p.clovCoeffT = QDP::Real(1.0); Real u0 = QDP::Real(1.0); - Chroma::Handle> fbc(new Chroma::SimpleFermBC(bcs)); Chroma::Handle> cfs(new Chroma::CreateSimpleFermState(fbc)); Chroma::UnprecCloverFermAct S_f(cfs, p); @@ -350,17 +349,16 @@ int main(int argc, char **argv) difference = res_chroma - res_grid; std::cout << "Norm of difference " << Grid::norm2(difference) << std::endl; - + // Isolate Clover term - calc_grid(Wilson, Ug, src, only_wilson, dag);// Wilson term + calc_grid(Wilson, Ug, src, only_wilson, dag); // Wilson term res_grid -= only_wilson; res_chroma -= only_wilson; - + std::cout << "Chroma:" << res_chroma << std::endl; std::cout << "Grid :" << res_grid << std::endl; - - - + difference = (res_grid-res_chroma); + std::cout << "Difference :" << difference << std::endl; } } @@ -371,7 +369,6 @@ int main(int argc, char **argv) } } - void calc_chroma(ChromaAction action, GaugeField &lat, FermionField &src, FermionField &res, int dag) { QDP::multi1d u(4); @@ -429,12 +426,14 @@ void make_gauge(GaugeField &Umu, FermionField &src) Grid::GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); Grid::QCD::SU3::HotConfiguration(RNG4, Umu); - + // Fermion field //Grid::gaussian(RNG4, src); Grid::QCD::SpinColourVector F; Grid::Complex c; + + std::vector x(4); // 4d fermions std::vector gd = src._grid->GlobalDimensions(); @@ -446,15 +445,20 @@ void make_gauge(GaugeField &Umu, FermionField &src) { for (x[3] = 0; x[3] < gd[3]; x[3]++) { - for (int sp = 0; sp < 1; sp++) + for (int sp = 0; sp < 4; sp++) { - for (int j = 1; j < 2; j++)// colours + for (int j = 0; j < 3; j++) // colours { - c = Grid::Complex(1.0, 0.0); - F()(sp)(j) = c; + F()(sp)(j) = Grid::Complex(0.0,0.0); + if (((sp == 0)|| (sp==3)) && (j==0)) + { + c = Grid::Complex(1.0, 0.0); + F()(sp)(j) = c; + } } } Grid::pokeSite(F, src, x); + } } } From cbda4f66e0cdfdcd1405cf6b1c20a8ea55e976ad Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Tue, 24 Oct 2017 10:20:13 +0100 Subject: [PATCH 22/43] Debug of the field strength --- lib/qcd/utils/WilsonLoops.h | 4 +++- tests/qdpxx/Test_qdpxx_wilson.cc | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index ff49cf4e..fe813298 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -337,7 +337,9 @@ static void StapleMult(GaugeMat &staple, const GaugeLorentz &Umu, int mu) { GaugeMat v = Vup - Vdn; GaugeMat u = PeekIndex(Umu, mu); // some redundant copies GaugeMat vu = v*u; - FS = 0.25*Ta(u*v + Cshift(vu, mu, -1)); + //FS = 0.25*Ta(u*v + Cshift(vu, mu, -1)); + FS = (u*v + Cshift(vu, mu, -1)); + FS = 0.125*(FS - adj(FS)); } static Real TopologicalCharge(GaugeLorentz &U){ diff --git a/tests/qdpxx/Test_qdpxx_wilson.cc b/tests/qdpxx/Test_qdpxx_wilson.cc index 8046c00d..7e2b3f7e 100644 --- a/tests/qdpxx/Test_qdpxx_wilson.cc +++ b/tests/qdpxx/Test_qdpxx_wilson.cc @@ -351,6 +351,7 @@ int main(int argc, char **argv) std::cout << "Norm of difference " << Grid::norm2(difference) << std::endl; // Isolate Clover term + /* calc_grid(Wilson, Ug, src, only_wilson, dag); // Wilson term res_grid -= only_wilson; res_chroma -= only_wilson; @@ -359,6 +360,7 @@ int main(int argc, char **argv) std::cout << "Grid :" << res_grid << std::endl; difference = (res_grid-res_chroma); std::cout << "Difference :" << difference << std::endl; + */ } } @@ -428,7 +430,8 @@ void make_gauge(GaugeField &Umu, FermionField &src) Grid::QCD::SU3::HotConfiguration(RNG4, Umu); // Fermion field - //Grid::gaussian(RNG4, src); + Grid::gaussian(RNG4, src); + /* Grid::QCD::SpinColourVector F; Grid::Complex c; @@ -450,7 +453,7 @@ void make_gauge(GaugeField &Umu, FermionField &src) for (int j = 0; j < 3; j++) // colours { F()(sp)(j) = Grid::Complex(0.0,0.0); - if (((sp == 0)|| (sp==3)) && (j==0)) + if (((sp == 0)|| (sp==3)) && (j==2)) { c = Grid::Complex(1.0, 0.0); F()(sp)(j) = c; @@ -463,6 +466,8 @@ void make_gauge(GaugeField &Umu, FermionField &src) } } } + */ + } void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD::LatticeFermion &src, Grid::QCD::LatticeFermion &res, int dag) From ec8cd11c1f7fce1c3deee79977745ba4f6c9776c Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Tue, 24 Oct 2017 13:21:17 +0100 Subject: [PATCH 23/43] Cleanup and prepare for pull request --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 279 ++++++++---------- lib/qcd/action/fermion/WilsonCloverFermion.h | 104 +++---- tests/core/Test_wilson_clover.cc | 10 +- tests/qdpxx/Test_qdpxx_wilson.cc | 172 +++++------ 4 files changed, 258 insertions(+), 307 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 5e7e0034..73e2bf69 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -39,29 +39,33 @@ namespace QCD template RealD WilsonCloverFermion::M(const FermionField &in, FermionField &out) { + FermionField temp(out._grid); + // Wilson term out.checkerboard = in.checkerboard; this->Dhop(in, out, DaggerNo); + // Clover term - // apply the sigma and Fmunu - FermionField temp(out._grid); Mooee(in, temp); + out += temp; - return axpy_norm(out, 4 + this->mass, in, out); + return norm2(out); } template RealD WilsonCloverFermion::Mdag(const FermionField &in, FermionField &out) { + FermionField temp(out._grid); + // Wilson term out.checkerboard = in.checkerboard; this->Dhop(in, out, DaggerYes); + // Clover term - // apply the sigma and Fmunu - FermionField temp(out._grid); MooeeDag(in, temp); - out+=temp; - return axpy_norm(out, 4 + this->mass, in, out); + + out += temp; + return norm2(out); } template @@ -80,14 +84,14 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); // Compute the Clover Operator acting on Colour and Spin - CloverTerm = fillCloverYZ(Bx); + CloverTerm = fillCloverYZ(Bx); CloverTerm += fillCloverXZ(By); CloverTerm += fillCloverXY(Bz); CloverTerm += fillCloverXT(Ex); CloverTerm += fillCloverYT(Ey); CloverTerm += fillCloverZT(Ez); - CloverTerm *= (0.5) * csw; - + CloverTerm *= (0.5) * csw; + CloverTerm += (4.0 + this->mass); int lvol = _Umu._grid->lSites(); int DimRep = Impl::Dimension; @@ -98,21 +102,20 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) std::vector 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; -//if (csw!=0){ + //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); - // if (site==0) std::cout << "site =" << site << "\n" << EigenCloverOp << std::endl; - + // if (site==0) std::cout << "site =" << site << "\n" << EigenCloverOp << std::endl; + EigenInvCloverOp = EigenCloverOp.inverse(); //std::cout << EigenInvCloverOp << std::endl; for (int j = 0; j < Ns; j++) @@ -120,35 +123,29 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) 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); - // if (site==0) std::cout << "site =" << site << "\n" << EigenInvCloverOp << std::endl; -// } + // if (site==0) std::cout << "site =" << site << "\n" << EigenInvCloverOp << std::endl; + // } pokeLocalSite(Qxinv, CloverTermInv, lcoor); - } - + } - - // Separate the even and odd parts. + // Separate the even and odd parts pickCheckerboard(Even, CloverTermEven, CloverTerm); - pickCheckerboard( Odd, CloverTermOdd, CloverTerm); - + pickCheckerboard(Odd, CloverTermOdd, CloverTerm); pickCheckerboard(Even, CloverTermDagEven, adj(CloverTerm)); - pickCheckerboard( Odd, CloverTermDagOdd, adj(CloverTerm)); - + pickCheckerboard(Odd, CloverTermDagOdd, adj(CloverTerm)); pickCheckerboard(Even, CloverTermInvEven, CloverTermInv); - pickCheckerboard( Odd, CloverTermInvOdd, CloverTermInv); - + pickCheckerboard(Odd, CloverTermInvOdd, CloverTermInv); pickCheckerboard(Even, CloverTermInvDagEven, adj(CloverTermInv)); - pickCheckerboard( Odd, CloverTermInvDagOdd, adj(CloverTermInv)); - + pickCheckerboard(Odd, CloverTermInvDagOdd, adj(CloverTermInv)); } template void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) { - conformable(in,out); + conformable(in, out); this->MooeeInternal(in, out, DaggerNo, InverseNo); } @@ -177,85 +174,50 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie CloverFieldType *Clover; assert(in.checkerboard == Odd || in.checkerboard == Even); - - - - if (dag){ - if (in._grid->_isCheckerBoarded){ - if (in.checkerboard == Odd){ -// std::cout << "Calling clover term adj Odd" << std::endl; - Clover = (inv) ? &CloverTermInvDagOdd : &CloverTermDagOdd; - -/* test - int DimRep = Impl::Dimension; - Eigen::MatrixXcd A = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep); - std::vector lcoor; - typename SiteCloverType::scalar_object Qx2 = zero; - GridBase *grid = in._grid; - int site = 0 ; - grid->LocalIndexToLocalCoor(site, lcoor); - peekLocalSite(Qx2, *Clover, lcoor); - 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++) - A(a + j * DimRep, b + k * DimRep) = Qx2()(j, k)(a, b); - std::cout << "adj Odd =" << site << "\n" << A << std::endl; - end test */ - - - - } else { -// std::cout << "Calling clover term adj Even" << std::endl; - Clover = (inv) ? &CloverTermInvDagEven : &CloverTermDagEven; - -/* test - int DimRep = Impl::Dimension; - Eigen::MatrixXcd A = Eigen::MatrixXcd::Zero(Ns * DimRep, Ns * DimRep); - std::vector lcoor; - typename SiteCloverType::scalar_object Qx2 = zero; - GridBase *grid = in._grid; - int site = 0 ; - grid->LocalIndexToLocalCoor(site, lcoor); - peekLocalSite(Qx2, *Clover, lcoor); - 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++) - A(a + j * DimRep, b + k * DimRep) = Qx2()(j, k)(a, b); - std::cout << "adj Odd =" << site << "\n" << A << std::endl; - end test */ - - + if (dag) + { + if (in._grid->_isCheckerBoarded) + { + if (in.checkerboard == Odd) + { + Clover = (inv) ? &CloverTermInvDagOdd : &CloverTermDagOdd; + } + else + { + Clover = (inv) ? &CloverTermInvDagEven : &CloverTermDagEven; + } + out = *Clover * in; + } + else + { + Clover = (inv) ? &CloverTermInv : &CloverTerm; + out = adj(*Clover) * in; } - // std::cout << GridLogMessage << "*Clover.checkerboard " << (*Clover).checkerboard << std::endl; - out = *Clover * in; - } else { - Clover = (inv) ? &CloverTermInv : &CloverTerm; - //out = adj(*Clover) * in; - out = adj(CloverTerm) * in; } + else + { + if (in._grid->_isCheckerBoarded) + { - - - - } else { - if (in._grid->_isCheckerBoarded){ - - 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; + 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; + } } - } } // MooeeInternal @@ -264,7 +226,6 @@ template void WilsonCloverFermion::MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) { - GaugeField tmp(mat._grid); conformable(U._grid, V._grid); @@ -282,30 +243,37 @@ void WilsonCloverFermion::MDeriv(GaugeField &mat, const FermionField &U, c template void WilsonCloverFermion::MooDeriv(GaugeField &mat, const FermionField &X, const FermionField &Y, int dag) { - -GridBase *grid = mat._grid; -//GaugeLinkField Lambdaodd(grid), Lambdaeven(grid), tmp(grid); -//Lambdaodd = zero; //Yodd*dag(Xodd)+Xodd*dag(Yodd); // I have to peek spin and decide the color structure -//Lambdaeven = zero; //Teven*dag(Xeven)+Xeven*dag(Yeven) + 2*(Dee^-1) + GridBase *grid = mat._grid; -GaugeLinkField Lambda(grid), tmp(grid); -Lambda=zero; + //GaugeLinkField Lambdaodd(grid), Lambdaeven(grid), tmp(grid); + //Lambdaodd = zero; //Yodd*dag(Xodd)+Xodd*dag(Yodd); // I have to peek spin and decide the color structure + //Lambdaeven = zero; //Teven*dag(Xeven)+Xeven*dag(Yeven) + 2*(Dee^-1) -conformable(mat._grid, X._grid); -conformable(Y._grid, X._grid); + GaugeLinkField Lambda(grid), tmp(grid); + Lambda = zero; -std::vector C1p(Nd,grid), C2p(Nd,grid), C3p(Nd,grid), C4p(Nd,grid); -std::vector C1m(Nd,grid), C2m(Nd,grid), C3m(Nd,grid), C4m(Nd,grid); -std::vector U(Nd, mat._grid); + conformable(mat._grid, X._grid); + conformable(Y._grid, X._grid); -for (int mu = 0; mu < Nd; mu++) { - U[mu] = PeekIndex(mat, mu); - C1p[mu]=zero; C2p[mu]=zero; C3p[mu]=zero; C4p[mu]=zero; - C1m[mu]=zero; C2m[mu]=zero; C3m[mu]=zero; C4m[mu]=zero; -} + std::vector C1p(Nd, grid), C2p(Nd, grid), C3p(Nd, grid), C4p(Nd, grid); + std::vector C1m(Nd, grid), C2m(Nd, grid), C3m(Nd, grid), C4m(Nd, grid); + std::vector U(Nd, mat._grid); -/* + for (int mu = 0; mu < Nd; mu++) + { + U[mu] = PeekIndex(mat, mu); + C1p[mu] = zero; + C2p[mu] = zero; + C3p[mu] = zero; + C4p[mu] = zero; + C1m[mu] = zero; + C2m[mu] = zero; + C3m[mu] = zero; + C4m[mu] = zero; + } + + /* PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { @@ -314,50 +282,49 @@ for (int mu = 0; mu < Nd; mu++) { T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()()); T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()()); } -*/ +*/ -for (int i=0;i<4;i++){ //spin - for(int j=0;j<4;j++){ //spin + for (int i = 0; i < 4; i++) + { //spin + for (int j = 0; j < 4; j++) + { //spin -for (int mu=0;mu<4;mu++){ //color - for (int nu=0;nu<4;nu++){ //color + for (int mu = 0; mu < 4; mu++) + { //color + for (int nu = 0; nu < 4; nu++) + { //color -// insertion in upper staple - tmp = Lambda * U[nu]; - C1p[mu]+=Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); + // insertion in upper staple + tmp = Lambda * U[nu]; + C1p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - tmp = Lambda * U[mu]; - C2p[mu]+= Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); + tmp = Lambda * U[mu]; + C2p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu]; - C3p[mu]+= Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu); - - tmp = Lambda; - C4p[mu]+= Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))),mu) * tmp; + tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu]; + C3p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu); -// insertion in lower staple - tmp = Lambda * U[nu]; - C1m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu); + tmp = Lambda; + C4p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu) * tmp; - tmp = Lambda * U[mu]; - C2m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, U[nu])), mu); + // insertion in lower staple + tmp = Lambda * U[nu]; + C1m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu); - tmp = Lambda * U[nu]; - C3m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu); + tmp = Lambda * U[mu]; + C2m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, U[nu])), mu); - tmp = Lambda; - C4m[mu]+= Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu)* tmp; + tmp = Lambda * U[nu]; + C3m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu); + + tmp = Lambda; + C4m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu) * tmp; + } + } + } } -} - -} -} - -//Still implementing. Have to be tested, and understood how to project EO - - - + //Still implementing. Have to be tested, and understood how to project EO } // Derivative parts diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index 18386485..34482941 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -26,6 +26,7 @@ See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ + #ifndef GRID_QCD_WILSON_CLOVER_FERMION_H #define GRID_QCD_WILSON_CLOVER_FERMION_H @@ -42,9 +43,11 @@ class WilsonCloverFermion : public WilsonFermion public: // Types definitions INHERIT_IMPL_TYPES(Impl); - template using iImplClover = iScalar, Ns> >; - typedef iImplClover SiteCloverType; - typedef Lattice CloverFieldType; + template + using iImplClover = iScalar, Ns>>; + typedef iImplClover SiteCloverType; + typedef Lattice CloverFieldType; + public: typedef WilsonFermion WilsonBase; @@ -58,19 +61,21 @@ public: Fgrid, Hgrid, _mass, p), - CloverTerm(&Fgrid), - CloverTermInv(&Fgrid), - CloverTermEven(&Hgrid), - CloverTermOdd(&Hgrid), - CloverTermInvEven(&Hgrid), - CloverTermInvOdd(&Hgrid), - CloverTermDagEven(&Hgrid), //test - CloverTermDagOdd(&Hgrid), //test - CloverTermInvDagEven(&Hgrid), //test - CloverTermInvDagOdd(&Hgrid) //test + CloverTerm(&Fgrid), + CloverTermInv(&Fgrid), + CloverTermEven(&Hgrid), + CloverTermOdd(&Hgrid), + CloverTermInvEven(&Hgrid), + CloverTermInvOdd(&Hgrid), + CloverTermDagEven(&Hgrid), + CloverTermDagOdd(&Hgrid), + CloverTermInvDagEven(&Hgrid), + CloverTermInvDagOdd(&Hgrid) { csw = _csw; assert(Nd == 4); // require 4 dimensions + + if (csw == 0) std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw = 0" << std::endl; } virtual RealD M(const FermionField &in, FermionField &out); @@ -91,12 +96,12 @@ public: private: // here fixing the 4 dimensions, make it more general? - RealD csw; // Clover coefficient - CloverFieldType CloverTerm=zero, CloverTermInv=zero; // Clover term - CloverFieldType CloverTermEven=zero, CloverTermOdd=zero; // Clover term EO - CloverFieldType CloverTermInvEven=zero, CloverTermInvOdd=zero; // Clover term Inv EO - CloverFieldType CloverTermDagEven=zero, CloverTermDagOdd=zero; // Clover term Dag EO - CloverFieldType CloverTermInvDagEven=zero, CloverTermInvDagOdd=zero; // Clover term Inv Dag EO + RealD csw; // Clover coefficient + 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 // eventually these two can be compressed into 6x6 blocks instead of the 12x12 // using the DeGrand-Rossi basis for the gamma matrices @@ -113,9 +118,9 @@ private: T._odata[i]()(2, 3) = timesMinusI(F._odata[i]()()); T._odata[i]()(3, 2) = timesMinusI(F._odata[i]()()); } - - return T; -} + + return T; + } CloverFieldType fillCloverXZ(const GaugeLinkField &F) { @@ -129,9 +134,9 @@ private: T._odata[i]()(2, 3) = -F._odata[i]()(); T._odata[i]()(3, 2) = F._odata[i]()(); } - - return T; -} + + return T; + } CloverFieldType fillCloverXY(const GaugeLinkField &F) { @@ -145,9 +150,9 @@ private: T._odata[i]()(2, 2) = timesMinusI(F._odata[i]()()); T._odata[i]()(3, 3) = timesI(F._odata[i]()()); } - - return T; -} + + return T; + } CloverFieldType fillCloverXT(const GaugeLinkField &F) { @@ -156,14 +161,14 @@ private: PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { - 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]()()); + 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]()()); } - - return T; -} + + return T; + } CloverFieldType fillCloverYT(const GaugeLinkField &F) { @@ -172,14 +177,14 @@ private: 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]()()); + 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]()()); } - - return T; -} + + return T; + } CloverFieldType fillCloverZT(const GaugeLinkField &F) { @@ -188,17 +193,16 @@ private: PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { - 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]()()); + 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]()()); } - - return T; -} + return T; + } }; } } -#endif // GRID_QCD_WILSON_CLOVER_FERMION_H +#endif // GRID_QCD_WILSON_CLOVER_FERMION_H diff --git a/tests/core/Test_wilson_clover.cc b/tests/core/Test_wilson_clover.cc index 9a5fffe2..9a55f6b2 100644 --- a/tests/core/Test_wilson_clover.cc +++ b/tests/core/Test_wilson_clover.cc @@ -237,7 +237,7 @@ int main (int argc, char ** argv) setCheckerboard(src,src_o); - //Gauge Transformation + ////////////////////// Gauge Transformation std::vector seeds2({5,6,7,8}); GridParallelRNG pRNG2(&Grid); pRNG2.SeedFixedIntegers(seeds2); LatticeColourMatrix Omega(&Grid); @@ -251,7 +251,7 @@ int main (int argc, char ** argv) U_prime_mu=Omega*U[mu]*adj(ShiftedOmega); pokeLorentz(U_prime,U_prime_mu,mu); } - + ///////////////// WilsonCloverFermionR Dwc_prime(U_prime,Grid,RBGrid,mass,csw,params); Dwc_prime.ImportGauge(U_prime); @@ -298,7 +298,7 @@ int main (int argc, char ** argv) std::cout< +#include +#include +#include // Mass -double mq = 0.0; +double mq = 0.01; // Define Wilson Types typedef Grid::QCD::WilsonImplR::FermionField FermionField; typedef Grid::QCD::LatticeGaugeField GaugeField; -#include -#include -#include - enum ChromaAction { Wilson, // Wilson WilsonClover // CloverFermions }; -void make_gauge(GaugeField &lat, FermionField &src); -void calc_grid(ChromaAction CA, GaugeField &lat, FermionField &src, FermionField &res, int dag); -void calc_chroma(ChromaAction CA, GaugeField &lat, FermionField &src, FermionField &res, int dag); - namespace Chroma { @@ -286,91 +281,6 @@ public: }; } // namespace Chroma -int main(int argc, char **argv) -{ - - /******************************************************** - * Setup QDP - *********************************************************/ - Chroma::initialize(&argc, &argv); - Chroma::WilsonTypeFermActs4DEnv::registerAll(); - - /******************************************************** - * Setup Grid - *********************************************************/ - Grid::Grid_init(&argc, &argv); - Grid::GridCartesian *UGrid = Grid::QCD::SpaceTimeGrid::makeFourDimGrid(Grid::GridDefaultLatt(), - Grid::GridDefaultSimd(Grid::QCD::Nd, Grid::vComplex::Nsimd()), - Grid::GridDefaultMpi()); - - std::vector gd = UGrid->GlobalDimensions(); - QDP::multi1d nrow(QDP::Nd); - for (int mu = 0; mu < 4; mu++) - nrow[mu] = gd[mu]; - - QDP::Layout::setLattSize(nrow); - QDP::Layout::create(); - - GaugeField Ug(UGrid); - FermionField src(UGrid); - FermionField res_chroma(UGrid); - FermionField res_grid(UGrid); - FermionField only_wilson(UGrid); - FermionField difference(UGrid); - - std::vector ActionList({Wilson, WilsonClover}); - std::vector ActionName({"Wilson", "WilsonClover"}); - - { - - for (int i = 0; i < ActionList.size(); i++) - { - std::cout << "*****************************" << std::endl; - std::cout << "Action " << ActionName[i] << std::endl; - std::cout << "*****************************" << std::endl; - make_gauge(Ug, src); // fills the gauge field and the fermion field with random numbers - - for (int dag = 0; dag < 2; dag++) - { - - { - - std::cout << "Dag = " << dag << std::endl; - - calc_chroma(ActionList[i], Ug, src, res_chroma, dag); - - // Remove the normalisation of Chroma Gauge links ???????? - std::cout << "Norm of Chroma " << ActionName[i] << " multiply " << Grid::norm2(res_chroma) << std::endl; - calc_grid(ActionList[i], Ug, src, res_grid, dag); - - std::cout << "Norm of gauge " << Grid::norm2(Ug) << std::endl; - - std::cout << "Norm of Grid " << ActionName[i] << " multiply " << Grid::norm2(res_grid) << std::endl; - - difference = res_chroma - res_grid; - std::cout << "Norm of difference " << Grid::norm2(difference) << std::endl; - - // Isolate Clover term - /* - calc_grid(Wilson, Ug, src, only_wilson, dag); // Wilson term - res_grid -= only_wilson; - res_chroma -= only_wilson; - - std::cout << "Chroma:" << res_chroma << std::endl; - std::cout << "Grid :" << res_grid << std::endl; - difference = (res_grid-res_chroma); - std::cout << "Difference :" << difference << std::endl; - */ - } - } - - std::cout << "Finished test " << std::endl; - - Chroma::finalize(); - } - } -} - void calc_chroma(ChromaAction action, GaugeField &lat, FermionField &src, FermionField &res, int dag) { QDP::multi1d u(4); @@ -467,7 +377,6 @@ void make_gauge(GaugeField &Umu, FermionField &src) } } */ - } void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD::LatticeFermion &src, Grid::QCD::LatticeFermion &res, int dag) @@ -512,3 +421,76 @@ void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD assert(0); } + +int main(int argc, char **argv) +{ + + /******************************************************** + * Setup QDP + *********************************************************/ + Chroma::initialize(&argc, &argv); + Chroma::WilsonTypeFermActs4DEnv::registerAll(); + + /******************************************************** + * Setup Grid + *********************************************************/ + Grid::Grid_init(&argc, &argv); + Grid::GridCartesian *UGrid = Grid::QCD::SpaceTimeGrid::makeFourDimGrid(Grid::GridDefaultLatt(), + Grid::GridDefaultSimd(Grid::QCD::Nd, Grid::vComplex::Nsimd()), + Grid::GridDefaultMpi()); + + std::vector gd = UGrid->GlobalDimensions(); + QDP::multi1d nrow(QDP::Nd); + for (int mu = 0; mu < 4; mu++) + nrow[mu] = gd[mu]; + + QDP::Layout::setLattSize(nrow); + QDP::Layout::create(); + + GaugeField Ug(UGrid); + FermionField src(UGrid); + FermionField res_chroma(UGrid); + FermionField res_grid(UGrid); + FermionField only_wilson(UGrid); + FermionField difference(UGrid); + + std::vector ActionList({Wilson, WilsonClover}); + std::vector ActionName({"Wilson", "WilsonClover"}); + + { + + for (int i = 0; i < ActionList.size(); i++) + { + std::cout << "*****************************" << std::endl; + std::cout << "Action " << ActionName[i] << std::endl; + std::cout << "*****************************" << std::endl; + make_gauge(Ug, src); // fills the gauge field and the fermion field with random numbers + + for (int dag = 0; dag < 2; dag++) + { + + { + + std::cout << "Dag = " << dag << std::endl; + + calc_chroma(ActionList[i], Ug, src, res_chroma, dag); + + // Remove the normalisation of Chroma Gauge links ???????? + std::cout << "Norm of Chroma " << ActionName[i] << " multiply " << Grid::norm2(res_chroma) << std::endl; + calc_grid(ActionList[i], Ug, src, res_grid, dag); + + std::cout << "Norm of gauge " << Grid::norm2(Ug) << std::endl; + + std::cout << "Norm of Grid " << ActionName[i] << " multiply " << Grid::norm2(res_grid) << std::endl; + + difference = res_chroma - res_grid; + std::cout << "Norm of difference " << Grid::norm2(difference) << std::endl; + } + } + + std::cout << "Finished test " << std::endl; + + Chroma::finalize(); + } + } +} From 657779374be6b8e02ce8eb6452316acc310fdf26 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Tue, 24 Oct 2017 13:27:17 +0100 Subject: [PATCH 24/43] Adding vscode to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6b92b1a4..8eccbc7d 100644 --- a/.gitignore +++ b/.gitignore @@ -123,5 +123,6 @@ make-bin-BUCK.sh lib/qcd/spin/gamma-gen/*.h lib/qcd/spin/gamma-gen/*.cc +.vscode/ .vscode/settings.json settings.json From 2986aa76f80f2857d846c0e48f508de8299052a3 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Tue, 24 Oct 2017 13:32:02 +0100 Subject: [PATCH 25/43] Restoring Perfcounts --- lib/perfmon/PerfCount.h | 3 +-- lib/perfmon/Stat.cc | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/perfmon/PerfCount.h b/lib/perfmon/PerfCount.h index cb27c283..73d2c70f 100644 --- a/lib/perfmon/PerfCount.h +++ b/lib/perfmon/PerfCount.h @@ -90,10 +90,9 @@ inline uint64_t cyclecount(void){ } #elif defined __x86_64__ inline uint64_t cyclecount(void){ - //return __rdtsc(); + return __rdtsc(); // unsigned int dummy; // return __rdtscp(&dummy); -return 0; // <- remove this; } #else diff --git a/lib/perfmon/Stat.cc b/lib/perfmon/Stat.cc index 75679412..3f47fd83 100644 --- a/lib/perfmon/Stat.cc +++ b/lib/perfmon/Stat.cc @@ -57,37 +57,35 @@ void PmuStat::start(void) pmu_start(); ++count; xmemctrs(&mrstart, &mwstart); - //tstart = __rdtsc(); -tstart=0; + tstart = __rdtsc(); #endif } void PmuStat::enter(int t) { #ifdef __x86_64__ - counters[0][t] = 0;//__rdpmc(0); - counters[1][t] = 0;//__rdpmc(1); - counters[2][t] = 0;//__rdpmc((1<<30)|0); - counters[3][t] = 0;//__rdpmc((1<<30)|1); - counters[4][t] = 0;//__rdpmc((1<<30)|2); - counters[5][t] = 0;//__rdtsc(); + counters[0][t] = __rdpmc(0); + counters[1][t] = __rdpmc(1); + counters[2][t] = __rdpmc((1<<30)|0); + counters[3][t] = __rdpmc((1<<30)|1); + counters[4][t] = __rdpmc((1<<30)|2); + counters[5][t] = __rdtsc(); #endif } void PmuStat::exit(int t) { #ifdef __x86_64__ - counters[0][t] = 0;//__rdpmc(0) - counters[0][t]; - counters[1][t] = 0;// __rdpmc(1) - counters[1][t]; - counters[2][t] = 0;// __rdpmc((1<<30)|0) - counters[2][t]; - counters[3][t] = 0;// __rdpmc((1<<30)|1) - counters[3][t]; - counters[4][t] = 0;// __rdpmc((1<<30)|2) - counters[4][t]; - counters[5][t] = 0;// __rdtsc() - counters[5][t]; + counters[0][t] = __rdpmc(0) - counters[0][t]; + counters[1][t] = __rdpmc(1) - counters[1][t]; + counters[2][t] = __rdpmc((1<<30)|0) - counters[2][t]; + counters[3][t] = __rdpmc((1<<30)|1) - counters[3][t]; + counters[4][t] = __rdpmc((1<<30)|2) - counters[4][t]; + counters[5][t] = __rdtsc() - counters[5][t]; #endif } void PmuStat::accum(int nthreads) { #ifdef __x86_64__ - // tend = __rdtsc(); - tend =0 ; + tend = __rdtsc(); xmemctrs(&mrend, &mwend); pmu_stop(); for (int t = 0; t < nthreads; ++t) { From 91b8bf061323e5aeb73f84c41345a07447a90e47 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Thu, 26 Oct 2017 18:23:55 +0100 Subject: [PATCH 26/43] Debugging force term --- lib/qcd/action/fermion/FermionOperatorImpl.h | 52 ++++- lib/qcd/action/fermion/WilsonCloverFermion.cc | 30 +-- lib/qcd/action/fermion/WilsonCloverFermion.h | 128 ++++++++++- tests/forces/Test_wilson_force.cc | 7 +- tests/forces/Test_wilsonclover_force.cc | 209 ++++++++++++++++++ 5 files changed, 395 insertions(+), 31 deletions(-) create mode 100644 tests/forces/Test_wilsonclover_force.cc diff --git a/lib/qcd/action/fermion/FermionOperatorImpl.h b/lib/qcd/action/fermion/FermionOperatorImpl.h index 9d24deb2..89bd9a15 100644 --- a/lib/qcd/action/fermion/FermionOperatorImpl.h +++ b/lib/qcd/action/fermion/FermionOperatorImpl.h @@ -254,8 +254,22 @@ namespace QCD { GaugeLinkField link(mat._grid); link = TraceIndex(outerProduct(Btilde,A)); PokeIndex(mat,link,mu); - } + } + + inline void outerProductImpl(PropagatorField &mat, const FermionField &B, const FermionField &A){ + mat = outerProduct(B,A); + } + + inline void TraceSpinImpl(GaugeLinkField &mat, PropagatorField&P) { + mat = TraceIndex(P); + } + inline void extractLinkField(std::vector &mat, DoubledGaugeField &Uds){ + for (int mu = 0; mu < Nd; mu++) + mat[mu] = PeekIndex(Uds, mu); + } + + inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField Ã,int mu){ int Ls=Btilde._grid->_fdimensions[0]; @@ -373,6 +387,19 @@ class DomainWallVec5dImpl : public PeriodicGaugeImpl< GaugeImplTypes< S,Nrepres assert(0); } + inline void outerProductImpl(PropagatorField &mat, const FermionField &Btilde, const FermionField &A){ + assert(0); + } + + inline void TraceSpinImpl(GaugeLinkField &mat, PropagatorField&P) { + assert(0); + } + + inline void extractLinkField(std::vector &mat, DoubledGaugeField &Uds){ + assert(0); + } + + inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField Ã, int mu) { assert(0); @@ -611,6 +638,25 @@ class GparityWilsonImpl : public ConjugateGaugeImpl(P); + parallel_for(auto ss = tmp.begin(); ss < tmp.end(); ss++) { + mat[ss]() = tmp[ss](0, 0) + conjugate(tmp[ss](1, 1)); + } + */ + } + + inline void extractLinkField(std::vector &mat, DoubledGaugeField &Uds){ + assert(0); + } + inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField Ã, int mu) { int Ls = Btilde._grid->_fdimensions[0]; @@ -751,8 +797,8 @@ class StaggeredImpl : public PeriodicGaugeImpl(outerProduct(Btilde,A)); PokeIndex(mat,link,mu); - } - + } + inline void InsertForce5D(GaugeField &mat, FermionField &Btilde, FermionField Ã,int mu){ assert (0); // Must never hit diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 1dd12f52..2159fffc 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -43,11 +43,15 @@ RealD WilsonCloverFermion::M(const FermionField &in, FermionField &out) // Wilson term out.checkerboard = in.checkerboard; - this->Dhop(in, out, DaggerNo); + //this->Dhop(in, out, DaggerNo); // Clover term Mooee(in, temp); + //hack + out = zero; + + out += temp; return norm2(out); } @@ -59,11 +63,14 @@ RealD WilsonCloverFermion::Mdag(const FermionField &in, FermionField &out) // Wilson term out.checkerboard = in.checkerboard; - this->Dhop(in, out, DaggerYes); + //this->Dhop(in, out, DaggerYes); // Clover term MooeeDag(in, temp); + //hack + out = zero; + out += temp; return norm2(out); } @@ -84,7 +91,7 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); // Compute the Clover Operator acting on Colour and Spin - CloverTerm = fillCloverYZ(Bx); + CloverTerm = fillCloverYZ(Bx); CloverTerm += fillCloverXZ(By); CloverTerm += fillCloverXY(Bz); CloverTerm += fillCloverXT(Ex); @@ -223,23 +230,6 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie } // MooeeInternal -// Derivative parts -template -void WilsonCloverFermion::MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag) -{ - - GaugeField tmp(mat._grid); - - conformable(U._grid, V._grid); - conformable(U._grid, mat._grid); - - mat.checkerboard = U.checkerboard; - tmp.checkerboard = U.checkerboard; - - this->DhopDeriv(mat, U, V, dag); - MooDeriv(tmp, U, V, dag); - mat += tmp; -} // Derivative parts template diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index 34482941..d8a42129 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -67,15 +67,18 @@ public: CloverTermOdd(&Hgrid), CloverTermInvEven(&Hgrid), CloverTermInvOdd(&Hgrid), - CloverTermDagEven(&Hgrid), - CloverTermDagOdd(&Hgrid), - CloverTermInvDagEven(&Hgrid), - CloverTermInvDagOdd(&Hgrid) + CloverTermDagEven(&Hgrid), + CloverTermDagOdd(&Hgrid), + CloverTermInvDagEven(&Hgrid), + CloverTermInvDagOdd(&Hgrid) { csw = _csw; assert(Nd == 4); // require 4 dimensions - if (csw == 0) std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw = 0" << std::endl; + if (csw == 0) + std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw = 0" << std::endl; + + ImportGauge(_Umu); } virtual RealD M(const FermionField &in, FermionField &out); @@ -87,16 +90,127 @@ public: virtual void MooeeInvDag(const FermionField &in, FermionField &out); virtual void MooeeInternal(const FermionField &in, FermionField &out, int dag, int inv); - virtual void MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag); + //virtual void MDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag); 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); void ImportGauge(const GaugeField &_Umu); + // 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 U(Nd, this->Umu._grid); + + Impl::extractLinkField(U, this->Umu); + + force = zero; + // Derivative of the Wilson hopping term + //this->DhopDeriv(force, X, Y, dag); + + /////////////////////////////////////////////////////////// + // Clover term derivative + /////////////////////////////////////////////////////////// + Impl::outerProductImpl(Lambda, X, Y); + + 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; + PropagatorField Slambda = Gamma(sigma[count]) * Lambda; + Impl::TraceSpinImpl(lambda, Slambda); //traceSpin + force_mu += Cmunu(U, lambda, mu, nu); + count++; + } + + pokeLorentz(clover_force, U[mu] * force_mu, mu); + } + clover_force *= csw / 8.; + force += clover_force; + } + + // Computing C_{\mu \nu}(x) as in Eq.(B.39) in Zbigniew Sroczynski's PhD thesis + GaugeLinkField Cmunu(std::vector &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 + + // C1+ + tmp = lambda * U[nu]; + out = Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); + + // C2+ + tmp = U[mu] * Impl::CovShiftIdentityForward(adj(lambda), mu); + out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); + + // C3+ + tmp = U[nu] * Impl::CovShiftIdentityForward(adj(lambda), nu); + 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; + } + private: // here fixing the 4 dimensions, make it more general? - RealD csw; // Clover coefficient + RealD csw; // Clover coefficient CloverFieldType CloverTerm, CloverTermInv; // Clover term CloverFieldType CloverTermEven, CloverTermOdd; // Clover term EO CloverFieldType CloverTermInvEven, CloverTermInvOdd; // Clover term Inv EO diff --git a/tests/forces/Test_wilson_force.cc b/tests/forces/Test_wilson_force.cc index 1f34a48a..f834726b 100644 --- a/tests/forces/Test_wilson_force.cc +++ b/tests/forces/Test_wilson_force.cc @@ -50,7 +50,12 @@ int main (int argc, char ** argv) std::vector seeds({1,2,3,4}); GridParallelRNG pRNG(&Grid); - pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); + std::vector vrand(4); + std::srand(std::time(0)); + std::generate(vrand.begin(), vrand.end(), std::rand); + std::cout << GridLogMessage << vrand << std::endl; + pRNG.SeedFixedIntegers(vrand); + //pRNG.SeedFixedIntegers(std::vector({45,12,81,9})); LatticeFermion phi (&Grid); gaussian(pRNG,phi); LatticeFermion Mphi (&Grid); diff --git a/tests/forces/Test_wilsonclover_force.cc b/tests/forces/Test_wilsonclover_force.cc new file mode 100644 index 00000000..c99cfa98 --- /dev/null +++ b/tests/forces/Test_wilsonclover_force.cc @@ -0,0 +1,209 @@ +/************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./tests/Test_wilson_force.cc + + Copyright (C) 2015 + +Author: Peter Boyle + + 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 + *************************************************************************************/ +/* END LEGAL */ +#include + +using namespace std; +using namespace Grid; +using namespace Grid::QCD; + +int main(int argc, char **argv) +{ + Grid_init(&argc, &argv); + + std::vector latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd()); + std::vector mpi_layout = GridDefaultMpi(); + + GridCartesian Grid(latt_size, simd_layout, mpi_layout); + GridRedBlackCartesian RBGrid(&Grid); + + int threads = GridThread::GetThreads(); + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + std::vector seeds({1, 2, 3, 4}); + + GridParallelRNG pRNG(&Grid); + std::vector vrand(4); + std::srand(std::time(0)); + std::generate(vrand.begin(), vrand.end(), std::rand); + std::cout << GridLogMessage << vrand << std::endl; + pRNG.SeedFixedIntegers(vrand); + + LatticeFermion phi(&Grid); + gaussian(pRNG, phi); + LatticeFermion Mphi(&Grid); + LatticeFermion MphiPrime(&Grid); + + LatticeGaugeField U(&Grid); + + SU3::HotConfiguration(pRNG,U); + //SU3::ColdConfiguration(pRNG, U); + + //////////////////////////////////// + // Unmodified matrix element + //////////////////////////////////// + RealD mass = -4.0; //kills the diagonal term + Real csw = 1.0; + WilsonCloverFermionR Dw(U, Grid, RBGrid, mass, csw); + + Dw.M(phi, Mphi); + ComplexD S = innerProduct(Mphi, Mphi); // Action : pdag MdagM p + + // get the deriv of phidag MdagM phi with respect to "U" + LatticeGaugeField UdSdU(&Grid); + LatticeGaugeField tmp(&Grid); + + Dw.MDeriv(tmp, Mphi, phi, DaggerNo); UdSdU = tmp; + Dw.MDeriv(tmp, phi, Mphi, DaggerYes); UdSdU += tmp; + // Take the traceless antihermitian component + UdSdU = Ta(UdSdU); + + //////////////////////////////////// + // Modify the gauge field a little + //////////////////////////////////// + RealD dt = 0.0001; + RealD Hmom = 0.0; + RealD Hmomprime = 0.0; + RealD Hmompp = 0.0; + LatticeColourMatrix mommu(&Grid); + LatticeColourMatrix forcemu(&Grid); + LatticeGaugeField mom(&Grid); + LatticeGaugeField Uprime(&Grid); + + for (int mu = 0; mu < Nd; mu++) { + // Traceless antihermitian momentum; gaussian in lie alg + SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); + Hmom -= real(sum(trace(mommu * mommu))); + PokeIndex(mom, mommu, mu); + } + + parallel_for(int ss=0;ssoSites();ss++){ + for (int mu = 0; mu < Nd; mu++) + Uprime[ss]._internal[mu] = ProjectOnGroup(Exponentiate(mom[ss]._internal[mu], dt, 12) * U[ss]._internal[mu]); + } + + std::cout << GridLogMessage << "Initial mom hamiltonian is " << Hmom << std::endl; + + // New action + Dw.ImportGauge(Uprime); + Dw.M(phi, MphiPrime); + + ComplexD Sprime = innerProduct(MphiPrime, MphiPrime); + + ////////////////////////////////////////////// + // Use derivative to estimate dS + ////////////////////////////////////////////// + + /////////////////////////////////////////////////////// + std::cout << GridLogMessage << "Antihermiticity tests - 1 " << std::endl; + for (int mu = 0; mu < Nd; mu++) + { + mommu = PeekIndex(mom, mu); + std::cout << GridLogMessage << " Mommu " << norm2(mommu) << std::endl; + mommu = mommu + adj(mommu); + std::cout << GridLogMessage << " Test: Mommu + Mommudag " << norm2(mommu) << std::endl; + mommu = PeekIndex(UdSdU, mu); + std::cout << GridLogMessage << " dsdumu " << norm2(mommu) << std::endl; + mommu = mommu + adj(mommu); + std::cout << GridLogMessage << " Test: dsdumu + dag " << norm2(mommu) << std::endl; + std::cout << "" << std::endl; + } + //////////////////////////////////////////////////////// + + LatticeComplex dS(&Grid); + dS = zero; + LatticeComplex dSmom(&Grid); + dSmom = zero; + LatticeComplex dSmom2(&Grid); + dSmom2 = zero; + + + // need for this??? + // ultimately it is just a 2.0 factor in UdSdU + for (int mu = 0; mu < Nd; mu++) + { + mommu = PeekIndex(UdSdU, mu); // P_mu = + mommu = Ta(mommu) * 2.0; // Mom = (P_mu - P_mu^dag) - trace(P_mu - P_mu^dag) + PokeIndex(UdSdU, mommu, mu); // UdSdU_mu = Mom + } + + std::cout << GridLogMessage<< "Antihermiticity tests - 2 " << std::endl; + for (int mu = 0; mu < Nd; mu++) + { + mommu = PeekIndex(mom, mu); + std::cout << GridLogMessage << " Mommu " << norm2(mommu) << std::endl; + mommu = mommu + adj(mommu); + std::cout << GridLogMessage << " Mommu + Mommudag " << norm2(mommu) << std::endl; + mommu = PeekIndex(UdSdU, mu); + std::cout << GridLogMessage << " dsdumu " << norm2(mommu) << std::endl; + mommu = mommu + adj(mommu); + std::cout << GridLogMessage << " dsdumu + dag " << norm2(mommu) << std::endl; + std::cout << "" << std::endl; + } + ///////////////////////////////////////////////////// + + + for (int mu = 0; mu < Nd; mu++) + { + forcemu = PeekIndex(UdSdU, mu); + mommu = PeekIndex(mom, mu); + + // Update PF action density + dS = dS + trace(mommu * forcemu) * dt; + + dSmom = dSmom - trace(mommu * forcemu) * dt; + dSmom2 = dSmom2 - trace(forcemu * forcemu) * (0.25 * dt * dt); + + // Update mom action density + mommu = mommu + forcemu * (dt * 0.5); + + Hmomprime -= real(sum(trace(mommu * mommu))); + } + + ComplexD dSpred = sum(dS); + ComplexD dSm = sum(dSmom); + ComplexD dSm2 = sum(dSmom2); + + std::cout << GridLogMessage << "Initial mom hamiltonian is " << Hmom << std::endl; + std::cout << GridLogMessage << "Final mom hamiltonian is " << Hmomprime << std::endl; + std::cout << GridLogMessage << "Delta mom hamiltonian is " << Hmomprime - Hmom << std::endl; + + std::cout << GridLogMessage << " S " << S << std::endl; + std::cout << GridLogMessage << " Sprime " << Sprime << std::endl; + std::cout << GridLogMessage << "dS " << Sprime - S << std::endl; + std::cout << GridLogMessage << "predict dS " << dSpred << std::endl; + std::cout << GridLogMessage << "dSm " << dSm << std::endl; + std::cout << GridLogMessage << "dSm2" << dSm2 << std::endl; + + std::cout << GridLogMessage << "Total dS " << Hmomprime - Hmom + Sprime - S << std::endl; + + assert(fabs(real(Sprime - S - dSpred)) < 1.0); + + std::cout << GridLogMessage << "Done" << std::endl; + Grid_finalize(); +} From 76bcf6cd8c767b0f3a254b3407b951cdf0782d6d Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Thu, 26 Oct 2017 18:45:41 +0100 Subject: [PATCH 27/43] Deleting vscode settings file --- .vscode/settings.json | 51 ------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index f13d503b..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,51 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ - "files.associations": { - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "array": "cpp", - "atomic": "cpp", - "*.tcc": "cpp", - "chrono": "cpp", - "codecvt": "cpp", - "condition_variable": "cpp", - "cstdint": "cpp", - "exception": "cpp", - "slist": "cpp", - "functional": "cpp", - "initializer_list": "cpp", - "iosfwd": "cpp", - "limits": "cpp", - "memory": "cpp", - "mutex": "cpp", - "new": "cpp", - "ratio": "cpp", - "stdexcept": "cpp", - "system_error": "cpp", - "thread": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "typeinfo": "cpp", - "utility": "cpp", - "iostream": "cpp", - "strstream": "cpp", - "complex": "cpp", - "fstream": "cpp", - "iomanip": "cpp", - "istream": "cpp", - "ostream": "cpp", - "sstream": "cpp", - "streambuf": "cpp", - "algorithm": "cpp" - } -} \ No newline at end of file From f941c4ee180aa20b3f3a24a939018357457e5bbf Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Sun, 29 Oct 2017 11:43:33 +0000 Subject: [PATCH 28/43] Clover term force ok --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 9 +- lib/qcd/action/fermion/WilsonCloverFermion.h | 24 ++-- lib/qcd/utils/WilsonLoops.h | 2 +- tests/forces/Test_wilsonclover_force.cc | 118 +++++++++++++++--- 4 files changed, 118 insertions(+), 35 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 2159fffc..e678835a 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -48,10 +48,7 @@ RealD WilsonCloverFermion::M(const FermionField &in, FermionField &out) // Clover term Mooee(in, temp); - //hack - out = zero; - - + out= zero; out += temp; return norm2(out); } @@ -68,9 +65,7 @@ RealD WilsonCloverFermion::Mdag(const FermionField &in, FermionField &out) // Clover term MooeeDag(in, temp); - //hack - out = zero; - + out=zero; out += temp; return norm2(out); } diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index d8a42129..402a9a7e 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -122,6 +122,8 @@ public: // Clover term derivative /////////////////////////////////////////////////////////// Impl::outerProductImpl(Lambda, X, Y); + //std::cout << "Lambda:" << Lambda << std::endl; + Gamma::Algebra sigma[] = { Gamma::Algebra::SigmaXY, @@ -153,16 +155,18 @@ public: for (int nu = 0; nu < 4; nu++) { if (mu == nu) continue; - PropagatorField Slambda = Gamma(sigma[count]) * Lambda; - Impl::TraceSpinImpl(lambda, Slambda); //traceSpin - force_mu += Cmunu(U, lambda, mu, nu); + PropagatorField Slambda = Gamma(sigma[count]) * Lambda; // sigma checked + Impl::TraceSpinImpl(lambda, Slambda); // traceSpin ok + force_mu -= Cmunu(U, lambda, mu, nu); // checked count++; } pokeLorentz(clover_force, U[mu] * force_mu, mu); } - clover_force *= csw / 8.; + clover_force *= csw; force += clover_force; + + } // Computing C_{\mu \nu}(x) as in Eq.(B.39) in Zbigniew Sroczynski's PhD thesis @@ -170,20 +174,19 @@ public: { conformable(lambda._grid, U[0]._grid); GaugeLinkField out(lambda._grid), tmp(lambda._grid); - // insertion in upper staple // please check redundancy of shift operations - + // C1+ tmp = lambda * U[nu]; out = Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - + // C2+ - tmp = U[mu] * Impl::CovShiftIdentityForward(adj(lambda), mu); + tmp = U[mu] * Impl::ShiftStaple(adj(lambda), mu); out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - + // C3+ - tmp = U[nu] * Impl::CovShiftIdentityForward(adj(lambda), nu); + tmp = U[nu] * Impl::ShiftStaple(adj(lambda), nu); out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu); // C4+ @@ -259,6 +262,7 @@ private: PARALLEL_FOR_LOOP for (int i = 0; i < CloverTerm._grid->oSites(); i++) { + 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]()()); diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index fe813298..86609ffc 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -327,7 +327,7 @@ static void StapleMult(GaugeMat &staple, const GaugeLorentz &Umu, int mu) { static void FieldStrength(GaugeMat &FS, const GaugeLorentz &Umu, int mu, int nu){ // Fmn +--<--+ Ut +--<--+ // | | | | - // (x)+-->--+ +-->--+(x) + // (x)+-->--+ +-->--+(x) - h.c. // | | | | // +--<--+ +--<--+ diff --git a/tests/forces/Test_wilsonclover_force.cc b/tests/forces/Test_wilsonclover_force.cc index c99cfa98..82adb8ab 100644 --- a/tests/forces/Test_wilsonclover_force.cc +++ b/tests/forces/Test_wilsonclover_force.cc @@ -1,6 +1,6 @@ /************************************************************************************* - Grid physics library, www.github.com/paboyle/Grid + Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/Test_wilson_force.cc @@ -45,14 +45,17 @@ int main(int argc, char **argv) int threads = GridThread::GetThreads(); std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; - std::vector seeds({1, 2, 3, 4}); + std::vector seeds({1, 2, 30, 50}); GridParallelRNG pRNG(&Grid); + std::vector vrand(4); std::srand(std::time(0)); std::generate(vrand.begin(), vrand.end(), std::rand); std::cout << GridLogMessage << vrand << std::endl; pRNG.SeedFixedIntegers(vrand); + + //pRNG.SeedFixedIntegers(seeds); LatticeFermion phi(&Grid); gaussian(pRNG, phi); @@ -61,16 +64,53 @@ int main(int argc, char **argv) LatticeGaugeField U(&Grid); - SU3::HotConfiguration(pRNG,U); +/* + std::vector x(4); // 4d fermions + std::vector gd = Grid.GlobalDimensions(); + Grid::QCD::SpinColourVector F; + Grid::Complex c; + + phi = zero; + for (x[0] = 0; x[0] < 1; x[0]++) + { + for (x[1] = 0; x[1] < 1; x[1]++) + { + for (x[2] = 0; x[2] < 1; x[2]++) + { + for (x[3] = 0; x[3] < 1; x[3]++) + { + for (int sp = 0; sp < 4; sp++) + { + for (int j = 0; j < 3; j++) // colours + { + F()(sp)(j) = Grid::Complex(0.0,0.0); + if (((sp == 0) && (j==0))) + { + c = Grid::Complex(1.0, 0.0); + F()(sp)(j) = c; + } + } + } + Grid::pokeSite(F, phi, x); + + } + } + } + } +*/ + + std::vector site = {0, 0, 0, 0}; + SU3::HotConfiguration(pRNG, U); //SU3::ColdConfiguration(pRNG, U); + //////////////////////////////////// // Unmodified matrix element //////////////////////////////////// RealD mass = -4.0; //kills the diagonal term Real csw = 1.0; WilsonCloverFermionR Dw(U, Grid, RBGrid, mass, csw); - + Dw.ImportGauge(U); Dw.M(phi, Mphi); ComplexD S = innerProduct(Mphi, Mphi); // Action : pdag MdagM p @@ -78,11 +118,23 @@ int main(int argc, char **argv) LatticeGaugeField UdSdU(&Grid); LatticeGaugeField tmp(&Grid); - Dw.MDeriv(tmp, Mphi, phi, DaggerNo); UdSdU = tmp; - Dw.MDeriv(tmp, phi, Mphi, DaggerYes); UdSdU += tmp; + //////////////////////////////////////////// + Dw.MDeriv(tmp, Mphi, phi, DaggerNo); + UdSdU = tmp; + Dw.MDeriv(tmp, phi, Mphi, DaggerYes); + UdSdU += tmp; + ///////////////////////////////////////////// + // Take the traceless antihermitian component - UdSdU = Ta(UdSdU); - + //UdSdU = Ta(UdSdU); + + //std::cout << UdSdU << std::endl; + //SU3::LatticeAlgebraVector hforce(&Grid); + LatticeColourMatrix mommu(&Grid); + //mommu = PeekIndex(UdSdU, 0); + //SU3::projectOnAlgebra(hforce, mommu); + //std::cout << hforce << std::endl; + //////////////////////////////////// // Modify the gauge field a little //////////////////////////////////// @@ -90,28 +142,63 @@ int main(int argc, char **argv) RealD Hmom = 0.0; RealD Hmomprime = 0.0; RealD Hmompp = 0.0; - LatticeColourMatrix mommu(&Grid); LatticeColourMatrix forcemu(&Grid); LatticeGaugeField mom(&Grid); LatticeGaugeField Uprime(&Grid); + for (int mu = 0; mu < Nd; mu++) { // Traceless antihermitian momentum; gaussian in lie alg SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); Hmom -= real(sum(trace(mommu * mommu))); PokeIndex(mom, mommu, mu); } + /* + SU3::AlgebraVector h; + SU3::LatticeAlgebraVector hl(&Grid); + h()()(0) = 1.0; + hl = zero; + pokeSite(h, hl, site); + SU3::FundamentalLieAlgebraMatrix(hl, mommu); + mom = zero; + PokeIndex(mom, mommu, 0); + Hmom -= real(sum(trace(mommu * mommu))); + */ + /* parallel_for(int ss=0;ssoSites();ss++){ - for (int mu = 0; mu < Nd; mu++) + for (int mu = 0; mu < Nd; mu++) Uprime[ss]._internal[mu] = ProjectOnGroup(Exponentiate(mom[ss]._internal[mu], dt, 12) * U[ss]._internal[mu]); - } + } +*/ + + for (int mu = 0; mu < Nd; mu++) + { + parallel_for(auto i = mom.begin(); i < mom.end(); i++) + { + Uprime[i](mu) = U[i](mu); + Uprime[i](mu) += mom[i](mu) * U[i](mu) * dt; + Uprime[i](mu) += mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt / 2.0); + Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt / 6.0); + Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt * dt / 24.0); + Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt * dt * dt / 120.0); + Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt * dt * dt * dt / 720.0); + } + } std::cout << GridLogMessage << "Initial mom hamiltonian is " << Hmom << std::endl; - + // New action + LatticeGaugeField diff(&Grid); + diff = Uprime - U; + //std::cout << "Diff:" << diff << std::endl; Dw.ImportGauge(Uprime); Dw.M(phi, MphiPrime); + LatticeFermion DiffFermion(&Grid); + DiffFermion = MphiPrime - Mphi; + //std::cout << "DiffFermion:" << DiffFermion << std::endl; + //std::cout << "Mphi:" << Mphi << std::endl; + //std::cout << "MphiPrime:" << MphiPrime << std::endl; ComplexD Sprime = innerProduct(MphiPrime, MphiPrime); @@ -143,16 +230,14 @@ int main(int argc, char **argv) dSmom2 = zero; - // need for this??? - // ultimately it is just a 2.0 factor in UdSdU for (int mu = 0; mu < Nd; mu++) { - mommu = PeekIndex(UdSdU, mu); // P_mu = + mommu = PeekIndex(UdSdU, mu); // P_mu = mommu = Ta(mommu) * 2.0; // Mom = (P_mu - P_mu^dag) - trace(P_mu - P_mu^dag) PokeIndex(UdSdU, mommu, mu); // UdSdU_mu = Mom } - std::cout << GridLogMessage<< "Antihermiticity tests - 2 " << std::endl; + std::cout << GridLogMessage << "Antihermiticity tests - 2 " << std::endl; for (int mu = 0; mu < Nd; mu++) { mommu = PeekIndex(mom, mu); @@ -167,7 +252,6 @@ int main(int argc, char **argv) } ///////////////////////////////////////////////////// - for (int mu = 0; mu < Nd; mu++) { forcemu = PeekIndex(UdSdU, mu); From 749189fd7209181f7923cb77ba8075c0efaf420b Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Sun, 29 Oct 2017 12:03:08 +0000 Subject: [PATCH 29/43] Full clover force correct --- lib/qcd/action/fermion/WilsonCloverFermion.cc | 6 +- lib/qcd/action/fermion/WilsonCloverFermion.h | 2 +- tests/forces/Test_wilsonclover_force.cc | 123 ++---------------- 3 files changed, 15 insertions(+), 116 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index e678835a..fff970a2 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -43,12 +43,11 @@ RealD WilsonCloverFermion::M(const FermionField &in, FermionField &out) // Wilson term out.checkerboard = in.checkerboard; - //this->Dhop(in, out, DaggerNo); + this->Dhop(in, out, DaggerNo); // Clover term Mooee(in, temp); - out= zero; out += temp; return norm2(out); } @@ -60,12 +59,11 @@ RealD WilsonCloverFermion::Mdag(const FermionField &in, FermionField &out) // Wilson term out.checkerboard = in.checkerboard; - //this->Dhop(in, out, DaggerYes); + this->Dhop(in, out, DaggerYes); // Clover term MooeeDag(in, temp); - out=zero; out += temp; return norm2(out); } diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index 402a9a7e..cd13b225 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -116,7 +116,7 @@ public: force = zero; // Derivative of the Wilson hopping term - //this->DhopDeriv(force, X, Y, dag); + this->DhopDeriv(force, X, Y, dag); /////////////////////////////////////////////////////////// // Clover term derivative diff --git a/tests/forces/Test_wilsonclover_force.cc b/tests/forces/Test_wilsonclover_force.cc index 82adb8ab..bcf67be4 100644 --- a/tests/forces/Test_wilsonclover_force.cc +++ b/tests/forces/Test_wilsonclover_force.cc @@ -48,13 +48,12 @@ int main(int argc, char **argv) std::vector seeds({1, 2, 30, 50}); GridParallelRNG pRNG(&Grid); - + std::vector vrand(4); std::srand(std::time(0)); std::generate(vrand.begin(), vrand.end(), std::rand); std::cout << GridLogMessage << vrand << std::endl; pRNG.SeedFixedIntegers(vrand); - //pRNG.SeedFixedIntegers(seeds); LatticeFermion phi(&Grid); @@ -64,50 +63,14 @@ int main(int argc, char **argv) LatticeGaugeField U(&Grid); -/* - std::vector x(4); // 4d fermions - std::vector gd = Grid.GlobalDimensions(); - Grid::QCD::SpinColourVector F; - Grid::Complex c; - - phi = zero; - for (x[0] = 0; x[0] < 1; x[0]++) - { - for (x[1] = 0; x[1] < 1; x[1]++) - { - for (x[2] = 0; x[2] < 1; x[2]++) - { - for (x[3] = 0; x[3] < 1; x[3]++) - { - for (int sp = 0; sp < 4; sp++) - { - for (int j = 0; j < 3; j++) // colours - { - F()(sp)(j) = Grid::Complex(0.0,0.0); - if (((sp == 0) && (j==0))) - { - c = Grid::Complex(1.0, 0.0); - F()(sp)(j) = c; - } - } - } - Grid::pokeSite(F, phi, x); - - } - } - } - } -*/ - std::vector site = {0, 0, 0, 0}; SU3::HotConfiguration(pRNG, U); - //SU3::ColdConfiguration(pRNG, U); - + //SU3::ColdConfiguration(pRNG, U);// Clover term zero //////////////////////////////////// // Unmodified matrix element //////////////////////////////////// - RealD mass = -4.0; //kills the diagonal term + RealD mass = 0.1; Real csw = 1.0; WilsonCloverFermionR Dw(U, Grid, RBGrid, mass, csw); Dw.ImportGauge(U); @@ -125,103 +88,42 @@ int main(int argc, char **argv) UdSdU += tmp; ///////////////////////////////////////////// - // Take the traceless antihermitian component - //UdSdU = Ta(UdSdU); - - //std::cout << UdSdU << std::endl; - //SU3::LatticeAlgebraVector hforce(&Grid); - LatticeColourMatrix mommu(&Grid); - //mommu = PeekIndex(UdSdU, 0); - //SU3::projectOnAlgebra(hforce, mommu); - //std::cout << hforce << std::endl; - //////////////////////////////////// // Modify the gauge field a little //////////////////////////////////// - RealD dt = 0.0001; + RealD dt = 0.00005; RealD Hmom = 0.0; RealD Hmomprime = 0.0; RealD Hmompp = 0.0; + LatticeColourMatrix mommu(&Grid); LatticeColourMatrix forcemu(&Grid); LatticeGaugeField mom(&Grid); LatticeGaugeField Uprime(&Grid); - - for (int mu = 0; mu < Nd; mu++) { + for (int mu = 0; mu < Nd; mu++) + { // Traceless antihermitian momentum; gaussian in lie alg SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); Hmom -= real(sum(trace(mommu * mommu))); PokeIndex(mom, mommu, mu); - } - /* - SU3::AlgebraVector h; - SU3::LatticeAlgebraVector hl(&Grid); - h()()(0) = 1.0; - hl = zero; - pokeSite(h, hl, site); - SU3::FundamentalLieAlgebraMatrix(hl, mommu); - mom = zero; - PokeIndex(mom, mommu, 0); - Hmom -= real(sum(trace(mommu * mommu))); - */ - /* - parallel_for(int ss=0;ssoSites();ss++){ - for (int mu = 0; mu < Nd; mu++) - Uprime[ss]._internal[mu] = ProjectOnGroup(Exponentiate(mom[ss]._internal[mu], dt, 12) * U[ss]._internal[mu]); - } -*/ - - for (int mu = 0; mu < Nd; mu++) - { - parallel_for(auto i = mom.begin(); i < mom.end(); i++) + parallel_for(int ss = 0; ss < mom._grid->oSites(); ss++) { - Uprime[i](mu) = U[i](mu); - Uprime[i](mu) += mom[i](mu) * U[i](mu) * dt; - Uprime[i](mu) += mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt / 2.0); - Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt / 6.0); - Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt * dt / 24.0); - Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt * dt * dt / 120.0); - Uprime[i](mu) += mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * mom[i](mu) * U[i](mu) * (dt * dt * dt * dt * dt * dt / 720.0); + Uprime[ss]._internal[mu] = ProjectOnGroup(Exponentiate(mom[ss]._internal[mu], dt, 12) * U[ss]._internal[mu]); } } std::cout << GridLogMessage << "Initial mom hamiltonian is " << Hmom << std::endl; // New action - LatticeGaugeField diff(&Grid); - diff = Uprime - U; - //std::cout << "Diff:" << diff << std::endl; Dw.ImportGauge(Uprime); Dw.M(phi, MphiPrime); - LatticeFermion DiffFermion(&Grid); - DiffFermion = MphiPrime - Mphi; - //std::cout << "DiffFermion:" << DiffFermion << std::endl; - //std::cout << "Mphi:" << Mphi << std::endl; - //std::cout << "MphiPrime:" << MphiPrime << std::endl; - ComplexD Sprime = innerProduct(MphiPrime, MphiPrime); ////////////////////////////////////////////// // Use derivative to estimate dS ////////////////////////////////////////////// - /////////////////////////////////////////////////////// - std::cout << GridLogMessage << "Antihermiticity tests - 1 " << std::endl; - for (int mu = 0; mu < Nd; mu++) - { - mommu = PeekIndex(mom, mu); - std::cout << GridLogMessage << " Mommu " << norm2(mommu) << std::endl; - mommu = mommu + adj(mommu); - std::cout << GridLogMessage << " Test: Mommu + Mommudag " << norm2(mommu) << std::endl; - mommu = PeekIndex(UdSdU, mu); - std::cout << GridLogMessage << " dsdumu " << norm2(mommu) << std::endl; - mommu = mommu + adj(mommu); - std::cout << GridLogMessage << " Test: dsdumu + dag " << norm2(mommu) << std::endl; - std::cout << "" << std::endl; - } - //////////////////////////////////////////////////////// - LatticeComplex dS(&Grid); dS = zero; LatticeComplex dSmom(&Grid); @@ -229,7 +131,6 @@ int main(int argc, char **argv) LatticeComplex dSmom2(&Grid); dSmom2 = zero; - for (int mu = 0; mu < Nd; mu++) { mommu = PeekIndex(UdSdU, mu); // P_mu = @@ -237,7 +138,7 @@ int main(int argc, char **argv) PokeIndex(UdSdU, mommu, mu); // UdSdU_mu = Mom } - std::cout << GridLogMessage << "Antihermiticity tests - 2 " << std::endl; + std::cout << GridLogMessage << "Antihermiticity tests" << std::endl; for (int mu = 0; mu < Nd; mu++) { mommu = PeekIndex(mom, mu); @@ -279,8 +180,8 @@ int main(int argc, char **argv) std::cout << GridLogMessage << " S " << S << std::endl; std::cout << GridLogMessage << " Sprime " << Sprime << std::endl; - std::cout << GridLogMessage << "dS " << Sprime - S << std::endl; - std::cout << GridLogMessage << "predict dS " << dSpred << std::endl; + std::cout << GridLogMessage << "dS (S' - S) :" << Sprime - S << std::endl; + std::cout << GridLogMessage << "predict dS (force) :" << dSpred << std::endl; std::cout << GridLogMessage << "dSm " << dSm << std::endl; std::cout << GridLogMessage << "dSm2" << dSm2 << std::endl; From fa5e4add47bfdb2d0c54486ebb99236b9db11326 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Tue, 31 Oct 2017 18:20:38 +0000 Subject: [PATCH 30/43] Added support for anisotropy to the WilsonFermion class --- lib/qcd/action/fermion/WilsonFermion.cc | 42 ++++++++++++++++++++----- lib/qcd/action/fermion/WilsonFermion.h | 21 +++++++++++-- tests/qdpxx/Test_qdpxx_wilson.cc | 28 ++++++++++++++--- 3 files changed, 76 insertions(+), 15 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonFermion.cc b/lib/qcd/action/fermion/WilsonFermion.cc index 19f9674d..55ef5a51 100644 --- a/lib/qcd/action/fermion/WilsonFermion.cc +++ b/lib/qcd/action/fermion/WilsonFermion.cc @@ -47,7 +47,8 @@ int WilsonFermionStatic::HandOptDslash; template WilsonFermion::WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid, GridRedBlackCartesian &Hgrid, RealD _mass, - const ImplParams &p) + const ImplParams &p, + const WilsonAnisotropyCoefficients &anis) : Kernels(p), _grid(&Fgrid), _cbgrid(&Hgrid), @@ -60,16 +61,41 @@ WilsonFermion::WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid, Umu(&Fgrid), UmuEven(&Hgrid), UmuOdd(&Hgrid), - _tmp(&Hgrid) + _tmp(&Hgrid), + anisotropyCoeff(anis) { // Allocate the required comms buffer ImportGauge(_Umu); + if (anisotropyCoeff.isAnisotropic){ + diag_mass = mass + 1.0 + (Nd-1)*(anisotropyCoeff.nu / anisotropyCoeff.xi_0); + } else { + diag_mass = 4.0 + mass; + } + + } template void WilsonFermion::ImportGauge(const GaugeField &_Umu) { 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(_Umu, mu); + if (mu != anisotropyCoeff.t_direction) + U_dir *= (anisotropyCoeff.nu / anisotropyCoeff.xi_0); + + PokeIndex(HUmu, U_dir, mu); + } + } + else + { + HUmu = _Umu * (-0.5); + } Impl::DoubleStore(GaugeGrid(), Umu, HUmu); pickCheckerboard(Even, UmuEven, Umu); pickCheckerboard(Odd, UmuOdd, Umu); @@ -83,14 +109,14 @@ template RealD WilsonFermion::M(const FermionField &in, FermionField &out) { out.checkerboard = in.checkerboard; Dhop(in, out, DaggerNo); - return axpy_norm(out, 4 + mass, in, out); + return axpy_norm(out, diag_mass, in, out); } template RealD WilsonFermion::Mdag(const FermionField &in, FermionField &out) { out.checkerboard = in.checkerboard; Dhop(in, out, DaggerYes); - return axpy_norm(out, 4 + mass, in, out); + return axpy_norm(out, diag_mass, in, out); } template @@ -114,7 +140,7 @@ void WilsonFermion::MeooeDag(const FermionField &in, FermionField &out) { template void WilsonFermion::Mooee(const FermionField &in, FermionField &out) { out.checkerboard = in.checkerboard; - typename FermionField::scalar_type scal(4.0 + mass); + typename FermionField::scalar_type scal(diag_mass); out = scal * in; } @@ -127,7 +153,7 @@ void WilsonFermion::MooeeDag(const FermionField &in, FermionField &out) { template void WilsonFermion::MooeeInv(const FermionField &in, FermionField &out) { out.checkerboard = in.checkerboard; - out = (1.0/(4.0+mass))*in; + out = (1.0/(diag_mass))*in; } template @@ -204,7 +230,7 @@ void WilsonFermion::DerivInternal(StencilImpl &st, DoubledGaugeField &U, FermionField Btilde(B._grid); FermionField Atilde(B._grid); - Atilde = A; + Atilde = A;//redundant st.HaloExchange(B, compressor); diff --git a/lib/qcd/action/fermion/WilsonFermion.h b/lib/qcd/action/fermion/WilsonFermion.h index 50f4f884..7b2b5206 100644 --- a/lib/qcd/action/fermion/WilsonFermion.h +++ b/lib/qcd/action/fermion/WilsonFermion.h @@ -44,6 +44,19 @@ class WilsonFermionStatic { 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 WilsonFermion : public WilsonKernels, public WilsonFermionStatic { public: @@ -117,8 +130,9 @@ class WilsonFermion : public WilsonKernels, public WilsonFermionStatic { // Constructor WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid, - GridRedBlackCartesian &Hgrid, RealD _mass, - const ImplParams &p = ImplParams()); + GridRedBlackCartesian &Hgrid, RealD _mass, + const ImplParams &p = ImplParams(), + const WilsonAnisotropyCoefficients &anis = WilsonAnisotropyCoefficients() ); // DoubleStore impl dependent void ImportGauge(const GaugeField &_Umu); @@ -130,6 +144,7 @@ class WilsonFermion : public WilsonKernels, public WilsonFermionStatic { // protected: public: RealD mass; + RealD diag_mass; GridBase *_grid; GridBase *_cbgrid; @@ -146,6 +161,8 @@ class WilsonFermion : public WilsonKernels, public WilsonFermionStatic { LebesgueOrder Lebesgue; LebesgueOrder LebesgueEvenOdd; + + WilsonAnisotropyCoefficients anisotropyCoeff; }; typedef WilsonFermion WilsonFermionF; diff --git a/tests/qdpxx/Test_qdpxx_wilson.cc b/tests/qdpxx/Test_qdpxx_wilson.cc index 6e6eb213..a084ebad 100644 --- a/tests/qdpxx/Test_qdpxx_wilson.cc +++ b/tests/qdpxx/Test_qdpxx_wilson.cc @@ -32,7 +32,7 @@ #include // Mass -double mq = 0.02; +double mq = 0.1; // Define Wilson Types typedef Grid::QCD::WilsonImplR::FermionField FermionField; @@ -255,6 +255,12 @@ public: Chroma::WilsonFermActParams p; 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> fbc(new Chroma::SimpleFermBC(bcs)); Chroma::Handle> cfs(new Chroma::CreateSimpleFermState(fbc)); @@ -269,7 +275,13 @@ public: p.Mass = _mq; p.clovCoeffR = 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> fbc(new Chroma::SimpleFermBC(bcs)); Chroma::Handle> cfs(new Chroma::CreateSimpleFermState(fbc)); @@ -391,8 +403,13 @@ void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD if (action == Wilson) { - - Grid::QCD::WilsonFermionR Wf(Umu, *UGrid, *UrbGrid, _mass); + WilsonAnisotropyCoefficients anis; + 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; @@ -406,7 +423,8 @@ void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD if (action == WilsonClover) { Grid::RealD _csw = 1.0; - + WilsonAnisotropyCoefficients anis; + WilsonImplParams implParam; Grid::QCD::WilsonCloverFermionR Wf(Umu, *UGrid, *UrbGrid, _mass, _csw); Wf.ImportGauge(Umu); From 8e057721a91c3d58bb3c076f111504aacb515906 Mon Sep 17 00:00:00 2001 From: Guido Cossu Date: Wed, 1 Nov 2017 12:50:54 +0000 Subject: [PATCH 31/43] Anisotropic Clover term written and tested --- lib/algorithms/LinearOperator.h | 10 +- lib/qcd/action/fermion/WilsonCloverFermion.cc | 102 +--- lib/qcd/action/fermion/WilsonCloverFermion.h | 116 +++-- lib/qcd/action/fermion/WilsonFermion.h | 9 +- tests/core/Test_wilson_clover.cc | 492 ++++++++++-------- tests/forces/Test_wilsonclover_force.cc | 2 +- .../Test_hmc_EOWilsonCloverFermionGauge.cc | 139 +++++ .../hmc/Test_hmc_WilsonCloverFermionGauge.cc | 126 +++++ tests/qdpxx/Test_qdpxx_wilson.cc | 15 +- 9 files changed, 637 insertions(+), 374 deletions(-) create mode 100644 tests/hmc/Test_hmc_EOWilsonCloverFermionGauge.cc create mode 100644 tests/hmc/Test_hmc_WilsonCloverFermionGauge.cc diff --git a/lib/algorithms/LinearOperator.h b/lib/algorithms/LinearOperator.h index f1b8820e..ee97e96d 100644 --- a/lib/algorithms/LinearOperator.h +++ b/lib/algorithms/LinearOperator.h @@ -183,11 +183,13 @@ namespace Grid { virtual RealD Mpc (const Field &in, Field &out) =0; virtual RealD MpcDag (const Field &in, Field &out) =0; virtual void MpcDagMpc(const Field &in, Field &out,RealD &ni,RealD &no) { - Field tmp(in._grid); + Field tmp(in._grid); + tmp.checkerboard = in.checkerboard; ni=Mpc(in,tmp); no=MpcDag(tmp,out); } virtual void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ + out.checkerboard = in.checkerboard; MpcDagMpc(in,out,n1,n2); } virtual void HermOp(const Field &in, Field &out){ @@ -215,13 +217,15 @@ namespace Grid { public: SchurDiagMooeeOperator (Matrix &Mat): _Mat(Mat){}; virtual RealD Mpc (const Field &in, Field &out) { - Field tmp(in._grid); -// std::cout <<"grid pointers: in._grid="<< in._grid << " out._grid=" << out._grid << " _Mat.Grid=" << _Mat.Grid() << " _Mat.RedBlackGrid=" << _Mat.RedBlackGrid() << std::endl; + Field tmp(in._grid); + tmp.checkerboard = !in.checkerboard; + //std::cout <<"grid pointers: in._grid="<< in._grid << " out._grid=" << out._grid << " _Mat.Grid=" << _Mat.Grid() << " _Mat.RedBlackGrid=" << _Mat.RedBlackGrid() << std::endl; _Mat.Meooe(in,tmp); _Mat.MooeeInv(tmp,out); _Mat.Meooe(out,tmp); + //std::cout << "cb in " << in.checkerboard << " cb out " << out.checkerboard << std::endl; _Mat.Mooee(in,out); return axpy_norm(out,-1.0,tmp,out); } diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index fff970a2..3ec90e06 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -84,14 +84,14 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) WilsonLoops::FieldStrength(Ez, _Umu, Tdir, Zdir); // Compute the Clover Operator acting on Colour and Spin - CloverTerm = fillCloverYZ(Bx); - CloverTerm += fillCloverXZ(By); - CloverTerm += fillCloverXY(Bz); - CloverTerm += fillCloverXT(Ex); - CloverTerm += fillCloverYT(Ey); - CloverTerm += fillCloverZT(Ez); - CloverTerm *= (0.5) * csw; - CloverTerm += (4.0 + this->mass); + // 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; @@ -145,7 +145,6 @@ void WilsonCloverFermion::ImportGauge(const GaugeField &_Umu) template void WilsonCloverFermion::Mooee(const FermionField &in, FermionField &out) { - conformable(in, out); this->MooeeInternal(in, out, DaggerNo, InverseNo); } @@ -158,14 +157,12 @@ void WilsonCloverFermion::MooeeDag(const FermionField &in, FermionField &o template void WilsonCloverFermion::MooeeInv(const FermionField &in, FermionField &out) { - conformable(in,out); this->MooeeInternal(in, out, DaggerNo, InverseYes); } template void WilsonCloverFermion::MooeeInvDag(const FermionField &in, FermionField &out) { - conformable(in,out); this->MooeeInternal(in, out, DaggerYes, InverseYes); } @@ -228,88 +225,7 @@ void WilsonCloverFermion::MooeeInternal(const FermionField &in, FermionFie template void WilsonCloverFermion::MooDeriv(GaugeField &mat, const FermionField &X, const FermionField &Y, int dag) { - - GridBase *grid = mat._grid; - - //GaugeLinkField Lambdaodd(grid), Lambdaeven(grid), tmp(grid); - //Lambdaodd = zero; //Yodd*dag(Xodd)+Xodd*dag(Yodd); // I have to peek spin and decide the color structure - //Lambdaeven = zero; //Teven*dag(Xeven)+Xeven*dag(Yeven) + 2*(Dee^-1) - - GaugeLinkField Lambda(grid), tmp(grid); - Lambda = zero; - - conformable(mat._grid, X._grid); - conformable(Y._grid, X._grid); - - std::vector C1p(Nd, grid), C2p(Nd, grid), C3p(Nd, grid), C4p(Nd, grid); - std::vector C1m(Nd, grid), C2m(Nd, grid), C3m(Nd, grid), C4m(Nd, grid); - std::vector U(Nd, mat._grid); - - for (int mu = 0; mu < Nd; mu++) - { - U[mu] = PeekIndex(mat, mu); - C1p[mu] = zero; - C2p[mu] = zero; - C3p[mu] = zero; - C4p[mu] = zero; - C1m[mu] = zero; - C2m[mu] = zero; - C3m[mu] = zero; - C4m[mu] = zero; - } - - /* - PARALLEL_FOR_LOOP - 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]()()); - } -*/ - - for (int i = 0; i < 4; i++) - { //spin - for (int j = 0; j < 4; j++) - { //spin - - for (int mu = 0; mu < 4; mu++) - { //color - for (int nu = 0; nu < 4; nu++) - { //color - - // insertion in upper staple - tmp = Lambda * U[nu]; - C1p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - - tmp = Lambda * U[mu]; - C2p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - - tmp = Impl::CovShiftIdentityForward(Lambda, nu) * U[nu]; - C3p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu); - - tmp = Lambda; - C4p[mu] += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu) * tmp; - - // insertion in lower staple - tmp = Lambda * U[nu]; - C1m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu); - - tmp = Lambda * U[mu]; - C2m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, U[nu])), mu); - - tmp = Lambda * U[nu]; - C3m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, tmp)), mu); - - tmp = Lambda; - C4m[mu] += Impl::ShiftStaple(Impl::CovShiftBackward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, U[nu])), mu) * tmp; - } - } - } - } - - //Still implementing. Have to be tested, and understood how to project EO + assert(0); } // Derivative parts diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.h b/lib/qcd/action/fermion/WilsonCloverFermion.h index cd13b225..268564c0 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.h +++ b/lib/qcd/action/fermion/WilsonCloverFermion.h @@ -6,8 +6,8 @@ Copyright (C) 2017 - Author: paboyle Author: Guido Cossu + Author: David Preti <> 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 @@ -37,6 +37,22 @@ namespace Grid namespace QCD { +/////////////////////////////////////////////////////////////////// +// Wilson Clover +// +// Operator ( with anisotropy coefficients): +// +// Q = 1 + (Nd-1)/xi_0 + m +// + W_t + (nu/xi_0) * W_s +// - 1/2*[ csw_t * sum_s (sigma_ts F_ts) + (csw_s/xi_0) * sum_ss (sigma_ss F_ss) ] +// +// s spatial, t temporal directions. +// where W_t and W_s are the temporal and spatial components of the +// Wilson Dirac operator +// +// csw_r = csw_t to recover the isotropic version +////////////////////////////////////////////////////////////////// + template class WilsonCloverFermion : public WilsonFermion { @@ -55,28 +71,43 @@ public: // Constructors WilsonCloverFermion(GaugeField &_Umu, GridCartesian &Fgrid, GridRedBlackCartesian &Hgrid, - RealD _mass, - RealD _csw, - const ImplParams &p = ImplParams()) : WilsonFermion(_Umu, - Fgrid, - Hgrid, - _mass, p), - CloverTerm(&Fgrid), - CloverTermInv(&Fgrid), - CloverTermEven(&Hgrid), - CloverTermOdd(&Hgrid), - CloverTermInvEven(&Hgrid), - CloverTermInvOdd(&Hgrid), - CloverTermDagEven(&Hgrid), - CloverTermDagOdd(&Hgrid), - CloverTermInvDagEven(&Hgrid), - CloverTermInvDagOdd(&Hgrid) + const RealD _mass, + const RealD _csw_r = 0.0, + const RealD _csw_t = 0.0, + const WilsonAnisotropyCoefficients &clover_anisotropy = WilsonAnisotropyCoefficients(), + const ImplParams &impl_p = ImplParams()) : WilsonFermion(_Umu, + Fgrid, + Hgrid, + _mass, impl_p, clover_anisotropy), + CloverTerm(&Fgrid), + CloverTermInv(&Fgrid), + CloverTermEven(&Hgrid), + CloverTermOdd(&Hgrid), + CloverTermInvEven(&Hgrid), + CloverTermInvOdd(&Hgrid), + CloverTermDagEven(&Hgrid), + CloverTermDagOdd(&Hgrid), + CloverTermInvDagEven(&Hgrid), + CloverTermInvDagOdd(&Hgrid) { - csw = _csw; assert(Nd == 4); // require 4 dimensions - if (csw == 0) - std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw = 0" << std::endl; + if (clover_anisotropy.isAnisotropic) + { + csw_r = _csw_r * 0.5 / clover_anisotropy.xi_0; + diag_mass = _mass + 1.0 + (Nd - 1) * (clover_anisotropy.nu / clover_anisotropy.xi_0); + } + else + { + csw_r = _csw_r * 0.5; + diag_mass = 4.0 + _mass; + } + csw_t = _csw_t * 0.5; + + if (csw_r == 0) + std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw_r = 0" << std::endl; + if (csw_t == 0) + std::cout << GridLogWarning << "Initializing WilsonCloverFermion with csw_t = 0" << std::endl; ImportGauge(_Umu); } @@ -105,15 +136,15 @@ public: GaugeField clover_force(force._grid); PropagatorField Lambda(force._grid); - // Here we are hitting some performance issues: + // Guido: 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 U(Nd, this->Umu._grid); - + Impl::extractLinkField(U, this->Umu); - + force = zero; // Derivative of the Wilson hopping term this->DhopDeriv(force, X, Y, dag); @@ -121,10 +152,9 @@ public: /////////////////////////////////////////////////////////// // Clover term derivative /////////////////////////////////////////////////////////// - Impl::outerProductImpl(Lambda, X, Y); + Impl::outerProductImpl(Lambda, X, Y); //std::cout << "Lambda:" << Lambda << std::endl; - Gamma::Algebra sigma[] = { Gamma::Algebra::SigmaXY, Gamma::Algebra::SigmaXZ, @@ -148,25 +178,34 @@ public: */ int count = 0; - clover_force = zero; + clover_force = zero; for (int mu = 0; mu < 4; mu++) { force_mu = zero; for (int nu = 0; nu < 4; nu++) { - if (mu == nu) continue; + if (mu == nu) + continue; + + RealD factor; + if (nu == 4 || mu == 4) + { + factor = 2.0 * csw_t; + } + else + { + factor = 2.0 * csw_r; + } PropagatorField Slambda = Gamma(sigma[count]) * Lambda; // sigma checked - Impl::TraceSpinImpl(lambda, Slambda); // traceSpin ok - force_mu -= Cmunu(U, lambda, mu, nu); // checked + Impl::TraceSpinImpl(lambda, Slambda); // traceSpin ok + force_mu -= factor*Cmunu(U, lambda, mu, nu); // checked count++; } pokeLorentz(clover_force, U[mu] * force_mu, mu); } - clover_force *= csw; + //clover_force *= csw; force += clover_force; - - } // Computing C_{\mu \nu}(x) as in Eq.(B.39) in Zbigniew Sroczynski's PhD thesis @@ -176,15 +215,15 @@ public: GaugeLinkField out(lambda._grid), tmp(lambda._grid); // insertion in upper staple // please check redundancy of shift operations - + // C1+ tmp = lambda * U[nu]; out = Impl::ShiftStaple(Impl::CovShiftForward(tmp, nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - + // C2+ tmp = U[mu] * Impl::ShiftStaple(adj(lambda), mu); out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(tmp, mu, Impl::CovShiftIdentityBackward(U[nu], nu))), mu); - + // C3+ tmp = U[nu] * Impl::ShiftStaple(adj(lambda), nu); out += Impl::ShiftStaple(Impl::CovShiftForward(U[nu], nu, Impl::CovShiftBackward(U[mu], mu, Impl::CovShiftIdentityBackward(tmp, nu))), mu); @@ -213,16 +252,17 @@ public: private: // here fixing the 4 dimensions, make it more general? - RealD csw; // Clover coefficient + RealD csw_r; // Clover coefficient - spatial + RealD csw_t; // Clover coefficient - temporal + RealD diag_mass; // Mass term 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 - // eventually these two can be compressed into 6x6 blocks instead of the 12x12 + // eventually these can be compressed into 6x6 blocks instead of the 12x12 // using the DeGrand-Rossi basis for the gamma matrices - CloverFieldType fillCloverYZ(const GaugeLinkField &F) { CloverFieldType T(F._grid); diff --git a/lib/qcd/action/fermion/WilsonFermion.h b/lib/qcd/action/fermion/WilsonFermion.h index 7b2b5206..ca5eba8b 100644 --- a/lib/qcd/action/fermion/WilsonFermion.h +++ b/lib/qcd/action/fermion/WilsonFermion.h @@ -45,10 +45,11 @@ class WilsonFermionStatic { }; struct WilsonAnisotropyCoefficients{ - bool isAnisotropic; - int t_direction; - double xi_0; - double nu; + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonAnisotropyCoefficients, + bool, isAnisotropic, + int, t_direction, + double, xi_0, + double, nu); WilsonAnisotropyCoefficients(): isAnisotropic(false), diff --git a/tests/core/Test_wilson_clover.cc b/tests/core/Test_wilson_clover.cc index 9a55f6b2..9281e298 100644 --- a/tests/core/Test_wilson_clover.cc +++ b/tests/core/Test_wilson_clover.cc @@ -1,4 +1,4 @@ - /************************************************************************************* +/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid @@ -24,302 +24,334 @@ See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ - /* END LEGAL */ +/* END LEGAL */ #include using namespace std; using namespace Grid; using namespace Grid::QCD; -int main (int argc, char ** argv) +int main(int argc, char **argv) { - Grid_init(&argc,&argv); + Grid_init(&argc, &argv); - std::vector latt_size = GridDefaultLatt(); - std::vector simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); - std::vector mpi_layout = GridDefaultMpi(); - GridCartesian Grid(latt_size,simd_layout,mpi_layout); - GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); + std::vector latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd()); + std::vector mpi_layout = GridDefaultMpi(); + GridCartesian Grid(latt_size, simd_layout, mpi_layout); + GridRedBlackCartesian RBGrid(&Grid); int threads = GridThread::GetThreads(); - std::cout< seeds({1,2,3,4}); - GridParallelRNG pRNG(&Grid); + std::vector seeds({1, 2, 3, 4}); + GridParallelRNG pRNG(&Grid); pRNG.SeedFixedIntegers(seeds); // pRNG.SeedFixedIntegers(std::vector({45,12,81,9}); - typedef typename WilsonCloverFermionR::FermionField FermionField; - typename WilsonCloverFermionR::ImplParams params; + typedef typename WilsonCloverFermionR::FermionField FermionField; + typename WilsonCloverFermionR::ImplParams params; + WilsonAnisotropyCoefficients anis; - FermionField src (&Grid); random(pRNG,src); - FermionField result(&Grid); result=zero; - FermionField result2(&Grid); result2=zero; - FermionField ref(&Grid); ref=zero; - FermionField tmp(&Grid); tmp=zero; - FermionField err(&Grid); err=zero; - FermionField err2(&Grid); err2=zero; - FermionField phi (&Grid); random(pRNG,phi); - FermionField chi (&Grid); random(pRNG,chi); - LatticeGaugeField Umu(&Grid); SU3::HotConfiguration(pRNG,Umu); - std::vector U(4,&Grid); + FermionField src(&Grid); + random(pRNG, src); + FermionField result(&Grid); + result = zero; + FermionField result2(&Grid); + result2 = zero; + FermionField ref(&Grid); + ref = zero; + FermionField tmp(&Grid); + tmp = zero; + FermionField err(&Grid); + err = zero; + FermionField err2(&Grid); + err2 = zero; + FermionField phi(&Grid); + random(pRNG, phi); + FermionField chi(&Grid); + random(pRNG, chi); + LatticeGaugeField Umu(&Grid); + SU3::HotConfiguration(pRNG, Umu); + std::vector U(4, &Grid); - - double volume=1; - for(int mu=0;mu * = < chi | Deo^dag| phi> "< * = < chi | Deo^dag| phi> " << std::endl; + std::cout << GridLogMessage << "==============================================================" << std::endl; - FermionField dchi_e (&RBGrid); - FermionField dchi_o (&RBGrid); + FermionField chi_e(&RBGrid); + FermionField chi_o(&RBGrid); - FermionField phi_e (&RBGrid); - FermionField phi_o (&RBGrid); + FermionField dchi_e(&RBGrid); + FermionField dchi_o(&RBGrid); - FermionField dphi_e (&RBGrid); - FermionField dphi_o (&RBGrid); + FermionField phi_e(&RBGrid); + FermionField phi_o(&RBGrid); - pickCheckerboard(Even,chi_e,chi); - pickCheckerboard(Odd ,chi_o,chi); - pickCheckerboard(Even,phi_e,phi); - pickCheckerboard(Odd ,phi_o,phi); + FermionField dphi_e(&RBGrid); + FermionField dphi_o(&RBGrid); - Dwc.Meooe(chi_e,dchi_o); - Dwc.Meooe(chi_o,dchi_e); - Dwc.MeooeDag(phi_e,dphi_o); - Dwc.MeooeDag(phi_o,dphi_e); + pickCheckerboard(Even, chi_e, chi); + pickCheckerboard(Odd, chi_o, chi); + pickCheckerboard(Even, phi_e, phi); + pickCheckerboard(Odd, phi_o, phi); - ComplexD pDce = innerProduct(phi_e,dchi_e); - ComplexD pDco = innerProduct(phi_o,dchi_o); - ComplexD cDpe = innerProduct(chi_e,dphi_e); - ComplexD cDpo = innerProduct(chi_o,dphi_o); + Dwc.Meooe(chi_e, dchi_o); + Dwc.Meooe(chi_o, dchi_e); + Dwc.MeooeDag(phi_e, dphi_o); + Dwc.MeooeDag(phi_o, dphi_e); - std::cout< seeds2({5,6,7,8}); - GridParallelRNG pRNG2(&Grid); pRNG2.SeedFixedIntegers(seeds2); + std::vector seeds2({5, 6, 7, 8}); + GridParallelRNG pRNG2(&Grid); + pRNG2.SeedFixedIntegers(seeds2); LatticeColourMatrix Omega(&Grid); LatticeColourMatrix ShiftedOmega(&Grid); - LatticeGaugeField U_prime(&Grid); U_prime=zero; - LatticeColourMatrix U_prime_mu(&Grid); U_prime_mu=zero; + LatticeGaugeField U_prime(&Grid); + U_prime = zero; + LatticeColourMatrix U_prime_mu(&Grid); + U_prime_mu = zero; SU::LieRandomize(pRNG2, Omega, 1.0); - for (int mu=0;mu + +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 +*************************************************************************************/ +/* END LEGAL */ +#include + +int main(int argc, char **argv) { + using namespace Grid; + using namespace Grid::QCD; + + Grid_init(&argc, &argv); + int threads = GridThread::GetThreads(); + // here make a routine to print all the relevant information on the run + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + // Typedefs to simplify notation + typedef GenericHMCRunner HMCWrapper; // Uses the default minimum norm + typedef WilsonImplR FermionImplPolicy; + typedef WilsonCloverFermionR FermionAction; + typedef typename FermionAction::FermionField FermionField; + + + //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + HMCWrapper TheHMC; + + // Grid from the command line + TheHMC.Resources.AddFourDimGrid("gauge"); + // Possibile to create the module by hand + // hardcoding parameters or using a Reader + + + // Checkpointer definition + CheckpointerParameters CPparams; + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar; + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + // here there is too much indirection + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + RealD beta = 5.6 ; + WilsonGaugeActionR Waction(beta); + + // temporarily need a gauge field + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + LatticeGaugeField U(GridPtr); + + Real mass = 0.01; + Real csw = 1.0; + + FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass, csw); + + ConjugateGradient CG(1.0e-8, 2000); + + TwoFlavourEvenOddPseudoFermionAction Nf2(FermOp, CG, CG); + + // Set smearing (true/false), default: false + Nf2.is_smeared = false; + + + // Collect actions + ActionLevel Level1(1); + Level1.push_back(&Nf2); + + ActionLevel Level2(4); + Level2.push_back(&Waction); + + TheHMC.TheAction.push_back(Level1); + TheHMC.TheAction.push_back(Level2); + ///////////////////////////////////////////////////////////// + + /* + double rho = 0.1; // smearing parameter + int Nsmear = 2; // number of smearing levels + Smear_Stout Stout(rho); + SmearedConfiguration SmearingPolicy( + UGrid, Nsmear, Stout); + */ + + // HMC parameters are serialisable + TheHMC.Parameters.MD.MDsteps = 20; + TheHMC.Parameters.MD.trajL = 1.0; + + TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + TheHMC.Run(); // no smearing + // TheHMC.Run(SmearingPolicy); // for smearing + + Grid_finalize(); + +} // main + + + + + + + diff --git a/tests/hmc/Test_hmc_WilsonCloverFermionGauge.cc b/tests/hmc/Test_hmc_WilsonCloverFermionGauge.cc new file mode 100644 index 00000000..322bb304 --- /dev/null +++ b/tests/hmc/Test_hmc_WilsonCloverFermionGauge.cc @@ -0,0 +1,126 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./tests/Test_hmc_WilsonFermionGauge.cc + +Copyright (C) 2017 + +Author: Guido Cossu + +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 +*************************************************************************************/ +/* END LEGAL */ +#include + +int main(int argc, char **argv) +{ + using namespace Grid; + using namespace Grid::QCD; + + Grid_init(&argc, &argv); + int threads = GridThread::GetThreads(); + // here make a routine to print all the relevant information on the run + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + // Typedefs to simplify notation + typedef GenericHMCRunner HMCWrapper; // Uses the default minimum norm + typedef WilsonImplR FermionImplPolicy; + typedef WilsonCloverFermionR FermionAction; + typedef typename FermionAction::FermionField FermionField; + + //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + HMCWrapper TheHMC; + + // Grid from the command line + TheHMC.Resources.AddFourDimGrid("gauge"); + + // Checkpointer definition + CheckpointerParameters CPparams; + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar; + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + RealD beta = 5.6; + WilsonGaugeActionR Waction(beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + // temporarily need a gauge field + LatticeGaugeField U(GridPtr); + + Real mass = 0.01; + Real csw = 1.0; + + FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass, csw); + ConjugateGradient CG(1.0e-8, 5000); + + TwoFlavourPseudoFermionAction Nf2(FermOp, CG, CG); + + // Set smearing (true/false), default: false + Nf2.is_smeared = false; + + // Collect actions + ActionLevel Level1(1); + Level1.push_back(&Nf2); + + ActionLevel Level2(4); + Level2.push_back(&Waction); + + TheHMC.TheAction.push_back(Level1); + TheHMC.TheAction.push_back(Level2); + ///////////////////////////////////////////////////////////// + + /* + double rho = 0.1; // smearing parameter + int Nsmear = 2; // number of smearing levels + Smear_Stout Stout(rho); + SmearedConfiguration SmearingPolicy( + UGrid, Nsmear, Stout); + */ + + // HMC parameters are serialisable + TheHMC.Parameters.MD.MDsteps = 20; + TheHMC.Parameters.MD.trajL = 1.0; + + TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + TheHMC.Run(); // no smearing + // TheHMC.Run(SmearingPolicy); // for smearing + + Grid_finalize(); + +} // main diff --git a/tests/qdpxx/Test_qdpxx_wilson.cc b/tests/qdpxx/Test_qdpxx_wilson.cc index a084ebad..29e9c9ce 100644 --- a/tests/qdpxx/Test_qdpxx_wilson.cc +++ b/tests/qdpxx/Test_qdpxx_wilson.cc @@ -274,10 +274,10 @@ public: Chroma::CloverFermActParams p; p.Mass = _mq; p.clovCoeffR = QDP::Real(1.0); - p.clovCoeffT = QDP::Real(1.0); + p.clovCoeffT = QDP::Real(2.0); p.u0 = QDP::Real(1.0); AnisoParam_t _apar; - _apar.anisoP = false; + _apar.anisoP = true; _apar.t_dir = 3; // in 4d _apar.xi_0 = 2.0; _apar.nu = 1.0; @@ -422,10 +422,15 @@ void calc_grid(ChromaAction action, Grid::QCD::LatticeGaugeField &Umu, Grid::QCD if (action == WilsonClover) { - Grid::RealD _csw = 1.0; + Grid::RealD _csw_r = 1.0; + Grid::RealD _csw_t = 2.0; WilsonAnisotropyCoefficients anis; - WilsonImplParams implParam; - Grid::QCD::WilsonCloverFermionR Wf(Umu, *UGrid, *UrbGrid, _mass, _csw); + anis.isAnisotropic = true; + anis.t_direction = 3; + anis.xi_0 = 2.0; + anis.nu = 1.0; + WilsonImplParams CloverImplParam; + Grid::QCD::WilsonCloverFermionR Wf(Umu, *UGrid, *UrbGrid, _mass, _csw_r, _csw_t, anis, CloverImplParam); Wf.ImportGauge(Umu); std::cout << Grid::GridLogMessage << " Calling Grid Wilson Clover Fermion multiply " << std::endl; From 7b42ac9982da4b9f6c9ae0934ccef62506672425 Mon Sep 17 00:00:00 2001 From: pretidav Date: Thu, 2 Nov 2017 21:58:16 +0100 Subject: [PATCH 32/43] added polyakov loop observable to the hmc --- lib/qcd/modules/ObservableModules.h | 13 ++++ lib/qcd/observables/hmc_observable.h | 2 + lib/qcd/observables/polyakov_loop.h | 68 +++++++++++++++++++ lib/qcd/utils/WilsonLoops.h | 23 +++++++ .../hmc/Test_hmc_WilsonCloverFermionGauge.cc | 3 + 5 files changed, 109 insertions(+) create mode 100644 lib/qcd/observables/polyakov_loop.h diff --git a/lib/qcd/modules/ObservableModules.h b/lib/qcd/modules/ObservableModules.h index 24511617..fbffc236 100644 --- a/lib/qcd/modules/ObservableModules.h +++ b/lib/qcd/modules/ObservableModules.h @@ -92,6 +92,19 @@ class PlaquetteMod: public ObservableModule, NoParameters> PlaquetteMod(): ObsBase(NoParameters()){} }; +template < class Impl > +class PolyakovMod: public ObservableModule, NoParameters>{ + typedef ObservableModule, NoParameters> ObsBase; + using ObsBase::ObsBase; // for constructors + + // acquire resource + virtual void initialize(){ + this->ObservablePtr.reset(new PolyakovLogger()); + } + public: + PolyakovMod(): ObsBase(NoParameters()){} +}; + template < class Impl > class TopologicalChargeMod: public ObservableModule, TopologyObsParameters>{ diff --git a/lib/qcd/observables/hmc_observable.h b/lib/qcd/observables/hmc_observable.h index db629ce7..fcf11774 100644 --- a/lib/qcd/observables/hmc_observable.h +++ b/lib/qcd/observables/hmc_observable.h @@ -45,5 +45,7 @@ class HmcObservable { #include "plaquette.h" #include "topological_charge.h" +#include "polyakov_loop.h" + #endif // HMC_OBSERVABLE_H diff --git a/lib/qcd/observables/polyakov_loop.h b/lib/qcd/observables/polyakov_loop.h new file mode 100644 index 00000000..d708b474 --- /dev/null +++ b/lib/qcd/observables/polyakov_loop.h @@ -0,0 +1,68 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./lib/qcd/modules/polyakov_line.h + +Copyright (C) 2017 + +Author: David Preti + +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 +*************************************************************************************/ +/* END LEGAL */ + +#ifndef HMC_POLYAKOV_H +#define HMC_POLYAKOV_H + +namespace Grid { +namespace QCD { + +// this is only defined for a gauge theory +template +class PolyakovLogger : public HmcObservable { + public: + // here forces the Impl to be of gauge fields + // if not the compiler will complain + INHERIT_GIMPL_TYPES(Impl); + + // necessary for HmcObservable compatibility + typedef typename Impl::Field Field; + + void TrajectoryComplete(int traj, + Field &U, + GridSerialRNG &sRNG, + GridParallelRNG &pRNG) { + + ComplexD polyakov = WilsonLoops::avgPolyakovLoop(U); + + int def_prec = std::cout.precision(); + + std::cout << GridLogMessage + << std::setprecision(std::numeric_limits::digits10 + 1) + << "Polyakov Loop: [ " << traj << " ] "<< polyakov << std::endl; + + std::cout.precision(def_prec); + + } +}; + +} // namespace QCD +} // namespace Grid + +#endif // HMC_POLYAKOV_H diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index 86609ffc..1e57015c 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -123,6 +123,29 @@ public: return sumplaq / vol / faces / Nc; // Nd , Nc dependent... FIXME } + + ////////////////////////////////////////////////// + // average over all x,y,z the temporal loop + ////////////////////////////////////////////////// + static ComplexD avgPolyakovLoop(const GaugeField &Umu) { //assume Nd=4 + GaugeMat Ut(Umu._grid), P(Umu._grid); + ComplexD out; + int T = Umu._grid->GlobalDimensions()[3]; + int X = Umu._grid->GlobalDimensions()[0]; + int Y = Umu._grid->GlobalDimensions()[1]; + int Z = Umu._grid->GlobalDimensions()[2]; + + std::cout << X << Y << Z << T << std::endl; + Ut = peekLorentz(Umu,3); //Select temporal direction + P = Ut; + for (int t=1;t PlaqObs; TheHMC.Resources.AddObservable(); + + typedef PolyakovMod PolyakovObs; + TheHMC.Resources.AddObservable(); ////////////////////////////////////////////// ///////////////////////////////////////////////////////////// From c79606a5dc4acfc4ba1453262b344031bee8a07b Mon Sep 17 00:00:00 2001 From: pretidav Date: Fri, 3 Nov 2017 22:46:32 +0100 Subject: [PATCH 33/43] Test production code wilson clover. Still missing QObs measurement on-the-fly. --- lib/qcd/utils/WilsonLoops.h | 1 - tests/hmc/Test_hmc_WCFG_Production.cc | 210 ++++++++++++++++++++++++++ 2 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 tests/hmc/Test_hmc_WCFG_Production.cc diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index 1e57015c..cdd76ecc 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -135,7 +135,6 @@ public: int Y = Umu._grid->GlobalDimensions()[1]; int Z = Umu._grid->GlobalDimensions()[2]; - std::cout << X << Y << Z << T << std::endl; Ut = peekLorentz(Umu,3); //Select temporal direction P = Ut; for (int t=1;t + +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 +*************************************************************************************/ +/* END LEGAL */ +#include + + +namespace Grid{ + struct FermionParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(FermionParameters, + double, mass, + double, csw, + double, StoppingCondition, + int, MaxCGIterations, + bool, ApplySmearing); + }; + + + struct WilsonCloverHMCParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonCloverHMCParameters, + double, gauge_beta, + FermionParameters, WilsonClover) + + template + WilsonCloverHMCParameters(Reader& Reader){ + read(Reader, "Action", *this); + } + }; + + struct SmearingParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(SmearingParameters, + double, rho, + Integer, Nsmear) + + template + SmearingParameters(Reader& Reader){ + read(Reader, "StoutSmearing", *this); + } + + }; + + +} + +int main(int argc, char **argv) +{ + using namespace Grid; + using namespace Grid::QCD; + + Grid_init(&argc, &argv); + int threads = GridThread::GetThreads(); + // here make a routine to print all the relevant information on the run + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + // Typedefs to simplify notation + typedef GenericHMCRunner HMCWrapper; // Uses the default minimum norm + typedef WilsonImplR FermionImplPolicy; + typedef WilsonCloverFermionR FermionAction; + typedef typename FermionAction::FermionField FermionField; + typedef Grid::JSONReader Serialiser; + + //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + HMCWrapper TheHMC; + + // Grid from the command line + TheHMC.ReadCommandLine(argc, argv); + if (TheHMC.ParameterFile.empty()){ + std::cout << "Input file not specified." + << "Use --ParameterFile option in the command line.\nAborting" + << std::endl; + exit(1); + } + Serialiser Reader(TheHMC.ParameterFile); + WilsonCloverHMCParameters MyParams(Reader); + + // Apply smearing to the fermionic action + bool ApplySmearing = MyParams.WilsonClover.ApplySmearing; + + TheHMC.Resources.AddFourDimGrid("gauge"); + + // Checkpointer definition + CheckpointerParameters CPparams(Reader); + + /* + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + */ + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar(Reader); + /* + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + */ + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + + typedef PolyakovMod PolyakovObs; + TheHMC.Resources.AddObservable(); + + //typedef TopologicalChargeMod QObs; + //TopologyObsParameters TopParams(Reader); + //TheHMC.Resources.AddObservable(TopParams); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + + //RealD beta = 5.6; + WilsonGaugeActionR Waction(MyParams.gauge_beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + // temporarily need a gauge field + LatticeGaugeField U(GridPtr); + + //Real mass = 0.01; + //Real csw = 1.0; + + Real mass = MyParams.WilsonClover.mass; + Real csw = MyParams.WilsonClover.csw; + + std::cout << "mass and csw" << mass << " and " << csw << std::endl; + + FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass, csw, csw); + ConjugateGradient CG(MyParams.WilsonClover.StoppingCondition, MyParams.WilsonClover.MaxCGIterations); + TwoFlavourPseudoFermionAction Nf2(FermOp, CG, CG); + + // Set smearing (true/false), default: false + Nf2.is_smeared = ApplySmearing; + + // Collect actions + ActionLevel Level1(1); + Level1.push_back(&Nf2); + + ActionLevel Level2(4); + Level2.push_back(&Waction); + + TheHMC.TheAction.push_back(Level1); + TheHMC.TheAction.push_back(Level2); + ///////////////////////////////////////////////////////////// + + + /* + double rho = 0.1; // smearing parameter + int Nsmear = 2; // number of smearing levels + Smear_Stout Stout(rho); + SmearedConfiguration SmearingPolicy( + UGrid, Nsmear, Stout); + */ + + // HMC parameters are serialisable + + TheHMC.Parameters.initialize(Reader); + //TheHMC.Parameters.MD.MDsteps = 20; + //TheHMC.Parameters.MD.trajL = 1.0; + + if (ApplySmearing){ + SmearingParameters SmPar(Reader); + //double rho = 0.1; // smearing parameter + //int Nsmear = 3; // number of smearing levels + Smear_Stout Stout(SmPar.rho); + SmearedConfiguration SmearingPolicy(GridPtr, SmPar.Nsmear, Stout); + TheHMC.Run(SmearingPolicy); // for smearing + } else { + TheHMC.Run(); // no smearing + } + + //TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + //TheHMC.Run(); // no smearing + // TheHMC.Run(SmearingPolicy); // for smearing + + Grid_finalize(); + +} // main From 915f610da0c986c43ee706f8716ebbb453b0342c Mon Sep 17 00:00:00 2001 From: pretidav Date: Sat, 4 Nov 2017 01:17:06 +0100 Subject: [PATCH 34/43] clover 2indexSymm hmc production test created. clover 2indexAsymm and clover mixed to be filled. --- lib/qcd/action/fermion/Fermion.h | 17 ++ lib/qcd/action/fermion/FermionOperatorImpl.h | 4 + lib/qcd/action/fermion/WilsonCloverFermion.cc | 6 +- tests/hmc/Test_hmc_WC2ASFG_Production.cc | 129 +++++++++++ tests/hmc/Test_hmc_WC2SFG_Production.cc | 212 ++++++++++++++++++ tests/hmc/Test_hmc_WCMixedRepFG_Production.cc | 139 ++++++++++++ 6 files changed, 504 insertions(+), 3 deletions(-) create mode 100644 tests/hmc/Test_hmc_WC2ASFG_Production.cc create mode 100644 tests/hmc/Test_hmc_WC2SFG_Production.cc create mode 100644 tests/hmc/Test_hmc_WCMixedRepFG_Production.cc diff --git a/lib/qcd/action/fermion/Fermion.h b/lib/qcd/action/fermion/Fermion.h index bc8397ba..2a008cb7 100644 --- a/lib/qcd/action/fermion/Fermion.h +++ b/lib/qcd/action/fermion/Fermion.h @@ -106,6 +106,10 @@ typedef WilsonFermion WilsonTwoIndexSymmetricFermi typedef WilsonFermion WilsonTwoIndexSymmetricFermionF; typedef WilsonFermion WilsonTwoIndexSymmetricFermionD; +typedef WilsonFermion WilsonTwoIndexAntiSymmetricFermionR; +typedef WilsonFermion WilsonTwoIndexAntiSymmetricFermionF; +typedef WilsonFermion WilsonTwoIndexAntiSymmetricFermionD; + // Twisted mass fermion typedef WilsonTMFermion WilsonTMFermionR; typedef WilsonTMFermion WilsonTMFermionF; @@ -116,6 +120,19 @@ typedef WilsonCloverFermion WilsonCloverFermionR; typedef WilsonCloverFermion WilsonCloverFermionF; typedef WilsonCloverFermion WilsonCloverFermionD; +typedef WilsonCloverFermion WilsonCloverAdjFermionR; +typedef WilsonCloverFermion WilsonCloverAdjFermionF; +typedef WilsonCloverFermion WilsonCloverAdjFermionD; + +typedef WilsonCloverFermion WilsonCloverTwoIndexSymmetricFermionR; +typedef WilsonCloverFermion WilsonCloverTwoIndexSymmetricFermionF; +typedef WilsonCloverFermion WilsonCloverTwoIndexSymmetricFermionD; + +typedef WilsonCloverFermion WilsonCloverTwoIndexAntiSymmetricFermionR; +typedef WilsonCloverFermion WilsonCloverTwoIndexAntiSymmetricFermionF; +typedef WilsonCloverFermion WilsonCloverTwoIndexAntiSymmetricFermionD; + +// Domain Wall fermions typedef DomainWallFermion DomainWallFermionR; typedef DomainWallFermion DomainWallFermionF; typedef DomainWallFermion DomainWallFermionD; diff --git a/lib/qcd/action/fermion/FermionOperatorImpl.h b/lib/qcd/action/fermion/FermionOperatorImpl.h index 89bd9a15..85d6ffea 100644 --- a/lib/qcd/action/fermion/FermionOperatorImpl.h +++ b/lib/qcd/action/fermion/FermionOperatorImpl.h @@ -1004,6 +1004,10 @@ typedef WilsonImpl Wilso typedef WilsonImpl WilsonTwoIndexSymmetricImplF; // Float typedef WilsonImpl WilsonTwoIndexSymmetricImplD; // Double +typedef WilsonImpl WilsonTwoIndexAntiSymmetricImplR; // Real.. whichever prec +typedef WilsonImpl WilsonTwoIndexAntiSymmetricImplF; // Float +typedef WilsonImpl WilsonTwoIndexAntiSymmetricImplD; // Double + typedef DomainWallVec5dImpl DomainWallVec5dImplR; // Real.. whichever prec typedef DomainWallVec5dImpl DomainWallVec5dImplF; // Float typedef DomainWallVec5dImpl DomainWallVec5dImplD; // Double diff --git a/lib/qcd/action/fermion/WilsonCloverFermion.cc b/lib/qcd/action/fermion/WilsonCloverFermion.cc index 3ec90e06..3c082446 100644 --- a/lib/qcd/action/fermion/WilsonCloverFermion.cc +++ b/lib/qcd/action/fermion/WilsonCloverFermion.cc @@ -235,9 +235,9 @@ void WilsonCloverFermion::MeeDeriv(GaugeField &mat, const FermionField &U, assert(0); // not implemented yet } -FermOpTemplateInstantiate(WilsonCloverFermion); // now only for the fundamental representation -//AdjointFermOpTemplateInstantiate(WilsonCloverFermion); -//TwoIndexFermOpTemplateInstantiate(WilsonCloverFermion); +FermOpTemplateInstantiate(WilsonCloverFermion); +AdjointFermOpTemplateInstantiate(WilsonCloverFermion); +TwoIndexFermOpTemplateInstantiate(WilsonCloverFermion); //GparityFermOpTemplateInstantiate(WilsonCloverFermion); } } diff --git a/tests/hmc/Test_hmc_WC2ASFG_Production.cc b/tests/hmc/Test_hmc_WC2ASFG_Production.cc new file mode 100644 index 00000000..b0d1d3a4 --- /dev/null +++ b/tests/hmc/Test_hmc_WC2ASFG_Production.cc @@ -0,0 +1,129 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./tests/Test_hmc_WilsonAdjointFermionGauge.cc + +Copyright (C) 2015 + +Author: Peter Boyle +Author: neo + +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 +*************************************************************************************/ +/* END LEGAL */ +#include "Grid/Grid.h" + +int main(int argc, char **argv) { + using namespace Grid; + using namespace Grid::QCD; + + // Here change the allowed (higher) representations + typedef Representations< FundamentalRepresentation, TwoIndexAntiSymmetricRepresentation > TheRepresentations; + + Grid_init(&argc, &argv); + int threads = GridThread::GetThreads(); + // here make a routine to print all the relevant information on the run + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + // Typedefs to simplify notation + typedef GenericHMCRunnerHirep HMCWrapper; + + typedef WilsonTwoIndexAntiSymmetricImplR FermionImplPolicy; // gauge field implemetation for the pseudofermions + typedef WilsonTwoIndexAntiSymmetricFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) + typedef typename FermionAction::FermionField FermionField; + + //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + HMCWrapper TheHMC; + + // Grid from the command line + TheHMC.Resources.AddFourDimGrid("gauge"); + // Possibile to create the module by hand + // hardcoding parameters or using a Reader + + + // Checkpointer definition + CheckpointerParameters CPparams; + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar; + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + RealD beta = 2.25 ; + WilsonGaugeActionR Waction(beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + // temporarily need a gauge field + TwoIndexSymmetricRepresentation::LatticeField U(GridPtr); + + Real mass = -0.95; + + // Can we define an overloaded operator that does not need U and initialises + // it with zeroes? + FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass); + + ConjugateGradient CG(1.0e-8, 2000, false); + + TwoFlavourPseudoFermionAction Nf2(FermOp, CG, CG); + + // Set smearing (true/false), default: false + Nf2.is_smeared = false; + + + // Collect actions + ActionLevel Level1(1); + Level1.push_back(&Nf2); + + ActionLevel Level2(4); + Level2.push_back(&Waction); + + TheHMC.TheAction.push_back(Level1); + TheHMC.TheAction.push_back(Level2); + + // HMC parameters are serialisable + TheHMC.Parameters.MD.MDsteps = 20; + TheHMC.Parameters.MD.trajL = 1.0; + + TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + TheHMC.Run(); // no smearing + // TheHMC.Run(SmearingPolicy); // for smearing + + Grid_finalize(); + +} // main + + diff --git a/tests/hmc/Test_hmc_WC2SFG_Production.cc b/tests/hmc/Test_hmc_WC2SFG_Production.cc new file mode 100644 index 00000000..8d5fc458 --- /dev/null +++ b/tests/hmc/Test_hmc_WC2SFG_Production.cc @@ -0,0 +1,212 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./tests/Test_hmc_WilsonFermionGauge.cc + +Copyright (C) 2017 + +Author: Guido Cossu + +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 +*************************************************************************************/ +/* END LEGAL */ +#include + + +namespace Grid{ + struct FermionParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(FermionParameters, + double, mass, + double, csw, + double, StoppingCondition, + int, MaxCGIterations, + bool, ApplySmearing); + }; + + + struct WilsonCloverHMCParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonCloverHMCParameters, + double, gauge_beta, + FermionParameters, WilsonClover) + + template + WilsonCloverHMCParameters(Reader& Reader){ + read(Reader, "Action", *this); + } + }; + + struct SmearingParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(SmearingParameters, + double, rho, + Integer, Nsmear) + + template + SmearingParameters(Reader& Reader){ + read(Reader, "StoutSmearing", *this); + } + + }; + + +} + +int main(int argc, char **argv) +{ + using namespace Grid; + using namespace Grid::QCD; + + typedef Representations< FundamentalRepresentation, TwoIndexSymmetricRepresentation > TheRepresentations; + + Grid_init(&argc, &argv); + int threads = GridThread::GetThreads(); + // here make a routine to print all the relevant information on the run + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + // Typedefs to simplify notation + typedef GenericHMCRunnerHirep HMCWrapper; // Uses the default minimum norm + typedef WilsonTwoIndexSymmetricImplR FermionImplPolicy; // gauge field implemetation for the pseudofermions + typedef WilsonCloverTwoIndexSymmetricFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) + typedef typename FermionAction::FermionField FermionField; + typedef Grid::JSONReader Serialiser; + + //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + HMCWrapper TheHMC; + + // Grid from the command line + TheHMC.ReadCommandLine(argc, argv); + if (TheHMC.ParameterFile.empty()){ + std::cout << "Input file not specified." + << "Use --ParameterFile option in the command line.\nAborting" + << std::endl; + exit(1); + } + Serialiser Reader(TheHMC.ParameterFile); + WilsonCloverHMCParameters MyParams(Reader); + + // Apply smearing to the fermionic action + bool ApplySmearing = MyParams.WilsonClover.ApplySmearing; + + TheHMC.Resources.AddFourDimGrid("gauge"); + + // Checkpointer definition + CheckpointerParameters CPparams(Reader); + + /* + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + */ + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar(Reader); + /* + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + */ + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + + typedef PolyakovMod PolyakovObs; + TheHMC.Resources.AddObservable(); + + //typedef TopologicalChargeMod QObs; + //TopologyObsParameters TopParams(Reader); + //TheHMC.Resources.AddObservable(TopParams); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + + //RealD beta = 5.6; + WilsonGaugeActionR Waction(MyParams.gauge_beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + // temporarily need a gauge field + TwoIndexSymmetricRepresentation::LatticeField U(GridPtr); + + //Real mass = 0.01; + //Real csw = 1.0; + + Real mass = MyParams.WilsonClover.mass; + Real csw = MyParams.WilsonClover.csw; + + std::cout << "mass and csw" << mass << " and " << csw << std::endl; + + FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass, csw, csw); + ConjugateGradient CG(MyParams.WilsonClover.StoppingCondition, MyParams.WilsonClover.MaxCGIterations); + TwoFlavourPseudoFermionAction Nf2(FermOp, CG, CG); + + // Set smearing (true/false), default: false + Nf2.is_smeared = ApplySmearing; + + // Collect actions + ActionLevel Level1(1); + Level1.push_back(&Nf2); + + ActionLevel Level2(4); + Level2.push_back(&Waction); + + TheHMC.TheAction.push_back(Level1); + TheHMC.TheAction.push_back(Level2); + ///////////////////////////////////////////////////////////// + + + /* + double rho = 0.1; // smearing parameter + int Nsmear = 2; // number of smearing levels + Smear_Stout Stout(rho); + SmearedConfiguration SmearingPolicy( + UGrid, Nsmear, Stout); + */ + + // HMC parameters are serialisable + + TheHMC.Parameters.initialize(Reader); + //TheHMC.Parameters.MD.MDsteps = 20; + //TheHMC.Parameters.MD.trajL = 1.0; + + if (ApplySmearing){ + SmearingParameters SmPar(Reader); + //double rho = 0.1; // smearing parameter + //int Nsmear = 3; // number of smearing levels + Smear_Stout Stout(SmPar.rho); + SmearedConfiguration SmearingPolicy(GridPtr, SmPar.Nsmear, Stout); + TheHMC.Run(SmearingPolicy); // for smearing + } else { + TheHMC.Run(); // no smearing + } + + //TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + //TheHMC.Run(); // no smearing + // TheHMC.Run(SmearingPolicy); // for smearing + + Grid_finalize(); + +} // main diff --git a/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc b/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc new file mode 100644 index 00000000..b54345cf --- /dev/null +++ b/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc @@ -0,0 +1,139 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./tests/Test_hmc_WilsonAdjointFermionGauge.cc + +Copyright (C) 2015 + +Author: Peter Boyle +Author: Peter Boyle +Author: neo +Author: paboyle + +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 +*************************************************************************************/ +/* END LEGAL */ +#include "Grid/Grid.h" + + + + +int main(int argc, char **argv) { + using namespace Grid; + using namespace Grid::QCD; + + // Here change the allowed (higher) representations + typedef Representations< FundamentalRepresentation, AdjointRepresentation , TwoIndexSymmetricRepresentation> TheRepresentations; + + Grid_init(&argc, &argv); + int threads = GridThread::GetThreads(); + // here make a routine to print all the relevant information on the run + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + // Typedefs to simplify notation + typedef GenericHMCRunnerHirep HMCWrapper; + + typedef WilsonAdjImplR AdjImplPolicy; // gauge field implemetation for the pseudofermions + typedef WilsonAdjFermionR AdjFermionAction; // type of lattice fermions (Wilson, DW, ...) + typedef WilsonTwoIndexSymmetricImplR SymmImplPolicy; + typedef WilsonTwoIndexSymmetricFermionR SymmFermionAction; + + + typedef typename AdjFermionAction::FermionField AdjFermionField; + typedef typename SymmFermionAction::FermionField SymmFermionField; + + //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + HMCWrapper TheHMC; + + // Grid from the command line + TheHMC.Resources.AddFourDimGrid("gauge"); + // Possibile to create the module by hand + // hardcoding parameters or using a Reader + + + // Checkpointer definition + CheckpointerParameters CPparams; + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar; + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + RealD beta = 2.25 ; + WilsonGaugeActionR Waction(beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + // temporarily need a gauge field + AdjointRepresentation::LatticeField UA(GridPtr); + TwoIndexSymmetricRepresentation::LatticeField US(GridPtr); + + Real adjoint_mass = -0.1; + Real symm_mass = -0.5; + AdjFermionAction AdjFermOp(UA, *GridPtr, *GridRBPtr, adjoint_mass); + SymmFermionAction SymmFermOp(US, *GridPtr, *GridRBPtr, symm_mass); + + ConjugateGradient CG_adj(1.0e-8, 10000, false); + ConjugateGradient CG_symm(1.0e-8, 10000, false); + + // Pass two solvers: one for the force computation and one for the action + TwoFlavourPseudoFermionAction Nf2_Adj(AdjFermOp, CG_adj, CG_adj); + TwoFlavourPseudoFermionAction Nf2_Symm(SymmFermOp, CG_symm, CG_symm); + + // Collect actions + ActionLevel Level1(1); + Level1.push_back(&Nf2_Adj); + Level1.push_back(&Nf2_Symm); + + + ActionLevel Level2(4); + Level2.push_back(&Waction); + + TheHMC.TheAction.push_back(Level1); + TheHMC.TheAction.push_back(Level2); + + // HMC parameters are serialisable + TheHMC.Parameters.MD.MDsteps = 20; + TheHMC.Parameters.MD.trajL = 1.0; + + TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + TheHMC.Run(); // no smearing + + Grid_finalize(); + +} // main + + From a4934292182ffa1e96a5ecad2062f3ce06727f1c Mon Sep 17 00:00:00 2001 From: pretidav Date: Sat, 4 Nov 2017 18:16:54 +0100 Subject: [PATCH 35/43] added Production tests for MixedRep, Adj, 2S, 2AS. Still missing QObs. The HMC is not printing correctly all the actions and forces. --- lib/qcd/action/fermion/FermionCore.h | 4 +- lib/qcd/action/fermion/WilsonKernelsHand.cc | 3 +- tests/hmc/Test_hmc_WC2ASFG_Production.cc | 162 +++++++++---- tests/hmc/Test_hmc_WCMixedRepFG_Production.cc | 215 ++++++++++++------ tests/hmc/Test_hmc_WCadjFG_Production.cc | 213 +++++++++++++++++ 5 files changed, 491 insertions(+), 106 deletions(-) create mode 100644 tests/hmc/Test_hmc_WCadjFG_Production.cc diff --git a/lib/qcd/action/fermion/FermionCore.h b/lib/qcd/action/fermion/FermionCore.h index 17006961..60632c3a 100644 --- a/lib/qcd/action/fermion/FermionCore.h +++ b/lib/qcd/action/fermion/FermionCore.h @@ -70,7 +70,9 @@ Author: Peter Boyle #define TwoIndexFermOpTemplateInstantiate(A) \ template class A; \ - template class A; + template class A; \ + template class A; \ + template class A; #define FermOp5dVecTemplateInstantiate(A) \ template class A; \ diff --git a/lib/qcd/action/fermion/WilsonKernelsHand.cc b/lib/qcd/action/fermion/WilsonKernelsHand.cc index 80b81714..aa6b5f6b 100644 --- a/lib/qcd/action/fermion/WilsonKernelsHand.cc +++ b/lib/qcd/action/fermion/WilsonKernelsHand.cc @@ -946,5 +946,6 @@ INSTANTIATE_THEM(DomainWallVec5dImplFH); INSTANTIATE_THEM(DomainWallVec5dImplDF); INSTANTIATE_THEM(ZDomainWallVec5dImplFH); INSTANTIATE_THEM(ZDomainWallVec5dImplDF); - +INSTANTIATE_THEM(WilsonTwoIndexAntiSymmetricImplF); +INSTANTIATE_THEM(WilsonTwoIndexAntiSymmetricImplD); }} diff --git a/tests/hmc/Test_hmc_WC2ASFG_Production.cc b/tests/hmc/Test_hmc_WC2ASFG_Production.cc index b0d1d3a4..d255ab5d 100644 --- a/tests/hmc/Test_hmc_WC2ASFG_Production.cc +++ b/tests/hmc/Test_hmc_WC2ASFG_Production.cc @@ -2,12 +2,11 @@ Grid physics library, www.github.com/paboyle/Grid -Source file: ./tests/Test_hmc_WilsonAdjointFermionGauge.cc +Source file: ./tests/Test_hmc_WilsonFermionGauge.cc -Copyright (C) 2015 +Copyright (C) 2017 -Author: Peter Boyle -Author: neo +Author: Guido Cossu 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 @@ -27,103 +26,188 @@ See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#include "Grid/Grid.h" +#include -int main(int argc, char **argv) { + +namespace Grid{ + struct FermionParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(FermionParameters, + double, mass, + double, csw, + double, StoppingCondition, + int, MaxCGIterations, + bool, ApplySmearing); + }; + + + struct WilsonCloverHMCParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonCloverHMCParameters, + double, gauge_beta, + FermionParameters, WilsonClover) + + template + WilsonCloverHMCParameters(Reader& Reader){ + read(Reader, "Action", *this); + } + }; + + struct SmearingParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(SmearingParameters, + double, rho, + Integer, Nsmear) + + template + SmearingParameters(Reader& Reader){ + read(Reader, "StoutSmearing", *this); + } + + }; + + +} + +int main(int argc, char **argv) +{ using namespace Grid; using namespace Grid::QCD; - // Here change the allowed (higher) representations - typedef Representations< FundamentalRepresentation, TwoIndexAntiSymmetricRepresentation > TheRepresentations; + typedef Representations< FundamentalRepresentation, TwoIndexAntiSymmetricRepresentation > TheRepresentations; Grid_init(&argc, &argv); int threads = GridThread::GetThreads(); // here make a routine to print all the relevant information on the run std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; - // Typedefs to simplify notation - typedef GenericHMCRunnerHirep HMCWrapper; - + // Typedefs to simplify notation + typedef GenericHMCRunnerHirep HMCWrapper; // Uses the default minimum norm typedef WilsonTwoIndexAntiSymmetricImplR FermionImplPolicy; // gauge field implemetation for the pseudofermions - typedef WilsonTwoIndexAntiSymmetricFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) + typedef WilsonCloverTwoIndexAntiSymmetricFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) typedef typename FermionAction::FermionField FermionField; + typedef Grid::JSONReader Serialiser; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: HMCWrapper TheHMC; // Grid from the command line - TheHMC.Resources.AddFourDimGrid("gauge"); - // Possibile to create the module by hand - // hardcoding parameters or using a Reader + TheHMC.ReadCommandLine(argc, argv); + if (TheHMC.ParameterFile.empty()){ + std::cout << "Input file not specified." + << "Use --ParameterFile option in the command line.\nAborting" + << std::endl; + exit(1); + } + Serialiser Reader(TheHMC.ParameterFile); + WilsonCloverHMCParameters MyParams(Reader); + // Apply smearing to the fermionic action + bool ApplySmearing = MyParams.WilsonClover.ApplySmearing; + + TheHMC.Resources.AddFourDimGrid("gauge"); // Checkpointer definition - CheckpointerParameters CPparams; + CheckpointerParameters CPparams(Reader); + + /* CPparams.config_prefix = "ckpoint_lat"; CPparams.rng_prefix = "ckpoint_rng"; CPparams.saveInterval = 5; CPparams.format = "IEEE64BIG"; + */ TheHMC.Resources.LoadNerscCheckpointer(CPparams); - RNGModuleParameters RNGpar; + RNGModuleParameters RNGpar(Reader); + /* RNGpar.serial_seeds = "1 2 3 4 5"; RNGpar.parallel_seeds = "6 7 8 9 10"; TheHMC.Resources.SetRNGSeeds(RNGpar); + */ + TheHMC.Resources.SetRNGSeeds(RNGpar); // Construct observables typedef PlaquetteMod PlaqObs; TheHMC.Resources.AddObservable(); + + typedef PolyakovMod PolyakovObs; + TheHMC.Resources.AddObservable(); + + //typedef TopologicalChargeMod QObs; + //TopologyObsParameters TopParams(Reader); + //TheHMC.Resources.AddObservable(TopParams); ////////////////////////////////////////////// ///////////////////////////////////////////////////////////// // Collect actions, here use more encapsulation - // need wrappers of the fermionic classes + // need wrappers of the fermionic classes // that have a complex construction // standard - RealD beta = 2.25 ; - WilsonGaugeActionR Waction(beta); - - auto GridPtr = TheHMC.Resources.GetCartesian(); + + //RealD beta = 5.6; + WilsonGaugeActionR Waction(MyParams.gauge_beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); // temporarily need a gauge field - TwoIndexSymmetricRepresentation::LatticeField U(GridPtr); + TwoIndexAntiSymmetricRepresentation::LatticeField U(GridPtr); - Real mass = -0.95; + //Real mass = 0.01; + //Real csw = 1.0; - // Can we define an overloaded operator that does not need U and initialises - // it with zeroes? - FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass); + Real mass = MyParams.WilsonClover.mass; + Real csw = MyParams.WilsonClover.csw; - ConjugateGradient CG(1.0e-8, 2000, false); + std::cout << "mass and csw" << mass << " and " << csw << std::endl; + FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass, csw, csw); + ConjugateGradient CG(MyParams.WilsonClover.StoppingCondition, MyParams.WilsonClover.MaxCGIterations); TwoFlavourPseudoFermionAction Nf2(FermOp, CG, CG); // Set smearing (true/false), default: false - Nf2.is_smeared = false; + Nf2.is_smeared = ApplySmearing; - - // Collect actions - ActionLevel Level1(1); + // Collect actions + ActionLevel Level1(1); Level1.push_back(&Nf2); - ActionLevel Level2(4); + ActionLevel Level2(4); Level2.push_back(&Waction); TheHMC.TheAction.push_back(Level1); TheHMC.TheAction.push_back(Level2); + ///////////////////////////////////////////////////////////// - // HMC parameters are serialisable - TheHMC.Parameters.MD.MDsteps = 20; - TheHMC.Parameters.MD.trajL = 1.0; - TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file - TheHMC.Run(); // no smearing + /* + double rho = 0.1; // smearing parameter + int Nsmear = 2; // number of smearing levels + Smear_Stout Stout(rho); + SmearedConfiguration SmearingPolicy( + UGrid, Nsmear, Stout); + */ + + // HMC parameters are serialisable + + TheHMC.Parameters.initialize(Reader); + //TheHMC.Parameters.MD.MDsteps = 20; + //TheHMC.Parameters.MD.trajL = 1.0; + + if (ApplySmearing){ + SmearingParameters SmPar(Reader); + //double rho = 0.1; // smearing parameter + //int Nsmear = 3; // number of smearing levels + Smear_Stout Stout(SmPar.rho); + SmearedConfiguration SmearingPolicy(GridPtr, SmPar.Nsmear, Stout); + TheHMC.Run(SmearingPolicy); // for smearing + } else { + TheHMC.Run(); // no smearing + } + + //TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + //TheHMC.Run(); // no smearing // TheHMC.Run(SmearingPolicy); // for smearing Grid_finalize(); } // main - diff --git a/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc b/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc index b54345cf..a79452f4 100644 --- a/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc +++ b/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc @@ -32,6 +32,40 @@ directory #include "Grid/Grid.h" +namespace Grid{ + struct FermionParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(FermionParameters, + double, mass, + double, csw, + double, StoppingCondition, + int, MaxCGIterations, + bool, ApplySmearing); + }; + + struct WilsonCloverHMCParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonCloverHMCParameters, + double, gauge_beta, + FermionParameters, WilsonCloverFund, + FermionParameters, WilsonCloverAS) + + template + WilsonCloverHMCParameters(Reader& Reader){ + read(Reader, "Action", *this); + } + }; + + struct SmearingParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(SmearingParameters, + double, rho, + Integer, Nsmear) + + template + SmearingParameters(Reader& Reader){ + read(Reader, "StoutSmearing", *this); + } + + }; +} int main(int argc, char **argv) { @@ -39,7 +73,7 @@ int main(int argc, char **argv) { using namespace Grid::QCD; // Here change the allowed (higher) representations - typedef Representations< FundamentalRepresentation, AdjointRepresentation , TwoIndexSymmetricRepresentation> TheRepresentations; + typedef Representations< FundamentalRepresentation, TwoIndexAntiSymmetricRepresentation> TheRepresentations; Grid_init(&argc, &argv); int threads = GridThread::GetThreads(); @@ -49,91 +83,142 @@ int main(int argc, char **argv) { // Typedefs to simplify notation typedef GenericHMCRunnerHirep HMCWrapper; - typedef WilsonAdjImplR AdjImplPolicy; // gauge field implemetation for the pseudofermions - typedef WilsonAdjFermionR AdjFermionAction; // type of lattice fermions (Wilson, DW, ...) - typedef WilsonTwoIndexSymmetricImplR SymmImplPolicy; - typedef WilsonTwoIndexSymmetricFermionR SymmFermionAction; + typedef WilsonImplR FundImplPolicy; + typedef WilsonCloverFermionR FundFermionAction; + typedef typename FundFermionAction::FermionField FundFermionField; + typedef WilsonTwoIndexAntiSymmetricImplR ASymmImplPolicy; + typedef WilsonCloverTwoIndexAntiSymmetricFermionR ASymmFermionAction; + typedef typename ASymmFermionAction::FermionField ASymmFermionField; - typedef typename AdjFermionAction::FermionField AdjFermionField; - typedef typename SymmFermionAction::FermionField SymmFermionField; - + typedef Grid::JSONReader Serialiser; //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: HMCWrapper TheHMC; - - // Grid from the command line - TheHMC.Resources.AddFourDimGrid("gauge"); - // Possibile to create the module by hand - // hardcoding parameters or using a Reader - - - // Checkpointer definition - CheckpointerParameters CPparams; - CPparams.config_prefix = "ckpoint_lat"; - CPparams.rng_prefix = "ckpoint_rng"; - CPparams.saveInterval = 5; - CPparams.format = "IEEE64BIG"; - TheHMC.Resources.LoadNerscCheckpointer(CPparams); - - RNGModuleParameters RNGpar; - RNGpar.serial_seeds = "1 2 3 4 5"; - RNGpar.parallel_seeds = "6 7 8 9 10"; - TheHMC.Resources.SetRNGSeeds(RNGpar); - - // Construct observables - typedef PlaquetteMod PlaqObs; - TheHMC.Resources.AddObservable(); - ////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////// - // Collect actions, here use more encapsulation - // need wrappers of the fermionic classes - // that have a complex construction - // standard - RealD beta = 2.25 ; - WilsonGaugeActionR Waction(beta); + // Grid from the command line + TheHMC.ReadCommandLine(argc, argv); + if (TheHMC.ParameterFile.empty()){ + std::cout << "Input file not specified." + << "Use --ParameterFile option in the command line.\nAborting" + << std::endl; + exit(1); + } + Serialiser Reader(TheHMC.ParameterFile); + WilsonCloverHMCParameters MyParams(Reader); + + // Apply smearing to the fermionic action + bool ApplySmearingFund = MyParams.WilsonCloverFund.ApplySmearing; + bool ApplySmearingAS = MyParams.WilsonCloverAS.ApplySmearing; - auto GridPtr = TheHMC.Resources.GetCartesian(); - auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); - // temporarily need a gauge field - AdjointRepresentation::LatticeField UA(GridPtr); - TwoIndexSymmetricRepresentation::LatticeField US(GridPtr); + TheHMC.Resources.AddFourDimGrid("gauge"); + + // Checkpointer definition + CheckpointerParameters CPparams(Reader); + + /* + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + */ + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar(Reader); + /* + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + */ + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + + typedef PolyakovMod PolyakovObs; + TheHMC.Resources.AddObservable(); + + //typedef TopologicalChargeMod QObs; + //TopologyObsParameters TopParams(Reader); + //TheHMC.Resources.AddObservable(TopParams); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + + //RealD beta = 5.6; + WilsonGaugeActionR Waction(MyParams.gauge_beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + // temporarily need a gauge field + FundamentalRepresentation::LatticeField UF(GridPtr); + TwoIndexAntiSymmetricRepresentation::LatticeField UAS(GridPtr); - Real adjoint_mass = -0.1; - Real symm_mass = -0.5; - AdjFermionAction AdjFermOp(UA, *GridPtr, *GridRBPtr, adjoint_mass); - SymmFermionAction SymmFermOp(US, *GridPtr, *GridRBPtr, symm_mass); - ConjugateGradient CG_adj(1.0e-8, 10000, false); - ConjugateGradient CG_symm(1.0e-8, 10000, false); + Real Fundmass = MyParams.WilsonCloverFund.mass; + Real Fundcsw = MyParams.WilsonCloverFund.csw; + Real ASmass = MyParams.WilsonCloverAS.mass; + Real AScsw = MyParams.WilsonCloverAS.csw; - // Pass two solvers: one for the force computation and one for the action - TwoFlavourPseudoFermionAction Nf2_Adj(AdjFermOp, CG_adj, CG_adj); - TwoFlavourPseudoFermionAction Nf2_Symm(SymmFermOp, CG_symm, CG_symm); + + + std::cout << "Fund: mass and csw" << Fundmass << " and " << Fundcsw << std::endl; + std::cout << "AS : mass and csw" << ASmass << " and " << AScsw << std::endl; + + + FundFermionAction FundFermOp(UF, *GridPtr, *GridRBPtr, Fundmass, Fundcsw, Fundcsw); + ConjugateGradient CG_Fund(MyParams.WilsonCloverFund.StoppingCondition, MyParams.WilsonCloverFund.MaxCGIterations); + TwoFlavourPseudoFermionAction Nf2_Fund(FundFermOp, CG_Fund, CG_Fund); + + ASymmFermionAction ASFermOp(UAS, *GridPtr, *GridRBPtr, ASmass, AScsw, AScsw); + ConjugateGradient CG_AS(MyParams.WilsonCloverAS.StoppingCondition, MyParams.WilsonCloverAS.MaxCGIterations); + TwoFlavourPseudoFermionAction Nf2_AS(ASFermOp, CG_AS, CG_AS); + + Nf2_Fund.is_smeared = ApplySmearingFund; + Nf2_AS.is_smeared = ApplySmearingAS; + // Collect actions - ActionLevel Level1(1); - Level1.push_back(&Nf2_Adj); - Level1.push_back(&Nf2_Symm); + ActionLevel Level1(1); + Level1.push_back(&Nf2_Fund); + Level1.push_back(&Nf2_AS); - ActionLevel Level2(4); + ActionLevel Level2(4); Level2.push_back(&Waction); TheHMC.TheAction.push_back(Level1); TheHMC.TheAction.push_back(Level2); - // HMC parameters are serialisable - TheHMC.Parameters.MD.MDsteps = 20; - TheHMC.Parameters.MD.trajL = 1.0; + TheHMC.Parameters.initialize(Reader); + //TheHMC.Parameters.MD.MDsteps = 20; + //TheHMC.Parameters.MD.trajL = 1.0; +/* + if (ApplySmearingFund || ApplySmearingAS){ + SmearingParameters SmPar(Reader); + //double rho = 0.1; // smearing parameter + //int Nsmear = 3; // number of smearing levels + Smear_Stout Stout(SmPar.rho); + SmearedConfiguration SmearingPolicy(GridPtr, SmPar.Nsmear, Stout); + TheHMC.Run(SmearingPolicy); // for smearing + } else { + TheHMC.Run(); // no smearing + } +*/ + TheHMC.Run(); - TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file - TheHMC.Run(); // no smearing + + //TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + //TheHMC.Run(); // no smearing + // TheHMC.Run(SmearingPolicy); // for smearing Grid_finalize(); } // main - - diff --git a/tests/hmc/Test_hmc_WCadjFG_Production.cc b/tests/hmc/Test_hmc_WCadjFG_Production.cc new file mode 100644 index 00000000..b99c1189 --- /dev/null +++ b/tests/hmc/Test_hmc_WCadjFG_Production.cc @@ -0,0 +1,213 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./tests/Test_hmc_WilsonFermionGauge.cc + +Copyright (C) 2017 + +Author: Guido Cossu + +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 +*************************************************************************************/ +/* END LEGAL */ +#include + + +namespace Grid{ + struct FermionParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(FermionParameters, + double, mass, + double, csw, + double, StoppingCondition, + int, MaxCGIterations, + bool, ApplySmearing); + }; + + + struct WilsonCloverHMCParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonCloverHMCParameters, + double, gauge_beta, + FermionParameters, WilsonClover) + + template + WilsonCloverHMCParameters(Reader& Reader){ + read(Reader, "Action", *this); + } + }; + + struct SmearingParameters: Serializable { + GRID_SERIALIZABLE_CLASS_MEMBERS(SmearingParameters, + double, rho, + Integer, Nsmear) + + template + SmearingParameters(Reader& Reader){ + read(Reader, "StoutSmearing", *this); + } + + }; + + +} + +int main(int argc, char **argv) +{ + using namespace Grid; + using namespace Grid::QCD; + + typedef Representations< FundamentalRepresentation, AdjointRepresentation > TheRepresentations; + + Grid_init(&argc, &argv); + int threads = GridThread::GetThreads(); + // here make a routine to print all the relevant information on the run + std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl; + + // Typedefs to simplify notation + typedef GenericHMCRunnerHirep HMCWrapper; // Uses the default minimum norm + typedef WilsonAdjImplR FermionImplPolicy; // gauge field implemetation for the pseudofermions + typedef WilsonCloverAdjFermionR FermionAction; // type of lattice fermions (Wilson, DW, ...) + typedef typename FermionAction::FermionField FermionField; + typedef Grid::JSONReader Serialiser; + + //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + HMCWrapper TheHMC; + + // Grid from the command line + TheHMC.ReadCommandLine(argc, argv); + if (TheHMC.ParameterFile.empty()){ + std::cout << "Input file not specified." + << "Use --ParameterFile option in the command line.\nAborting" + << std::endl; + exit(1); + } + Serialiser Reader(TheHMC.ParameterFile); + WilsonCloverHMCParameters MyParams(Reader); + + // Apply smearing to the fermionic action + bool ApplySmearing = MyParams.WilsonClover.ApplySmearing; + + TheHMC.Resources.AddFourDimGrid("gauge"); + + // Checkpointer definition + CheckpointerParameters CPparams(Reader); + + /* + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.saveInterval = 5; + CPparams.format = "IEEE64BIG"; + */ + + TheHMC.Resources.LoadNerscCheckpointer(CPparams); + + RNGModuleParameters RNGpar(Reader); + /* + RNGpar.serial_seeds = "1 2 3 4 5"; + RNGpar.parallel_seeds = "6 7 8 9 10"; + TheHMC.Resources.SetRNGSeeds(RNGpar); + */ + TheHMC.Resources.SetRNGSeeds(RNGpar); + + // Construct observables + typedef PlaquetteMod PlaqObs; + TheHMC.Resources.AddObservable(); + + typedef PolyakovMod PolyakovObs; + TheHMC.Resources.AddObservable(); + + //typedef TopologicalChargeMod QObs; + //TopologyObsParameters TopParams(Reader); + //TheHMC.Resources.AddObservable(TopParams); + ////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////// + // Collect actions, here use more encapsulation + // need wrappers of the fermionic classes + // that have a complex construction + // standard + + //RealD beta = 5.6; + WilsonGaugeActionR Waction(MyParams.gauge_beta); + + auto GridPtr = TheHMC.Resources.GetCartesian(); + auto GridRBPtr = TheHMC.Resources.GetRBCartesian(); + + // temporarily need a gauge field + AdjointRepresentation::LatticeField U(GridPtr); + + //Real mass = 0.01; + //Real csw = 1.0; + + Real mass = MyParams.WilsonClover.mass; + Real csw = MyParams.WilsonClover.csw; + + std::cout << "mass and csw" << mass << " and " << csw << std::endl; + + FermionAction FermOp(U, *GridPtr, *GridRBPtr, mass, csw, csw); + ConjugateGradient CG(MyParams.WilsonClover.StoppingCondition, MyParams.WilsonClover.MaxCGIterations); + TwoFlavourPseudoFermionAction Nf2(FermOp, CG, CG); + + // Set smearing (true/false), default: false + Nf2.is_smeared = ApplySmearing; + + // Collect actions + ActionLevel Level1(1); + Level1.push_back(&Nf2); + + ActionLevel Level2(4); + Level2.push_back(&Waction); + + TheHMC.TheAction.push_back(Level1); + TheHMC.TheAction.push_back(Level2); + ///////////////////////////////////////////////////////////// + + + /* + double rho = 0.1; // smearing parameter + int Nsmear = 2; // number of smearing levels + Smear_Stout Stout(rho); + SmearedConfiguration SmearingPolicy( + UGrid, Nsmear, Stout); + */ + + // HMC parameters are serialisable + + TheHMC.Parameters.initialize(Reader); + //TheHMC.Parameters.MD.MDsteps = 20; + //TheHMC.Parameters.MD.trajL = 1.0; + + if (ApplySmearing){ + SmearingParameters SmPar(Reader); + //double rho = 0.1; // smearing parameter + //int Nsmear = 3; // number of smearing levels + Smear_Stout Stout(SmPar.rho); + SmearedConfiguration SmearingPolicy(GridPtr, SmPar.Nsmear, Stout); + TheHMC.Run(SmearingPolicy); // for smearing + } else { + TheHMC.Run(); // no smearing + } + + //TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file + //TheHMC.Run(); // no smearing + // TheHMC.Run(SmearingPolicy); // for smearing + + Grid_finalize(); + +} // main + From 59d9ccf70cfaa57078aafe81aa3455f8e05b7d48 Mon Sep 17 00:00:00 2001 From: pretidav Date: Wed, 8 Nov 2017 22:02:32 +0100 Subject: [PATCH 36/43] restored WilsonKernelsHand.cc and added Qtop to production codes --- lib/qcd/action/fermion/WilsonKernelsHand.cc | 2 -- tests/hmc/Test_hmc_WCMixedRepFG_Production.cc | 6 +++--- tests/hmc/Test_hmc_WCadjFG_Production.cc | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/qcd/action/fermion/WilsonKernelsHand.cc b/lib/qcd/action/fermion/WilsonKernelsHand.cc index aa6b5f6b..90e6cb9b 100644 --- a/lib/qcd/action/fermion/WilsonKernelsHand.cc +++ b/lib/qcd/action/fermion/WilsonKernelsHand.cc @@ -946,6 +946,4 @@ INSTANTIATE_THEM(DomainWallVec5dImplFH); INSTANTIATE_THEM(DomainWallVec5dImplDF); INSTANTIATE_THEM(ZDomainWallVec5dImplFH); INSTANTIATE_THEM(ZDomainWallVec5dImplDF); -INSTANTIATE_THEM(WilsonTwoIndexAntiSymmetricImplF); -INSTANTIATE_THEM(WilsonTwoIndexAntiSymmetricImplD); }} diff --git a/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc b/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc index a79452f4..aa5cce85 100644 --- a/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc +++ b/tests/hmc/Test_hmc_WCMixedRepFG_Production.cc @@ -140,9 +140,9 @@ int main(int argc, char **argv) { typedef PolyakovMod PolyakovObs; TheHMC.Resources.AddObservable(); - //typedef TopologicalChargeMod QObs; - //TopologyObsParameters TopParams(Reader); - //TheHMC.Resources.AddObservable(TopParams); + typedef TopologicalChargeMod QObs; + TopologyObsParameters TopParams(Reader); + TheHMC.Resources.AddObservable(TopParams); ////////////////////////////////////////////// ///////////////////////////////////////////////////////////// diff --git a/tests/hmc/Test_hmc_WCadjFG_Production.cc b/tests/hmc/Test_hmc_WCadjFG_Production.cc index b99c1189..48cea756 100644 --- a/tests/hmc/Test_hmc_WCadjFG_Production.cc +++ b/tests/hmc/Test_hmc_WCadjFG_Production.cc @@ -131,9 +131,9 @@ int main(int argc, char **argv) typedef PolyakovMod PolyakovObs; TheHMC.Resources.AddObservable(); - //typedef TopologicalChargeMod QObs; - //TopologyObsParameters TopParams(Reader); - //TheHMC.Resources.AddObservable(TopParams); + typedef TopologicalChargeMod QObs; + TopologyObsParameters TopParams(Reader); + TheHMC.Resources.AddObservable(TopParams); ////////////////////////////////////////////// ///////////////////////////////////////////////////////////// From 6a15e2e8ef25e54c966d44169c7f2ab4d6d1c1d0 Mon Sep 17 00:00:00 2001 From: pretidav Date: Sun, 12 Nov 2017 14:16:19 +0100 Subject: [PATCH 37/43] Added WilsonTwoIndexAntiSymmImpl instantiation in WilsonKernelsHand.cc (shoud not be necessary) --- lib/qcd/action/fermion/WilsonKernelsHand.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/qcd/action/fermion/WilsonKernelsHand.cc b/lib/qcd/action/fermion/WilsonKernelsHand.cc index 90e6cb9b..aa6b5f6b 100644 --- a/lib/qcd/action/fermion/WilsonKernelsHand.cc +++ b/lib/qcd/action/fermion/WilsonKernelsHand.cc @@ -946,4 +946,6 @@ INSTANTIATE_THEM(DomainWallVec5dImplFH); INSTANTIATE_THEM(DomainWallVec5dImplDF); INSTANTIATE_THEM(ZDomainWallVec5dImplFH); INSTANTIATE_THEM(ZDomainWallVec5dImplDF); +INSTANTIATE_THEM(WilsonTwoIndexAntiSymmetricImplF); +INSTANTIATE_THEM(WilsonTwoIndexAntiSymmetricImplD); }} From 4ce63af7d5945b89043797b4de1613f0fbaf4798 Mon Sep 17 00:00:00 2001 From: pretidav Date: Fri, 22 Dec 2017 19:02:07 +0100 Subject: [PATCH 38/43] Working on Hadrons with Hirep. (QCD is set for SU4) --- extras/Hadrons/Modules.hpp | 42 ++--- .../Hadrons/Modules/MAction/WilsonClover.hpp | 142 +++++++++++++++ extras/Hadrons/Modules/MFermion/GaugeProp.hpp | 13 +- extras/Hadrons/Modules/MGauge/FundtoHirep.cc | 75 ++++++++ extras/Hadrons/Modules/MGauge/FundtoHirep.hpp | 77 ++++++++ extras/Hadrons/modules.inc | 51 +++--- lib/qcd/QCD.h | 18 +- lib/qcd/action/fermion/WilsonFermion.h | 3 +- tests/hadrons/Test_hadrons_2AS_spectrum.cc | 168 ++++++++++++++++++ tests/lanczos/Test_WCMultiRep_lanczos.cc | 108 +++++++++++ 10 files changed, 637 insertions(+), 60 deletions(-) create mode 100644 extras/Hadrons/Modules/MAction/WilsonClover.hpp create mode 100644 extras/Hadrons/Modules/MGauge/FundtoHirep.cc create mode 100644 extras/Hadrons/Modules/MGauge/FundtoHirep.hpp create mode 100644 tests/hadrons/Test_hadrons_2AS_spectrum.cc create mode 100644 tests/lanczos/Test_WCMultiRep_lanczos.cc diff --git a/extras/Hadrons/Modules.hpp b/extras/Hadrons/Modules.hpp index c27254aa..262795e8 100644 --- a/extras/Hadrons/Modules.hpp +++ b/extras/Hadrons/Modules.hpp @@ -1,25 +1,27 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/extras/Hadrons/Modules/MAction/WilsonClover.hpp b/extras/Hadrons/Modules/MAction/WilsonClover.hpp new file mode 100644 index 00000000..44b1f0b7 --- /dev/null +++ b/extras/Hadrons/Modules/MAction/WilsonClover.hpp @@ -0,0 +1,142 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: extras/Hadrons/Modules/MAction/Wilson.hpp + +Copyright (C) 2015 +Copyright (C) 2016 + +Author: Antonin Portelli + +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 +*************************************************************************************/ +/* END LEGAL */ + +#ifndef Hadrons_MAction_WilsonClover_hpp_ +#define Hadrons_MAction_WilsonClover_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * TWilson quark action * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MAction) + +class WilsonCloverPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonCloverPar, + std::string, gauge, + double , mass, + double , csw_r, + double , csw_t, + WilsonAnisotropyCoefficients ,clover_anisotropy, + std::string, boundary + ); +}; + +template +class TWilsonClover: public Module +{ +public: + FGS_TYPE_ALIASES(FImpl,); +public: + // constructor + TWilsonClover(const std::string name); + // destructor + virtual ~TWilsonClover(void) = default; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_NS(WilsonClover, TWilsonClover, MAction); + +/****************************************************************************** + * TWilsonClover template implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TWilsonClover::TWilsonClover(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TWilsonClover::getInput(void) +{ + std::vector in = {par().gauge}; + + return in; +} + +template +std::vector TWilsonClover::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TWilsonClover::setup(void) +{ + unsigned int size; + + size = 2*env().template lattice4dSize(); + env().registerObject(getName(), size); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TWilsonClover::execute() +{ + LOG(Message) << "Setting up TWilsonClover fermion matrix with m= " << par().mass + << " using gauge field '" << par().gauge << "'" << std::endl; + LOG(Message) << "Fermion boundary conditions: " << par().boundary + << std::endl; + LOG(Message) << "clover term csw_r= " << par().csw_r + << " csw_t= " << par().csw_t + << std::endl; + auto &U = *env().template getObject(par().gauge); + auto &grid = *env().getGrid(); + auto &gridRb = *env().getRbGrid(); + std::vector boundary = strToVec(par().boundary); + typename WilsonCloverFermion::ImplParams implParams(boundary); + FMat *fMatPt = new WilsonCloverFermion(U, grid, gridRb, par().mass, + par().csw_r, + par().csw_t, + par().clover_anisotropy, + implParams); + env().setObject(getName(), fMatPt); +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_WilsonClover_hpp_ diff --git a/extras/Hadrons/Modules/MFermion/GaugeProp.hpp b/extras/Hadrons/Modules/MFermion/GaugeProp.hpp index b4f9edcc..4e802710 100644 --- a/extras/Hadrons/Modules/MFermion/GaugeProp.hpp +++ b/extras/Hadrons/Modules/MFermion/GaugeProp.hpp @@ -43,7 +43,6 @@ private: }; MODULE_REGISTER_NS(GaugeProp, TGaugeProp, MFermion); - /****************************************************************************** * TGaugeProp implementation * ******************************************************************************/ @@ -103,7 +102,7 @@ void TGaugeProp::execute(void) LOG(Message) << "Inverting using solver '" << par().solver << "' on source '" << par().source << "'" << std::endl; for (unsigned int s = 0; s < Ns; ++s) - for (unsigned int c = 0; c < Nc; ++c) + for (unsigned int c = 0; c < FImpl::Dimension; ++c) { LOG(Message) << "Inversion for spin= " << s << ", color= " << c << std::endl; @@ -112,12 +111,12 @@ void TGaugeProp::execute(void) { if (Ls_ == 1) { - PropToFerm(source, fullSrc, s, c); + PropToFerm(source, fullSrc, s, c); } else { source = zero; - PropToFerm(tmp, fullSrc, s, c); + PropToFerm(tmp, fullSrc, s, c); InsertSlice(tmp, source, 0, 0); InsertSlice(tmp, source, Ls_-1, 0); axpby_ssp_pplus(source, 0., source, 1., source, 0, 0); @@ -133,12 +132,12 @@ void TGaugeProp::execute(void) } else { - PropToFerm(source, fullSrc, s, c); + PropToFerm(source, fullSrc, s, c); } } sol = zero; solver(sol, source); - FermToProp(prop, sol, s, c); + FermToProp(prop, sol, s, c); // create 4D propagators from 5D one if necessary if (Ls_ > 1) { @@ -148,7 +147,7 @@ void TGaugeProp::execute(void) axpby_ssp_pminus(sol, 0., sol, 1., sol, 0, 0); axpby_ssp_pplus(sol, 1., sol, 1., sol, 0, Ls_-1); ExtractSlice(tmp, sol, 0, 0); - FermToProp(p4d, tmp, s, c); + FermToProp(p4d, tmp, s, c); } } } diff --git a/extras/Hadrons/Modules/MGauge/FundtoHirep.cc b/extras/Hadrons/Modules/MGauge/FundtoHirep.cc new file mode 100644 index 00000000..f15a3b7c --- /dev/null +++ b/extras/Hadrons/Modules/MGauge/FundtoHirep.cc @@ -0,0 +1,75 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: extras/Hadrons/Modules/MGauge/FundtoHirep.cc + +Copyright (C) 2015 +Copyright (C) 2016 + + +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 +*************************************************************************************/ +/* END LEGAL */ + +#include + +using namespace Grid; +using namespace Hadrons; +using namespace MGauge; + +// constructor ///////////////////////////////////////////////////////////////// +template +TFundtoHirep::TFundtoHirep(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TFundtoHirep::getInput(void) +{ + std::vector in; + return in; +} + +template +std::vector TFundtoHirep::getOutput(void) +{ + std::vector out = {getName()}; + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TFundtoHirep::setup(void) +{ + env().template registerLattice(getName()); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TFundtoHirep::execute(void) +{ + auto &U = *env().template getObject(par().gaugeconf); + LOG(Message) << "Transforming Representation" << std::endl; + + Rep TargetRepresentation(U._grid); + TargetRepresentation.update_representation(U); + + typename Rep::LatticeField &URep = *env().template createLattice(getName()); + URep = TargetRepresentation.U; +} diff --git a/extras/Hadrons/Modules/MGauge/FundtoHirep.hpp b/extras/Hadrons/Modules/MGauge/FundtoHirep.hpp new file mode 100644 index 00000000..6f072783 --- /dev/null +++ b/extras/Hadrons/Modules/MGauge/FundtoHirep.hpp @@ -0,0 +1,77 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: extras/Hadrons/Modules/MGauge/FundtoHirep.hpp + +Copyright (C) 2015 +Copyright (C) 2016 + +Author: David Preti + Guido Cossu + +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 +*************************************************************************************/ +/* END LEGAL */ + +#ifndef Hadrons_MGauge_FundtoHirep_hpp_ +#define Hadrons_MGauge_FundtoHirep_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Load a NERSC configuration * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MGauge) + +class FundtoHirepPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(FundtoHirepPar, + std::string, gaugeconf); +}; + +template +class TFundtoHirep: public Module +{ +public: + // constructor + TFundtoHirep(const std::string name); + // destructor + virtual ~TFundtoHirep(void) = default; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + void setup(void); + // execution + void execute(void); +}; + +//MODULE_REGISTER_NS(FundtoAdjoint, TFundtoHirep, MGauge); +//MODULE_REGISTER_NS(FundtoTwoIndexSym, TFundtoHirep, MGauge); +//MODULE_REGISTER_NS(FundtoTwoIndexAsym, TFundtoHirep, MGauge); + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MGauge_FundtoHirep_hpp_ diff --git a/extras/Hadrons/modules.inc b/extras/Hadrons/modules.inc index 669b08ba..089341c1 100644 --- a/extras/Hadrons/modules.inc +++ b/extras/Hadrons/modules.inc @@ -1,38 +1,41 @@ modules_cc =\ + Modules/MScalar/ChargedProp.cc \ + Modules/MScalar/FreeProp.cc \ Modules/MContraction/WeakHamiltonianEye.cc \ Modules/MContraction/WeakHamiltonianNonEye.cc \ Modules/MContraction/WeakNeutral4ptDisc.cc \ - Modules/MGauge/Load.cc \ - Modules/MGauge/Random.cc \ Modules/MGauge/StochEm.cc \ Modules/MGauge/Unit.cc \ - Modules/MScalar/ChargedProp.cc \ - Modules/MScalar/FreeProp.cc + Modules/MGauge/Load.cc \ + Modules/MGauge/FundtoHirep.cc \ + Modules/MGauge/Random.cc modules_hpp =\ - Modules/MAction/DWF.hpp \ - Modules/MAction/Wilson.hpp \ - Modules/MContraction/Baryon.hpp \ - Modules/MContraction/DiscLoop.hpp \ - Modules/MContraction/Gamma3pt.hpp \ - Modules/MContraction/Meson.hpp \ - Modules/MContraction/WeakHamiltonian.hpp \ - Modules/MContraction/WeakHamiltonianEye.hpp \ - Modules/MContraction/WeakHamiltonianNonEye.hpp \ - Modules/MContraction/WeakNeutral4ptDisc.hpp \ - Modules/MFermion/GaugeProp.hpp \ - Modules/MGauge/Load.hpp \ - Modules/MGauge/Random.hpp \ - Modules/MGauge/StochEm.hpp \ - Modules/MGauge/Unit.hpp \ Modules/MLoop/NoiseLoop.hpp \ Modules/MScalar/ChargedProp.hpp \ - Modules/MScalar/FreeProp.hpp \ Modules/MScalar/Scalar.hpp \ + Modules/MScalar/FreeProp.hpp \ + Modules/MSource/Wall.hpp \ + Modules/MSource/SeqGamma.hpp \ + Modules/MSource/Point.hpp \ + Modules/MSource/Z2.hpp \ + Modules/MFermion/GaugeProp.hpp \ + Modules/MContraction/Meson.hpp \ + Modules/MContraction/WeakHamiltonianNonEye.hpp \ + Modules/MContraction/WeakHamiltonianEye.hpp \ + Modules/MContraction/DiscLoop.hpp \ + Modules/MContraction/Baryon.hpp \ + Modules/MContraction/Gamma3pt.hpp \ + Modules/MContraction/WeakNeutral4ptDisc.hpp \ + Modules/MContraction/WeakHamiltonian.hpp \ Modules/MSink/Point.hpp \ Modules/MSolver/RBPrecCG.hpp \ - Modules/MSource/Point.hpp \ - Modules/MSource/SeqGamma.hpp \ - Modules/MSource/Wall.hpp \ - Modules/MSource/Z2.hpp + Modules/MGauge/StochEm.hpp \ + Modules/MGauge/FundtoHirep.hpp \ + Modules/MGauge/Unit.hpp \ + Modules/MGauge/Load.hpp \ + Modules/MGauge/Random.hpp \ + Modules/MAction/WilsonClover.hpp \ + Modules/MAction/DWF.hpp \ + Modules/MAction/Wilson.hpp diff --git a/lib/qcd/QCD.h b/lib/qcd/QCD.h index 9913a071..2caea7e9 100644 --- a/lib/qcd/QCD.h +++ b/lib/qcd/QCD.h @@ -49,7 +49,7 @@ namespace QCD { static const int Zm = 6; static const int Tm = 7; - static const int Nc=3; + static const int Nc=4; static const int Ns=4; static const int Nd=4; static const int Nhs=2; // half spinor @@ -421,15 +421,16 @@ namespace QCD { ////////////////////////////////////////////// // Fermion <-> propagator assignements ////////////////////////////////////////////// - template - void FermToProp(Prop &p, const Ferm &f, const int s, const int c) + //template + template + void FermToProp(typename Fimpl::PropagatorField &p, const typename Fimpl::FermionField &f, const int s, const int c) { - for(int j = 0; j < Ns; ++j) + for(int j = 0; j < Ns; ++j) { auto pjs = peekSpin(p, j, s); auto fj = peekSpin(f, j); - for(int i = 0; i < Nc; ++i) + for(int i = 0; i < Fimpl::Dimension; ++i) { pokeColour(pjs, peekColour(fj, i), i, c); } @@ -437,15 +438,16 @@ namespace QCD { } } - template - void PropToFerm(Ferm &f, const Prop &p, const int s, const int c) + //template + template + void PropToFerm(typename Fimpl::FermionField &f, const typename Fimpl::PropagatorField &p, const int s, const int c) { for(int j = 0; j < Ns; ++j) { auto pjs = peekSpin(p, j, s); auto fj = peekSpin(f, j); - for(int i = 0; i < Nc; ++i) + for(int i = 0; i < Fimpl::Dimension; ++i) { pokeColour(fj, peekColour(pjs, i, c), i); } diff --git a/lib/qcd/action/fermion/WilsonFermion.h b/lib/qcd/action/fermion/WilsonFermion.h index ca5eba8b..0aea4b68 100644 --- a/lib/qcd/action/fermion/WilsonFermion.h +++ b/lib/qcd/action/fermion/WilsonFermion.h @@ -44,7 +44,8 @@ class WilsonFermionStatic { static const int npoint = 8; }; -struct WilsonAnisotropyCoefficients{ + struct WilsonAnisotropyCoefficients: Serializable + { GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonAnisotropyCoefficients, bool, isAnisotropic, int, t_direction, diff --git a/tests/hadrons/Test_hadrons_2AS_spectrum.cc b/tests/hadrons/Test_hadrons_2AS_spectrum.cc new file mode 100644 index 00000000..2f519834 --- /dev/null +++ b/tests/hadrons/Test_hadrons_2AS_spectrum.cc @@ -0,0 +1,168 @@ +/******************************************************************************* + Grid physics library, www.github.com/paboyle/Grid + + Source file: tests/hadrons/Test_hadrons_spectrum.cc + + Copyright (C) 2015 + + Author: Antonin Portelli + + 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. + *******************************************************************************/ + +#include + +using namespace Grid; +using namespace Hadrons; + + + BEGIN_HADRONS_NAMESPACE + BEGIN_MODULE_NAMESPACE(MFermion) + MODULE_REGISTER_NS(GaugeProp2AS, TGaugeProp, MFermion); + END_MODULE_NAMESPACE + BEGIN_MODULE_NAMESPACE(MSource) + MODULE_REGISTER_NS(Point2AS, TPoint, MSource); + END_MODULE_NAMESPACE + BEGIN_MODULE_NAMESPACE(MContraction) + MODULE_REGISTER_NS(Meson2AS, ARG(TMeson), MContraction); +// MODULE_REGISTER_NS(BaryonMultirep, ARG(TBaryon), MContraction); + END_MODULE_NAMESPACE + BEGIN_MODULE_NAMESPACE(MSink) + MODULE_REGISTER_NS(ScalarPoint2AS, TPoint, MSink); + END_MODULE_NAMESPACE + BEGIN_MODULE_NAMESPACE(MSolver) + MODULE_REGISTER_NS(RBPrecCG2AS, TRBPrecCG, MSolver); + END_MODULE_NAMESPACE + BEGIN_MODULE_NAMESPACE(MAction) + MODULE_REGISTER_NS(WilsonClover2AS, TWilsonClover, MAction); + END_MODULE_NAMESPACE + END_HADRONS_NAMESPACE + + +int main(int argc, char *argv[]) +{ + // initialization ////////////////////////////////////////////////////////// + Grid_init(&argc, &argv); + HadronsLogError.Active(GridLogError.isActive()); + HadronsLogWarning.Active(GridLogWarning.isActive()); + HadronsLogMessage.Active(GridLogMessage.isActive()); + HadronsLogIterative.Active(GridLogIterative.isActive()); + HadronsLogDebug.Active(GridLogDebug.isActive()); + LOG(Message) << "Grid initialized" << std::endl; + // run setup /////////////////////////////////////////////////////////////// + Application application; + std::vector flavour = {"l", "s"}; + std::vector mass = {-0.01, -0.04}; + double csw = 1.0; + // global parameters + Application::GlobalPar globalPar; + globalPar.trajCounter.start = 1500; + globalPar.trajCounter.end = 1520; + globalPar.trajCounter.step = 20; + globalPar.seed = "1 2 3 4"; + application.setPar(globalPar); + // gauge field + application.createModule("gauge"); + MSource::Point2AS::Par ptPar; + ptPar.position = "0 0 0 0"; + application.createModule("pt", ptPar); + // sink + MSink::ScalarPoint2AS::Par sinkPar; + sinkPar.mom = "0 0 0"; + application.createModule("sink", sinkPar); + + // set fermion boundary conditions to be periodic space, antiperiodic time. + std::string boundary = "1 1 1 -1"; + + for (unsigned int i = 0; i < flavour.size(); ++i) + { + // actions + MAction::WilsonClover2AS::Par actionPar; + actionPar.gauge = "gauge"; + actionPar.mass = mass[i]; + actionPar.csw_r = csw; + actionPar.csw_t = csw; + actionPar.clover_anisotropy.isAnisotropic= false; + actionPar.clover_anisotropy.t_direction = Nd-1 ; + actionPar.clover_anisotropy.xi_0 = 1.0 ; + actionPar.clover_anisotropy.nu = 1.0 ; + actionPar.boundary = boundary; + application.createModule("WilsonClover2AS_" + flavour[i], actionPar); + + // solvers + MSolver::RBPrecCG2AS::Par solverPar; + solverPar.action = "WilsonClover2AS_" + flavour[i]; + solverPar.residual = 1.0e-8; + application.createModule("CG_" + flavour[i], + solverPar); + + // propagators + MFermion::GaugeProp2AS::Par quarkPar; + quarkPar.solver = "CG_" + flavour[i]; + quarkPar.source = "pt"; + application.createModule("Qpt_" + flavour[i], quarkPar); + quarkPar.source = "z2"; + application.createModule("QZ2_" + flavour[i], quarkPar); + } + for (unsigned int i = 0; i < flavour.size(); ++i) + for (unsigned int j = i; j < flavour.size(); ++j) + { + MContraction::Meson2AS::Par mesPar; + + mesPar.output = "mesons2AS/pt_" + flavour[i] + flavour[j]; + mesPar.q1 = "Qpt_" + flavour[i]; + mesPar.q2 = "Qpt_" + flavour[j]; + mesPar.gammas = "all"; + mesPar.sink = "sink"; + application.createModule("meson_pt_" + + flavour[i] + flavour[j], + mesPar); + + // mesPar.output = "mesons2AS/Z2_" + flavour[i] + flavour[j]; + // mesPar.q1 = "QZ2_" + flavour[i]; + // mesPar.q2 = "QZ2_" + flavour[j]; + // mesPar.gammas = "all"; + // mesPar.sink = "sink"; + // application.createModule("meson_Z2_" + // + flavour[i] + flavour[j], + // mesPar); + } + for (unsigned int i = 0; i < flavour.size(); ++i) + for (unsigned int j = i; j < flavour.size(); ++j) + for (unsigned int k = j; k < flavour.size(); ++k) + { + MContraction::Baryon::Par barPar; + + barPar.output = "baryons/pt_" + flavour[i] + flavour[j] + flavour[k]; + barPar.q1 = "Qpt_" + flavour[i]; + barPar.q2 = "Qpt_" + flavour[j]; + barPar.q3 = "Qpt_" + flavour[k]; + application.createModule( + "baryon_pt_" + flavour[i] + flavour[j] + flavour[k], barPar); + } + + // execution + application.saveParameterFile("spectrum.xml"); + application.run(); + + // epilogue + LOG(Message) << "Grid is finalizing now" << std::endl; + Grid_finalize(); + + return EXIT_SUCCESS; +} diff --git a/tests/lanczos/Test_WCMultiRep_lanczos.cc b/tests/lanczos/Test_WCMultiRep_lanczos.cc new file mode 100644 index 00000000..e8549234 --- /dev/null +++ b/tests/lanczos/Test_WCMultiRep_lanczos.cc @@ -0,0 +1,108 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./tests/Test_dwf_lanczos.cc + +Copyright (C) 2015 + +Author: Peter Boyle + +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 +*************************************************************************************/ +/* END LEGAL */ +#include + +using namespace std; +using namespace Grid; +using namespace Grid::QCD; + +typedef WilsonFermionR FermionOp; +typedef typename WilsonFermionR::FermionField FermionField; + + +RealD AllZero(RealD x) { return 0.; } + +int main(int argc, char** argv) { + Grid_init(&argc, &argv); + + GridCartesian* UGrid = SpaceTimeGrid::makeFourDimGrid( + GridDefaultLatt(), GridDefaultSimd(Nd, vComplex::Nsimd()), + GridDefaultMpi()); + GridRedBlackCartesian* UrbGrid = + SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); + GridCartesian* FGrid = UGrid; + GridRedBlackCartesian* FrbGrid = UrbGrid; + printf("UGrid=%p UrbGrid=%p FGrid=%p FrbGrid=%p\n", UGrid, UrbGrid, FGrid, + FrbGrid); + + std::vector seeds4({1, 2, 3, 4}); + std::vector seeds5({5, 6, 7, 8}); + GridParallelRNG RNG5(FGrid); + RNG5.SeedFixedIntegers(seeds5); + GridParallelRNG RNG4(UGrid); + RNG4.SeedFixedIntegers(seeds4); + GridParallelRNG RNG5rb(FrbGrid); + RNG5.SeedFixedIntegers(seeds5); + + LatticeGaugeField Umu(UGrid); + SU3::HotConfiguration(RNG4, Umu); + +/* + std::vector U(4, UGrid); + for (int mu = 0; mu < Nd; mu++) { + U[mu] = PeekIndex(Umu, mu); + } +*/ + + RealD mass = -0.1; + RealD M5 = 1.8; + RealD mob_b = 1.5; + FermionOp WilsonOperator(Umu,*FGrid,*FrbGrid,mass); + MdagMLinearOperator HermOp(WilsonOperator); /// <----- + //SchurDiagTwoOperator HermOp(WilsonOperator); + + const int Nstop = 20; + const int Nk = 60; + const int Np = 60; + const int Nm = Nk + Np; + const int MaxIt = 10000; + RealD resid = 1.0e-6; + + std::vector Coeffs{0, 1.}; + Polynomial PolyX(Coeffs); + Chebyshev Cheb(0.0, 10., 12); + ImplicitlyRestartedLanczos IRL(HermOp, PolyX, Nstop, Nk, Nm, + resid, MaxIt); + + std::vector eval(Nm); + FermionField src(FGrid); + gaussian(RNG5, src); + std::vector evec(Nm, FGrid); + for (int i = 0; i < 1; i++) { + std::cout << i << " / " << Nm << " grid pointer " << evec[i]._grid + << std::endl; + }; + + int Nconv; + IRL.calc(eval, evec, src, Nconv); + + std::cout << eval << std::endl; + + Grid_finalize(); +} From 9028e278e4ededffb45b4d2e510c79860d536584 Mon Sep 17 00:00:00 2001 From: David Preti Date: Sat, 6 Jan 2018 15:57:38 +0100 Subject: [PATCH 39/43] Trying to fix a bug with SU4 mesons (still under investigation) --- extras/Hadrons/Modules/MGauge/Load.cc | 3 +- extras/Hadrons/Modules/MGauge/Random.cc | 2 +- extras/Hadrons/Modules/MGauge/Unit.cc | 2 +- tests/hadrons/Test_hadrons_wilsonFund.cc | 160 +++++++++++++++++++++++ 4 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 tests/hadrons/Test_hadrons_wilsonFund.cc diff --git a/extras/Hadrons/Modules/MGauge/Load.cc b/extras/Hadrons/Modules/MGauge/Load.cc index 062e7e98..97be9539 100644 --- a/extras/Hadrons/Modules/MGauge/Load.cc +++ b/extras/Hadrons/Modules/MGauge/Load.cc @@ -66,7 +66,8 @@ void TLoad::setup(void) void TLoad::execute(void) { FieldMetaData header; - std::string fileName = par().file + "." + + std::string fileName = par().file + "ckpoint_lat." + std::to_string(env().getTrajectory()); LOG(Message) << "Loading NERSC configuration from file '" << fileName diff --git a/extras/Hadrons/Modules/MGauge/Random.cc b/extras/Hadrons/Modules/MGauge/Random.cc index c10fdfc3..5c063361 100644 --- a/extras/Hadrons/Modules/MGauge/Random.cc +++ b/extras/Hadrons/Modules/MGauge/Random.cc @@ -65,5 +65,5 @@ void TRandom::execute(void) { LOG(Message) << "Generating random gauge configuration" << std::endl; LatticeGaugeField &U = *env().createLattice(getName()); - SU3::HotConfiguration(*env().get4dRng(), U); + SU4::HotConfiguration(*env().get4dRng(), U); } diff --git a/extras/Hadrons/Modules/MGauge/Unit.cc b/extras/Hadrons/Modules/MGauge/Unit.cc index 18d75c59..12696ee9 100644 --- a/extras/Hadrons/Modules/MGauge/Unit.cc +++ b/extras/Hadrons/Modules/MGauge/Unit.cc @@ -65,5 +65,5 @@ void TUnit::execute(void) { LOG(Message) << "Creating unit gauge configuration" << std::endl; LatticeGaugeField &U = *env().createLattice(getName()); - SU3::ColdConfiguration(*env().get4dRng(), U); + SU4::ColdConfiguration(*env().get4dRng(), U); } diff --git a/tests/hadrons/Test_hadrons_wilsonFund.cc b/tests/hadrons/Test_hadrons_wilsonFund.cc new file mode 100644 index 00000000..aff8a670 --- /dev/null +++ b/tests/hadrons/Test_hadrons_wilsonFund.cc @@ -0,0 +1,160 @@ +/******************************************************************************* + Grid physics library, www.github.com/paboyle/Grid + + Source file: tests/hadrons/Test_hadrons_spectrum.cc + + Copyright (C) 2015 + + Author: Antonin Portelli + + 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. + *******************************************************************************/ + +#include + +using namespace Grid; +using namespace Hadrons; + +int main(int argc, char *argv[]) +{ + // initialization ////////////////////////////////////////////////////////// + Grid_init(&argc, &argv); + HadronsLogError.Active(GridLogError.isActive()); + HadronsLogWarning.Active(GridLogWarning.isActive()); + HadronsLogMessage.Active(GridLogMessage.isActive()); + HadronsLogIterative.Active(GridLogIterative.isActive()); + HadronsLogDebug.Active(GridLogDebug.isActive()); + LOG(Message) << "Grid initialized" << std::endl; + + // run setup /////////////////////////////////////////////////////////////// + Application application; + std::vector flavour = {"l"}; + std::vector mass = {-0.1}; + double csw = 0.0; + + // global parameters + Application::GlobalPar globalPar; + + globalPar.trajCounter.start = 1; + globalPar.trajCounter.end = 2; + globalPar.trajCounter.step = 1; + + globalPar.trajCounter.start = 309; + globalPar.trajCounter.end = 310; + globalPar.trajCounter.step = 1; + globalPar.seed = "1 2 3 4"; + application.setPar(globalPar); + // gauge field + application.createModule("gauge"); + //application.createModule("gauge"); + + // sources + //MSource::Z2::Par z2Par; + //z2Par.tA = 0; + //z2Par.tB = 0; + //application.createModule("z2", z2Par); + MSource::Point::Par ptPar; + ptPar.position = "0 0 0 0"; + application.createModule("pt", ptPar); + // sink + MSink::Point::Par sinkPar; + sinkPar.mom = "0 0 0"; + application.createModule("sink", sinkPar); + + // set fermion boundary conditions to be periodic space, antiperiodic time. + std::string boundary = "1 1 1 -1"; + + for (unsigned int i = 0; i < flavour.size(); ++i) + { + // actions + MAction::WilsonClover::Par actionPar; + actionPar.gauge = "gauge"; + actionPar.mass = mass[i]; + actionPar.boundary = boundary; + actionPar.csw_r = csw; + actionPar.csw_t = csw; + + // !!!!! Check if Anisotropy works !!!!! + actionPar.clover_anisotropy.isAnisotropic= false; + actionPar.clover_anisotropy.t_direction = 3 ; // Explicit for D=4 + actionPar.clover_anisotropy.xi_0 = 1.0 ; + actionPar.clover_anisotropy.nu = 1.0 ; + + application.createModule("WilsonClover_" + flavour[i], actionPar); + + // solvers + MSolver::RBPrecCG::Par solverPar; + solverPar.action = "WilsonClover_" + flavour[i]; + solverPar.residual = 1.0e-8; + application.createModule("CG_" + flavour[i], + solverPar); + + // propagators + MFermion::GaugeProp::Par quarkPar; + quarkPar.solver = "CG_" + flavour[i]; + quarkPar.source = "pt"; + application.createModule("Qpt_" + flavour[i], quarkPar); + // quarkPar.source = "z2"; + // application.createModule("QZ2_" + flavour[i], quarkPar); + } + for (unsigned int i = 0; i < flavour.size(); ++i) + for (unsigned int j = i; j < flavour.size(); ++j) + { + MContraction::Meson::Par mesPar; + + mesPar.output = "Fund_mesons/pt_" + flavour[i] + flavour[j]; + mesPar.q1 = "Qpt_" + flavour[i]; + mesPar.q2 = "Qpt_" + flavour[j]; + mesPar.gammas = "all"; + mesPar.sink = "sink"; + application.createModule("meson_pt_" + + flavour[i] + flavour[j], + mesPar); + // mesPar.output = "mesons/Z2_" + flavour[i] + flavour[j]; + // mesPar.q1 = "QZ2_" + flavour[i]; + // mesPar.q2 = "QZ2_" + flavour[j]; + // mesPar.gammas = "all"; + // mesPar.sink = "sink"; + // application.createModule("meson_Z2_" + // + flavour[i] + flavour[j], + // mesPar); + } + for (unsigned int i = 0; i < flavour.size(); ++i) + for (unsigned int j = i; j < flavour.size(); ++j) + for (unsigned int k = j; k < flavour.size(); ++k) + { + MContraction::Baryon::Par barPar; + + barPar.output = "Fund_baryons/pt_" + flavour[i] + flavour[j] + flavour[k]; + barPar.q1 = "Qpt_" + flavour[i]; + barPar.q2 = "Qpt_" + flavour[j]; + barPar.q3 = "Qpt_" + flavour[k]; + application.createModule( + "baryon_pt_" + flavour[i] + flavour[j] + flavour[k], barPar); + } + + // execution + application.saveParameterFile("WilsonClover_spectrum.xml"); + application.run(); + + // epilogue + LOG(Message) << "Grid is finalizing now" << std::endl; + Grid_finalize(); + + return EXIT_SUCCESS; +} From a3affac963b85fa2f8de4296c58b31eaf737279b Mon Sep 17 00:00:00 2001 From: David Preti Date: Wed, 10 Jan 2018 14:56:54 +0100 Subject: [PATCH 40/43] SU3 restored + output filename for mesons and baryons fixed. --- extras/Hadrons/Modules/MContraction/Baryon.hpp | 4 +++- extras/Hadrons/Modules/MContraction/Meson.hpp | 4 +++- extras/Hadrons/Modules/MGauge/Random.cc | 2 +- extras/Hadrons/Modules/MGauge/Unit.cc | 2 +- lib/qcd/QCD.h | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/extras/Hadrons/Modules/MContraction/Baryon.hpp b/extras/Hadrons/Modules/MContraction/Baryon.hpp index 78bde5a2..358f7025 100644 --- a/extras/Hadrons/Modules/MContraction/Baryon.hpp +++ b/extras/Hadrons/Modules/MContraction/Baryon.hpp @@ -112,7 +112,9 @@ void TBaryon::execute(void) << " quarks '" << par().q1 << "', '" << par().q2 << "', and '" << par().q3 << "'" << std::endl; - CorrWriter writer(par().output); + std::string output_name = par().output + "." + std::to_string(env().getTrajectory()); + + CorrWriter writer(output_name); PropagatorField1 &q1 = *env().template getObject(par().q1); PropagatorField2 &q2 = *env().template getObject(par().q2); PropagatorField3 &q3 = *env().template getObject(par().q2); diff --git a/extras/Hadrons/Modules/MContraction/Meson.hpp b/extras/Hadrons/Modules/MContraction/Meson.hpp index 7810326a..5355bace 100644 --- a/extras/Hadrons/Modules/MContraction/Meson.hpp +++ b/extras/Hadrons/Modules/MContraction/Meson.hpp @@ -165,8 +165,10 @@ void TMeson::execute(void) LOG(Message) << "Computing meson contractions '" << getName() << "' using" << " quarks '" << par().q1 << "' and '" << par().q2 << "'" << std::endl; + + std::string output_name = par().output + "." + std::to_string(env().getTrajectory()); - CorrWriter writer(par().output); + CorrWriter writer(output_name); std::vector buf; std::vector result; Gamma g5(Gamma::Algebra::Gamma5); diff --git a/extras/Hadrons/Modules/MGauge/Random.cc b/extras/Hadrons/Modules/MGauge/Random.cc index 5c063361..c10fdfc3 100644 --- a/extras/Hadrons/Modules/MGauge/Random.cc +++ b/extras/Hadrons/Modules/MGauge/Random.cc @@ -65,5 +65,5 @@ void TRandom::execute(void) { LOG(Message) << "Generating random gauge configuration" << std::endl; LatticeGaugeField &U = *env().createLattice(getName()); - SU4::HotConfiguration(*env().get4dRng(), U); + SU3::HotConfiguration(*env().get4dRng(), U); } diff --git a/extras/Hadrons/Modules/MGauge/Unit.cc b/extras/Hadrons/Modules/MGauge/Unit.cc index 12696ee9..18d75c59 100644 --- a/extras/Hadrons/Modules/MGauge/Unit.cc +++ b/extras/Hadrons/Modules/MGauge/Unit.cc @@ -65,5 +65,5 @@ void TUnit::execute(void) { LOG(Message) << "Creating unit gauge configuration" << std::endl; LatticeGaugeField &U = *env().createLattice(getName()); - SU4::ColdConfiguration(*env().get4dRng(), U); + SU3::ColdConfiguration(*env().get4dRng(), U); } diff --git a/lib/qcd/QCD.h b/lib/qcd/QCD.h index 2caea7e9..9c6d54d4 100644 --- a/lib/qcd/QCD.h +++ b/lib/qcd/QCD.h @@ -49,7 +49,7 @@ namespace QCD { static const int Zm = 6; static const int Tm = 7; - static const int Nc=4; + static const int Nc=3; static const int Ns=4; static const int Nd=4; static const int Nhs=2; // half spinor From cf858deb16a393270d4b14c702031aae50257da3 Mon Sep 17 00:00:00 2001 From: pretidav Date: Wed, 10 Jan 2018 18:43:02 +0100 Subject: [PATCH 41/43] Lanczos with 2 reps fixed (tobe tested) --- tests/lanczos/Test_WCMultiRep_lanczos.cc | 128 +++++++++++++++++------ 1 file changed, 95 insertions(+), 33 deletions(-) diff --git a/tests/lanczos/Test_WCMultiRep_lanczos.cc b/tests/lanczos/Test_WCMultiRep_lanczos.cc index e8549234..98180db1 100644 --- a/tests/lanczos/Test_WCMultiRep_lanczos.cc +++ b/tests/lanczos/Test_WCMultiRep_lanczos.cc @@ -32,8 +32,17 @@ using namespace std; using namespace Grid; using namespace Grid::QCD; -typedef WilsonFermionR FermionOp; -typedef typename WilsonFermionR::FermionField FermionField; + +//typedef WilsonCloverFermionR FermionOp; +//typedef typename WilsonFermionR::FermionField FermionField; + +typedef WilsonImplR FundImplPolicy; +typedef WilsonCloverFermionR FundFermionAction; +typedef typename FundFermionAction::FermionField FundFermionField; + +typedef WilsonTwoIndexAntiSymmetricImplR ASymmImplPolicy; +typedef WilsonCloverTwoIndexAntiSymmetricFermionR ASymmFermionAction; +typedef typename ASymmFermionAction::FermionField ASymmFermionField; RealD AllZero(RealD x) { return 0.; } @@ -60,49 +69,102 @@ int main(int argc, char** argv) { GridParallelRNG RNG5rb(FrbGrid); RNG5.SeedFixedIntegers(seeds5); - LatticeGaugeField Umu(UGrid); - SU3::HotConfiguration(RNG4, Umu); + GridParallelRNG pRNG(UGrid); + GridSerialRNG sRNG; -/* - std::vector U(4, UGrid); - for (int mu = 0; mu < Nd; mu++) { - U[mu] = PeekIndex(Umu, mu); - } -*/ + FundamentalRepresentation::LatticeField Umu(UGrid); + + TwoIndexAntiSymmetricRepresentation HiRep(UGrid); + TwoIndexAntiSymmetricRepresentation::LatticeField UmuAS(UGrid); - RealD mass = -0.1; - RealD M5 = 1.8; - RealD mob_b = 1.5; - FermionOp WilsonOperator(Umu,*FGrid,*FrbGrid,mass); - MdagMLinearOperator HermOp(WilsonOperator); /// <----- - //SchurDiagTwoOperator HermOp(WilsonOperator); + + CheckpointerParameters CPparams; + + CPparams.config_prefix = "ckpoint_lat"; + CPparams.rng_prefix = "ckpoint_rng"; + CPparams.format = "IEEE64BIG"; - const int Nstop = 20; - const int Nk = 60; - const int Np = 60; +//NerscHmcCheckpointer Checkpoint(std::string("ckpoint_lat"), + // std::string("ckpoint_rng"), 1); + +NerscHmcCheckpointer Checkpoint(CPparams); + + int CNFGSTART=1; + int CNFGEND=2; + int CNFGSTEP=1; + + Real Fundmass = -0.1; + Real Fundcsw = 1.0; + Real ASmass = -0.1; + Real AScsw = 1.0; + + std::cout << "Fund: mass and csw" << Fundmass << " and " << Fundcsw << std::endl; + std::cout << "AS : mass and csw" << ASmass << " and " << AScsw << std::endl; + + const int Nstop = 30; + const int Nk = 40; + const int Np = 40; const int Nm = Nk + Np; const int MaxIt = 10000; - RealD resid = 1.0e-6; + RealD resid = 1.0e-8; - std::vector Coeffs{0, 1.}; - Polynomial PolyX(Coeffs); - Chebyshev Cheb(0.0, 10., 12); - ImplicitlyRestartedLanczos IRL(HermOp, PolyX, Nstop, Nk, Nm, + for (int cnfg=CNFGSTART;cnfg<=CNFGEND;cnfg+=CNFGSTEP){ + Checkpoint.CheckpointRestore(cnfg,Umu, sRNG, pRNG); + + //SU4::HotConfiguration(RNG4, Umu); // temporary, then read. + + HiRep.update_representation(Umu); + UmuAS = HiRep.U; + + FundFermionAction FundFermOp(Umu,*FGrid,*FrbGrid, Fundmass, Fundcsw, Fundcsw); + MdagMLinearOperator HermOpFund(FundFermOp); /// <----- + + ASymmFermionAction ASFermOp(UmuAS,*FGrid,*FrbGrid, ASmass, AScsw, AScsw); + MdagMLinearOperator HermOpAS(ASFermOp); /// <----- + + std::vector Coeffs{0, -1.}; + Polynomial FundPolyX(Coeffs); + Chebyshev FundCheb(0.0, 10., 12); + ImplicitlyRestartedLanczos IRL_Fund(HermOpFund, FundPolyX, Nstop, Nk, Nm, resid, MaxIt); + + Polynomial ASPolyX(Coeffs); + Chebyshev ASCheb(0.0, 10., 12); + ImplicitlyRestartedLanczos IRL_AS(HermOpAS, ASPolyX, Nstop, Nk, Nm, + resid, MaxIt); + + std::vector Fundeval(Nm); + std::vector ASeval(Nm); - std::vector eval(Nm); - FermionField src(FGrid); - gaussian(RNG5, src); - std::vector evec(Nm, FGrid); + FundFermionField Fundsrc(FGrid); + ASymmFermionField ASsrc(FGrid); + + gaussian(RNG5, Fundsrc); + gaussian(RNG5, ASsrc); + + std::vector Fundevec(Nm, FGrid); + std::vector ASevec(Nm, FGrid); + for (int i = 0; i < 1; i++) { - std::cout << i << " / " << Nm << " grid pointer " << evec[i]._grid + std::cout << i << " / " << Nm << "Fund: grid pointer " << Fundevec[i]._grid << std::endl; }; + for (int i = 0; i < 1; i++) { + std::cout << i << " / " << Nm << "AS: grid pointer " << ASevec[i]._grid + << std::endl; + }; + + int FundNconv, ASNconv; + IRL_Fund.calc(Fundeval, Fundevec, Fundsrc, FundNconv); + IRL_AS.calc(ASeval, ASevec, ASsrc, ASNconv); - int Nconv; - IRL.calc(eval, evec, src, Nconv); - - std::cout << eval << std::endl; + for (int i=0;i