/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/qdpxx/Test_qdpxx_loops_staples.cc Copyright (C) 2015 Author: Azusa Yamaguchi 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 double calc_grid_p (Grid::QCD::LatticeGaugeField & lat); double calc_chroma_p (Grid::QCD::LatticeGaugeField & lat); double calc_grid_r (Grid::QCD::LatticeGaugeField & lat); double calc_grid_IW (Grid::QCD::LatticeGaugeField & lat); double calc_grid_r_dir (Grid::QCD::LatticeGaugeField & lat); double calc_chroma_r (Grid::QCD::LatticeGaugeField & lat); double calc_chroma_IW (Grid::QCD::LatticeGaugeField & lat); void check_grid_r_staple(Grid::QCD::LatticeGaugeField & Umu); void check_grid_p_staple(Grid::QCD::LatticeGaugeField & Umu); const double beta=2.6; const double c1=-0.331; #include #include #include namespace Chroma { class ChromaWrapper { public: typedef multi1d U; static void ImportGauge(Grid::QCD::LatticeGaugeField & gr, QDP::multi1d & ch) { Grid::QCD::LorentzColourMatrix LCM; Grid::Complex cc; QDP::ColorMatrix cm; QDP::Complex c; std::vector x(4); QDP::multi1d cx(4); std::vector gd= gr.Grid()->GlobalDimensions(); for (x[0]=0;x[0] GetRBCAction ( U &u ) { Chroma::CreatePeriodicGaugeState CPGS; Chroma::Handle< Chroma::CreateGaugeState > cgs (new Chroma::CreatePeriodicGaugeState); Chroma::Handle< Chroma::LinearGaugeAction> action = new Chroma::RBCGaugeAct(cgs,beta,c1); return action; } static Chroma::Handle< Chroma::LinearGaugeAction > GetRectangle ( U &u ) { Chroma::CreatePeriodicGaugeState CPGS; Chroma::Handle< Chroma::CreateGaugeState > cgs (new Chroma::CreatePeriodicGaugeState); Chroma::Handle< Chroma::LinearGaugeAction> action = new Chroma::RectGaugeAct(cgs, Real(c1)); return action; } static Chroma::Handle< Chroma::LinearGaugeAction > GetPlaquette ( U &u ) { Chroma::CreatePeriodicGaugeState CPGS; Chroma::Handle< Chroma::CreateGaugeState > cgs (new Chroma::CreatePeriodicGaugeState); Chroma::Handle< Chroma::LinearGaugeAction> action = new Chroma::WilsonGaugeAct(cgs, Real(beta)); return action; } }; } int main (int argc,char **argv ) { /******************************************************** * Setup QDP *********************************************************/ Chroma::initialize(&argc,&argv); Chroma::WilsonTypeFermActs4DEnv::registerAll(); /******************************************************** * Setup Grid *********************************************************/ Grid::Grid_init(&argc,&argv); Grid::GridCartesian * UGrid = Grid::QCD::SpaceTimeGrid::makeFourDimGrid(Grid::GridDefaultLatt(), Grid::GridDefaultSimd(Grid::QCD::Nd,Grid::vComplex::Nsimd()), Grid::GridDefaultMpi()); std::vector gd = UGrid->GlobalDimensions(); QDP::multi1d nrow(QDP::Nd); for(int mu=0;mu<4;mu++) nrow[mu] = gd[mu]; QDP::Layout::setLattSize(nrow); QDP::Layout::create(); Grid::QCD::LatticeGaugeField lat(UGrid); double s_grid = calc_grid_p (lat); double s_chroma = calc_chroma_p(lat); // Match conventions double vol = UGrid->gSites(); s_chroma+= beta * QDP::Nd * (QDP::Nd-1)*vol *0.5; std::cout << " Chroma/Grid plaquette = " < U; QDP::multi1d u(4); Chroma::ChromaWrapper::ImportGauge(lat,u) ; for(int mu=0;mu<4;mu++){ std::cout <<"Imported Gauge norm ["< > gs(action->getCreateState()(u)); Real act = action->S(gs); double s = toDouble(act); return s; } double calc_chroma_r(Grid::QCD::LatticeGaugeField & lat) { typedef QDP::multi1d U; QDP::multi1d u(4); Chroma::ChromaWrapper::ImportGauge(lat,u) ; for(int mu=0;mu<4;mu++){ std::cout <<"Imported Gauge norm ["< > gs(action->getCreateState()(u)); Real act = action->S(gs); double s = toDouble(act); return s; } // Conventions matching: // // Chroma: // // w_plaq is defined in MesPlq as // w_plaq =( 2/(V*Nd*(Nd-1)*Nc)) * Sum Re Tr Plaq // // S = -(coeff/(Nc) Sum Re Tr Plaq // // S = -coeff * (V*Nd*(Nd-1)/2) w_plaq // = -coeff * (V*Nd*(Nd-1)/2)*(2/(V*Nd*(Nd-1)*Nc))* Sum Re Tr Plaq // = -coeff * (1/(Nc)) * Sum Re Tr Plaq // // Grid: has 1-plaq as usual to define Fmunu // // action = beta*(1.0 -plaq)*(Nd*(Nd-1.0))*vol*0.5; // action = beta * Nd*Nd-1*vol*0.5 - beta * Nd*Nd-1*vol*0.5*plaq // // plaq == sumplaq * 2/(V*Nd*(Nd-1)*Nc) double calc_chroma_p(Grid::QCD::LatticeGaugeField & lat) { typedef QDP::multi1d U; QDP::multi1d u(4); Chroma::ChromaWrapper::ImportGauge(lat,u) ; for(int mu=0;mu<4;mu++){ std::cout <<"Imported Gauge norm ["< > gs(action->getCreateState()(u)); Real act = action->S(gs); double s = toDouble(act); return s; } double calc_grid_p(Grid::QCD::LatticeGaugeField & Umu) { std::vector seeds4({1,2,3,4}); Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); Grid::QCD::SU3::HotConfiguration(RNG4,Umu); Grid::QCD::LatticeColourMatrix tmp(UGrid); tmp = Grid::zero; Grid::QCD::PokeIndex(Umu,tmp,2); Grid::QCD::PokeIndex(Umu,tmp,3); Grid::QCD::WilsonGaugeActionR Wilson(beta); // Just take beta = 1.0 return Wilson.S(Umu); } double calc_grid_r(Grid::QCD::LatticeGaugeField & Umu) { Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::QCD::PlaqPlusRectangleActionR Wilson(0.0,c1); // Just take beta = 0.0 return Wilson.S(Umu); } double calc_grid_IW(Grid::QCD::LatticeGaugeField & Umu) { Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::QCD::IwasakiGaugeActionR Iwasaki(beta); return Iwasaki.S(Umu); } double calc_grid_r_dir(Grid::QCD::LatticeGaugeField & Umu) { Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); std::vector U(4,UGrid); for(int mu=0;mu(Umu,mu); } Grid::QCD::LatticeComplex rect(UGrid); Grid::QCD::TComplex trect; Grid::QCD::Complex crect; Grid::RealD rrect; Grid::RealD vol = UGrid->gSites(); for(int mu=0;mu seeds4({1,2,3,4}); Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::QCD::PlaqPlusRectangleActionR Wilson(0.0,c1); // Just take beta = 0.0 Grid::QCD::LatticeColourMatrix staple(UGrid); Grid::QCD::LatticeColourMatrix link(UGrid); Grid::QCD::LatticeComplex Traced(UGrid); Grid::Complex Rplaq(0.0); for(int mu=0;mugSites(); // for mu, nu!=mu => 12 // 6 loops contribute to staple for each orientation. // Nc=3. // Vol as for each site Grid::RealD RectScale(1.0/vol/12.0/6.0/3.0); Grid::QCD::ColourWilsonLoops::RectStaple(staple,Umu,mu); link = Grid::QCD::PeekIndex(Umu,mu); Traced = Grid::trace( link*staple) * RectScale; Grid::QCD::TComplex Tp = Grid::sum(Traced); Grid::Complex p = Grid::TensorRemove(Tp); std::cout<< "Rect from RectStaple "< seeds4({1,2,3,4}); Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::QCD::PlaqPlusRectangleActionR Wilson(1.0,0.0); // Just take c1 = 0.0 Grid::QCD::LatticeColourMatrix staple(UGrid); Grid::QCD::LatticeColourMatrix link(UGrid); Grid::QCD::LatticeComplex Traced(UGrid); Grid::Complex plaq(0.0); for(int mu=0;mugSites(); // for mu, nu!=mu => 12 // 2 loops contribute to staple for each orientation. // Nc=3. // Vol as for each site Grid::RealD Scale(1.0/vol/12.0/2.0/3.0); Grid::QCD::ColourWilsonLoops::Staple(staple,Umu,mu); link = Grid::QCD::PeekIndex(Umu,mu); Traced = Grid::trace( link*staple) * Scale; Grid::QCD::TComplex Tp = Grid::sum(Traced); Grid::Complex p = Grid::TensorRemove(Tp); std::cout<< "Plaq from PlaqStaple "<