/************************************************************************************* grid` physics library, www.github.com/paboyle/Grid Copyright (C) 2015 Author: Azusa Yamaguchi Author: Peter Boyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ //#include #ifndef GRID_QCD_GAUGE_FIX_H #define GRID_QCD_GAUGE_FIX_H NAMESPACE_BEGIN(Grid); template class FourierAcceleratedGaugeFixer : public Gimpl { public: INHERIT_GIMPL_TYPES(Gimpl); typedef typename Gimpl::GaugeLinkField GaugeMat; typedef typename Gimpl::GaugeField GaugeLorentz; static void GaugeLinkToLieAlgebraField(const std::vector &U,std::vector &A) { for(int mu=0;mu &A,GaugeMat &dmuAmu,int orthog) { dmuAmu=Zero(); for(int mu=0;mu::avgPlaquette(Umu); Real org_link_trace=WilsonLoops::linkTrace(Umu); Real old_trace = org_link_trace; Real trG; xform=1.0; std::vector U(Nd,grid); GaugeMat dmuAmu(grid); { Real plaq =WilsonLoops::avgPlaquette(Umu); Real link_trace=WilsonLoops::linkTrace(Umu); if( (orthog>=0) && (orthog(Umu,U[mu],mu); // Monitor progress and convergence test // infrequently to minimise cost overhead if ( i %20 == 0 ) { Real plaq =WilsonLoops::avgPlaquette(Umu); Real link_trace=WilsonLoops::linkTrace(Umu); if (Fourier) std::cout << GridLogMessage << "Fourier Iteration "< &U,GaugeMat &xform,Real & alpha, GaugeMat & dmuAmu,int orthog) { GridBase *grid = U[0].Grid(); std::vector A(Nd,grid); GaugeMat g(grid); GaugeLinkToLieAlgebraField(U,A); ExpiAlphaDmuAmu(A,g,alpha,dmuAmu,orthog); Real vol = grid->gSites(); Real trG = TensorRemove(sum(trace(g))).real()/vol/Nc; xform = g*xform ; SU::GaugeTransform(U,g); return trG; } static Real FourierAccelSteepestDescentStep(std::vector &U,GaugeMat &xform,Real & alpha, GaugeMat & dmuAmu,int orthog) { GridBase *grid = U[0].Grid(); Real vol = grid->gSites(); FFT theFFT((GridCartesian *)grid); LatticeComplex Fp(grid); LatticeComplex psq(grid); psq=Zero(); LatticeComplex pmu(grid); LatticeComplex one(grid); one = Complex(1.0,0.0); GaugeMat g(grid); GaugeMat dmuAmu_p(grid); std::vector A(Nd,grid); GaugeLinkToLieAlgebraField(U,A); DmuAmu(A,dmuAmu,orthog); std::vector mask(Nd,1); for(int mu=0;muGlobalDimensions(); Coordinate coor(grid->_ndimension,0); for(int mu=0;mu=0) && (orthogGlobalDimensions()[orthog];t++){ coor[orthog]=t; pokeSite(TComplex(16.0),Fp,coor); } } dmuAmu_p = dmuAmu_p * Fp; theFFT.FFT_dim_mask(dmuAmu,dmuAmu_p,mask,FFT::backward); GaugeMat ciadmam(grid); Complex cialpha(0.0,-alpha); ciadmam = dmuAmu*cialpha; SU::taExp(ciadmam,g); Real trG = TensorRemove(sum(trace(g))).real()/vol/Nc; xform = g*xform ; SU::GaugeTransform(U,g); return trG; } static void ExpiAlphaDmuAmu(const std::vector &A,GaugeMat &g,Real & alpha, GaugeMat &dmuAmu,int orthog) { GridBase *grid = g.Grid(); Complex cialpha(0.0,-alpha); GaugeMat ciadmam(grid); DmuAmu(A,dmuAmu,orthog); ciadmam = dmuAmu*cialpha; SU::taExp(ciadmam,g); } }; NAMESPACE_END(Grid); #endif