mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 04:37:05 +01:00
Open up dependency on Eigen and FFTW
This commit is contained in:
79
tests/core/Make.inc
Normal file
79
tests/core/Make.inc
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
bin_PROGRAMS += Test_GaugeAction Test_RectPlaq Test_cf_coarsen_support Test_contfrac_even_odd Test_cshift_red_black Test_cshift_red_black_rotate Test_cshift_rotate Test_dwf_even_odd Test_dwf_rb5d Test_gamma Test_gparity Test_gpwilson_even_odd Test_lie_generators Test_main Test_quenched_update Test_rng Test_rng_fixed Test_wilson_even_odd Test_wilson_tm_even_odd
|
||||
|
||||
|
||||
Test_GaugeAction_SOURCES=Test_GaugeAction.cc
|
||||
Test_GaugeAction_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_RectPlaq_SOURCES=Test_RectPlaq.cc
|
||||
Test_RectPlaq_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_cf_coarsen_support_SOURCES=Test_cf_coarsen_support.cc
|
||||
Test_cf_coarsen_support_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_contfrac_even_odd_SOURCES=Test_contfrac_even_odd.cc
|
||||
Test_contfrac_even_odd_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_cshift_red_black_SOURCES=Test_cshift_red_black.cc
|
||||
Test_cshift_red_black_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_cshift_red_black_rotate_SOURCES=Test_cshift_red_black_rotate.cc
|
||||
Test_cshift_red_black_rotate_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_cshift_rotate_SOURCES=Test_cshift_rotate.cc
|
||||
Test_cshift_rotate_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_dwf_even_odd_SOURCES=Test_dwf_even_odd.cc
|
||||
Test_dwf_even_odd_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_dwf_rb5d_SOURCES=Test_dwf_rb5d.cc
|
||||
Test_dwf_rb5d_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_gamma_SOURCES=Test_gamma.cc
|
||||
Test_gamma_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_gparity_SOURCES=Test_gparity.cc
|
||||
Test_gparity_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_gpwilson_even_odd_SOURCES=Test_gpwilson_even_odd.cc
|
||||
Test_gpwilson_even_odd_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_lie_generators_SOURCES=Test_lie_generators.cc
|
||||
Test_lie_generators_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_main_SOURCES=Test_main.cc
|
||||
Test_main_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_quenched_update_SOURCES=Test_quenched_update.cc
|
||||
Test_quenched_update_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_rng_SOURCES=Test_rng.cc
|
||||
Test_rng_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_rng_fixed_SOURCES=Test_rng_fixed.cc
|
||||
Test_rng_fixed_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_wilson_even_odd_SOURCES=Test_wilson_even_odd.cc
|
||||
Test_wilson_even_odd_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_wilson_tm_even_odd_SOURCES=Test_wilson_tm_even_odd.cc
|
||||
Test_wilson_tm_even_odd_LDADD=-lGrid
|
||||
|
19
tests/core/Makefile.am
Normal file
19
tests/core/Makefile.am
Normal file
@ -0,0 +1,19 @@
|
||||
# additional include paths necessary to compile the C++ library
|
||||
|
||||
bin_PROGRAMS =
|
||||
SUBDIRS =
|
||||
|
||||
AM_CXXFLAGS = -I$(top_srcdir)/include
|
||||
AM_LDFLAGS = -L$(top_builddir)/lib
|
||||
|
||||
if USE_LAPACK
|
||||
AM_CXXFLAGS += -DUSE_LAPACK
|
||||
if USE_LAPACK_LIB
|
||||
#if test "X${ac_LAPACK}X" != XyesX
|
||||
AM_CXXFLAGS += -I$(ac_LAPACK)/include
|
||||
AM_LDFLAGS += -L$(ac_LAPACK)/lib
|
||||
#fi
|
||||
endif
|
||||
endif
|
||||
|
||||
include Make.inc
|
175
tests/core/Test_GaugeAction.cc
Normal file
175
tests/core/Test_GaugeAction.cc
Normal file
@ -0,0 +1,175 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_GaugeAction.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
|
||||
/* For Metropolis */
|
||||
class Metropolis {
|
||||
public:
|
||||
GridSerialRNG & sRNG;
|
||||
Metropolis(GridSerialRNG & _sRNG) : sRNG(_sRNG) {};
|
||||
bool AcceptReject(const RealD Delta)
|
||||
{
|
||||
RealD rand;
|
||||
|
||||
if(Delta <=0.0) return true;
|
||||
|
||||
random(sRNG,rand);
|
||||
if(rand <= exp(-Delta))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
|
||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
std::vector<int> latt_size ({16,16,16,32});
|
||||
std::vector<int> clatt_size ({4,4,4,8});
|
||||
int orthodir=3;
|
||||
int orthosz =latt_size[orthodir];
|
||||
|
||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||
GridCartesian Coarse(clatt_size,simd_layout,mpi_layout);
|
||||
|
||||
LatticeGaugeField Umu(&Fine);
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,&Fine);
|
||||
|
||||
NerscField header;
|
||||
|
||||
std::string file("./ckpoint_lat.4000");
|
||||
NerscIO::readConfiguration(Umu,header,file);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
||||
}
|
||||
|
||||
// Painful ; fix syntactical niceness : to check reader
|
||||
LatticeComplex LinkTrace(&Fine);
|
||||
LinkTrace=zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
LinkTrace = LinkTrace + trace(U[mu]);
|
||||
}
|
||||
|
||||
// (1+2+3)=6 = N(N-1)/2 terms // equals to Double S Chorma
|
||||
// in LatticeGaugeField out Plaq
|
||||
// class WilsonLoop {
|
||||
// RealD plaquette(LatticeGaugeField &Umu);
|
||||
// void staple(LatticeSomethingorOther,LatticeGaugeField &Umu);
|
||||
// RealD rectangle(LatticeGaugeField &Umu);
|
||||
// LatticeComplex sitePlaquette()
|
||||
// }
|
||||
// covariantCshift ???
|
||||
// GaugeActionBase
|
||||
// GaugeActionPlaquette
|
||||
// GaugeActionPlaquettePlusRectangle
|
||||
// GaugeActionIwasaki
|
||||
// GaugeActionSymanzik
|
||||
// GaugeActionWilson
|
||||
// Heatbath and quenched update.
|
||||
//
|
||||
LatticeColourMatrix tmpU(&Fine);
|
||||
|
||||
LatticeComplex Plaq(&Fine);
|
||||
LatticeComplex cPlaq(&Coarse);
|
||||
Plaq = zero;
|
||||
for(int mu=1;mu<Nd;mu++){
|
||||
for(int nu=0;nu<mu;nu++){
|
||||
Plaq = Plaq + trace(PeriodicBC::CovShiftForward(U[mu],mu,U[nu])*adj(PeriodicBC::CovShiftForward(U[nu],nu,U[mu])));
|
||||
}
|
||||
}
|
||||
|
||||
double vol = Fine.gSites();
|
||||
Complex PlaqScale(1.0/vol/6.0/3.0);
|
||||
RealD StapScale(1.0/vol/6.0/3.0);
|
||||
std::cout<<GridLogMessage <<"PlaqScale" << PlaqScale<<std::endl;
|
||||
std::vector<TComplex> Plaq_T(orthosz);
|
||||
sliceSum(Plaq,Plaq_T,Nd-1);
|
||||
int Nt = Plaq_T.size();
|
||||
|
||||
|
||||
TComplex Plaq_T_sum;
|
||||
Plaq_T_sum=zero;
|
||||
for(int t=0;t<Nt;t++){
|
||||
Plaq_T_sum = Plaq_T_sum+Plaq_T[t];
|
||||
Complex Pt=TensorRemove(Plaq_T[t]);
|
||||
std::cout<<GridLogMessage << "sliced ["<<t<<"]" <<Pt*PlaqScale*Real(Nt) << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
Complex Pt = TensorRemove(Plaq_T_sum);
|
||||
std::cout<<GridLogMessage << "total " <<Pt*PlaqScale<<std::endl;
|
||||
}
|
||||
|
||||
TComplex Tp = sum(Plaq);
|
||||
Complex p = TensorRemove(Tp);
|
||||
std::cout<<GridLogMessage << "calculated plaquettes " <<p*PlaqScale<<std::endl;
|
||||
|
||||
RealD avg_plaq = ColourWilsonLoops::avgPlaquette(Umu);
|
||||
std::cout<<GridLogMessage << "NEW : calculated real plaquettes " <<avg_plaq<<std::endl;
|
||||
|
||||
RealD stap_plaq=0.0;
|
||||
LatticeColourMatrix stap(&Fine);
|
||||
LatticeComplex stap_tr(&Fine);
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
ColourWilsonLoops::Staple(stap,Umu,mu);
|
||||
stap_tr = trace(stap*U[mu]);
|
||||
TComplex Ts = sum(stap_tr);
|
||||
Complex s = TensorRemove(Ts);
|
||||
stap_plaq+=real(s);
|
||||
}
|
||||
std::cout<<GridLogMessage << "NEW : plaquette via staples"<< stap_plaq*StapScale*0.25<< std::endl;
|
||||
Complex LinkTraceScale(1.0/vol/4.0/3.0);
|
||||
TComplex Tl = sum(LinkTrace);
|
||||
Complex l = TensorRemove(Tl);
|
||||
std::cout<<GridLogMessage << "calculated link trace " <<l*LinkTraceScale<<std::endl;
|
||||
|
||||
blockSum(cPlaq,Plaq);
|
||||
TComplex TcP = sum(cPlaq);
|
||||
Complex ll= TensorRemove(TcP);
|
||||
std::cout<<GridLogMessage << "coarsened plaquettes sum to " <<ll*PlaqScale<<std::endl;
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
||||
|
||||
|
324
tests/core/Test_RectPlaq.cc
Normal file
324
tests/core/Test_RectPlaq.cc
Normal file
@ -0,0 +1,324 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_RectPlaq.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
|
||||
/* For Metropolis */
|
||||
class Metropolis {
|
||||
public:
|
||||
GridSerialRNG & sRNG;
|
||||
Metropolis(GridSerialRNG & _sRNG) : sRNG(_sRNG) {};
|
||||
bool AcceptReject(const RealD Delta)
|
||||
{
|
||||
RealD rand;
|
||||
|
||||
if(Delta <=0.0) return true;
|
||||
|
||||
random(sRNG,rand);
|
||||
if(rand <= exp(-Delta))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void RectPlaq(const std::vector<LatticeColourMatrix> &U, LatticeComplex &RectPlaqValue )
|
||||
{
|
||||
RectPlaqValue=zero;
|
||||
// 12 * vol loops
|
||||
for(int mu=1;mu<Nd;mu++){
|
||||
for(int nu=0;nu<mu;nu++){
|
||||
RectPlaqValue = RectPlaqValue + trace(
|
||||
PeriodicBC::CovShiftForward(U[mu],mu,PeriodicBC::CovShiftForward(U[mu],mu,U[nu]))* // ->->|
|
||||
adj(PeriodicBC::CovShiftForward(U[nu],nu,PeriodicBC::CovShiftForward(U[mu],mu,U[mu]))) );
|
||||
RectPlaqValue = RectPlaqValue + trace(
|
||||
PeriodicBC::CovShiftForward(U[mu],mu,PeriodicBC::CovShiftForward(U[nu],nu,U[nu]))* // ->||
|
||||
adj(PeriodicBC::CovShiftForward(U[nu],nu,PeriodicBC::CovShiftForward(U[nu],nu,U[mu]))) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RectPlaqDeriv(const std::vector<LatticeColourMatrix> &U, LatticeComplex &RectPlaqValue )
|
||||
{
|
||||
|
||||
}
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
std::vector<int> latt_size ({16,16,16,32});
|
||||
std::vector<int> clatt_size ({4,4,4,8});
|
||||
int orthodir=3;
|
||||
int orthosz =latt_size[orthodir];
|
||||
|
||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||
GridCartesian Coarse(clatt_size,simd_layout,mpi_layout);
|
||||
|
||||
LatticeGaugeField Umu(&Fine);
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,&Fine);
|
||||
|
||||
NerscField header;
|
||||
|
||||
std::string file("./ckpoint_lat.4000");
|
||||
NerscIO::readConfiguration(Umu,header,file);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
||||
}
|
||||
|
||||
// Painful ; fix syntactical niceness : to check reader
|
||||
LatticeComplex LinkTrace(&Fine);
|
||||
LinkTrace=zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
LinkTrace = LinkTrace + trace(U[mu]);
|
||||
}
|
||||
|
||||
|
||||
LatticeComplex Plaq(&Fine);
|
||||
LatticeComplex cPlaq(&Coarse);
|
||||
Plaq = zero;
|
||||
for(int mu=1;mu<Nd;mu++){
|
||||
for(int nu=0;nu<mu;nu++){
|
||||
Plaq = Plaq + trace(PeriodicBC::CovShiftForward(U[mu],mu,U[nu])*adj(PeriodicBC::CovShiftForward(U[nu],nu,U[mu])));
|
||||
}
|
||||
}
|
||||
|
||||
LatticeComplex RectPlaqValue(&Fine);
|
||||
double vol = Fine.gSites();
|
||||
Complex PlaqScale(1.0/vol/6.0/3.0);
|
||||
Complex RectScale(1.0/vol/12.0/3.0);
|
||||
|
||||
std::cout<<GridLogMessage <<"PlaqScale" << PlaqScale<<std::endl;
|
||||
std::cout<<GridLogMessage <<"RectScale" << RectScale<<std::endl;
|
||||
|
||||
RectPlaq(U,RectPlaqValue);
|
||||
|
||||
TComplex TRp = sum(RectPlaqValue);
|
||||
Complex rp = TensorRemove(TRp);
|
||||
std::cout<<GridLogMessage << "calculated Rect plaquettes A " <<rp*RectScale<<std::endl;
|
||||
|
||||
|
||||
// Rect Plaq Calc Deriv
|
||||
|
||||
LatticeComplex RectPlaq_d(&Fine);
|
||||
RectPlaq_d = zero;
|
||||
LatticeColourMatrix ds_U(&Fine);
|
||||
LatticeColourMatrix left_2(&Fine);
|
||||
LatticeColourMatrix upper_l(&Fine);
|
||||
LatticeColourMatrix upper_staple(&Fine);
|
||||
LatticeColourMatrix down_staple(&Fine);
|
||||
LatticeColourMatrix tmp(&Fine);
|
||||
|
||||
// 2x1 // Each link has 2*(Nd-1) + 4*(Nd-1) = 6(Nd-1) , 1x2 and 2x1 loops attached.
|
||||
// //
|
||||
// // For producing the rectangle term normalised to number of loops
|
||||
// // there are Vol x Nd.(Nd-1) x 2 / 2 distinct loops total. (mu<nu, mu>nu)
|
||||
// //
|
||||
// // Expect scale factor to be
|
||||
// //
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
ds_U=zero; // dS / dUmu
|
||||
|
||||
for(int nu=0;nu<Nd;nu++){
|
||||
|
||||
if ( nu != mu ) {
|
||||
/*
|
||||
(x) ---> ---> : U(x,mu)*U(x+mu, mu)
|
||||
*/
|
||||
left_2= PeriodicBC::CovShiftForward(U[mu],mu,U[mu]);
|
||||
/*
|
||||
upper_l = <---- <---
|
||||
^
|
||||
| =>tmp
|
||||
(x+2mu)
|
||||
Unu(x+2mu) Umudag(x+mu+nu) Umudag(x+nu)
|
||||
*/
|
||||
|
||||
tmp=Cshift(U[nu],mu,2);
|
||||
upper_l= PeriodicBC::CovShiftForward(tmp,nu,adj(left_2)); // i.e. upper_l
|
||||
/*
|
||||
upper_staple= <---- <--- ^
|
||||
| |
|
||||
V (x) (x + 2mu)
|
||||
*/
|
||||
// Unu(x+2mu) Umudag(x+mu+nu) Umudag(x+nu) Unudag(x)
|
||||
upper_staple= upper_l*adj(U[nu]);
|
||||
/*
|
||||
down_staple= ^
|
||||
| |
|
||||
(x) <----- <---- V x + 2mu
|
||||
*/
|
||||
down_staple= adj(left_2*tmp)*U[nu];
|
||||
/*
|
||||
ds_U+= <---- <--- ^
|
||||
| |
|
||||
(x-mu) V-----> (x + mu)
|
||||
*/
|
||||
tmp=upper_staple*U[mu];
|
||||
ds_U+= Cshift(tmp,mu,-1);
|
||||
/*
|
||||
ds_U+= (x-mu) ^----> (x + mu)
|
||||
| |
|
||||
<-----<--- V
|
||||
*/
|
||||
tmp=PeriodicBC::CovShiftBackward(U[mu],nu,down_staple);
|
||||
ds_U+=Cshift(tmp,mu,-1);
|
||||
/*
|
||||
ds_U+= <----<---- ^
|
||||
| |
|
||||
(x) V -----> (x + 2mu)
|
||||
*/
|
||||
tmp=Cshift(U[mu],mu,1);
|
||||
/*
|
||||
ds_U+= (x) ^ ----> (x + 2mu)
|
||||
| |
|
||||
<---- <----V
|
||||
*/
|
||||
ds_U+=tmp*(upper_staple+down_staple);
|
||||
|
||||
/*****Part 2********/
|
||||
/*
|
||||
^
|
||||
|
|
||||
upper= ^
|
||||
|
|
||||
(x)
|
||||
*/
|
||||
LatticeColourMatrix up2= PeriodicBC::CovShiftForward(U[nu],nu,U[nu]);
|
||||
/*
|
||||
<----^
|
||||
|
|
||||
upper_l= ^
|
||||
|
|
||||
(x)
|
||||
*/
|
||||
// Unu(x+mu)Unu(x+mu+nu) UmuDag(x+nu+nu) lives at X
|
||||
upper_l= PeriodicBC::CovShiftForward(Cshift(up2,mu,1),nu,Cshift(adj(U[mu]),nu,1));
|
||||
/*
|
||||
|<----^
|
||||
upper_staple = V |
|
||||
| ^
|
||||
(x) V |
|
||||
*/
|
||||
|
||||
ds_U+= upper_l*adj(up2);
|
||||
|
||||
/*
|
||||
|
|
||||
V
|
||||
downer_l= |
|
||||
(x)<----V
|
||||
*/
|
||||
upper_l= adj(PeriodicBC::CovShiftForward(U[mu],mu,up2)); //downer_l
|
||||
/*
|
||||
^ |
|
||||
down_staple = | V
|
||||
^ |
|
||||
| V
|
||||
(x)<----
|
||||
down_staple= upper*upper_l;
|
||||
*/
|
||||
tmp= upper_l*up2;
|
||||
ds_U+= Cshift(tmp,nu,-2);
|
||||
|
||||
|
||||
//TRp = sum(RectPlaq_d);
|
||||
//rp = TensorRemove(TRp);
|
||||
//std::cout << GridLogMessage<< " Rect[" << " " << "] = "<< TensorRemove(TRp) <<std::endl;
|
||||
}}
|
||||
|
||||
RectPlaq_d += trace( U[mu]*ds_U) * 0.25;
|
||||
}
|
||||
|
||||
TRp = sum(RectPlaq_d);
|
||||
rp = TensorRemove(TRp);
|
||||
std::cout<<GridLogMessage << "calculated Rect plaquettes_d " <<rp*RectScale<<std::endl;
|
||||
|
||||
|
||||
std::vector<TComplex> Plaq_T(orthosz);
|
||||
sliceSum(Plaq,Plaq_T,Nd-1);
|
||||
int Nt = Plaq_T.size();
|
||||
|
||||
|
||||
TComplex Plaq_T_sum;
|
||||
Plaq_T_sum=zero;
|
||||
for(int t=0;t<Nt;t++){
|
||||
Plaq_T_sum = Plaq_T_sum+Plaq_T[t];
|
||||
Complex Pt=TensorRemove(Plaq_T[t]);
|
||||
std::cout<<GridLogMessage << "sliced ["<<t<<"]" <<Pt*PlaqScale*Real(Nt) << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
Complex Pt = TensorRemove(Plaq_T_sum);
|
||||
std::cout<<GridLogMessage << "total " <<Pt*PlaqScale<<std::endl;
|
||||
}
|
||||
|
||||
TComplex Tp = sum(Plaq);
|
||||
Complex p = TensorRemove(Tp);
|
||||
std::cout<<GridLogMessage << "calculated plaquettes " <<p*PlaqScale<<std::endl;
|
||||
|
||||
RealD avg_plaq = ColourWilsonLoops::avgPlaquette(Umu);
|
||||
std::cout<<GridLogMessage << "NEW : calculated real plaquettes " <<avg_plaq<<std::endl;
|
||||
// Staple Plaq
|
||||
RealD StapScale(1.0/vol/6.0/3.0);
|
||||
|
||||
RealD stap_plaq=0.0;
|
||||
LatticeColourMatrix stap(&Fine);
|
||||
LatticeComplex stap_tr(&Fine);
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
ColourWilsonLoops::Staple(stap,Umu,mu);
|
||||
stap_tr = trace(U[mu]*stap);
|
||||
TComplex Ts = sum(stap_tr);
|
||||
Complex s = TensorRemove(Ts);
|
||||
stap_plaq+=real(s);
|
||||
}
|
||||
std::cout<<GridLogMessage << "NEW : plaquette via staples"<< stap_plaq*StapScale*0.25<< std::endl;
|
||||
Complex LinkTraceScale(1.0/vol/4.0/3.0);
|
||||
TComplex Tl = sum(LinkTrace);
|
||||
Complex l = TensorRemove(Tl);
|
||||
std::cout<<GridLogMessage << "calculated link trace " <<l*LinkTraceScale<<std::endl;
|
||||
|
||||
blockSum(cPlaq,Plaq);
|
||||
TComplex TcP = sum(cPlaq);
|
||||
Complex ll= TensorRemove(TcP);
|
||||
std::cout<<GridLogMessage << "coarsened plaquettes sum to " <<ll*PlaqScale<<std::endl;
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
||||
|
114
tests/core/Test_cf_coarsen_support.cc
Normal file
114
tests/core/Test_cf_coarsen_support.cc
Normal file
@ -0,0 +1,114 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_cf_coarsen_support.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::GammaMatrix Gmu [] = {
|
||||
Gamma::GammaX,
|
||||
Gamma::GammaY,
|
||||
Gamma::GammaZ,
|
||||
Gamma::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
const int Ls=9;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
LatticeFermion src(FGrid); random(RNG5,src);
|
||||
LatticeFermion result(FGrid); result=zero;
|
||||
LatticeFermion ref(FGrid); ref=zero;
|
||||
LatticeFermion tmp(FGrid);
|
||||
LatticeFermion err(FGrid);
|
||||
LatticeGaugeField Umu(UGrid); random(RNG4,Umu);
|
||||
|
||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U[mu] = PeekIndex<LorentzIndex>(Umu,mu);
|
||||
}
|
||||
|
||||
RealD mass=0.1;
|
||||
RealD M5=1.8;
|
||||
|
||||
{
|
||||
OverlapWilsonContFracTanhFermionR Dcf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,1.0);
|
||||
HermitianLinearOperator<OverlapWilsonContFracTanhFermionR,LatticeFermion> HermIndefOp(Dcf);
|
||||
|
||||
HermIndefOp.Op(src,ref);
|
||||
HermIndefOp.OpDiag(src,result);
|
||||
|
||||
for(int d=0;d<4;d++){
|
||||
HermIndefOp.OpDir(src,tmp,d,+1); result=result+tmp;
|
||||
std::cout<<GridLogMessage<<"dir "<<d<<" tmp "<<norm2(tmp)<<std::endl;
|
||||
HermIndefOp.OpDir(src,tmp,d,-1); result=result+tmp;
|
||||
std::cout<<GridLogMessage<<"dir "<<d<<" tmp "<<norm2(tmp)<<std::endl;
|
||||
}
|
||||
err = result-ref;
|
||||
std::cout<<GridLogMessage<<"Error "<<norm2(err)<<std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
OverlapWilsonPartialFractionTanhFermionR Dpf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,1.0);
|
||||
HermitianLinearOperator<OverlapWilsonPartialFractionTanhFermionR,LatticeFermion> HermIndefOp(Dpf);
|
||||
|
||||
HermIndefOp.Op(src,ref);
|
||||
HermIndefOp.OpDiag(src,result);
|
||||
|
||||
for(int d=0;d<4;d++){
|
||||
HermIndefOp.OpDir(src,tmp,d,+1); result=result+tmp;
|
||||
std::cout<<GridLogMessage<<"dir "<<d<<" tmp "<<norm2(tmp)<<std::endl;
|
||||
HermIndefOp.OpDir(src,tmp,d,-1); result=result+tmp;
|
||||
std::cout<<GridLogMessage<<"dir "<<d<<" tmp "<<norm2(tmp)<<std::endl;
|
||||
}
|
||||
|
||||
err = result-ref;
|
||||
std::cout<<GridLogMessage<<"Error "<<norm2(err)<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
}
|
259
tests/core/Test_contfrac_even_odd.cc
Normal file
259
tests/core/Test_contfrac_even_odd.cc
Normal file
@ -0,0 +1,259 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_contfrac_even_odd.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::GammaMatrix Gmu [] = {
|
||||
Gamma::GammaX,
|
||||
Gamma::GammaY,
|
||||
Gamma::GammaZ,
|
||||
Gamma::GammaT
|
||||
};
|
||||
|
||||
|
||||
template<class What>
|
||||
void TestWhat(What & Ddwf,
|
||||
GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid,
|
||||
GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid,
|
||||
RealD mass, RealD M5,
|
||||
GridParallelRNG *RNG4, GridParallelRNG *RNG5);
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
const int Ls=9;
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
LatticeGaugeField Umu(UGrid); random(RNG4,Umu);
|
||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
||||
|
||||
RealD mass=0.1;
|
||||
RealD M5 =1.8;
|
||||
|
||||
std::cout<<GridLogMessage <<"OverlapWilsonContFracTanhFermion test"<<std::endl;
|
||||
OverlapWilsonContFracTanhFermionR Dcf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,1.0);
|
||||
TestWhat<OverlapWilsonContFracTanhFermionR>(Dcf,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5);
|
||||
|
||||
std::cout<<GridLogMessage <<"OverlapWilsonContFracZolotarevFermion test"<<std::endl;
|
||||
OverlapWilsonContFracZolotarevFermionR Dcfz(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,0.1,6.0);
|
||||
TestWhat<OverlapWilsonContFracZolotarevFermionR>(Dcfz,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5);
|
||||
|
||||
std::cout<<GridLogMessage <<"OverlapWilsonPartialFractionTanhFermion test"<<std::endl;
|
||||
OverlapWilsonPartialFractionTanhFermionR Dpf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,1.0);
|
||||
TestWhat<OverlapWilsonPartialFractionTanhFermionR>(Dpf,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5);
|
||||
|
||||
std::cout<<GridLogMessage <<"OverlapWilsonPartialFractionZolotarevFermion test"<<std::endl;
|
||||
OverlapWilsonPartialFractionZolotarevFermionR Dpfz(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,0.1,6.0);
|
||||
TestWhat<OverlapWilsonPartialFractionZolotarevFermionR>(Dpfz,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5);
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
||||
template<class What>
|
||||
void TestWhat(What & Ddwf,
|
||||
GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid,
|
||||
GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid,
|
||||
RealD mass, RealD M5,
|
||||
GridParallelRNG *RNG4,
|
||||
GridParallelRNG *RNG5)
|
||||
{
|
||||
|
||||
LatticeFermion src (FGrid); random(*RNG5,src);
|
||||
LatticeFermion phi (FGrid); random(*RNG5,phi);
|
||||
LatticeFermion chi (FGrid); random(*RNG5,chi);
|
||||
LatticeFermion result(FGrid); result=zero;
|
||||
LatticeFermion ref(FGrid); ref=zero;
|
||||
LatticeFermion tmp(FGrid); tmp=zero;
|
||||
LatticeFermion err(FGrid); tmp=zero;
|
||||
|
||||
LatticeFermion src_e (FrbGrid);
|
||||
LatticeFermion src_o (FrbGrid);
|
||||
LatticeFermion r_e (FrbGrid);
|
||||
LatticeFermion r_o (FrbGrid);
|
||||
LatticeFermion r_eo (FGrid);
|
||||
LatticeFermion r_eeoo(FGrid);
|
||||
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Testing that Meo + Moe + Moo + Mee = Munprec "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,src_e,src);
|
||||
pickCheckerboard( Odd,src_o,src);
|
||||
|
||||
Ddwf.Meooe(src_e,r_o); std::cout<<GridLogMessage<<"Applied Meo "<<norm2(r_o)<<std::endl;
|
||||
Ddwf.Meooe(src_o,r_e); std::cout<<GridLogMessage<<"Applied Moe "<<norm2(r_e)<<std::endl;
|
||||
setCheckerboard(r_eo,r_o);
|
||||
setCheckerboard(r_eo,r_e);
|
||||
|
||||
Ddwf.Mooee(src_e,r_e); std::cout<<GridLogMessage<<"Applied Mee"<<norm2(r_e)<<std::endl;
|
||||
Ddwf.Mooee(src_o,r_o); std::cout<<GridLogMessage<<"Applied Moo"<<norm2(r_o)<<std::endl;
|
||||
setCheckerboard(r_eeoo,r_e);
|
||||
setCheckerboard(r_eeoo,r_o);
|
||||
|
||||
r_eo=r_eo+r_eeoo;
|
||||
Ddwf.M(src,ref);
|
||||
|
||||
// std::cout<<GridLogMessage << r_eo<<std::endl;
|
||||
// std::cout<<GridLogMessage << ref <<std::endl;
|
||||
|
||||
err= ref - r_eo;
|
||||
std::cout<<GridLogMessage << "EO norm diff "<< norm2(err)<< " "<<norm2(ref)<< " " << norm2(r_eo) <<std::endl;
|
||||
|
||||
LatticeComplex cerr(FGrid);
|
||||
cerr = localInnerProduct(err,err);
|
||||
// std::cout<<GridLogMessage << cerr<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test Ddagger is the dagger of D by requiring "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= < phi | Deo | chi > * = < chi | Deo^dag| phi> "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
LatticeFermion chi_e (FrbGrid);
|
||||
LatticeFermion chi_o (FrbGrid);
|
||||
|
||||
LatticeFermion dchi_e (FrbGrid);
|
||||
LatticeFermion dchi_o (FrbGrid);
|
||||
|
||||
LatticeFermion phi_e (FrbGrid);
|
||||
LatticeFermion phi_o (FrbGrid);
|
||||
|
||||
LatticeFermion dphi_e (FrbGrid);
|
||||
LatticeFermion dphi_o (FrbGrid);
|
||||
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
|
||||
Ddwf.Meooe(chi_e,dchi_o);
|
||||
Ddwf.Meooe(chi_o,dchi_e);
|
||||
Ddwf.MeooeDag(phi_e,dphi_o);
|
||||
Ddwf.MeooeDag(phi_o,dphi_e);
|
||||
|
||||
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);
|
||||
|
||||
std::cout<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDce-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDco-conj(cDpe) <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInv Mee = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Ddwf.Mooee(chi_e,src_e);
|
||||
Ddwf.MooeeInv(src_e,phi_e);
|
||||
|
||||
Ddwf.Mooee(chi_o,src_o);
|
||||
Ddwf.MooeeInv(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInvDag MeeDag = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Ddwf.MooeeDag(chi_e,src_e);
|
||||
Ddwf.MooeeInvDag(src_e,phi_e);
|
||||
|
||||
Ddwf.MooeeDag(chi_o,src_o);
|
||||
Ddwf.MooeeInvDag(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MpcDagMpc is Hermitian "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
random(*RNG5,phi);
|
||||
random(*RNG5,chi);
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
RealD t1,t2;
|
||||
|
||||
SchurDiagMooeeOperator<What,LatticeFermion> HermOpEO(Ddwf);
|
||||
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<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDco-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDce-conj(cDpe) <<std::endl;
|
||||
|
||||
}
|
223
tests/core/Test_cshift_red_black.cc
Normal file
223
tests/core/Test_cshift_red_black.cc
Normal file
@ -0,0 +1,223 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_cshift_red_black.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
int Nd = latt_size.size();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
std::vector<int> mask(Nd,1);
|
||||
mask[0]=0;
|
||||
|
||||
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBFine(latt_size,simd_layout,mpi_layout,mask,1);
|
||||
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
||||
|
||||
LatticeComplex U(&Fine);
|
||||
LatticeComplex ShiftU(&Fine);
|
||||
LatticeComplex rbShiftU(&Fine);
|
||||
LatticeComplex Ue(&RBFine);
|
||||
LatticeComplex Uo(&RBFine);
|
||||
LatticeComplex ShiftUe(&RBFine);
|
||||
LatticeComplex ShiftUo(&RBFine);
|
||||
LatticeComplex lex(&Fine);
|
||||
lex=zero;
|
||||
Integer stride =1;
|
||||
{
|
||||
double nrm;
|
||||
LatticeComplex coor(&Fine);
|
||||
|
||||
for(int d=0;d<Nd;d++){
|
||||
// Integer i=10000;
|
||||
Integer i=0;
|
||||
LatticeCoordinate(coor,d);
|
||||
lex = lex + coor*stride+i;
|
||||
stride=stride*latt_size[d];
|
||||
}
|
||||
U=lex;
|
||||
}
|
||||
|
||||
pickCheckerboard(Even,Ue,U);
|
||||
pickCheckerboard(Odd,Uo,U);
|
||||
|
||||
// std::cout<<GridLogMessage << U<<std::endl;
|
||||
std::cout<<GridLogMessage << "Ue " <<norm2(Ue)<<std::endl;
|
||||
std::cout<<GridLogMessage << "Uo " <<norm2(Uo)<<std::endl;
|
||||
|
||||
|
||||
TComplex cm;
|
||||
TComplex cmeo;
|
||||
for(int dir=0;dir<Nd;dir++){
|
||||
// if ( dir!=1 ) continue;
|
||||
for(int shift=0;shift<latt_size[dir];shift++){
|
||||
|
||||
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Even grid"<<std::endl;
|
||||
ShiftUe = Cshift(Ue,dir,shift); // Shift everything cb by cb
|
||||
std::cout<<GridLogMessage << "\tShiftUe " <<norm2(ShiftUe)<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Odd grid"<<std::endl;
|
||||
ShiftUo = Cshift(Uo,dir,shift);
|
||||
std::cout<<GridLogMessage << "\tShiftUo " <<norm2(ShiftUo)<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Recombined Even/Odd grids"<<std::endl;
|
||||
setCheckerboard(rbShiftU,ShiftUe);
|
||||
setCheckerboard(rbShiftU,ShiftUo);
|
||||
std::cout<<GridLogMessage << "\trbShiftU " <<norm2(rbShiftU)<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Full grid shift"<<std::endl;
|
||||
ShiftU = Cshift(U,dir,shift); // Shift everything
|
||||
std::cout<<GridLogMessage << "\tShiftU " <<norm2(rbShiftU)<<std::endl;
|
||||
|
||||
std::vector<int> coor(4);
|
||||
|
||||
std::cout<<GridLogMessage << "Checking the non-checkerboard shift"<<std::endl;
|
||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
||||
for(coor[1]=0;coor[1]<latt_size[1];coor[1]++){
|
||||
for(coor[0]=0;coor[0]<latt_size[0];coor[0]++){
|
||||
|
||||
peekSite(cm,ShiftU,coor);
|
||||
|
||||
///////// double nrm=norm2(U);
|
||||
|
||||
std::vector<int> scoor(coor);
|
||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||
|
||||
Integer slex = scoor[0]
|
||||
+ latt_size[0]*scoor[1]
|
||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
||||
|
||||
Complex scm(slex);
|
||||
|
||||
double nrm = abs(scm-cm()()());
|
||||
std::vector<int> peer(4);
|
||||
Complex ctmp = cm;
|
||||
Integer index=real(ctmp);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
|
||||
if (nrm > 0){
|
||||
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
index=real(scm);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
}}}}
|
||||
|
||||
int exx=0;
|
||||
std::cout<<GridLogMessage << "Checking the checkerboard shift"<<std::endl;
|
||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
||||
for(coor[1]=0;coor[1]<latt_size[1];coor[1]++){
|
||||
for(coor[0]=0;coor[0]<latt_size[0];coor[0]++){
|
||||
|
||||
peekSite(cm,rbShiftU,coor);
|
||||
|
||||
Integer checkerboard = RBFine.CheckerBoard(coor);
|
||||
|
||||
// std::cout << " coor "<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] \n ";
|
||||
// std::cout << "shift "<< shift <<" dir "<<dir<< " checker board "<< checkerboard << " ";
|
||||
// std::cout << "Uo " << ShiftUo.checkerboard << " Ue "<<ShiftUe.checkerboard<<std::endl;
|
||||
if ( checkerboard == ShiftUo.checkerboard ) {
|
||||
peekSite(cmeo,ShiftUo,coor);
|
||||
} else {
|
||||
peekSite(cmeo,ShiftUe,coor);
|
||||
}
|
||||
|
||||
|
||||
std::vector<int> scoor(coor);
|
||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||
|
||||
Integer slex = scoor[0]
|
||||
+ latt_size[0]*scoor[1]
|
||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
||||
|
||||
Complex scm(slex);
|
||||
|
||||
std::vector<int> peer(4);
|
||||
Complex ctmp=cmeo;
|
||||
Integer index=real(ctmp);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
|
||||
double nrm = abs(cmeo()()()-scm);
|
||||
if (nrm != 0) {
|
||||
std::cout<<"EOFAIL shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cmeo()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
index=real(scm);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
exx=1;
|
||||
|
||||
}
|
||||
|
||||
ctmp=cm;
|
||||
index=real(ctmp);
|
||||
nrm = abs(scm-cm()()());
|
||||
|
||||
if (nrm > 0){
|
||||
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
index=real(scm);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
exx=1;
|
||||
} else if (1) {
|
||||
std::cout<<GridLogMessage<<"PASS shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
}
|
||||
}}}}
|
||||
if (exx) exit(-1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Grid_finalize();
|
||||
}
|
223
tests/core/Test_cshift_red_black_rotate.cc
Normal file
223
tests/core/Test_cshift_red_black_rotate.cc
Normal file
@ -0,0 +1,223 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_cshift_red_black.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
int Nd = latt_size.size();
|
||||
std::vector<int> simd_layout( { vComplex::Nsimd(),1,1,1});
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
std::vector<int> mask(Nd,1);
|
||||
mask[0]=0;
|
||||
|
||||
GridCartesian Fine (latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBFine(latt_size,simd_layout,mpi_layout,mask,1);
|
||||
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
||||
|
||||
LatticeComplex U(&Fine);
|
||||
LatticeComplex ShiftU(&Fine);
|
||||
LatticeComplex rbShiftU(&Fine);
|
||||
LatticeComplex Ue(&RBFine);
|
||||
LatticeComplex Uo(&RBFine);
|
||||
LatticeComplex ShiftUe(&RBFine);
|
||||
LatticeComplex ShiftUo(&RBFine);
|
||||
LatticeComplex lex(&Fine);
|
||||
lex=zero;
|
||||
Integer stride =1;
|
||||
{
|
||||
double nrm;
|
||||
LatticeComplex coor(&Fine);
|
||||
|
||||
for(int d=0;d<Nd;d++){
|
||||
// Integer i=10000;
|
||||
Integer i=0;
|
||||
LatticeCoordinate(coor,d);
|
||||
lex = lex + coor*stride+i;
|
||||
stride=stride*latt_size[d];
|
||||
}
|
||||
U=lex;
|
||||
}
|
||||
|
||||
pickCheckerboard(Even,Ue,U);
|
||||
pickCheckerboard(Odd,Uo,U);
|
||||
|
||||
// std::cout<<GridLogMessage << U<<std::endl;
|
||||
std::cout<<GridLogMessage << "Ue " <<norm2(Ue)<<std::endl;
|
||||
std::cout<<GridLogMessage << "Uo " <<norm2(Uo)<<std::endl;
|
||||
|
||||
|
||||
TComplex cm;
|
||||
TComplex cmeo;
|
||||
for(int dir=0;dir<Nd;dir++){
|
||||
// if ( dir!=1 ) continue;
|
||||
for(int shift=0;shift<latt_size[dir];shift++){
|
||||
|
||||
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Even grid"<<std::endl;
|
||||
ShiftUe = Cshift(Ue,dir,shift); // Shift everything cb by cb
|
||||
std::cout<<GridLogMessage << "\tShiftUe " <<norm2(ShiftUe)<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Odd grid"<<std::endl;
|
||||
ShiftUo = Cshift(Uo,dir,shift);
|
||||
std::cout<<GridLogMessage << "\tShiftUo " <<norm2(ShiftUo)<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Recombined Even/Odd grids"<<std::endl;
|
||||
setCheckerboard(rbShiftU,ShiftUe);
|
||||
setCheckerboard(rbShiftU,ShiftUo);
|
||||
std::cout<<GridLogMessage << "\trbShiftU " <<norm2(rbShiftU)<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"Full grid shift"<<std::endl;
|
||||
ShiftU = Cshift(U,dir,shift); // Shift everything
|
||||
std::cout<<GridLogMessage << "\tShiftU " <<norm2(rbShiftU)<<std::endl;
|
||||
|
||||
std::vector<int> coor(4);
|
||||
|
||||
std::cout<<GridLogMessage << "Checking the non-checkerboard shift"<<std::endl;
|
||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
||||
for(coor[1]=0;coor[1]<latt_size[1];coor[1]++){
|
||||
for(coor[0]=0;coor[0]<latt_size[0];coor[0]++){
|
||||
|
||||
peekSite(cm,ShiftU,coor);
|
||||
|
||||
///////// double nrm=norm2(U);
|
||||
|
||||
std::vector<int> scoor(coor);
|
||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||
|
||||
Integer slex = scoor[0]
|
||||
+ latt_size[0]*scoor[1]
|
||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
||||
|
||||
Complex scm(slex);
|
||||
|
||||
double nrm = abs(scm-cm()()());
|
||||
std::vector<int> peer(4);
|
||||
Complex ctmp = cm;
|
||||
Integer index=real(ctmp);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
|
||||
if (nrm > 0){
|
||||
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
index=real(scm);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
}}}}
|
||||
|
||||
int exx=0;
|
||||
std::cout<<GridLogMessage << "Checking the checkerboard shift"<<std::endl;
|
||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
||||
for(coor[1]=0;coor[1]<latt_size[1];coor[1]++){
|
||||
for(coor[0]=0;coor[0]<latt_size[0];coor[0]++){
|
||||
|
||||
peekSite(cm,rbShiftU,coor);
|
||||
|
||||
Integer checkerboard = RBFine.CheckerBoard(coor);
|
||||
|
||||
// std::cout << " coor "<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] \n ";
|
||||
// std::cout << "shift "<< shift <<" dir "<<dir<< " checker board "<< checkerboard << " ";
|
||||
// std::cout << "Uo " << ShiftUo.checkerboard << " Ue "<<ShiftUe.checkerboard<<std::endl;
|
||||
if ( checkerboard == ShiftUo.checkerboard ) {
|
||||
peekSite(cmeo,ShiftUo,coor);
|
||||
} else {
|
||||
peekSite(cmeo,ShiftUe,coor);
|
||||
}
|
||||
|
||||
|
||||
std::vector<int> scoor(coor);
|
||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||
|
||||
Integer slex = scoor[0]
|
||||
+ latt_size[0]*scoor[1]
|
||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
||||
|
||||
Complex scm(slex);
|
||||
|
||||
std::vector<int> peer(4);
|
||||
Complex ctmp=cmeo;
|
||||
Integer index=real(ctmp);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
|
||||
double nrm = abs(cmeo()()()-scm);
|
||||
if (nrm != 0) {
|
||||
std::cout<<"EOFAIL shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cmeo()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
index=real(scm);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
exx=1;
|
||||
|
||||
}
|
||||
|
||||
ctmp=cm;
|
||||
index=real(ctmp);
|
||||
nrm = abs(scm-cm()()());
|
||||
|
||||
if (nrm > 0){
|
||||
std::cout<<"FAIL shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cout<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
index=real(scm);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
std::cout<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
exx=1;
|
||||
} else if (1) {
|
||||
std::cout<<GridLogMessage<<"PASS shift "<< shift<<" in dir "<< dir
|
||||
<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "
|
||||
<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
}
|
||||
}}}}
|
||||
if (exx) exit(-1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Grid_finalize();
|
||||
}
|
125
tests/core/Test_cshift_rotate.cc
Normal file
125
tests/core/Test_cshift_rotate.cc
Normal file
@ -0,0 +1,125 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_cshift.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout( { vComplex::Nsimd(),1,1,1});
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
GridParallelRNG FineRNG(&Fine); FineRNG.SeedRandomDevice();
|
||||
|
||||
LatticeComplex U(&Fine);
|
||||
LatticeComplex ShiftU(&Fine);
|
||||
|
||||
LatticeComplex lex(&Fine);
|
||||
lex=zero;
|
||||
Integer stride =1;
|
||||
{
|
||||
double nrm;
|
||||
LatticeComplex coor(&Fine);
|
||||
|
||||
for(int d=0;d<4;d++){
|
||||
LatticeCoordinate(coor,d);
|
||||
lex = lex + coor*stride;
|
||||
stride=stride*latt_size[d];
|
||||
}
|
||||
U=lex;
|
||||
}
|
||||
|
||||
|
||||
TComplex cm;
|
||||
|
||||
for(int dir=0;dir<4;dir++){
|
||||
for(int shift=0;shift<latt_size[dir];shift++){
|
||||
if ( Fine.IsBoss() )
|
||||
std::cout<<GridLogMessage<<"Shifting by "<<shift<<" in direction"<<dir<<std::endl;
|
||||
|
||||
ShiftU = Cshift(U,dir,shift); // Shift everything
|
||||
|
||||
/*
|
||||
std::cout << "U[0]" << U[0]<<std::endl;
|
||||
std::cout << "U[1]" << U[1]<<std::endl;
|
||||
std::cout << "ShiftU[0]" << ShiftU[0]<<std::endl;
|
||||
std::cout << "ShiftU[1]" << ShiftU[1]<<std::endl;
|
||||
*/
|
||||
std::vector<int> coor(4);
|
||||
|
||||
for(coor[3]=0;coor[3]<latt_size[3];coor[3]++){
|
||||
for(coor[2]=0;coor[2]<latt_size[2];coor[2]++){
|
||||
for(coor[1]=0;coor[1]<latt_size[1];coor[1]++){
|
||||
for(coor[0]=0;coor[0]<latt_size[0];coor[0]++){
|
||||
|
||||
peekSite(cm,ShiftU,coor);
|
||||
|
||||
double nrm=norm2(U);
|
||||
|
||||
std::vector<int> scoor(coor);
|
||||
scoor[dir] = (scoor[dir]+shift)%latt_size[dir];
|
||||
|
||||
Integer slex = scoor[0]
|
||||
+ latt_size[0]*scoor[1]
|
||||
+ latt_size[0]*latt_size[1]*scoor[2]
|
||||
+ latt_size[0]*latt_size[1]*latt_size[2]*scoor[3];
|
||||
|
||||
Complex scm(slex);
|
||||
|
||||
nrm = abs(scm-cm()()());
|
||||
std::vector<int> peer(4);
|
||||
Complex tmp =cm;
|
||||
Integer index=real(tmp);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
|
||||
if (nrm > 0){
|
||||
std::cerr<<"FAIL shift "<< shift<<" in dir "<< dir<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cerr<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
index=real(scm);
|
||||
Lexicographic::CoorFromIndex(peer,index,latt_size);
|
||||
std::cerr<<"Expect "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
}
|
||||
/*
|
||||
else {
|
||||
std::cerr<<"PASS shift "<< shift<<" in dir "<< dir<<" ["<<coor[0]<<","<<coor[1]<<","<<coor[2]<<","<<coor[3]<<"] = "<< cm()()()<<" expect "<<scm<<" "<<nrm<<std::endl;
|
||||
std::cerr<<"Got "<<index<<" " << peer[0]<<","<<peer[1]<<","<<peer[2]<<","<<peer[3]<<std::endl;
|
||||
}
|
||||
*/
|
||||
}}}}
|
||||
}
|
||||
}
|
||||
|
||||
Grid_finalize();
|
||||
}
|
237
tests/core/Test_dwf_even_odd.cc
Normal file
237
tests/core/Test_dwf_even_odd.cc
Normal file
@ -0,0 +1,237 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_even_odd.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::GammaMatrix Gmu [] = {
|
||||
Gamma::GammaX,
|
||||
Gamma::GammaY,
|
||||
Gamma::GammaZ,
|
||||
Gamma::GammaT
|
||||
};
|
||||
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
|
||||
const int Ls=8;
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
|
||||
LatticeFermion src (FGrid); random(RNG5,src);
|
||||
LatticeFermion phi (FGrid); random(RNG5,phi);
|
||||
LatticeFermion chi (FGrid); random(RNG5,chi);
|
||||
LatticeFermion result(FGrid); result=zero;
|
||||
LatticeFermion ref(FGrid); ref=zero;
|
||||
LatticeFermion tmp(FGrid); tmp=zero;
|
||||
LatticeFermion err(FGrid); tmp=zero;
|
||||
LatticeGaugeField Umu(UGrid); random(RNG4,Umu);
|
||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
||||
|
||||
// Only one non-zero (y)
|
||||
Umu=zero;
|
||||
for(int nn=0;nn<Nd;nn++){
|
||||
random(RNG4,U[nn]);
|
||||
if ( nn>0 )
|
||||
U[nn]=zero;
|
||||
PokeIndex<LorentzIndex>(Umu,U[nn],nn);
|
||||
}
|
||||
|
||||
RealD mass=0.1;
|
||||
RealD M5 =1.8;
|
||||
DomainWallFermionR Ddwf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
||||
|
||||
LatticeFermion src_e (FrbGrid);
|
||||
LatticeFermion src_o (FrbGrid);
|
||||
LatticeFermion r_e (FrbGrid);
|
||||
LatticeFermion r_o (FrbGrid);
|
||||
LatticeFermion r_eo (FGrid);
|
||||
LatticeFermion r_eeoo(FGrid);
|
||||
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Testing that Meo + Moe + Moo + Mee = Munprec "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,src_e,src);
|
||||
pickCheckerboard(Odd,src_o,src);
|
||||
|
||||
Ddwf.Meooe(src_e,r_o); std::cout<<GridLogMessage<<"Applied Meo"<<std::endl;
|
||||
Ddwf.Meooe(src_o,r_e); std::cout<<GridLogMessage<<"Applied Moe"<<std::endl;
|
||||
setCheckerboard(r_eo,r_o);
|
||||
setCheckerboard(r_eo,r_e);
|
||||
|
||||
Ddwf.Mooee(src_e,r_e); std::cout<<GridLogMessage<<"Applied Mee"<<std::endl;
|
||||
Ddwf.Mooee(src_o,r_o); std::cout<<GridLogMessage<<"Applied Moo"<<std::endl;
|
||||
setCheckerboard(r_eeoo,r_e);
|
||||
setCheckerboard(r_eeoo,r_o);
|
||||
|
||||
r_eo=r_eo+r_eeoo;
|
||||
Ddwf.M(src,ref);
|
||||
|
||||
// std::cout<<GridLogMessage << r_eo<<std::endl;
|
||||
// std::cout<<GridLogMessage << ref <<std::endl;
|
||||
|
||||
err= ref - r_eo;
|
||||
std::cout<<GridLogMessage << "EO norm diff "<< norm2(err)<< " "<<norm2(ref)<< " " << norm2(r_eo) <<std::endl;
|
||||
|
||||
LatticeComplex cerr(FGrid);
|
||||
cerr = localInnerProduct(err,err);
|
||||
// std::cout<<GridLogMessage << cerr<<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test Ddagger is the dagger of D by requiring "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= < phi | Deo | chi > * = < chi | Deo^dag| phi> "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
LatticeFermion chi_e (FrbGrid);
|
||||
LatticeFermion chi_o (FrbGrid);
|
||||
|
||||
LatticeFermion dchi_e (FrbGrid);
|
||||
LatticeFermion dchi_o (FrbGrid);
|
||||
|
||||
LatticeFermion phi_e (FrbGrid);
|
||||
LatticeFermion phi_o (FrbGrid);
|
||||
|
||||
LatticeFermion dphi_e (FrbGrid);
|
||||
LatticeFermion dphi_o (FrbGrid);
|
||||
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
|
||||
Ddwf.Meooe(chi_e,dchi_o);
|
||||
Ddwf.Meooe(chi_o,dchi_e);
|
||||
Ddwf.MeooeDag(phi_e,dphi_o);
|
||||
Ddwf.MeooeDag(phi_o,dphi_e);
|
||||
|
||||
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);
|
||||
|
||||
std::cout<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDce-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDco-conj(cDpe) <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInv Mee = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Ddwf.Mooee(chi_e,src_e);
|
||||
Ddwf.MooeeInv(src_e,phi_e);
|
||||
|
||||
Ddwf.Mooee(chi_o,src_o);
|
||||
Ddwf.MooeeInv(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInvDag MeeDag = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Ddwf.MooeeDag(chi_e,src_e);
|
||||
Ddwf.MooeeInvDag(src_e,phi_e);
|
||||
|
||||
Ddwf.MooeeDag(chi_o,src_o);
|
||||
Ddwf.MooeeInvDag(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MpcDagMpc is Hermitian "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
random(RNG5,phi);
|
||||
random(RNG5,chi);
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
RealD t1,t2;
|
||||
|
||||
|
||||
SchurDiagMooeeOperator<DomainWallFermionR,LatticeFermion> HermOpEO(Ddwf);
|
||||
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<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDco-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDce-conj(cDpe) <<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
138
tests/core/Test_dwf_rb5d.cc
Normal file
138
tests/core/Test_dwf_rb5d.cc
Normal file
@ -0,0 +1,138 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_even_odd.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::GammaMatrix Gmu [] = {
|
||||
Gamma::GammaX,
|
||||
Gamma::GammaY,
|
||||
Gamma::GammaZ,
|
||||
Gamma::GammaT
|
||||
};
|
||||
|
||||
typedef WilsonFermion5D<DomainWallRedBlack5dImplR> WilsonFermion5DR;
|
||||
typedef WilsonFermion5D<DomainWallRedBlack5dImplF> WilsonFermion5DF;
|
||||
typedef WilsonFermion5D<DomainWallRedBlack5dImplD> WilsonFermion5DD;
|
||||
|
||||
typedef WilsonFermion5D<WilsonImplR> WilsonFermion5D_OKR;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
|
||||
const int Ls=32;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
|
||||
GridCartesian * sUGrid = SpaceTimeGrid::makeFourDimDWFGrid(GridDefaultLatt(),GridDefaultMpi());
|
||||
GridRedBlackCartesian * sUrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(sUGrid);
|
||||
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimDWFGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimDWFRedBlackGrid(Ls,UGrid);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
|
||||
LatticeFermion src (FGrid); random(RNG5,src);
|
||||
LatticeFermion result(FGrid); result=zero;
|
||||
LatticeFermion ref(FGrid); ref=zero;
|
||||
LatticeFermion tmp(FGrid);
|
||||
LatticeFermion err(FGrid);
|
||||
|
||||
LatticeGaugeField Umu(UGrid); random(RNG4,Umu);
|
||||
std::vector<LatticeColourMatrix> U(4,UGrid);
|
||||
|
||||
// Only one non-zero (y)
|
||||
/*
|
||||
Umu=zero;
|
||||
for(int nn=0;nn<Nd;nn++){
|
||||
random(RNG4,U[nn]);
|
||||
PokeIndex<LorentzIndex>(Umu,U[nn],nn);
|
||||
}
|
||||
*/
|
||||
|
||||
RealD mass=0.1;
|
||||
RealD M5 =1.8;
|
||||
typename WilsonFermion5DR::ImplParams params;
|
||||
|
||||
WilsonFermion5DR Dw(1,Umu,*FGrid,*FrbGrid,*sUGrid,M5,params);
|
||||
|
||||
Dw.Dhop(src,result,0);
|
||||
|
||||
std::cout << "Norm src = "<<norm2(src)<<" Norm res = "<<norm2(result) << std::endl;
|
||||
|
||||
|
||||
|
||||
GridCartesian * FokGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FokrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
WilsonFermion5D_OKR Dok(Umu,*FokGrid,*FokrbGrid,*UGrid,*UrbGrid,M5,params);
|
||||
|
||||
LatticeFermion src_ok (FokGrid);
|
||||
LatticeFermion ref_ok(FokGrid);
|
||||
LatticeFermion result_ok(FokGrid);
|
||||
|
||||
|
||||
for(int lidx=0;lidx<FGrid->lSites();lidx++){
|
||||
std::vector<int> lcoor;
|
||||
FGrid->LocalIndexToLocalCoor(lidx,lcoor);
|
||||
|
||||
SpinColourVector siteSrc;
|
||||
|
||||
peekLocalSite(siteSrc,src,lcoor);
|
||||
pokeLocalSite(siteSrc,src_ok,lcoor);
|
||||
|
||||
peekLocalSite(siteSrc,result,lcoor);
|
||||
pokeLocalSite(siteSrc,result_ok,lcoor);
|
||||
}
|
||||
|
||||
Dok.Dhop(src_ok,ref_ok,0);
|
||||
|
||||
std::cout << "Reference = "<<norm2(src_ok)<<" res = "<<norm2(ref_ok) << std::endl;
|
||||
ref_ok = ref_ok - result_ok;
|
||||
std::cout << "Reference diff = "<<norm2(result_ok)<< std::endl;
|
||||
std::cout << "Reference diff = "<<norm2(ref_ok)<< std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
223
tests/core/Test_gamma.cc
Normal file
223
tests/core/Test_gamma.cc
Normal file
@ -0,0 +1,223 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_gamma.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
//template<class vobj> class is_pod< iScalar<vobj> >
|
||||
//{
|
||||
//
|
||||
//};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
GridSerialRNG sRNG;
|
||||
sRNG.SeedRandomDevice();
|
||||
|
||||
SpinMatrix ident; ident=zero;
|
||||
SpinMatrix rnd ; random(sRNG,rnd);
|
||||
|
||||
SpinMatrix ll; ll=zero;
|
||||
SpinMatrix rr; rr=zero;
|
||||
SpinMatrix result;
|
||||
|
||||
SpinVector lv; random(sRNG,lv);
|
||||
SpinVector rv; random(sRNG,rv);
|
||||
|
||||
// std::cout<<GridLogMessage << " Is pod " << std::is_pod<SpinVector>::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod double " << std::is_pod<double>::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod ComplexF " << std::is_pod<ComplexF>::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is triv double " << std::has_trivial_default_constructor<double>::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is triv ComplexF " << std::has_trivial_default_constructor<ComplexF>::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod Scalar<double> " << std::is_pod<iScalar<double> >::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod Scalar<ComplexF> " << std::is_pod<iScalar<ComplexF> >::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod Scalar<vComplexF> " << std::is_pod<iScalar<vComplexF> >::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod Scalar<vComplexD> " << std::is_pod<iScalar<vComplexD> >::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod Scalar<vRealF> " << std::is_pod<iScalar<vRealF> >::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is pod Scalar<vRealD> " << std::is_pod<iScalar<vRealD> >::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is triv Scalar<double> " <<std::has_trivial_default_constructor<iScalar<double> >::value << std::endl;
|
||||
// std::cout<<GridLogMessage << " Is triv Scalar<vComplexD> "<<std::has_trivial_default_constructor<iScalar<vComplexD> >::value << std::endl;
|
||||
|
||||
for(int a=0;a<Ns;a++){
|
||||
ident()(a,a) = ComplexF(1.0);
|
||||
}
|
||||
|
||||
const Gamma::GammaMatrix *g = Gamma::GammaMatrices;
|
||||
const char **list = Gamma::GammaMatrixNames;
|
||||
|
||||
result =ll*Gamma(g[0])*rr;
|
||||
result =ll*Gamma(g[0]);
|
||||
rv = Gamma(g[0])*lv;
|
||||
|
||||
for(int mu=0;mu<12;mu++){
|
||||
|
||||
result = Gamma(g[mu])* ident;
|
||||
|
||||
for(int i=0;i<Ns;i++){
|
||||
|
||||
if(i==0) std::cout<<GridLogMessage << list[mu];
|
||||
else std::cout<<GridLogMessage << list[12];
|
||||
|
||||
std::cout<<"(";
|
||||
for(int j=0;j<Ns;j++){
|
||||
if ( abs(result()(i,j)())==0 ) {
|
||||
std::cout<< " 0";
|
||||
} else if ( abs(result()(i,j)() - Complex(0,1))==0){
|
||||
std::cout<< " i";
|
||||
} else if ( abs(result()(i,j)() + Complex(0,1))==0){
|
||||
std::cout<< "-i";
|
||||
} else if ( abs(result()(i,j)() - Complex(1,0))==0){
|
||||
std::cout<< " 1";
|
||||
} else if ( abs(result()(i,j)() + Complex(1,0))==0){
|
||||
std::cout<< "-1";
|
||||
}
|
||||
std::cout<<((j==Ns-1) ? ")" : "," );
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
}
|
||||
|
||||
std::cout << "Testing Gamma^2 - 1 = 0"<<std::endl;
|
||||
for(int mu=0;mu<6;mu++){
|
||||
result = Gamma(g[mu])* ident * Gamma(g[mu]);
|
||||
result = result - ident;
|
||||
RealD mag = norm2(result);
|
||||
std::cout << list[mu]<<" " << mag<<std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Testing (MinusGamma + G )M = 0"<<std::endl;
|
||||
for(int mu=0;mu<6;mu++){
|
||||
result = rnd * Gamma(g[mu]);
|
||||
result = result + rnd * Gamma(g[mu+6]);
|
||||
RealD mag = norm2(result);
|
||||
std::cout << list[mu]<<" " << mag<<std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Testing M(MinusGamma + G ) = 0"<<std::endl;
|
||||
for(int mu=0;mu<6;mu++){
|
||||
result = Gamma(g[mu]) *rnd;
|
||||
result = result + Gamma(g[mu+6])*rnd;
|
||||
RealD mag = norm2(result);
|
||||
std::cout << list[mu]<<" " << mag<<std::endl;
|
||||
}
|
||||
|
||||
// Testing spins and reconstructs
|
||||
SpinVector recon; random(sRNG,rv);
|
||||
SpinVector full;
|
||||
HalfSpinVector hsp,hsm;
|
||||
|
||||
// Xp
|
||||
double mag;
|
||||
spProjXp(hsm,rv);
|
||||
spReconXp(recon,hsm);
|
||||
full = rv + Gamma(Gamma::GammaX) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Xp "<< mag<<std::endl;
|
||||
|
||||
// Xm
|
||||
spProjXm(hsm,rv);
|
||||
spReconXm(recon,hsm);
|
||||
full = rv - Gamma(Gamma::GammaX) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Xm "<< mag<<std::endl;
|
||||
|
||||
// Yp
|
||||
spProjYp(hsm,rv);
|
||||
spReconYp(recon,hsm);
|
||||
full = rv + Gamma(Gamma::GammaY) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Yp "<< mag<<std::endl;
|
||||
|
||||
// Ym
|
||||
spProjYm(hsm,rv);
|
||||
spReconYm(recon,hsm);
|
||||
full = rv - Gamma(Gamma::GammaY) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Ym "<< mag<<std::endl;
|
||||
|
||||
// Zp
|
||||
spProjZp(hsm,rv);
|
||||
spReconZp(recon,hsm);
|
||||
full = rv + Gamma(Gamma::GammaZ) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Zp "<< mag<<std::endl;
|
||||
|
||||
// Zm
|
||||
spProjZm(hsm,rv);
|
||||
spReconZm(recon,hsm);
|
||||
full = rv - Gamma(Gamma::GammaZ) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Zm "<< mag<<std::endl;
|
||||
|
||||
// Tp
|
||||
spProjTp(hsm,rv);
|
||||
spReconTp(recon,hsm);
|
||||
full = rv + Gamma(Gamma::GammaT) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Tp "<< mag<<std::endl;
|
||||
|
||||
// Tm
|
||||
spProjTm(hsm,rv);
|
||||
spReconTm(recon,hsm);
|
||||
full = rv - Gamma(Gamma::GammaT) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "Tm "<< mag<<std::endl;
|
||||
|
||||
// 5p
|
||||
spProj5p(hsm,rv);
|
||||
spRecon5p(recon,hsm);
|
||||
full = rv + Gamma(Gamma::Gamma5) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "5p "<< mag<<std::endl;
|
||||
|
||||
// 5m
|
||||
spProj5m(hsm,rv);
|
||||
spRecon5m(recon,hsm);
|
||||
full = rv - Gamma(Gamma::Gamma5) *rv;
|
||||
mag = TensorRemove(norm2(full-recon));
|
||||
std::cout << "5m "<< mag<<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
266
tests/core/Test_gparity.cc
Normal file
266
tests/core/Test_gparity.cc
Normal file
@ -0,0 +1,266 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_gparity.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
typedef typename GparityDomainWallFermionR::FermionField FermionField;
|
||||
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
const int nu = 3;
|
||||
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
|
||||
const int Ls=4;
|
||||
const int L =4;
|
||||
std::vector<int> latt_2f(Nd,L);
|
||||
std::vector<int> latt_1f(Nd,L); latt_1f[nu] = 2*L;
|
||||
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi(); //node layout
|
||||
|
||||
GridCartesian * UGrid_1f = SpaceTimeGrid::makeFourDimGrid(latt_1f, simd_layout, mpi_layout);
|
||||
GridRedBlackCartesian * UrbGrid_1f = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid_1f);
|
||||
GridCartesian * FGrid_1f = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid_1f);
|
||||
GridRedBlackCartesian * FrbGrid_1f = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid_1f);
|
||||
|
||||
|
||||
GridCartesian * UGrid_2f = SpaceTimeGrid::makeFourDimGrid(latt_2f, simd_layout, mpi_layout);
|
||||
GridRedBlackCartesian * UrbGrid_2f = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid_2f);
|
||||
GridCartesian * FGrid_2f = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid_2f);
|
||||
GridRedBlackCartesian * FrbGrid_2f = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid_2f);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5_2f(FGrid_2f); RNG5_2f.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4_2f(UGrid_2f); RNG4_2f.SeedFixedIntegers(seeds4);
|
||||
|
||||
LatticeGaugeField Umu_2f(UGrid_2f);
|
||||
SU3::HotConfiguration(RNG4_2f,Umu_2f);
|
||||
|
||||
LatticeFermion src (FGrid_2f);
|
||||
LatticeFermion tmpsrc(FGrid_2f);
|
||||
FermionField src_2f(FGrid_2f);
|
||||
LatticeFermion src_1f(FGrid_1f);
|
||||
|
||||
// Replicate fermion source
|
||||
random(RNG5_2f,src);
|
||||
PokeIndex<0>(src_2f,src,0);
|
||||
tmpsrc=src*2.0;
|
||||
PokeIndex<0>(src_2f,tmpsrc,1);
|
||||
|
||||
LatticeFermion result_1f(FGrid_1f); result_1f=zero;
|
||||
LatticeGaugeField Umu_1f(UGrid_1f);
|
||||
Replicate(Umu_2f,Umu_1f);
|
||||
|
||||
//Coordinate grid for reference
|
||||
LatticeInteger xcoor_1f(UGrid_1f);
|
||||
LatticeCoordinate(xcoor_1f,nu);
|
||||
|
||||
//Copy-conjugate the gauge field
|
||||
//First C-shift the lattice by Lx/2
|
||||
{
|
||||
LatticeGaugeField Umu_shift = conjugate( Cshift(Umu_1f,nu,L) );
|
||||
Umu_1f = where( xcoor_1f >= Integer(L), Umu_shift, Umu_1f );
|
||||
|
||||
// hack test to check the same
|
||||
Replicate(Umu_2f,Umu_shift);
|
||||
Umu_shift=Umu_shift-Umu_1f;
|
||||
cout << GridLogMessage << "Umu diff " << norm2(Umu_shift)<<std::endl;
|
||||
|
||||
//Make the gauge field antiperiodic in nu-direction
|
||||
LatticeColourMatrix Unu(UGrid_1f);
|
||||
Unu = PeekIndex<LorentzIndex>(Umu_1f,nu);
|
||||
Unu = where(xcoor_1f == Integer(2*L-1), -Unu, Unu);
|
||||
PokeIndex<LorentzIndex>(Umu_1f,Unu,nu);
|
||||
}
|
||||
|
||||
//Coordinate grid for reference
|
||||
LatticeInteger xcoor_1f5(FGrid_1f);
|
||||
LatticeCoordinate(xcoor_1f5,1+nu);
|
||||
Replicate(src,src_1f);
|
||||
src_1f = where( xcoor_1f5 >= Integer(L), 2.0*src_1f,src_1f );
|
||||
|
||||
RealD mass=0.0;
|
||||
RealD M5=1.8;
|
||||
DomainWallFermionR Ddwf(Umu_1f,*FGrid_1f,*FrbGrid_1f,*UGrid_1f,*UrbGrid_1f,mass,M5);
|
||||
|
||||
LatticeFermion src_o_1f(FrbGrid_1f);
|
||||
LatticeFermion result_o_1f(FrbGrid_1f);
|
||||
pickCheckerboard(Odd,src_o_1f,src_1f);
|
||||
result_o_1f=zero;
|
||||
|
||||
SchurDiagMooeeOperator<DomainWallFermionR,LatticeFermion> HermOpEO(Ddwf);
|
||||
ConjugateGradient<LatticeFermion> CG(1.0e-8,10000);
|
||||
CG(HermOpEO,src_o_1f,result_o_1f);
|
||||
|
||||
// const int nu = 3;
|
||||
std::vector<int> twists(Nd,0);
|
||||
twists[nu] = 1;
|
||||
GparityDomainWallFermionR::ImplParams params;
|
||||
params.twists = twists;
|
||||
GparityDomainWallFermionR GPDdwf(Umu_2f,*FGrid_2f,*FrbGrid_2f,*UGrid_2f,*UrbGrid_2f,mass,M5,params);
|
||||
|
||||
for(int disp=-1;disp<=1;disp+=2)
|
||||
for(int mu=0;mu<5;mu++)
|
||||
{
|
||||
FermionField Dsrc_2f(FGrid_2f);
|
||||
|
||||
LatticeFermion Dsrc_1f(FGrid_1f);
|
||||
LatticeFermion Dsrc_2freplica(FGrid_1f);
|
||||
LatticeFermion Dsrc_2freplica0(FGrid_1f);
|
||||
LatticeFermion Dsrc_2freplica1(FGrid_1f);
|
||||
|
||||
if ( mu ==0 ) {
|
||||
std::cout << GridLogMessage<< " Cross checking entire hopping term"<<std::endl;
|
||||
GPDdwf.Dhop(src_2f,Dsrc_2f,DaggerNo);
|
||||
Ddwf.Dhop(src_1f,Dsrc_1f,DaggerNo);
|
||||
} else {
|
||||
std::cout << GridLogMessage<< " Cross checking mu="<<mu<< " disp="<< disp<<std::endl;
|
||||
GPDdwf.DhopDir(src_2f,Dsrc_2f,mu,disp);
|
||||
Ddwf.DhopDir(src_1f,Dsrc_1f,mu,disp);
|
||||
}
|
||||
|
||||
std::cout << GridLogMessage << "S norms "<< norm2(src_2f) << " " << norm2(src_1f) <<std::endl;
|
||||
std::cout << GridLogMessage << "D norms "<< norm2(Dsrc_2f)<< " " << norm2(Dsrc_1f) <<std::endl;
|
||||
|
||||
LatticeFermion Dsrc_2f0(FGrid_2f); Dsrc_2f0 = PeekIndex<0>(Dsrc_2f,0);
|
||||
LatticeFermion Dsrc_2f1(FGrid_2f); Dsrc_2f1 = PeekIndex<0>(Dsrc_2f,1);
|
||||
|
||||
// Dsrc_2f1 = Dsrc_2f1 - Dsrc_2f0;
|
||||
// std::cout << GridLogMessage << " Cross check two halves " <<norm2(Dsrc_2f1)<<std::endl;
|
||||
|
||||
Replicate(Dsrc_2f0,Dsrc_2freplica0);
|
||||
Replicate(Dsrc_2f1,Dsrc_2freplica1);
|
||||
|
||||
Dsrc_2freplica = where( xcoor_1f5 >= Integer(L), Dsrc_2freplica1,Dsrc_2freplica0 );
|
||||
Dsrc_2freplica = Dsrc_2freplica - Dsrc_1f ;
|
||||
std::cout << GridLogMessage << " Cross check against doubled latt " <<norm2(Dsrc_2freplica)<<std::endl;
|
||||
|
||||
// std::cout << Dsrc_2f <<std::endl;
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
FermionField chi (FGrid_2f); gaussian(RNG5_2f,chi);
|
||||
FermionField phi (FGrid_2f); gaussian(RNG5_2f,phi);
|
||||
|
||||
FermionField chi_e (FrbGrid_2f);
|
||||
FermionField chi_o (FrbGrid_2f);
|
||||
|
||||
FermionField dchi_e (FrbGrid_2f);
|
||||
FermionField dchi_o (FrbGrid_2f);
|
||||
|
||||
FermionField phi_e (FrbGrid_2f);
|
||||
FermionField phi_o (FrbGrid_2f);
|
||||
|
||||
FermionField dphi_e (FrbGrid_2f);
|
||||
FermionField dphi_o (FrbGrid_2f);
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
|
||||
GPDdwf.Meooe(chi_e,dchi_o);
|
||||
GPDdwf.Meooe(chi_o,dchi_e);
|
||||
GPDdwf.MeooeDag(phi_e,dphi_o);
|
||||
GPDdwf.MeooeDag(phi_o,dphi_e);
|
||||
|
||||
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);
|
||||
|
||||
std::cout<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDce-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDco-conj(cDpe) <<std::endl;
|
||||
|
||||
}
|
||||
|
||||
FermionField result_2f(FGrid_2f); result_2f=zero;
|
||||
FermionField src_o_2f(FrbGrid_2f);
|
||||
FermionField result_o_2f(FrbGrid_2f);
|
||||
pickCheckerboard(Odd,src_o_2f,src_2f);
|
||||
result_o_2f=zero;
|
||||
|
||||
ConjugateGradient<FermionField> CG2f(1.0e-8,10000);
|
||||
SchurDiagMooeeOperator<GparityDomainWallFermionR,FermionField> HermOpEO2f(GPDdwf);
|
||||
CG2f(HermOpEO2f,src_o_2f,result_o_2f);
|
||||
|
||||
std::cout << "2f cb "<<result_o_2f.checkerboard<<std::endl;
|
||||
std::cout << "1f cb "<<result_o_1f.checkerboard<<std::endl;
|
||||
|
||||
std::cout << " result norms " <<norm2(result_o_2f)<<" " <<norm2(result_o_1f)<<std::endl;
|
||||
|
||||
LatticeFermion res0o (FrbGrid_2f);
|
||||
LatticeFermion res1o (FrbGrid_2f);
|
||||
LatticeFermion res0 (FGrid_2f);
|
||||
LatticeFermion res1 (FGrid_2f);
|
||||
|
||||
res0=zero;
|
||||
res1=zero;
|
||||
|
||||
res0o = PeekIndex<0>(result_o_2f,0);
|
||||
res1o = PeekIndex<0>(result_o_2f,1);
|
||||
|
||||
std::cout << "res cb "<<res0o.checkerboard<<std::endl;
|
||||
std::cout << "res cb "<<res1o.checkerboard<<std::endl;
|
||||
|
||||
setCheckerboard(res0,res0o);
|
||||
setCheckerboard(res1,res1o);
|
||||
|
||||
LatticeFermion replica (FGrid_1f);
|
||||
LatticeFermion replica0(FGrid_1f);
|
||||
LatticeFermion replica1(FGrid_1f);
|
||||
Replicate(res0,replica0);
|
||||
Replicate(res1,replica1);
|
||||
|
||||
replica = where( xcoor_1f5 >= Integer(L), replica1,replica0 );
|
||||
|
||||
replica0 = zero;
|
||||
setCheckerboard(replica0,result_o_1f);
|
||||
|
||||
std::cout << "Norm2 solutions is " <<norm2(replica)<<" "<< norm2(replica0)<<std::endl;
|
||||
|
||||
replica = replica - replica0;
|
||||
|
||||
std::cout << "Norm2 of difference in solutions is " <<norm2(replica)<<std::endl;
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
}
|
222
tests/core/Test_gpwilson_even_odd.cc
Normal file
222
tests/core/Test_gpwilson_even_odd.cc
Normal file
@ -0,0 +1,222 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_gpwilson_even_odd.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> 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<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
// std::vector<int> seeds({1,2,3,4});
|
||||
// pRNG.SeedFixedIntegers(seeds);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
typedef typename GparityWilsonFermionR::FermionField FermionField;
|
||||
|
||||
FermionField src (&Grid); random(pRNG,src);
|
||||
FermionField phi (&Grid); random(pRNG,phi);
|
||||
FermionField chi (&Grid); random(pRNG,chi);
|
||||
FermionField result(&Grid); result=zero;
|
||||
FermionField ref(&Grid); ref=zero;
|
||||
FermionField tmp(&Grid); tmp=zero;
|
||||
FermionField err(&Grid); tmp=zero;
|
||||
LatticeGaugeField Umu(&Grid); random(pRNG,Umu);
|
||||
std::vector<LatticeColourMatrix> U(4,&Grid);
|
||||
|
||||
double volume=1;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
volume=volume*latt_size[mu];
|
||||
}
|
||||
|
||||
// Only one non-zero (y)
|
||||
Umu=zero;
|
||||
for(int nn=0;nn<Nd;nn++){
|
||||
random(pRNG,U[nn]);
|
||||
std::cout<<GridLogMessage<<"U[nn]"<<norm2(U[nn])<<std::endl;
|
||||
PokeIndex<LorentzIndex>(Umu,U[nn],nn);
|
||||
std::cout<<GridLogMessage<<"Umu"<<norm2(Umu)<<std::endl;
|
||||
}
|
||||
|
||||
RealD mass=0.1;
|
||||
|
||||
GparityWilsonFermionR::ImplParams params;
|
||||
std::vector<int> twists(Nd,0); twists[1] = 1;
|
||||
params.twists = twists;
|
||||
GparityWilsonFermionR Dw(Umu,Grid,RBGrid,mass,params);
|
||||
|
||||
FermionField src_e (&RBGrid);
|
||||
FermionField src_o (&RBGrid);
|
||||
FermionField r_e (&RBGrid);
|
||||
FermionField r_o (&RBGrid);
|
||||
FermionField r_eo (&Grid);
|
||||
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Testing that Deo + Doe = Dunprec "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,src_e,src);
|
||||
pickCheckerboard(Odd,src_o,src);
|
||||
|
||||
Dw.Meooe(src_e,r_o); std::cout<<GridLogMessage<<"Applied Meo"<<std::endl;
|
||||
Dw.Meooe(src_o,r_e); std::cout<<GridLogMessage<<"Applied Moe"<<std::endl;
|
||||
Dw.Dhop (src,ref,DaggerNo);
|
||||
|
||||
setCheckerboard(r_eo,r_o);
|
||||
setCheckerboard(r_eo,r_e);
|
||||
|
||||
err= ref - r_eo;
|
||||
std::cout<<GridLogMessage << "EO norm diff "<< norm2(err)<< " "<<norm2(ref)<< " " << norm2(r_eo) <<std::endl;
|
||||
|
||||
LatticeComplex cerr(&Grid);
|
||||
cerr = localInnerProduct(err,err);
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test Ddagger is the dagger of D by requiring "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= < phi | Deo | chi > * = < chi | Deo^dag| phi> "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
FermionField chi_e (&RBGrid);
|
||||
FermionField chi_o (&RBGrid);
|
||||
|
||||
FermionField dchi_e (&RBGrid);
|
||||
FermionField dchi_o (&RBGrid);
|
||||
|
||||
FermionField phi_e (&RBGrid);
|
||||
FermionField phi_o (&RBGrid);
|
||||
|
||||
FermionField dphi_e (&RBGrid);
|
||||
FermionField dphi_o (&RBGrid);
|
||||
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
|
||||
Dw.Meooe(chi_e,dchi_o);
|
||||
Dw.Meooe(chi_o,dchi_e);
|
||||
Dw.MeooeDag(phi_e,dphi_o);
|
||||
Dw.MeooeDag(phi_o,dphi_e);
|
||||
|
||||
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);
|
||||
|
||||
std::cout<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDce-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDco-conj(cDpe) <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInv Mee = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Dw.Mooee(chi_e,src_e);
|
||||
Dw.MooeeInv(src_e,phi_e);
|
||||
|
||||
Dw.Mooee(chi_o,src_o);
|
||||
Dw.MooeeInv(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInvDag MeeDag = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Dw.MooeeDag(chi_e,src_e);
|
||||
Dw.MooeeInvDag(src_e,phi_e);
|
||||
|
||||
Dw.MooeeDag(chi_o,src_o);
|
||||
Dw.MooeeInvDag(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MpcDagMpc is Hermitian "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
random(pRNG,phi);
|
||||
random(pRNG,chi);
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
RealD t1,t2;
|
||||
|
||||
SchurDiagMooeeOperator<GparityWilsonFermionR,FermionField> HermOpEO(Dw);
|
||||
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<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDco-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDce-conj(cDpe) <<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
76
tests/core/Test_lie_generators.cc
Normal file
76
tests/core/Test_lie_generators.cc
Normal file
@ -0,0 +1,76 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_lie_generators.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt({4,4,4,8});
|
||||
GridCartesian * grid = SpaceTimeGrid::makeFourDimGrid(latt,
|
||||
GridDefaultSimd(Nd,vComplex::Nsimd()),
|
||||
GridDefaultMpi());
|
||||
|
||||
GridRedBlackCartesian * rbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(grid);
|
||||
|
||||
std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
std::cout<<GridLogMessage<<"* Generators for SU(2)"<<std::endl;
|
||||
std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
SU2::printGenerators();
|
||||
SU2::testGenerators();
|
||||
|
||||
std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
std::cout<<GridLogMessage<<"* Generators for SU(3)"<<std::endl;
|
||||
std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
SU3::printGenerators();
|
||||
SU3::testGenerators();
|
||||
|
||||
// std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
// std::cout<<GridLogMessage<<"* Generators for SU(4)"<<std::endl;
|
||||
// std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
// SU4::printGenerators();
|
||||
// SU4::testGenerators();
|
||||
|
||||
// std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
// std::cout<<GridLogMessage<<"* Generators for SU(5)"<<std::endl;
|
||||
// std::cout<<GridLogMessage<<"*********************************************"<<std::endl;
|
||||
// SU5::printGenerators();
|
||||
// SU5::testGenerators();
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
||||
|
613
tests/core/Test_main.cc
Normal file
613
tests/core/Test_main.cc
Normal file
@ -0,0 +1,613 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_main.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: neo <cossu@post.kek.jp>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
/*
|
||||
Grid_main.cc(232): error: no suitable user-defined conversion from "Grid::iScalar<Grid::iMatrix<Grid::iScalar<Grid::Complex>, 4>>" to "const Grid::iScalar<Grid::iScalar<Grid::iMatrix<Grid::Complex, 3>>>" exists
|
||||
c_m = peekIdiot<SpinColourMatrix>(scm,1,2);
|
||||
*/
|
||||
template<class vobj> auto peekIdiot(const vobj &rhs,int i,int j) -> decltype(peekIndex<2>(rhs,0,0))
|
||||
{
|
||||
return peekIndex<2>(rhs,i,j);
|
||||
}
|
||||
template<class vobj> auto peekDumKopf(const vobj &rhs,int i,int j) -> decltype(peekIndex<3>(rhs,0,0))
|
||||
{
|
||||
return peekIndex<3>(rhs,i,j);
|
||||
}
|
||||
template<class vobj> auto peekDumKopf(const vobj &rhs,int i) -> decltype(peekIndex<3>(rhs,0))
|
||||
{
|
||||
return peekIndex<3>(rhs,i);
|
||||
}
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
latt_size.resize(4);
|
||||
|
||||
#ifdef AVX512
|
||||
for(int omp=128;omp<236;omp+=16){
|
||||
#else
|
||||
for(int omp=1;omp<2;omp*=20){
|
||||
#endif
|
||||
|
||||
#ifdef OMP
|
||||
omp_set_num_threads(omp);
|
||||
#endif
|
||||
|
||||
for(int lat=8;lat<=16;lat+=40){
|
||||
|
||||
std::cout << "Lat "<<lat<<std::endl;
|
||||
|
||||
latt_size[0] = lat;
|
||||
latt_size[1] = lat;
|
||||
latt_size[2] = lat;
|
||||
latt_size[3] = lat;
|
||||
double volume = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3];
|
||||
|
||||
GridCartesian Fine(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian rbFine(latt_size,simd_layout,mpi_layout);
|
||||
GridParallelRNG FineRNG(&Fine);
|
||||
GridSerialRNG SerialRNG;
|
||||
GridSerialRNG SerialRNG1;
|
||||
|
||||
FineRNG.SeedRandomDevice();
|
||||
SerialRNG.SeedRandomDevice();
|
||||
|
||||
std::cout <<"SerialRNG" << SerialRNG._generators[0] <<std::endl;
|
||||
|
||||
std::vector<typename GridSerialRNG::RngStateType> saved;
|
||||
SerialRNG.GetState(saved,0);
|
||||
SerialRNG1.SetState(saved,0);
|
||||
|
||||
RealD dd1,dd2;
|
||||
|
||||
std::cout << "Testing RNG state save restore"<<std::endl;
|
||||
for(int i=0;i<10;i++){
|
||||
random(SerialRNG,dd1);
|
||||
random(SerialRNG1,dd2);
|
||||
std::cout << "i "<<i<<" "<<dd1<< " " <<dd2<<std::endl;
|
||||
}
|
||||
LatticeColourMatrix Foo(&Fine);
|
||||
LatticeColourMatrix Bar(&Fine);
|
||||
|
||||
LatticeSpinColourMatrix scFoo(&Fine);
|
||||
LatticeSpinColourMatrix scBar(&Fine);
|
||||
|
||||
LatticeColourMatrix Shifted(&Fine);
|
||||
LatticeColourMatrix ShiftedCheck(&Fine);
|
||||
LatticeColourMatrix rShifted(&rbFine);
|
||||
LatticeColourMatrix bShifted(&rbFine);
|
||||
|
||||
LatticeColourMatrix rFoo(&rbFine);
|
||||
LatticeColourMatrix bFoo(&rbFine);
|
||||
|
||||
LatticeColourMatrix FooBar(&Fine);
|
||||
LatticeSpinColourMatrix scFooBar(&Fine);
|
||||
|
||||
LatticeColourVector cVec(&Fine);
|
||||
LatticeSpinVector sVec(&Fine);
|
||||
LatticeSpinColourVector scVec(&Fine);
|
||||
|
||||
LatticeColourMatrix cMat(&Fine);
|
||||
LatticeSpinMatrix sMat(&Fine);
|
||||
LatticeSpinColourMatrix scMat(&Fine);
|
||||
|
||||
LatticeLorentzColourMatrix lcMat(&Fine);
|
||||
|
||||
|
||||
LatticeComplex scalar(&Fine);
|
||||
LatticeReal rscalar(&Fine);
|
||||
LatticeReal iscalar(&Fine);
|
||||
|
||||
SpinMatrix GammaFive;
|
||||
iSpinMatrix<vComplex> iGammaFive;
|
||||
ColourMatrix cmat;
|
||||
|
||||
random(FineRNG,Foo);
|
||||
gaussian(FineRNG,Bar);
|
||||
random(FineRNG,scFoo);
|
||||
random(FineRNG,scBar);
|
||||
|
||||
random(FineRNG,cMat);
|
||||
random(FineRNG,sMat);
|
||||
random(FineRNG,scMat);
|
||||
random(FineRNG,lcMat);
|
||||
random(FineRNG,cVec);
|
||||
random(FineRNG,sVec);
|
||||
random(FineRNG,scVec);
|
||||
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
TComplex tr = trace(cmat);
|
||||
|
||||
|
||||
cVec = cMat * cVec; // LatticeColourVector = LatticeColourMatrix * LatticeColourVector
|
||||
sVec = sMat * sVec; // LatticeSpinVector = LatticeSpinMatrix * LatticeSpinVector
|
||||
scVec= scMat * scVec;// LatticeSpinColourVector = LatticeSpinColourMatrix * LatticeSpinColourVector
|
||||
scVec= cMat * scVec; // LatticeSpinColourVector = LatticeColourMatrix * LatticeSpinColourVector
|
||||
scVec= sMat * scVec; // LatticeSpinColourVector = LatticeSpinMatrix * LatticeSpinColourVector
|
||||
|
||||
cMat = outerProduct(cVec,cVec);
|
||||
scalar = localInnerProduct(cVec,cVec);
|
||||
|
||||
cMat = Ta(cMat); //traceless antihermitian
|
||||
|
||||
|
||||
scalar += scalar;
|
||||
scalar -= scalar;
|
||||
scalar *= scalar;
|
||||
add(scalar,scalar,scalar);
|
||||
sub(scalar,scalar,scalar);
|
||||
mult(scalar,scalar,scalar);
|
||||
|
||||
mac(scalar,scalar,scalar);
|
||||
scalar = scalar+scalar;
|
||||
scalar = scalar-scalar;
|
||||
scalar = scalar*scalar;
|
||||
|
||||
scalar=outerProduct(scalar,scalar);
|
||||
|
||||
scalar=adj(scalar);
|
||||
|
||||
// rscalar=real(scalar);
|
||||
// iscalar=imag(scalar);
|
||||
// scalar =cmplx(rscalar,iscalar);
|
||||
PokeIndex<ColourIndex>(cVec,scalar,1);
|
||||
|
||||
|
||||
scalar=transpose(scalar);
|
||||
scalar=TransposeIndex<ColourIndex>(scalar);
|
||||
scalar=TraceIndex<SpinIndex>(scalar);
|
||||
scalar=PeekIndex<ColourIndex>(cVec,0);
|
||||
|
||||
scalar=trace(scalar);
|
||||
scalar=localInnerProduct(cVec,cVec);
|
||||
scalar=localNorm2(cVec);
|
||||
|
||||
// -=,+=,*=,()
|
||||
// add,+,sub,-,mult,mac,*
|
||||
// adj,conjugate
|
||||
// real,imag
|
||||
// transpose,transposeIndex
|
||||
// trace,traceIndex
|
||||
// peekIndex
|
||||
// innerProduct,outerProduct,
|
||||
// localNorm2
|
||||
// localInnerProduct
|
||||
|
||||
|
||||
scMat = sMat*scMat; // LatticeSpinColourMatrix = LatticeSpinMatrix * LatticeSpinColourMatrix
|
||||
|
||||
|
||||
///////////////////////
|
||||
// Non-lattice (const objects) * Lattice
|
||||
ColourMatrix cm;
|
||||
SpinColourMatrix scm;
|
||||
vSpinColourMatrix vscm;
|
||||
Complex cplx(1.0);
|
||||
Integer myint=1;
|
||||
double mydouble=1.0;
|
||||
|
||||
// vSpinColourMatrix vscm;
|
||||
scMat = cMat*scMat;
|
||||
scm = cm * scm; // SpinColourMatrix = ColourMatrix * SpinColourMatrix
|
||||
scm = scm *cm; // SpinColourMatrix = SpinColourMartix * ColourMatrix
|
||||
scm = GammaFive * scm ; // SpinColourMatrix = SpinMatrix * SpinColourMatrix
|
||||
scm = scm* GammaFive ; // SpinColourMatrix = SpinColourMatrix * SpinMatrix
|
||||
|
||||
scm = scm*cplx;
|
||||
vscm = vscm*cplx;
|
||||
scMat = scMat*cplx;
|
||||
|
||||
scm = cplx*scm;
|
||||
vscm = cplx*vscm;
|
||||
scMat = cplx*scMat;
|
||||
scm = myint*scm;
|
||||
vscm = myint*vscm;
|
||||
scMat = scMat*myint;
|
||||
|
||||
scm = scm*mydouble;
|
||||
vscm = vscm*mydouble;
|
||||
scMat = scMat*mydouble;
|
||||
scMat = mydouble*scMat;
|
||||
cMat = mydouble*cMat;
|
||||
|
||||
sMat = adj(sMat); // LatticeSpinMatrix adjoint
|
||||
sMat = iGammaFive*sMat; // SpinMatrix * LatticeSpinMatrix
|
||||
sMat = GammaFive*sMat; // SpinMatrix * LatticeSpinMatrix
|
||||
scMat= adj(scMat);
|
||||
cMat= adj(cMat);
|
||||
cm=adj(cm);
|
||||
scm=adj(scm);
|
||||
scm=transpose(scm);
|
||||
scm=transposeIndex<1>(scm);
|
||||
|
||||
|
||||
random(SerialRNG, cm);
|
||||
std::cout<<GridLogMessage << cm << std::endl;
|
||||
|
||||
cm = Ta(cm);
|
||||
TComplex tracecm= trace(cm);
|
||||
std::cout<<GridLogMessage << cm << std::endl;
|
||||
|
||||
|
||||
cm = Exponentiate(cm, 2.0, 12);
|
||||
std::cout<<GridLogMessage << cm << " " << std::endl;
|
||||
Complex det = Determinant(cm);
|
||||
std::cout<<GridLogMessage << "determinant: " << det << std::endl;
|
||||
std::cout<<GridLogMessage << "norm: " << norm2(cm) << std::endl;
|
||||
|
||||
cm = ProjectOnGroup(cm);
|
||||
std::cout<<GridLogMessage << cm << " " << std::endl;
|
||||
std::cout<<GridLogMessage << "norm: " << norm2(cm) << std::endl;
|
||||
cm = ProjectOnGroup(cm);
|
||||
std::cout<<GridLogMessage << cm << " " << std::endl;
|
||||
std::cout<<GridLogMessage << "norm: " << norm2(cm) << std::endl;
|
||||
|
||||
|
||||
// det = Determinant(cm);
|
||||
// std::cout<<GridLogMessage << "determinant: " << det << std::endl;
|
||||
|
||||
|
||||
// Foo = Foo+scalar; // LatticeColourMatrix+Scalar
|
||||
// Foo = Foo*scalar; // LatticeColourMatrix*Scalar
|
||||
// Foo = Foo-scalar; // LatticeColourMatrix-Scalar
|
||||
// Foo = scalar*Foo; // Scalar*LatticeColourMatrix
|
||||
// Foo = scalar+Foo; // Scalar+LatticeColourMatrix
|
||||
// Foo = scalar-Foo; // Scalar-LatticeColourMatrix
|
||||
|
||||
LatticeComplex trscMat(&Fine);
|
||||
trscMat = trace(scMat); // Trace
|
||||
|
||||
// Exponentiate test
|
||||
std::vector<int> mysite {0,0,0,0};
|
||||
random(FineRNG,cMat);
|
||||
cMat = Ta(cMat);
|
||||
peekSite(cm, cMat, mysite);
|
||||
std::cout<<GridLogMessage << cm << " " << std::endl;
|
||||
cm = Exponentiate(cm, 1.0, 12);
|
||||
std::cout<<GridLogMessage << cm << " " << std::endl;
|
||||
std::cout<<GridLogMessage << "norm: " << norm2(cm) << std::endl;
|
||||
|
||||
|
||||
std::cout<<GridLogMessage << "norm cMmat : " << norm2(cMat) << std::endl;
|
||||
cMat = expMat(cMat, ComplexD(1.0, 0.0));
|
||||
std::cout<<GridLogMessage << "norm expMat: " << norm2(cMat) << std::endl;
|
||||
peekSite(cm, cMat, mysite);
|
||||
std::cout<<GridLogMessage << cm << " " << std::endl;
|
||||
std::cout<<GridLogMessage << "determinant: " << Determinant(cm) << std::endl;
|
||||
std::cout<<GridLogMessage << "norm: " << norm2(cm) << std::endl;
|
||||
|
||||
|
||||
// LatticeComplex trlcMat(&Fine);
|
||||
// trlcMat = trace(lcMat); // Trace involving iVector - now generates error
|
||||
|
||||
|
||||
{ // Peek-ology and Poke-ology, with a little app-ology
|
||||
Complex c;
|
||||
ColourMatrix c_m;
|
||||
SpinMatrix s_m;
|
||||
SpinColourMatrix sc_m;
|
||||
|
||||
s_m = TensorIndexRecursion<ColourIndex>::traceIndex(sc_m); // Map to traceColour
|
||||
c_m = TensorIndexRecursion<SpinIndex>::traceIndex(sc_m); // map to traceSpin
|
||||
|
||||
c = TensorIndexRecursion<SpinIndex>::traceIndex(s_m);
|
||||
c = TensorIndexRecursion<ColourIndex>::traceIndex(c_m);
|
||||
|
||||
s_m = TensorIndexRecursion<ColourIndex>::peekIndex(scm,0,0);
|
||||
c_m = TensorIndexRecursion<SpinIndex>::peekIndex(scm,1,2);
|
||||
// c_m = peekSpin<SpinColourMatrix>(scm,1,2);
|
||||
// c_m = peekIdiot<SpinColourMatrix>(scm,1,2);
|
||||
|
||||
printf("c. Level %d\n",c_m.TensorLevel);
|
||||
printf("c. Level %d\n",c_m().TensorLevel);
|
||||
printf("c. Level %d\n",c_m()().TensorLevel);
|
||||
|
||||
c_m()() = scm()(0,0); //ColourComponents of CM <= ColourComponents of SpinColourMatrix
|
||||
scm()(1,1) = cm()(); //ColourComponents of CM <= ColourComponents of SpinColourMatrix
|
||||
c = scm()(1,1)(1,2);
|
||||
scm()(1,1)(2,1) = c;
|
||||
|
||||
// pokeIndex<ColourIndex> (c_m,c,0,0);
|
||||
}
|
||||
|
||||
FooBar = Bar;
|
||||
/*
|
||||
{
|
||||
std::vector<int> coor(4);
|
||||
for(int d=0;d<4;d++) coor[d] = 0;
|
||||
peekSite(cmat,Foo,coor);
|
||||
Foo = zero;
|
||||
pokeSite(cmat,Foo,coor);
|
||||
}
|
||||
random(Foo);
|
||||
*/
|
||||
lex_sites(Foo);
|
||||
|
||||
|
||||
Integer mm[4];
|
||||
mm[0]=1;
|
||||
mm[1]=Fine._rdimensions[0];
|
||||
mm[2]=Fine._ldimensions[0]*Fine._ldimensions[1];
|
||||
mm[3]=Fine._ldimensions[0]*Fine._ldimensions[1]*Fine._ldimensions[2];
|
||||
|
||||
LatticeInteger lex(&Fine);
|
||||
lex=zero;
|
||||
for(int d=0;d<4;d++){
|
||||
LatticeInteger coor(&Fine);
|
||||
LatticeCoordinate(coor,d);
|
||||
lex = lex + coor*mm[d];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Bar = zero;
|
||||
// Bar = where(lex<Integer(10),Foo,Bar);
|
||||
|
||||
|
||||
cout << "peeking sites..\n";
|
||||
{
|
||||
std::vector<int> coor(4);
|
||||
for(coor[3]=0;coor[3]<latt_size[3]/mpi_layout[3];coor[3]++){
|
||||
for(coor[2]=0;coor[2]<latt_size[2]/mpi_layout[2];coor[2]++){
|
||||
for(coor[1]=0;coor[1]<latt_size[1]/mpi_layout[1];coor[1]++){
|
||||
for(coor[0]=0;coor[0]<latt_size[0]/mpi_layout[0];coor[0]++){
|
||||
ColourMatrix bar;
|
||||
peekSite(bar,Bar,coor);
|
||||
for(int r=0;r<3;r++){
|
||||
for(int c=0;c<3;c++){
|
||||
// cout<<"bar "<<coor[0]<<coor[1]<<coor[2]<<coor[3] <<" "<<bar()()(r,c)<<std::endl;
|
||||
}}
|
||||
}}}}
|
||||
}
|
||||
|
||||
//setCheckerboard(ShiftedCheck,rFoo);
|
||||
//setCheckerboard(ShiftedCheck,bFoo);
|
||||
|
||||
|
||||
// Lattice SU(3) x SU(3)
|
||||
Fine.Barrier();
|
||||
FooBar = Foo * Bar;
|
||||
|
||||
// Lattice 12x12 GEMM
|
||||
scFooBar = scFoo * scBar;
|
||||
|
||||
// Benchmark some simple operations LatticeSU3 * Lattice SU3.
|
||||
double t0,t1,flops;
|
||||
double bytes;
|
||||
int ncall=5000;
|
||||
int Nc = Grid::QCD::Nc;
|
||||
|
||||
LatticeGaugeField U(&Fine);
|
||||
// LatticeColourMatrix Uy = peekLorentz(U,1);
|
||||
// LatticeColourMatrix Uy = peekDumKopf(U,1);
|
||||
|
||||
flops = ncall*1.0*volume*(8*Nc*Nc*Nc);
|
||||
bytes = ncall*1.0*volume*Nc*Nc *2*3*sizeof(Grid::Real);
|
||||
if ( Fine.IsBoss() ) {
|
||||
printf("%f flop and %f bytes\n",flops,bytes/ncall);
|
||||
}
|
||||
FooBar = Foo * Bar;
|
||||
Fine.Barrier();
|
||||
t0=usecond();
|
||||
for(int i=0;i<ncall;i++){
|
||||
Fine.Barrier();
|
||||
mult(FooBar,Foo,Bar); // this is better
|
||||
}
|
||||
|
||||
t1=usecond();
|
||||
Fine.Barrier();
|
||||
if ( Fine.IsBoss() ) {
|
||||
#ifdef OMP
|
||||
printf("mult NumThread %d , Lattice size %d , %f us per call\n",omp_get_max_threads(),lat,(t1-t0)/ncall);
|
||||
#endif
|
||||
printf("mult NumThread %d , Lattice size %d , %f us per call\n",omp,lat,(t1-t0)/ncall);
|
||||
printf("mult NumThread %d , Lattice size %d , %f Mflop/s\n",omp,lat,flops/(t1-t0));
|
||||
printf("mult NumThread %d , Lattice size %d , %f MB/s\n",omp,lat,bytes/(t1-t0));
|
||||
}
|
||||
mult(FooBar,Foo,Bar);
|
||||
FooBar = Foo * Bar;
|
||||
|
||||
bytes = ncall*1.0*volume*Nc*Nc *2*5*sizeof(Grid::Real);
|
||||
Fine.Barrier();
|
||||
t0=usecond();
|
||||
for(int i=0;i<ncall;i++){
|
||||
Fine.Barrier();
|
||||
mult(FooBar,Foo,Cshift(Bar,1,-1));
|
||||
//mult(FooBar,Foo,Bar);
|
||||
//FooBar = Foo * Bar; // this is bad
|
||||
}
|
||||
t1=usecond();
|
||||
Fine.Barrier();
|
||||
|
||||
FooBar = Foo * Bar;
|
||||
|
||||
if ( Fine.IsBoss() ) {
|
||||
printf("Cshift Mult: NumThread %d , Lattice size %d , %f us per call\n",omp,lat,(t1-t0)/ncall);
|
||||
printf("Cshift Mult: NumThread %d , Lattice size %d , %f Mflop/s\n",omp,lat,flops/(t1-t0));
|
||||
printf("Cshift Mult: NumThread %d , Lattice size %d , %f MB/s\n",omp,lat,bytes/(t1-t0));
|
||||
}
|
||||
// pickCheckerboard(0,rFoo,FooBar);
|
||||
// pickCheckerboard(1,bFoo,FooBar);
|
||||
// setCheckerboard(FooBar,rFoo);
|
||||
// setCheckerboard(FooBar,bFoo);
|
||||
|
||||
double nrm=0;
|
||||
|
||||
|
||||
LatticeColourMatrix deriv(&Fine);
|
||||
double half=0.5;
|
||||
deriv = 0.5*Cshift(Foo,0,1) - 0.5*Cshift(Foo,0,-1);
|
||||
|
||||
|
||||
for(int dir=0;dir<4;dir++){
|
||||
for(int shift=0;shift<latt_size[dir];shift++){
|
||||
|
||||
pickCheckerboard(0,rFoo,Foo); // Pick out red or black checkerboards
|
||||
pickCheckerboard(1,bFoo,Foo);
|
||||
|
||||
if ( Fine.IsBoss() ) {
|
||||
std::cout<<GridLogMessage << "Shifting both parities by "<< shift <<" direction "<< dir <<std::endl;
|
||||
}
|
||||
Shifted = Cshift(Foo,dir,shift); // Shift everything
|
||||
|
||||
bShifted = Cshift(rFoo,dir,shift); // Shift red->black
|
||||
rShifted = Cshift(bFoo,dir,shift); // Shift black->red
|
||||
|
||||
ShiftedCheck=zero;
|
||||
setCheckerboard(ShiftedCheck,bShifted); // Put them all together
|
||||
setCheckerboard(ShiftedCheck,rShifted); // and check the results (later)
|
||||
|
||||
// Check results
|
||||
std::vector<int> coor(4);
|
||||
for(coor[3]=0;coor[3]<latt_size[3]/mpi_layout[3];coor[3]++){
|
||||
for(coor[2]=0;coor[2]<latt_size[2]/mpi_layout[2];coor[2]++){
|
||||
for(coor[1]=0;coor[1]<latt_size[1]/mpi_layout[1];coor[1]++){
|
||||
for(coor[0]=0;coor[0]<latt_size[0]/mpi_layout[0];coor[0]++){
|
||||
|
||||
|
||||
|
||||
std::complex<Grid::Real> diff;
|
||||
|
||||
std::vector<int> shiftcoor = coor;
|
||||
shiftcoor[dir]=(shiftcoor[dir]+shift+latt_size[dir])%(latt_size[dir]/mpi_layout[dir]);
|
||||
|
||||
std::vector<int> rl(4);
|
||||
for(int dd=0;dd<4;dd++){
|
||||
rl[dd] = latt_size[dd]/simd_layout[dd]/mpi_layout[dd];
|
||||
}
|
||||
int lex = coor[0]%rl[0]
|
||||
+ (coor[1]%rl[1])*rl[0]
|
||||
+ (coor[2]%rl[2])*rl[0]*rl[1]
|
||||
+ (coor[3]%rl[3])*rl[0]*rl[1]*rl[2];
|
||||
lex +=
|
||||
+1000*(coor[0]/rl[0])
|
||||
+1000*(coor[1]/rl[1])*simd_layout[0]
|
||||
+1000*(coor[2]/rl[2])*simd_layout[0]*simd_layout[1]
|
||||
+1000*(coor[3]/rl[3])*simd_layout[0]*simd_layout[1]*simd_layout[2];
|
||||
|
||||
int lex_coor = shiftcoor[0]%rl[0]
|
||||
+ (shiftcoor[1]%rl[1])*rl[0]
|
||||
+ (shiftcoor[2]%rl[2])*rl[0]*rl[1]
|
||||
+ (shiftcoor[3]%rl[3])*rl[0]*rl[1]*rl[2];
|
||||
lex_coor +=
|
||||
+1000*(shiftcoor[0]/rl[0])
|
||||
+1000*(shiftcoor[1]/rl[1])*simd_layout[0]
|
||||
+1000*(shiftcoor[2]/rl[2])*simd_layout[0]*simd_layout[1]
|
||||
+1000*(shiftcoor[3]/rl[3])*simd_layout[0]*simd_layout[1]*simd_layout[2];
|
||||
|
||||
ColourMatrix foo;
|
||||
ColourMatrix bar;
|
||||
ColourMatrix shifted1;
|
||||
ColourMatrix shifted2;
|
||||
ColourMatrix shifted3;
|
||||
ColourMatrix foobar1;
|
||||
ColourMatrix foobar2;
|
||||
ColourMatrix mdiff,amdiff;
|
||||
|
||||
peekSite(shifted1,Shifted,coor);
|
||||
peekSite(shifted2,Foo,shiftcoor);
|
||||
peekSite(shifted3,ShiftedCheck,coor);
|
||||
peekSite(foo,Foo,coor);
|
||||
|
||||
mdiff = shifted1-shifted2;
|
||||
amdiff=adj(mdiff);
|
||||
ColourMatrix prod = amdiff*mdiff;
|
||||
Complex trprod = trace(prod);
|
||||
Real Ttr=real(trprod);
|
||||
double nn=Ttr;
|
||||
if ( nn > 0 )
|
||||
cout<<"Shift real trace fail "<<coor[0]<<coor[1]<<coor[2]<<coor[3] <<endl;
|
||||
|
||||
|
||||
for(int r=0;r<3;r++){
|
||||
for(int c=0;c<3;c++){
|
||||
diff =shifted1()()(r,c)-shifted2()()(r,c);
|
||||
nn=real(conjugate(diff)*diff);
|
||||
if ( nn > 0 )
|
||||
cout<<"Shift fail (shifted1/shifted2-ref) "<<coor[0]<<coor[1]<<coor[2]<<coor[3] <<" "
|
||||
<<shifted1()()(r,c)<<" "<<shifted2()()(r,c)
|
||||
<< " "<< foo()()(r,c)<< " lex expect " << lex_coor << " lex "<<lex<<endl;
|
||||
else if(0)
|
||||
cout<<"Shift pass 1vs2 "<<coor[0]<<coor[1]<<coor[2]<<coor[3] <<" "
|
||||
<<shifted1()()(r,c)<<" "<<shifted2()()(r,c)
|
||||
<< " "<< foo()()(r,c)<< " lex expect " << lex_coor << " lex "<<lex<<endl;
|
||||
}}
|
||||
|
||||
for(int r=0;r<3;r++){
|
||||
for(int c=0;c<3;c++){
|
||||
diff =shifted3()()(r,c)-shifted2()()(r,c);
|
||||
nn=real(conjugate(diff)*diff);
|
||||
if ( nn > 0 )
|
||||
cout<<"Shift rb fail (shifted3/shifted2-ref) "<<coor[0]<<coor[1]<<coor[2]<<coor[3] <<" "
|
||||
<<shifted3()()(r,c)<<" "<<shifted2()()(r,c)
|
||||
<< " "<< foo()()(r,c)<< " lex expect " << lex_coor << " lex "<<lex<<endl;
|
||||
else if(0)
|
||||
cout<<"Shift rb pass 3vs2 "<<coor[0]<<coor[1]<<coor[2]<<coor[3] <<" "
|
||||
<<shifted3()()(r,c)<<" "<<shifted2()()(r,c)
|
||||
<< " "<< foo()()(r,c)<< " lex expect " << lex_coor << " lex "<<lex<<endl;
|
||||
}}
|
||||
peekSite(bar,Bar,coor);
|
||||
|
||||
peekSite(foobar1,FooBar,coor);
|
||||
foobar2 = foo*bar;
|
||||
for(int r=0;r<Nc;r++){
|
||||
for(int c=0;c<Nc;c++){
|
||||
diff =foobar2()()(r,c)-foobar1()()(r,c);
|
||||
nrm = nrm + real(conjugate(diff)*diff);
|
||||
}}
|
||||
}}}}
|
||||
if( Fine.IsBoss() ){
|
||||
std::cout<<GridLogMessage << "LatticeColorMatrix * LatticeColorMatrix nrm diff = "<<nrm<<std::endl;
|
||||
}
|
||||
}}
|
||||
|
||||
} // loop for lat
|
||||
} // loop for omp
|
||||
|
||||
|
||||
std::cout<<GridLogMessage << sizeof(vComplexF) << std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
114
tests/core/Test_quenched_update.cc
Normal file
114
tests/core/Test_quenched_update.cc
Normal file
@ -0,0 +1,114 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_quenched_update.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt({8,8,8,8});
|
||||
GridCartesian * grid = SpaceTimeGrid::makeFourDimGrid(latt,
|
||||
GridDefaultSimd(Nd,vComplex::Nsimd()),
|
||||
GridDefaultMpi());
|
||||
|
||||
GridRedBlackCartesian * rbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(grid);
|
||||
|
||||
///////////////////////////////
|
||||
// Configuration of known size
|
||||
///////////////////////////////
|
||||
LatticeGaugeField Umu(grid);
|
||||
Umu=1.0; // Cold start
|
||||
|
||||
// RNG set up for test
|
||||
std::vector<int> pseeds({1,2,3,4,5}); // once I caught a fish alive
|
||||
std::vector<int> sseeds({6,7,8,9,10});// then i let it go again
|
||||
GridParallelRNG pRNG(grid); pRNG.SeedFixedIntegers(pseeds);
|
||||
GridSerialRNG sRNG; sRNG.SeedFixedIntegers(sseeds);
|
||||
|
||||
// SU3 colour operatoions
|
||||
LatticeColourMatrix link(grid);
|
||||
LatticeColourMatrix staple(grid);
|
||||
int mu=0;
|
||||
|
||||
// Apply heatbath to the link
|
||||
RealD beta=6.0;
|
||||
|
||||
int subsets[2] = { Even, Odd};
|
||||
LatticeInteger one(rbGrid); one = 1; // fill with ones
|
||||
LatticeInteger mask(grid);
|
||||
|
||||
for(int sweep=0;sweep<1000;sweep++){
|
||||
|
||||
RealD plaq = ColourWilsonLoops::avgPlaquette(Umu);
|
||||
|
||||
std::cout<<GridLogMessage<<"sweep "<<sweep<<" PLAQUETTE "<<plaq<<std::endl;
|
||||
|
||||
for( int cb=0;cb<2;cb++ ) {
|
||||
|
||||
one.checkerboard=subsets[cb];
|
||||
mask= zero;
|
||||
setCheckerboard(mask,one);
|
||||
|
||||
// std::cout<<GridLogMessage<<mask<<std::endl;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
// Get Link and Staple term in action; must contain Beta and
|
||||
// any other coeffs
|
||||
ColourWilsonLoops::Staple(staple,Umu,mu);
|
||||
|
||||
link = PeekIndex<LorentzIndex>(Umu,mu);
|
||||
|
||||
for( int subgroup=0;subgroup<SU3::su2subgroups();subgroup++ ) {
|
||||
|
||||
// update Even checkerboard
|
||||
SU3::SubGroupHeatBath(sRNG,pRNG,beta,link,staple,subgroup,20,mask);
|
||||
|
||||
}
|
||||
|
||||
PokeIndex<LorentzIndex>(Umu,link,mu);
|
||||
|
||||
//reunitarise link;
|
||||
ProjectOnGroup(Umu);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
77
tests/core/Test_rng.cc
Normal file
77
tests/core/Test_rng.cc
Normal file
@ -0,0 +1,77 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_rng.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridSerialRNG sRNG; sRNG.SeedRandomDevice();
|
||||
GridSerialRNG fsRNG; fsRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
GridParallelRNG pRNG(&Grid); pRNG.SeedRandomDevice();
|
||||
GridParallelRNG fpRNG(&Grid); fpRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
SpinMatrix rnd ;
|
||||
random(sRNG,rnd);
|
||||
std::cout<<GridLogMessage<<"Random Spin Matrix (random_device)\n"<< rnd<<std::endl;
|
||||
|
||||
random(fsRNG,rnd);
|
||||
std::cout<<GridLogMessage<<"Random Spin Matrix (fixed seed)\n"<< rnd<<std::endl;
|
||||
|
||||
SpinVector rv;
|
||||
random(sRNG,rv);
|
||||
std::cout<<GridLogMessage<<"Random Spin Vector (random device)\n"<< rv<<std::endl;
|
||||
|
||||
random(fsRNG,rv);
|
||||
std::cout<<GridLogMessage<<"Random Spin Vector (fixed seed)\n"<< rv<<std::endl;
|
||||
|
||||
gaussian(fsRNG,rv);
|
||||
std::cout<<GridLogMessage<<"Gaussian Spin Vector (fixed seed)\n"<< rv<<std::endl;
|
||||
|
||||
LatticeColourVector lcv(&Grid);
|
||||
random(pRNG,lcv);
|
||||
std::cout<<GridLogMessage<<"Random Lattice Colour Vector (random device)\n"<< lcv<<std::endl;
|
||||
|
||||
random(fpRNG,lcv);
|
||||
std::cout<<GridLogMessage<<"Random Lattice Colour Vector (fixed seed)\n"<< lcv<<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
78
tests/core/Test_rng_fixed.cc
Normal file
78
tests/core/Test_rng_fixed.cc
Normal file
@ -0,0 +1,78 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_rng_fixed.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(4,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridSerialRNG fsRNG; fsRNG.SeedFixedIntegers(seeds);
|
||||
GridParallelRNG fpRNG(&Grid); fpRNG.SeedFixedIntegers(seeds);
|
||||
|
||||
vComplexF tmp; random(fsRNG,tmp);
|
||||
std::cout<<GridLogMessage<<"Random vComplexF (fixed seed)\n"<< tmp<<std::endl;
|
||||
std::cout<<GridLogMessage<<"conjugate(tmp)\n"<< conjugate(tmp)<<std::endl;
|
||||
std::cout<<GridLogMessage<<"conjugate(tmp)*tmp\n"<< conjugate(tmp)*tmp<<std::endl;
|
||||
std::cout<<GridLogMessage<<"innerProduct"<< innerProduct(tmp,tmp)<<std::endl;
|
||||
std::cout<<GridLogMessage<<"Reduce(innerProduct)"<< Reduce(innerProduct(tmp,tmp))<<std::endl;
|
||||
|
||||
SpinMatrix rnd ;
|
||||
random(fsRNG,rnd);
|
||||
std::cout<<GridLogMessage<<"Random Spin Matrix (fixed seed)\n"<< rnd<<std::endl;
|
||||
|
||||
SpinVector rv;
|
||||
random(fsRNG,rv);
|
||||
std::cout<<GridLogMessage<<"Random Spin Vector (fixed seed)\n"<< rv<<std::endl;
|
||||
|
||||
gaussian(fsRNG,rv);
|
||||
std::cout<<GridLogMessage<<"Gaussian Spin Vector (fixed seed)\n"<< rv<<std::endl;
|
||||
|
||||
LatticeColourVector lcv(&Grid);
|
||||
|
||||
LatticeFermion src(&Grid); random(fpRNG,src);
|
||||
std::cout<<GridLogMessage << "src norm : " << norm2(src)<<std::endl;
|
||||
std::cout<<GridLogMessage << "src " << src<<std::endl;
|
||||
|
||||
random(fpRNG,lcv);
|
||||
std::cout<<GridLogMessage<<"Random Lattice Colour Vector (fixed seed)\n"<< lcv<<std::endl;
|
||||
|
||||
|
||||
Grid_finalize();
|
||||
}
|
229
tests/core/Test_wilson_even_odd.cc
Normal file
229
tests/core/Test_wilson_even_odd.cc
Normal file
@ -0,0 +1,229 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_even_odd.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::GammaMatrix Gmu [] = {
|
||||
Gamma::GammaX,
|
||||
Gamma::GammaY,
|
||||
Gamma::GammaZ,
|
||||
Gamma::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> 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<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
// std::vector<int> seeds({1,2,3,4});
|
||||
// pRNG.SeedFixedIntegers(seeds);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeFermion src (&Grid); random(pRNG,src);
|
||||
LatticeFermion phi (&Grid); random(pRNG,phi);
|
||||
LatticeFermion chi (&Grid); random(pRNG,chi);
|
||||
LatticeFermion result(&Grid); result=zero;
|
||||
LatticeFermion ref(&Grid); ref=zero;
|
||||
LatticeFermion tmp(&Grid); tmp=zero;
|
||||
LatticeFermion err(&Grid); tmp=zero;
|
||||
LatticeGaugeField Umu(&Grid); random(pRNG,Umu);
|
||||
std::vector<LatticeColourMatrix> U(4,&Grid);
|
||||
|
||||
double volume=1;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
volume=volume*latt_size[mu];
|
||||
}
|
||||
|
||||
// Only one non-zero (y)
|
||||
Umu=zero;
|
||||
for(int nn=0;nn<Nd;nn++){
|
||||
random(pRNG,U[nn]);
|
||||
std::cout<<GridLogMessage<<"U[nn]"<<norm2(U[nn])<<std::endl;
|
||||
PokeIndex<LorentzIndex>(Umu,U[nn],nn);
|
||||
std::cout<<GridLogMessage<<"Umu"<<norm2(Umu)<<std::endl;
|
||||
}
|
||||
|
||||
RealD mass=0.1;
|
||||
RealD mu = 0.1;
|
||||
WilsonTMFermionR Dw(Umu,Grid,RBGrid,mass,mu);
|
||||
|
||||
LatticeFermion src_e (&RBGrid);
|
||||
LatticeFermion src_o (&RBGrid);
|
||||
LatticeFermion r_e (&RBGrid);
|
||||
LatticeFermion r_o (&RBGrid);
|
||||
LatticeFermion r_eo (&Grid);
|
||||
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Testing that Deo + Doe = Dunprec "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,src_e,src);
|
||||
pickCheckerboard(Odd,src_o,src);
|
||||
|
||||
Dw.Meooe(src_e,r_o); std::cout<<GridLogMessage<<"Applied Meo"<<std::endl;
|
||||
Dw.Meooe(src_o,r_e); std::cout<<GridLogMessage<<"Applied Moe"<<std::endl;
|
||||
Dw.Dhop (src,ref,DaggerNo);
|
||||
|
||||
setCheckerboard(r_eo,r_o);
|
||||
setCheckerboard(r_eo,r_e);
|
||||
|
||||
err= ref - r_eo;
|
||||
std::cout<<GridLogMessage << "EO norm diff "<< norm2(err)<< " "<<norm2(ref)<< " " << norm2(r_eo) <<std::endl;
|
||||
|
||||
LatticeComplex cerr(&Grid);
|
||||
cerr = localInnerProduct(err,err);
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test Ddagger is the dagger of D by requiring "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= < phi | Deo | chi > * = < chi | Deo^dag| phi> "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
LatticeFermion chi_e (&RBGrid);
|
||||
LatticeFermion chi_o (&RBGrid);
|
||||
|
||||
LatticeFermion dchi_e (&RBGrid);
|
||||
LatticeFermion dchi_o (&RBGrid);
|
||||
|
||||
LatticeFermion phi_e (&RBGrid);
|
||||
LatticeFermion phi_o (&RBGrid);
|
||||
|
||||
LatticeFermion dphi_e (&RBGrid);
|
||||
LatticeFermion dphi_o (&RBGrid);
|
||||
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
|
||||
Dw.Meooe(chi_e,dchi_o);
|
||||
Dw.Meooe(chi_o,dchi_e);
|
||||
Dw.MeooeDag(phi_e,dphi_o);
|
||||
Dw.MeooeDag(phi_o,dphi_e);
|
||||
|
||||
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);
|
||||
|
||||
std::cout<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDce-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDco-conj(cDpe) <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInv Mee = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Dw.Mooee(chi_e,src_e);
|
||||
Dw.MooeeInv(src_e,phi_e);
|
||||
|
||||
Dw.Mooee(chi_o,src_o);
|
||||
Dw.MooeeInv(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInvDag MeeDag = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Dw.MooeeDag(chi_e,src_e);
|
||||
Dw.MooeeInvDag(src_e,phi_e);
|
||||
|
||||
Dw.MooeeDag(chi_o,src_o);
|
||||
Dw.MooeeInvDag(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MpcDagMpc is Hermitian "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
random(pRNG,phi);
|
||||
random(pRNG,chi);
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
RealD t1,t2;
|
||||
|
||||
SchurDiagMooeeOperator<WilsonTMFermionR,LatticeFermion> HermOpEO(Dw);
|
||||
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<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDco-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDce-conj(cDpe) <<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
228
tests/core/Test_wilson_tm_even_odd.cc
Normal file
228
tests/core/Test_wilson_tm_even_odd.cc
Normal file
@ -0,0 +1,228 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_tm_even_odd.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
|
||||
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>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
template<class d>
|
||||
struct scal {
|
||||
d internal;
|
||||
};
|
||||
|
||||
Gamma::GammaMatrix Gmu [] = {
|
||||
Gamma::GammaX,
|
||||
Gamma::GammaY,
|
||||
Gamma::GammaZ,
|
||||
Gamma::GammaT
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> 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<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
// std::vector<int> seeds({1,2,3,4});
|
||||
// pRNG.SeedFixedIntegers(seeds);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeFermion src (&Grid); random(pRNG,src);
|
||||
LatticeFermion phi (&Grid); random(pRNG,phi);
|
||||
LatticeFermion chi (&Grid); random(pRNG,chi);
|
||||
LatticeFermion result(&Grid); result=zero;
|
||||
LatticeFermion ref(&Grid); ref=zero;
|
||||
LatticeFermion tmp(&Grid); tmp=zero;
|
||||
LatticeFermion err(&Grid); tmp=zero;
|
||||
LatticeGaugeField Umu(&Grid); random(pRNG,Umu);
|
||||
std::vector<LatticeColourMatrix> U(4,&Grid);
|
||||
|
||||
double volume=1;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
volume=volume*latt_size[mu];
|
||||
}
|
||||
|
||||
// Only one non-zero (y)
|
||||
Umu=zero;
|
||||
for(int nn=0;nn<Nd;nn++){
|
||||
random(pRNG,U[nn]);
|
||||
std::cout<<GridLogMessage<<"U[nn]"<<norm2(U[nn])<<std::endl;
|
||||
PokeIndex<LorentzIndex>(Umu,U[nn],nn);
|
||||
std::cout<<GridLogMessage<<"Umu"<<norm2(Umu)<<std::endl;
|
||||
}
|
||||
|
||||
RealD mass=0.1;
|
||||
|
||||
WilsonFermionR Dw(Umu,Grid,RBGrid,mass);
|
||||
|
||||
LatticeFermion src_e (&RBGrid);
|
||||
LatticeFermion src_o (&RBGrid);
|
||||
LatticeFermion r_e (&RBGrid);
|
||||
LatticeFermion r_o (&RBGrid);
|
||||
LatticeFermion r_eo (&Grid);
|
||||
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Testing that Deo + Doe = Dunprec "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=========================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,src_e,src);
|
||||
pickCheckerboard(Odd,src_o,src);
|
||||
|
||||
Dw.Meooe(src_e,r_o); std::cout<<GridLogMessage<<"Applied Meo"<<std::endl;
|
||||
Dw.Meooe(src_o,r_e); std::cout<<GridLogMessage<<"Applied Moe"<<std::endl;
|
||||
Dw.Dhop (src,ref,DaggerNo);
|
||||
|
||||
setCheckerboard(r_eo,r_o);
|
||||
setCheckerboard(r_eo,r_e);
|
||||
|
||||
err= ref - r_eo;
|
||||
std::cout<<GridLogMessage << "EO norm diff "<< norm2(err)<< " "<<norm2(ref)<< " " << norm2(r_eo) <<std::endl;
|
||||
|
||||
LatticeComplex cerr(&Grid);
|
||||
cerr = localInnerProduct(err,err);
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test Ddagger is the dagger of D by requiring "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= < phi | Deo | chi > * = < chi | Deo^dag| phi> "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
LatticeFermion chi_e (&RBGrid);
|
||||
LatticeFermion chi_o (&RBGrid);
|
||||
|
||||
LatticeFermion dchi_e (&RBGrid);
|
||||
LatticeFermion dchi_o (&RBGrid);
|
||||
|
||||
LatticeFermion phi_e (&RBGrid);
|
||||
LatticeFermion phi_o (&RBGrid);
|
||||
|
||||
LatticeFermion dphi_e (&RBGrid);
|
||||
LatticeFermion dphi_o (&RBGrid);
|
||||
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
|
||||
Dw.Meooe(chi_e,dchi_o);
|
||||
Dw.Meooe(chi_o,dchi_e);
|
||||
Dw.MeooeDag(phi_e,dphi_o);
|
||||
Dw.MeooeDag(phi_o,dphi_e);
|
||||
|
||||
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);
|
||||
|
||||
std::cout<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDce-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDco-conj(cDpe) <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInv Mee = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Dw.Mooee(chi_e,src_e);
|
||||
Dw.MooeeInv(src_e,phi_e);
|
||||
|
||||
Dw.Mooee(chi_o,src_o);
|
||||
Dw.MooeeInv(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MeeInvDag MeeDag = 1 "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
|
||||
Dw.MooeeDag(chi_e,src_e);
|
||||
Dw.MooeeInvDag(src_e,phi_e);
|
||||
|
||||
Dw.MooeeDag(chi_o,src_o);
|
||||
Dw.MooeeInvDag(src_o,phi_o);
|
||||
|
||||
setCheckerboard(phi,phi_e);
|
||||
setCheckerboard(phi,phi_o);
|
||||
|
||||
err = phi-chi;
|
||||
std::cout<<GridLogMessage << "norm diff "<< norm2(err)<< std::endl;
|
||||
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
std::cout<<GridLogMessage<<"= Test MpcDagMpc is Hermitian "<<std::endl;
|
||||
std::cout<<GridLogMessage<<"=============================================================="<<std::endl;
|
||||
|
||||
random(pRNG,phi);
|
||||
random(pRNG,chi);
|
||||
pickCheckerboard(Even,chi_e,chi);
|
||||
pickCheckerboard(Odd ,chi_o,chi);
|
||||
pickCheckerboard(Even,phi_e,phi);
|
||||
pickCheckerboard(Odd ,phi_o,phi);
|
||||
RealD t1,t2;
|
||||
|
||||
SchurDiagMooeeOperator<WilsonFermionR,LatticeFermion> HermOpEO(Dw);
|
||||
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<<GridLogMessage <<"e "<<pDce<<" "<<cDpe <<std::endl;
|
||||
std::cout<<GridLogMessage <<"o "<<pDco<<" "<<cDpo <<std::endl;
|
||||
|
||||
std::cout<<GridLogMessage <<"pDce - conj(cDpo) "<< pDco-conj(cDpo) <<std::endl;
|
||||
std::cout<<GridLogMessage <<"pDco - conj(cDpe) "<< pDce-conj(cDpe) <<std::endl;
|
||||
|
||||
Grid_finalize();
|
||||
}
|
Reference in New Issue
Block a user