/************************************************************************************* 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::LatticeGaugeField & lat); double calc_chroma_p (Grid::LatticeGaugeField & lat); double calc_grid_r (Grid::LatticeGaugeField & lat); double calc_grid_IW (Grid::LatticeGaugeField & lat); double calc_grid_r_dir (Grid::LatticeGaugeField & lat); double calc_chroma_r (Grid::LatticeGaugeField & lat); double calc_chroma_IW (Grid::LatticeGaugeField & lat); void check_grid_r_staple(Grid::LatticeGaugeField & Umu); void check_grid_p_staple(Grid::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::LatticeGaugeField & gr, QDP::multi1d & ch) { Grid::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::SpaceTimeGrid::makeFourDimGrid(Grid::GridDefaultLatt(), Grid::GridDefaultSimd(Grid::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::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::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::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::LatticeGaugeField & Umu) { std::vector seeds4({1,2,3,4}); Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); Grid::SU3::HotConfiguration(RNG4,Umu); Grid::LatticeColourMatrix tmp(UGrid); tmp = Grid::zero; Grid::PokeIndex(Umu,tmp,2); Grid::PokeIndex(Umu,tmp,3); Grid::WilsonGaugeActionR Wilson(beta); // Just take beta = 1.0 return Wilson.S(Umu); } double calc_grid_r(Grid::LatticeGaugeField & Umu) { Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::PlaqPlusRectangleActionR Wilson(0.0,c1); // Just take beta = 0.0 return Wilson.S(Umu); } double calc_grid_IW(Grid::LatticeGaugeField & Umu) { Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); Grid::IwasakiGaugeActionR Iwasaki(beta); return Iwasaki.S(Umu); } double calc_grid_r_dir(Grid::LatticeGaugeField & Umu) { Grid::GridCartesian * UGrid = (Grid::GridCartesian *) Umu.Grid(); std::vector U(4,UGrid); for(int mu=0;mu(Umu,mu); } Grid::LatticeComplex rect(UGrid); Grid::TComplex trect; Grid::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::PlaqPlusRectangleActionR Wilson(0.0,c1); // Just take beta = 0.0 Grid::LatticeColourMatrix staple(UGrid); Grid::LatticeColourMatrix link(UGrid); Grid::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::ColourWilsonLoops::RectStaple(staple,Umu,mu); link = Grid::PeekIndex(Umu,mu); Traced = Grid::trace( link*staple) * RectScale; Grid::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::PlaqPlusRectangleActionR Wilson(1.0,0.0); // Just take c1 = 0.0 Grid::LatticeColourMatrix staple(UGrid); Grid::LatticeColourMatrix link(UGrid); Grid::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::ColourWilsonLoops::Staple(staple,Umu,mu); link = Grid::PeekIndex(Umu,mu); Traced = Grid::trace( link*staple) * Scale; Grid::TComplex Tp = Grid::sum(Traced); Grid::Complex p = Grid::TensorRemove(Tp); std::cout<< "Plaq from PlaqStaple "<