From 2bc4d0a20ec038786f6544783b368fed3bbfb804 Mon Sep 17 00:00:00 2001 From: Azusa Yamaguchi Date: Thu, 8 Jun 2017 22:21:25 +0100 Subject: [PATCH] Move code into utils --- tests/core/Test_fft_gfix.cc | 242 ++++-------------------------------- 1 file changed, 26 insertions(+), 216 deletions(-) diff --git a/tests/core/Test_fft_gfix.cc b/tests/core/Test_fft_gfix.cc index 7938241e..9732eb85 100644 --- a/tests/core/Test_fft_gfix.cc +++ b/tests/core/Test_fft_gfix.cc @@ -28,212 +28,6 @@ Author: Peter Boyle /* END LEGAL */ #include -using namespace Grid; -using namespace Grid::QCD; - -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) { - dmuAmu=zero; - for(int mu=0;mu::avgPlaquette(Umu); - Real org_link_trace=WilsonLoops::linkTrace(Umu); - Real old_trace = org_link_trace; - Real trG; - - std::vector U(Nd,grid); - GaugeMat dmuAmu(grid); - - for(int i=0;i(Umu,mu); - //trG = SteepestDescentStep(U,alpha,dmuAmu); - trG = FourierAccelSteepestDescentStep(U,alpha,dmuAmu); - for(int mu=0;mu(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); - - std::cout << GridLogMessage << " Iteration "< &U,Real & alpha, GaugeMat & dmuAmu) { - GridBase *grid = U[0]._grid; - - std::vector A(Nd,grid); - GaugeMat g(grid); - - GaugeLinkToLieAlgebraField(U,A); - ExpiAlphaDmuAmu(A,g,alpha,dmuAmu); - - - Real vol = grid->gSites(); - Real trG = TensorRemove(sum(trace(g))).real()/vol/Nc; - - SU::GaugeTransform(U,g); - - return trG; - } - - static Real FourierAccelSteepestDescentStep(std::vector &U,Real & alpha, GaugeMat & dmuAmu) { - - 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); - - theFFT.FFT_all_dim(dmuAmu_p,dmuAmu,FFT::forward); - - ////////////////////////////////// - // Work out Fp = psq_max/ psq... - ////////////////////////////////// - std::vector latt_size = grid->GlobalDimensions(); - std::vector coor(grid->_ndimension,0); - for(int mu=0;mu::taExp(ciadmam,g); - - Real trG = TensorRemove(sum(trace(g))).real()/vol/Nc; - - SU::GaugeTransform(U,g); - - return trG; - } - - static void ExpiAlphaDmuAmu(const std::vector &A,GaugeMat &g,Real & alpha, GaugeMat &dmuAmu) { - GridBase *grid = g._grid; - Complex cialpha(0.0,-alpha); - GaugeMat ciadmam(grid); - DmuAmu(A,dmuAmu); - ciadmam = dmuAmu*cialpha; - SU::taExp(ciadmam,g); - } -/* - //////////////////////////////////////////////////////////////// - // NB The FT for fields living on links has an extra phase in it - // Could add these to the FFT class as a later task since this code - // might be reused elsewhere ???? - //////////////////////////////////////////////////////////////// - static void InverseFourierTransformAmu(FFT &theFFT,const std::vector &Ap,std::vector &Ax) { - GridBase * grid = theFFT.Grid(); - std::vector latt_size = grid->GlobalDimensions(); - - ComplexField pmu(grid); - ComplexField pha(grid); - GaugeMat Apha(grid); - - Complex ci(0.0,1.0); - - for(int mu=0;mu &Ax,std::vector &Ap) { - GridBase * grid = theFFT.Grid(); - std::vector latt_size = grid->GlobalDimensions(); - - ComplexField pmu(grid); - ComplexField pha(grid); - Complex ci(0.0,1.0); - - // Sign convention for FFTW calls: - // A(x)= Sum_p e^ipx A(p) / V - // A(p)= Sum_p e^-ipx A(x) - - for(int mu=0;mu seeds({1,2,3,4}); @@ -264,22 +58,24 @@ int main (int argc, char ** argv) std::cout<< "*****************************************************************" <::avgPlaquette(Umu); std::cout << " Initial plaquette "<::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-10, 1.0e-10); + Umu = Urnd; + FourierAcceleratedGaugeFixer::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-12, 1.0e-12,false); plaq=WilsonLoops::avgPlaquette(Umu); std::cout << " Final plaquette "<::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-12, 1.0e-12,true); - // std::cout<< "*****************************************************************" <::avgPlaquette(Umu); + std::cout << " Final plaquette "<::avgPlaquette(Umu); + std::cout << " Initial plaquette "<::SteepestDescentGaugeFix(Umu,alpha,10000,1.0e-12, 1.0e-12,true); + + plaq=WilsonLoops::avgPlaquette(Umu); + std::cout << " Final plaquette "<