2016-01-02 14:51:32 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: ./tests/Test_gp_rect_force.cc
|
|
|
|
|
|
|
|
Copyright (C) 2015
|
|
|
|
|
|
|
|
Author: paboyle <paboyle@ph.ed.ac.uk>
|
|
|
|
|
|
|
|
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 */
|
2016-07-07 22:31:07 +01:00
|
|
|
#include <Grid/Grid.h>
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Grid;
|
2018-01-15 09:37:58 +00:00
|
|
|
;
|
2016-01-02 13:37:25 +00:00
|
|
|
|
2017-02-21 10:24:27 +00:00
|
|
|
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
int main (int argc, char ** argv)
|
|
|
|
{
|
|
|
|
Grid_init(&argc,&argv);
|
|
|
|
|
2018-02-24 22:19:28 +00:00
|
|
|
Coordinate latt_size = GridDefaultLatt();
|
|
|
|
Coordinate simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
|
|
|
Coordinate mpi_layout = GridDefaultMpi();
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
2017-06-22 08:14:34 +01:00
|
|
|
GridRedBlackCartesian RBGrid(&Grid);
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
int threads = GridThread::GetThreads();
|
|
|
|
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
|
|
|
|
|
|
|
std::vector<int> seeds({1,2,3,4});
|
|
|
|
|
|
|
|
GridParallelRNG pRNG(&Grid);
|
2017-04-01 16:29:40 +01:00
|
|
|
pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
LatticeGaugeField U(&Grid);
|
|
|
|
|
|
|
|
SU3::HotConfiguration(pRNG,U);
|
|
|
|
|
|
|
|
double beta = 1.0;
|
|
|
|
double c1 = 0.331;
|
|
|
|
|
2018-03-05 13:59:02 +00:00
|
|
|
ConjugatePlaqPlusRectangleActionR Action(beta,c1);
|
|
|
|
//ConjugateWilsonGaugeActionR Action(beta);
|
2016-01-02 13:37:25 +00:00
|
|
|
//WilsonGaugeActionR Action(beta);
|
|
|
|
|
|
|
|
ComplexD S = Action.S(U);
|
|
|
|
|
|
|
|
// get the deriv of phidag MdagM phi with respect to "U"
|
|
|
|
LatticeGaugeField UdSdU(&Grid);
|
|
|
|
|
|
|
|
Action.deriv(U,UdSdU);
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
// Modify the gauge field a little
|
|
|
|
////////////////////////////////////
|
2018-12-19 11:09:32 +00:00
|
|
|
RealD dt = 0.01;
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
LatticeColourMatrix mommu(&Grid);
|
|
|
|
LatticeColourMatrix forcemu(&Grid);
|
|
|
|
LatticeGaugeField mom(&Grid);
|
|
|
|
LatticeGaugeField Uprime(&Grid);
|
|
|
|
|
|
|
|
for(int mu=0;mu<Nd;mu++){
|
|
|
|
|
2016-07-08 15:40:11 +01:00
|
|
|
SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
|
|
|
|
|
|
|
// fourth order exponential approx
|
2018-03-04 16:40:11 +00:00
|
|
|
auto mom_v = mom.View();
|
|
|
|
auto Uprime_v= Uprime.View();
|
|
|
|
auto U_v = U.View();
|
|
|
|
thread_loop( (auto i=mom_v.begin();i<mom_v.end();i++),{ // exp(pmu dt) * Umu
|
|
|
|
Uprime_v[i](mu) = U_v[i](mu) + mom_v[i](mu)*U_v[i](mu)*dt ;
|
2018-01-28 01:00:55 +00:00
|
|
|
});
|
2016-01-02 13:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ComplexD Sprime = Action.S(Uprime);
|
|
|
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
// Use derivative to estimate dS
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
2018-01-27 23:46:02 +00:00
|
|
|
LatticeComplex dS(&Grid); dS = Zero();
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
for(int mu=0;mu<Nd;mu++){
|
|
|
|
|
|
|
|
auto UdSdUmu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
|
|
|
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
|
|
|
|
|
|
|
// Update gauge action density
|
|
|
|
// U = exp(p dt) U
|
|
|
|
// dU/dt = p U
|
|
|
|
// so dSdt = trace( dUdt dSdU) = trace( p UdSdUmu )
|
|
|
|
|
|
|
|
dS = dS - trace(mommu*UdSdUmu)*dt*2.0;
|
|
|
|
|
|
|
|
}
|
2017-05-30 23:37:02 +01:00
|
|
|
ComplexD dSpred = sum(dS);
|
2016-01-02 13:37:25 +00:00
|
|
|
|
|
|
|
std::cout << GridLogMessage << " S "<<S<<std::endl;
|
|
|
|
std::cout << GridLogMessage << " Sprime "<<Sprime<<std::endl;
|
|
|
|
std::cout << GridLogMessage << "dS "<<Sprime-S<<std::endl;
|
|
|
|
std::cout << GridLogMessage << "pred dS "<< dSpred <<std::endl;
|
2018-12-19 11:09:32 +00:00
|
|
|
assert( fabs(real(Sprime-S-dSpred)) < 1.0e-1 ) ;
|
2016-01-02 13:37:25 +00:00
|
|
|
std::cout<< GridLogMessage << "Done" <<std::endl;
|
|
|
|
Grid_finalize();
|
|
|
|
}
|