/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/lexLattice/Test_RectPlaq_lex.cc Copyright (C) 2026 Author: Peter Boyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ // // Plaquette and 2x1 rectangle built from covariant shifts, checked against // WilsonLoops, plus link trace and a blockSum coarsening. // // The measurement is written once against a gauge implementation and run in // both the vectorised and the lexicographic chart; every number must agree. // The configuration crosses layouts through NERSC IO, whose reader verifies // the header written by the other chart. // #include using namespace Grid; const RealD tol = 1.0e-10; template struct Measurements { RealD plaq_shift; RealD plaq_loops; RealD plaq_staple; RealD rect_shift; RealD rect_loops; RealD link; RealD coarse_plaq; }; template void Measure(typename Gimpl::Field &Umu,GridBase *coarse,Measurements &m) { typedef typename Gimpl::LinkField LinkField; typedef typename Gimpl::ComplexField ComplexField; typedef WilsonLoops WL; GridBase *grid = Umu.Grid(); RealD vol = grid->gSites(); std::vector U(Nd,grid); for(int mu=0;mu(Umu,mu); } /////////////////////////////////////////////////// // Link trace /////////////////////////////////////////////////// ComplexField LinkTrace(grid); LinkTrace = Zero(); for(int mu=0;mu void Report(std::string name,Measurements &m) { std::cout << GridLogMessage << name << ": plaquette shifts " << m.plaq_shift << " loops " << m.plaq_loops << " staples " << m.plaq_staple << std::endl; std::cout << GridLogMessage << name << ": rectangle shifts " << m.rect_shift << " loops " << m.rect_loops << std::endl; std::cout << GridLogMessage << name << ": link trace " << m.link << " coarsened plaquette " << m.coarse_plaq << std::endl; } template void SelfConsistent(Measurements &m) { GRID_ASSERT( fabs(m.plaq_shift - m.plaq_loops) < 1.0e-8 ); GRID_ASSERT( fabs(m.plaq_staple - m.plaq_loops) < 1.0e-8 ); GRID_ASSERT( fabs(m.rect_shift - m.rect_loops) < 1.0e-8 ); GRID_ASSERT( fabs(m.coarse_plaq - m.plaq_shift) < 1.0e-8 ); } int main (int argc, char ** argv) { Grid_init(&argc,&argv); Coordinate latt = GridDefaultLatt(); Coordinate vsimd = GridDefaultSimd(Nd,vComplexD::Nsimd()); Coordinate lsimd({1,1,1,1}); Coordinate mpi = GridDefaultMpi(); Coordinate clatt(Nd); for(int d=0;d vm; Measurements lm; Measure (Umu ,&vCoarse,vm); Measure(Ulex,&lCoarse,lm); Report("simd",vm); Report("lex ",lm); SelfConsistent(vm); SelfConsistent(lm); GRID_ASSERT( fabs(vm.plaq_shift - lm.plaq_shift ) < tol ); GRID_ASSERT( fabs(vm.plaq_loops - lm.plaq_loops ) < tol ); GRID_ASSERT( fabs(vm.plaq_staple - lm.plaq_staple) < tol ); GRID_ASSERT( fabs(vm.rect_shift - lm.rect_shift ) < tol ); GRID_ASSERT( fabs(vm.rect_loops - lm.rect_loops ) < tol ); GRID_ASSERT( fabs(vm.link - lm.link ) < tol ); GRID_ASSERT( fabs(vm.coarse_plaq - lm.coarse_plaq) < tol ); std::cout << GridLogMessage << "Test_RectPlaq_lex: ALL PASS" << std::endl; Grid_finalize(); }