mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 04:37:05 +01:00
Merge branch 'develop' into feature/hirep
This commit is contained in:
47
tests/forces/Make.inc
Normal file
47
tests/forces/Make.inc
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
bin_PROGRAMS += Test_contfrac_force Test_dwf_force Test_dwf_gpforce Test_gpdwf_force Test_gp_rect_force Test_gpwilson_force Test_partfrac_force Test_rect_force Test_wilson_force Test_wilson_force_phiMdagMphi Test_wilson_force_phiMphi
|
||||
|
||||
|
||||
Test_contfrac_force_SOURCES=Test_contfrac_force.cc
|
||||
Test_contfrac_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_dwf_force_SOURCES=Test_dwf_force.cc
|
||||
Test_dwf_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_dwf_gpforce_SOURCES=Test_dwf_gpforce.cc
|
||||
Test_dwf_gpforce_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_gpdwf_force_SOURCES=Test_gpdwf_force.cc
|
||||
Test_gpdwf_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_gp_rect_force_SOURCES=Test_gp_rect_force.cc
|
||||
Test_gp_rect_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_gpwilson_force_SOURCES=Test_gpwilson_force.cc
|
||||
Test_gpwilson_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_partfrac_force_SOURCES=Test_partfrac_force.cc
|
||||
Test_partfrac_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_rect_force_SOURCES=Test_rect_force.cc
|
||||
Test_rect_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_wilson_force_SOURCES=Test_wilson_force.cc
|
||||
Test_wilson_force_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_wilson_force_phiMdagMphi_SOURCES=Test_wilson_force_phiMdagMphi.cc
|
||||
Test_wilson_force_phiMdagMphi_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_wilson_force_phiMphi_SOURCES=Test_wilson_force_phiMphi.cc
|
||||
Test_wilson_force_phiMphi_LDADD=-lGrid
|
||||
|
19
tests/forces/Makefile.am
Normal file
19
tests/forces/Makefile.am
Normal file
@ -0,0 +1,19 @@
|
||||
# additional include paths necessary to compile the C++ library
|
||||
|
||||
bin_PROGRAMS =
|
||||
SUBDIRS =
|
||||
|
||||
AM_CXXFLAGS = -I$(top_srcdir)/include
|
||||
AM_LDFLAGS = -L$(top_builddir)/lib
|
||||
|
||||
if USE_LAPACK
|
||||
AM_CXXFLAGS += -DUSE_LAPACK
|
||||
if USE_LAPACK_LIB
|
||||
#if test "X${ac_LAPACK}X" != XyesX
|
||||
AM_CXXFLAGS += -I$(ac_LAPACK)/include
|
||||
AM_LDFLAGS += -L$(ac_LAPACK)/lib
|
||||
#fi
|
||||
endif
|
||||
endif
|
||||
|
||||
include Make.inc
|
153
tests/forces/Test_contfrac_force.cc
Normal file
153
tests/forces/Test_contfrac_force.cc
Normal file
@ -0,0 +1,153 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_contfrac_force.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
const int Ls=9;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
LatticeFermion phi (FGrid); gaussian(RNG5,phi);
|
||||
LatticeFermion Mphi (FGrid);
|
||||
LatticeFermion MphiPrime (FGrid);
|
||||
|
||||
LatticeGaugeField U(UGrid);
|
||||
|
||||
SU3::HotConfiguration(RNG4,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=0.01;
|
||||
RealD M5=1.8;
|
||||
OverlapWilsonContFracTanhFermionR Dcf(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,1.0);
|
||||
Dcf.M (phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(UGrid);
|
||||
LatticeGaugeField tmp(UGrid);
|
||||
|
||||
|
||||
Dcf.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
Dcf.MDeriv(tmp , phi, Mphi,DaggerYes ); UdSdU=(UdSdU+tmp);
|
||||
|
||||
LatticeFermion Ftmp (FGrid);
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.0001;
|
||||
|
||||
LatticeColourMatrix mommu(UGrid);
|
||||
LatticeColourMatrix forcemu(UGrid);
|
||||
LatticeGaugeField mom(UGrid);
|
||||
LatticeGaugeField Uprime(UGrid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =
|
||||
U[i](mu)
|
||||
+ mom[i](mu)*U[i](mu)*dt
|
||||
+ mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt/2.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt/6.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt/24.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt/120.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt*dt/720.0)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Dcf.ImportGauge(Uprime);
|
||||
Dcf.M (phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(MphiPrime ,MphiPrime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
LatticeComplex dS(UGrid); dS = zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu=Ta(mommu)*2.0;
|
||||
PokeIndex<LorentzIndex>(UdSdU,mommu,mu);
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
forcemu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update PF action density
|
||||
dS = dS+trace(mommu*forcemu)*dt;
|
||||
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
153
tests/forces/Test_dwf_force.cc
Normal file
153
tests/forces/Test_dwf_force.cc
Normal file
@ -0,0 +1,153 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_force.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
const int Ls=8;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
LatticeFermion phi (FGrid); gaussian(RNG5,phi);
|
||||
LatticeFermion Mphi (FGrid);
|
||||
LatticeFermion MphiPrime (FGrid);
|
||||
|
||||
LatticeGaugeField U(UGrid);
|
||||
|
||||
SU3::HotConfiguration(RNG4,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=0.01;
|
||||
RealD M5=1.8;
|
||||
DomainWallFermionR Ddwf(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
||||
Ddwf.M (phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(UGrid);
|
||||
LatticeGaugeField tmp(UGrid);
|
||||
|
||||
|
||||
Ddwf.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
Ddwf.MDeriv(tmp , phi, Mphi,DaggerYes ); UdSdU=(UdSdU+tmp);
|
||||
|
||||
LatticeFermion Ftmp (FGrid);
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.0001;
|
||||
|
||||
LatticeColourMatrix mommu(UGrid);
|
||||
LatticeColourMatrix forcemu(UGrid);
|
||||
LatticeGaugeField mom(UGrid);
|
||||
LatticeGaugeField Uprime(UGrid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =
|
||||
U[i](mu)
|
||||
+ mom[i](mu)*U[i](mu)*dt
|
||||
+ mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt/2.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt/6.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt/24.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt/120.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt*dt/720.0)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Ddwf.ImportGauge(Uprime);
|
||||
Ddwf.M (phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(MphiPrime ,MphiPrime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
LatticeComplex dS(UGrid); dS = zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu=Ta(mommu)*2.0;
|
||||
PokeIndex<LorentzIndex>(UdSdU,mommu,mu);
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
forcemu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update PF action density
|
||||
dS = dS+trace(mommu*forcemu)*dt;
|
||||
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
218
tests/forces/Test_dwf_gpforce.cc
Normal file
218
tests/forces/Test_dwf_gpforce.cc
Normal file
@ -0,0 +1,218 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_dwf_gpforce.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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
const int Ls=8;
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
typedef typename GparityDomainWallFermionR::FermionField FermionField;
|
||||
|
||||
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 RNG5(FGrid); RNG5.SeedRandomDevice();
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedRandomDevice();
|
||||
|
||||
FermionField phi (FGrid); gaussian(RNG5,phi);
|
||||
FermionField Mphi (FGrid);
|
||||
FermionField MphiPrime (FGrid);
|
||||
|
||||
LatticeGaugeField U(UGrid);
|
||||
|
||||
SU3::HotConfiguration(RNG4,U);
|
||||
// SU3::ColdConfiguration(pRNG,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=0.2; //kills the diagonal term
|
||||
RealD M5=1.8;
|
||||
// const int nu = 3;
|
||||
// std::vector<int> twists(Nd,0); // twists[nu] = 1;
|
||||
// GparityDomainWallFermionR::ImplParams params; params.twists = twists;
|
||||
// GparityDomainWallFermionR Ddwf(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,params);
|
||||
|
||||
// DomainWallFermionR Dw (U, Grid,RBGrid,mass,M5);
|
||||
|
||||
const int nu = 3;
|
||||
std::vector<int> twists(Nd,0);
|
||||
twists[nu] = 1;
|
||||
GparityDomainWallFermionR::ImplParams params;
|
||||
params.twists = twists;
|
||||
|
||||
GparityDomainWallFermionR Dw(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,params);
|
||||
|
||||
Dw.M (phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(UGrid);
|
||||
LatticeGaugeField tmp(UGrid);
|
||||
|
||||
Dw.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
Dw.MDeriv(tmp , phi, Mphi,DaggerYes ); UdSdU=(UdSdU+tmp);
|
||||
|
||||
FermionField Ftmp (FGrid);
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.0001;
|
||||
RealD Hmom = 0.0;
|
||||
RealD Hmomprime = 0.0;
|
||||
RealD Hmompp = 0.0;
|
||||
LatticeColourMatrix mommu(UGrid);
|
||||
LatticeColourMatrix forcemu(UGrid);
|
||||
LatticeGaugeField mom(UGrid);
|
||||
LatticeGaugeField Uprime(UGrid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
Hmom -= real(sum(trace(mommu*mommu)));
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =
|
||||
U[i](mu)
|
||||
+ mom[i](mu)*U[i](mu)*dt
|
||||
+ mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt/2.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt/6.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt/24.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt/120.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt*dt/720.0)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::cout << GridLogMessage <<"Initial mom hamiltonian is "<< Hmom <<std::endl;
|
||||
Dw.ImportGauge(Uprime);
|
||||
Dw.M (phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(MphiPrime ,MphiPrime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
std::cout << "" <<std::endl;
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
std::cout << GridLogMessage<< " Mommu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " Mommu + Mommudag " << norm2(mommu)<<std::endl;
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
std::cout << GridLogMessage<< " dsdumu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " dsdumu + dag " << norm2(mommu)<<std::endl;
|
||||
}
|
||||
|
||||
LatticeComplex dS(UGrid); dS = zero;
|
||||
LatticeComplex dSmom(UGrid); dSmom = zero;
|
||||
LatticeComplex dSmom2(UGrid); dSmom2 = zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu=Ta(mommu)*2.0;
|
||||
PokeIndex<LorentzIndex>(UdSdU,mommu,mu);
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
std::cout << GridLogMessage<< " Mommu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " Mommu + Mommudag " << norm2(mommu)<<std::endl;
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
std::cout << GridLogMessage<< " dsdumu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " dsdumu + dag " << norm2(mommu)<<std::endl;
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
forcemu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update PF action density
|
||||
dS = dS+trace(mommu*forcemu)*dt;
|
||||
|
||||
dSmom = dSmom - trace(mommu*forcemu) * dt;
|
||||
dSmom2 = dSmom2 - trace(forcemu*forcemu) *(0.25* dt*dt);
|
||||
|
||||
// Update mom action density
|
||||
mommu = mommu + forcemu*(dt*0.5);
|
||||
|
||||
Hmomprime -= real(sum(trace(mommu*mommu)));
|
||||
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
Complex dSm = sum(dSmom);
|
||||
Complex dSm2 = sum(dSmom2);
|
||||
|
||||
|
||||
std::cout << GridLogMessage <<"Initial mom hamiltonian is "<< Hmom <<std::endl;
|
||||
std::cout << GridLogMessage <<"Final mom hamiltonian is "<< Hmomprime <<std::endl;
|
||||
std::cout << GridLogMessage <<"Delta mom hamiltonian is "<< Hmomprime-Hmom <<std::endl;
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
std::cout << GridLogMessage <<"dSm "<< dSm<<std::endl;
|
||||
std::cout << GridLogMessage <<"dSm2"<< dSm2<<std::endl;
|
||||
|
||||
std::cout << GridLogMessage << "Total dS "<< Hmomprime - Hmom + Sprime - S <<std::endl;
|
||||
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
125
tests/forces/Test_gp_rect_force.cc
Normal file
125
tests/forces/Test_gp_rect_force.cc
Normal file
@ -0,0 +1,125 @@
|
||||
/*************************************************************************************
|
||||
|
||||
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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
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);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
|
||||
SU3::HotConfiguration(pRNG,U);
|
||||
|
||||
double beta = 1.0;
|
||||
double c1 = 0.331;
|
||||
|
||||
//GparityPlaqPlusRectangleActionR Action(beta,c1);
|
||||
ConjugateWilsonGaugeActionR Action(beta);
|
||||
//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
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.0001;
|
||||
|
||||
LatticeColourMatrix mommu(&Grid);
|
||||
LatticeColourMatrix forcemu(&Grid);
|
||||
LatticeGaugeField mom(&Grid);
|
||||
LatticeGaugeField Uprime(&Grid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){ // exp(pmu dt) * Umu
|
||||
Uprime[i](mu) = U[i](mu) + mom[i](mu)*U[i](mu)*dt ;
|
||||
}
|
||||
}
|
||||
|
||||
ComplexD Sprime = Action.S(Uprime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
LatticeComplex dS(&Grid); dS = zero;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
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;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
206
tests/forces/Test_gpdwf_force.cc
Normal file
206
tests/forces/Test_gpdwf_force.cc
Normal file
@ -0,0 +1,206 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_gpdwf_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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
const int Ls=8;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
typedef typename GparityDomainWallFermionR::FermionField FermionField;
|
||||
FermionField phi (FGrid); gaussian(RNG5,phi);
|
||||
FermionField Mphi (FGrid);
|
||||
FermionField MphiPrime (FGrid);
|
||||
|
||||
LatticeGaugeField U(UGrid);
|
||||
|
||||
SU3::HotConfiguration(RNG4,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=0.01;
|
||||
RealD M5=1.8;
|
||||
|
||||
const int nu = 3;
|
||||
std::vector<int> twists(Nd,0); twists[nu] = 1;
|
||||
GparityDomainWallFermionR::ImplParams params; params.twists = twists;
|
||||
GparityDomainWallFermionR Ddwf(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,params);
|
||||
Ddwf.M (phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(UGrid);
|
||||
LatticeGaugeField tmp(UGrid);
|
||||
|
||||
Ddwf.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
Ddwf.MDeriv(tmp , phi, Mphi,DaggerYes ); UdSdU=(UdSdU+tmp);
|
||||
|
||||
FermionField Ftmp (FGrid);
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.001;
|
||||
|
||||
LatticeColourMatrix mommu(UGrid);
|
||||
LatticeColourMatrix forcemu(UGrid);
|
||||
LatticeGaugeField mom(UGrid);
|
||||
LatticeGaugeField Uprime(UGrid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =
|
||||
U[i](mu)
|
||||
+ mom[i](mu)*U[i](mu)*dt
|
||||
+ mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt/2.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt/6.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt/24.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt/120.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt*dt/720.0)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Ddwf.ImportGauge(Uprime);
|
||||
Ddwf.M (phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(MphiPrime ,MphiPrime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
LatticeComplex dS(UGrid); dS = zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu=Ta(mommu)*2.0;
|
||||
PokeIndex<LorentzIndex>(UdSdU,mommu,mu);
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
forcemu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update PF action density
|
||||
dS = dS+trace(mommu*forcemu)*dt;
|
||||
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
// From TwoFlavourPseudoFermion:
|
||||
//////////////////////////////////////////////////////
|
||||
// dS/du = - phi^dag (Mdag M)^-1 [ Mdag dM + dMdag M ] (Mdag M)^-1 phi
|
||||
// = - phi^dag M^-1 dM (MdagM)^-1 phi - phi^dag (MdagM)^-1 dMdag dM (Mdag)^-1 phi
|
||||
//
|
||||
// = - Ydag dM X - Xdag dMdag Y
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
// Our conventions really make this UdSdU; We do not differentiate wrt Udag here.
|
||||
// So must take dSdU - adj(dSdU) and left multiply by mom to get dS/dt.
|
||||
//
|
||||
// When we have Gparity -- U and Uconj enter.
|
||||
//
|
||||
// dU/dt = p U
|
||||
// dUc/dt = p* Uc // Is p real, traceless, etc..
|
||||
//
|
||||
// dS/dt = dUdt dSdU = p U dSdU
|
||||
//
|
||||
// Gparity --- deriv is pc Uc dSdUc + p U dSdU
|
||||
//
|
||||
// Pmu = zero;
|
||||
// for(int mu=0;mu<Nd;mu++){
|
||||
// SU<Ncol>::GaussianFundamentalLieAlgebraMatrix(pRNG, Pmu);
|
||||
// PokeIndex<LorentzIndex>(P, Pmu, mu);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// GridBase *grid = out._grid;
|
||||
// LatticeReal ca (grid);
|
||||
// LatticeMatrix la (grid);
|
||||
// Complex ci(0.0,scale);
|
||||
// Matrix ta;
|
||||
// out=zero;
|
||||
// for(int a=0;a<generators();a++){
|
||||
// gaussian(pRNG,ca);
|
||||
// generator(a,ta);
|
||||
// la=toComplex(ca)*ci*ta; // i t_a Lambda_a c_a // c_a is gaussian
|
||||
// out += la;
|
||||
// }
|
||||
// p = sum_a i gauss_a t_a
|
||||
//
|
||||
// dU = p U dt
|
||||
//
|
||||
// dUc = p^c Uc dt = -i gauss_a t_a^c Uc
|
||||
//
|
||||
//
|
||||
// For Gparity the dS /dt from Uc links
|
||||
//
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
169
tests/forces/Test_gpwilson_force.cc
Normal file
169
tests/forces/Test_gpwilson_force.cc
Normal file
@ -0,0 +1,169 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_gpdwf_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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
const int Ls=8;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(),
|
||||
GridDefaultSimd(Nd,vComplex::Nsimd()),
|
||||
GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = UGrid;
|
||||
GridRedBlackCartesian * FrbGrid = UrbGrid;
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
typedef typename GparityDomainWallFermionR::FermionField FermionField;
|
||||
FermionField phi (FGrid); gaussian(RNG4,phi);
|
||||
FermionField Mphi (FGrid);
|
||||
FermionField MphiPrime (FGrid);
|
||||
|
||||
LatticeGaugeField U(UGrid);
|
||||
|
||||
SU3::HotConfiguration(RNG4,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=0.01;
|
||||
RealD M5=1.8;
|
||||
|
||||
const int nu = 3;
|
||||
std::vector<int> twists(Nd,0); twists[nu] = 1;
|
||||
GparityWilsonFermionR::ImplParams params; params.twists = twists;
|
||||
GparityWilsonFermionR Wil(U,*UGrid,*UrbGrid,mass,params);
|
||||
Wil.M (phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(UGrid);
|
||||
LatticeGaugeField tmp(UGrid);
|
||||
|
||||
Wil.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
Wil.MDeriv(tmp , phi, Mphi,DaggerYes ); UdSdU=(UdSdU+tmp);
|
||||
|
||||
FermionField Ftmp (FGrid);
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.00001;
|
||||
|
||||
LatticeColourMatrix mommu(UGrid);
|
||||
LatticeColourMatrix forcemu(UGrid);
|
||||
LatticeGaugeField mom(UGrid);
|
||||
LatticeGaugeField Uprime(UGrid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =
|
||||
U[i](mu)
|
||||
+ mom[i](mu)*U[i](mu)*dt
|
||||
+ mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt/2.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt/6.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt/24.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt/120.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt*dt/720.0)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Wil.ImportGauge(Uprime);
|
||||
Wil.M (phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(MphiPrime ,MphiPrime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
LatticeComplex dS(UGrid); dS = zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu=Ta(mommu)*2.0;
|
||||
PokeIndex<LorentzIndex>(UdSdU,mommu,mu);
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
forcemu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update PF action density
|
||||
dS = dS+trace(mommu*forcemu)*dt;
|
||||
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
// From TwoFlavourPseudoFermion:
|
||||
//////////////////////////////////////////////////////
|
||||
// dS/du = - phi^dag (Mdag M)^-1 [ Mdag dM + dMdag M ] (Mdag M)^-1 phi
|
||||
// = - phi^dag M^-1 dM (MdagM)^-1 phi - phi^dag (MdagM)^-1 dMdag dM (Mdag)^-1 phi
|
||||
//
|
||||
// = - Ydag dM X - Xdag dMdag Y
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
// So must take dSdU - adj(dSdU) and left multiply by mom to get dS/dt.
|
||||
//
|
||||
//
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
153
tests/forces/Test_partfrac_force.cc
Normal file
153
tests/forces/Test_partfrac_force.cc
Normal file
@ -0,0 +1,153 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_partfrac_force.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
const int Ls=9;
|
||||
|
||||
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
||||
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
||||
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
||||
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
||||
|
||||
std::vector<int> seeds4({1,2,3,4});
|
||||
std::vector<int> seeds5({5,6,7,8});
|
||||
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
||||
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
LatticeFermion phi (FGrid); gaussian(RNG5,phi);
|
||||
LatticeFermion Mphi (FGrid);
|
||||
LatticeFermion MphiPrime (FGrid);
|
||||
|
||||
LatticeGaugeField U(UGrid);
|
||||
|
||||
SU3::HotConfiguration(RNG4,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=0.01;
|
||||
RealD M5=1.8;
|
||||
OverlapWilsonPartialFractionTanhFermionR Dpf(U,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,1.0);
|
||||
Dpf.M (phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(UGrid);
|
||||
LatticeGaugeField tmp(UGrid);
|
||||
|
||||
|
||||
Dpf.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
Dpf.MDeriv(tmp , phi, Mphi,DaggerYes ); UdSdU=(UdSdU+tmp);
|
||||
|
||||
LatticeFermion Ftmp (FGrid);
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.0001;
|
||||
|
||||
LatticeColourMatrix mommu(UGrid);
|
||||
LatticeColourMatrix forcemu(UGrid);
|
||||
LatticeGaugeField mom(UGrid);
|
||||
LatticeGaugeField Uprime(UGrid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(RNG4, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =
|
||||
U[i](mu)
|
||||
+ mom[i](mu)*U[i](mu)*dt
|
||||
+ mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt/2.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt/6.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt/24.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt/120.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt*dt/720.0)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Dpf.ImportGauge(Uprime);
|
||||
Dpf.M (phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(MphiPrime ,MphiPrime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
LatticeComplex dS(UGrid); dS = zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu=Ta(mommu)*2.0;
|
||||
PokeIndex<LorentzIndex>(UdSdU,mommu,mu);
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
forcemu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update PF action density
|
||||
dS = dS+trace(mommu*forcemu)*dt;
|
||||
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
124
tests/forces/Test_rect_force.cc
Normal file
124
tests/forces/Test_rect_force.cc
Normal file
@ -0,0 +1,124 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_rect_force.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
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);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
|
||||
SU3::HotConfiguration(pRNG,U);
|
||||
|
||||
double beta = 1.0;
|
||||
double c1 = 0.331;
|
||||
|
||||
PlaqPlusRectangleActionR Action(beta,c1);
|
||||
// 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
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.0001;
|
||||
|
||||
LatticeColourMatrix mommu(&Grid);
|
||||
LatticeColourMatrix forcemu(&Grid);
|
||||
LatticeGaugeField mom(&Grid);
|
||||
LatticeGaugeField Uprime(&Grid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){ // exp(pmu dt) * Umu
|
||||
Uprime[i](mu) = U[i](mu) + mom[i](mu)*U[i](mu)*dt ;
|
||||
}
|
||||
}
|
||||
|
||||
ComplexD Sprime = Action.S(Uprime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
LatticeComplex dS(&Grid); dS = zero;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
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;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
202
tests/forces/Test_wilson_force.cc
Normal file
202
tests/forces/Test_wilson_force.cc
Normal file
@ -0,0 +1,202 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_force.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
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);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeFermion phi (&Grid); gaussian(pRNG,phi);
|
||||
LatticeFermion Mphi (&Grid);
|
||||
LatticeFermion MphiPrime (&Grid);
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
|
||||
//SU2::HotConfiguration(pRNG,U);
|
||||
SU3::ColdConfiguration(pRNG,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=-4.0; //kills the diagonal term
|
||||
WilsonFermionR Dw (U, Grid,RBGrid,mass);
|
||||
Dw.M (phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(&Grid);
|
||||
LatticeGaugeField tmp(&Grid);
|
||||
|
||||
Dw.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
Dw.MDeriv(tmp , phi, Mphi,DaggerYes ); UdSdU=(UdSdU+tmp);
|
||||
// Take the trace
|
||||
UdSdU = Ta(UdSdU);
|
||||
|
||||
LatticeFermion Ftmp (&Grid);
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.0001;
|
||||
RealD Hmom = 0.0;
|
||||
RealD Hmomprime = 0.0;
|
||||
RealD Hmompp = 0.0;
|
||||
LatticeColourMatrix mommu(&Grid);
|
||||
LatticeColourMatrix forcemu(&Grid);
|
||||
LatticeGaugeField mom(&Grid);
|
||||
LatticeGaugeField Uprime(&Grid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
Hmom -= real(sum(trace(mommu*mommu)));
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
// fourth order exponential approx
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =
|
||||
U[i](mu)
|
||||
+ mom[i](mu)*U[i](mu)*dt
|
||||
+ mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt/2.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt/6.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt/24.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt/120.0)
|
||||
+ mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *mom[i](mu) *U[i](mu)*(dt*dt*dt*dt*dt*dt/720.0)
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::cout << GridLogMessage <<"Initial mom hamiltonian is "<< Hmom <<std::endl;
|
||||
Dw.ImportGauge(Uprime);
|
||||
Dw.M (phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(MphiPrime ,MphiPrime);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
std::cout << "" <<std::endl;
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
std::cout << GridLogMessage<< " Mommu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " Mommu + Mommudag " << norm2(mommu)<<std::endl;
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
std::cout << GridLogMessage<< " dsdumu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " dsdumu + dag " << norm2(mommu)<<std::endl;
|
||||
}
|
||||
|
||||
LatticeComplex dS(&Grid); dS = zero;
|
||||
LatticeComplex dSmom(&Grid); dSmom = zero;
|
||||
LatticeComplex dSmom2(&Grid); dSmom2 = zero;
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu=Ta(mommu)*2.0;
|
||||
PokeIndex<LorentzIndex>(UdSdU,mommu,mu);
|
||||
}
|
||||
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
std::cout << GridLogMessage<< " Mommu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " Mommu + Mommudag " << norm2(mommu)<<std::endl;
|
||||
mommu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
std::cout << GridLogMessage<< " dsdumu " << norm2(mommu)<<std::endl;
|
||||
mommu = mommu+adj(mommu);
|
||||
std::cout << GridLogMessage<< " dsdumu + dag " << norm2(mommu)<<std::endl;
|
||||
}
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
forcemu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update PF action density
|
||||
dS = dS+trace(mommu*forcemu)*dt;
|
||||
|
||||
dSmom = dSmom - trace(mommu*forcemu) * dt;
|
||||
dSmom2 = dSmom2 - trace(forcemu*forcemu) *(0.25* dt*dt);
|
||||
|
||||
// Update mom action density
|
||||
mommu = mommu + forcemu*(dt * 0.5);
|
||||
|
||||
Hmomprime -= real(sum(trace(mommu*mommu)));
|
||||
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
Complex dSm = sum(dSmom);
|
||||
Complex dSm2 = sum(dSmom2);
|
||||
|
||||
|
||||
std::cout << GridLogMessage <<"Initial mom hamiltonian is "<< Hmom <<std::endl;
|
||||
std::cout << GridLogMessage <<"Final mom hamiltonian is "<< Hmomprime <<std::endl;
|
||||
std::cout << GridLogMessage <<"Delta mom hamiltonian is "<< Hmomprime-Hmom <<std::endl;
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
std::cout << GridLogMessage <<"dSm "<< dSm<<std::endl;
|
||||
std::cout << GridLogMessage <<"dSm2"<< dSm2<<std::endl;
|
||||
|
||||
std::cout << GridLogMessage << "Total dS "<< Hmomprime - Hmom + Sprime - S <<std::endl;
|
||||
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
167
tests/forces/Test_wilson_force_phiMdagMphi.cc
Normal file
167
tests/forces/Test_wilson_force_phiMdagMphi.cc
Normal file
@ -0,0 +1,167 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_force_phiMdagMphi.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
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);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeFermion phi (&Grid); gaussian(pRNG,phi);
|
||||
LatticeFermion Mphi (&Grid);
|
||||
LatticeFermion Mdagphi (&Grid);
|
||||
LatticeFermion MphiPrime (&Grid);
|
||||
LatticeFermion MdagphiPrime (&Grid);
|
||||
LatticeFermion dMphi (&Grid);
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
|
||||
|
||||
SU3::HotConfiguration(pRNG,U);
|
||||
// SU3::ColdConfiguration(pRNG,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=-4.0; //kills the diagonal term
|
||||
WilsonFermionR Dw (U, Grid,RBGrid,mass);
|
||||
Dw.M (phi,Mphi);
|
||||
Dw.Mdag(phi,Mdagphi);
|
||||
|
||||
ComplexD S = innerProduct(Mphi,Mphi); // pdag MdagM p
|
||||
ComplexD Sdag = innerProduct(Mdagphi,Mdagphi); // pdag MMdag p
|
||||
|
||||
// get the deriv of phidag MdagM phi with respect to "U"
|
||||
LatticeGaugeField UdSdU(&Grid);
|
||||
LatticeGaugeField UdSdUdag(&Grid);
|
||||
LatticeGaugeField tmp(&Grid);
|
||||
|
||||
Dw.MDeriv(tmp , Mphi, phi,DaggerNo ); UdSdU=tmp;
|
||||
|
||||
Dw.MDeriv(tmp , Mdagphi, phi,DaggerYes ); UdSdUdag=tmp;
|
||||
|
||||
|
||||
LatticeFermion dMdagphi (&Grid); dMdagphi=zero;
|
||||
LatticeFermion Ftmp (&Grid);
|
||||
|
||||
|
||||
// Dw.MDeriv(UdSdU,Mdagphi, phi,DaggerYes );// UdSdU =UdSdU +tmp;
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little in one dir
|
||||
////////////////////////////////////
|
||||
RealD dt = 1.0e-3;
|
||||
|
||||
LatticeColourMatrix mommu(&Grid);
|
||||
LatticeGaugeField mom(&Grid);
|
||||
LatticeGaugeField Uprime(&Grid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
// Dw.DoubleStore(Dw.Umu,Uprime); // update U _and_ Udag
|
||||
Dw.DhopDirDisp(phi,Ftmp,mu,mu+4,DaggerYes);
|
||||
dMdagphi=dMdagphi+mommu*Ftmp*dt;
|
||||
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
Uprime[i](mu) =U[i](mu)+ mom[i](mu)*U[i](mu)*dt;
|
||||
Dw.Umu[i](mu) =Uprime[i](mu); // update U but _not_ Udag
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Dw.Mdag(phi,MdagphiPrime);
|
||||
Dw.M (phi,MphiPrime);
|
||||
|
||||
std::cout << GridLogMessage << "deltaMdag phi "<< norm2(dMdagphi) <<std::endl;
|
||||
Ftmp=MdagphiPrime - Mdagphi;
|
||||
std::cout << GridLogMessage << "diff Mdag phi "<< norm2(Ftmp) <<std::endl;
|
||||
Ftmp = Ftmp - dMdagphi;
|
||||
std::cout << GridLogMessage << "err Mdag phi "<< norm2(Ftmp) <<std::endl;
|
||||
std::cout << dMdagphi<<std::endl;
|
||||
Ftmp=MdagphiPrime - Mdagphi;
|
||||
std::cout << Ftmp<<std::endl;
|
||||
|
||||
|
||||
ComplexD Sprime = innerProduct(Mphi ,MphiPrime);
|
||||
ComplexD Sprimedag = innerProduct(Mdagphi,MdagphiPrime);
|
||||
|
||||
ComplexD deltaSdag = innerProduct(Mdagphi,dMdagphi);
|
||||
std::cout << GridLogMessage << "deltaSdag from inner prod of mom* M[u] "<<deltaSdag<<std::endl;
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
LatticeComplex dS(&Grid); dS = zero;
|
||||
LatticeComplex dSdag(&Grid); dSdag = zero;
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
// dS[i]() = dS[i]()+trace(mom[i](mu) * UdSdU[i](mu) - mom[i](mu)* adj( UdSdU[i](mu)) )*dt;
|
||||
dS[i]() = dS[i]()+trace(mom[i](mu) * UdSdU[i](mu) )*dt;
|
||||
dSdag[i]() = dSdag[i]()+trace(mom[i](mu) * UdSdUdag[i](mu) )*dt;
|
||||
}
|
||||
}
|
||||
Complex dSpred = sum(dS);
|
||||
Complex dSdagpred = sum(dSdag);
|
||||
|
||||
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 << "predict dS "<< dSpred <<std::endl;
|
||||
std::cout << "\n\n"<<std::endl;
|
||||
std::cout << GridLogMessage << " Sdag "<<Sdag<<std::endl;
|
||||
std::cout << GridLogMessage << " Sprimedag "<<Sprimedag<<std::endl;
|
||||
std::cout << GridLogMessage << "dSdag "<<Sprimedag-Sdag<<std::endl;
|
||||
std::cout << GridLogMessage << "predict dSdag "<< dSdagpred <<std::endl;
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
189
tests/forces/Test_wilson_force_phiMphi.cc
Normal file
189
tests/forces/Test_wilson_force_phiMphi.cc
Normal file
@ -0,0 +1,189 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_wilson_force_phiMphi.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
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);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeFermion phi (&Grid); gaussian(pRNG,phi);
|
||||
LatticeFermion Mphi (&Grid);
|
||||
LatticeFermion MphiPrime (&Grid);
|
||||
LatticeFermion dMphi (&Grid);
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
|
||||
|
||||
SU3::HotConfiguration(pRNG,U);
|
||||
|
||||
////////////////////////////////////
|
||||
// Unmodified matrix element
|
||||
////////////////////////////////////
|
||||
RealD mass=-4.0; //kills the diagonal term
|
||||
WilsonFermionR Dw (U, Grid,RBGrid,mass);
|
||||
Dw.M(phi,Mphi);
|
||||
|
||||
ComplexD S = innerProduct(phi,Mphi);
|
||||
|
||||
// get the deriv
|
||||
LatticeGaugeField UdSdU(&Grid);
|
||||
Dw.MDeriv(UdSdU,phi, phi,DaggerNo );
|
||||
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little in one dir
|
||||
////////////////////////////////////
|
||||
RealD dt = 1.0e-3;
|
||||
Complex Complex_i(0,1);
|
||||
|
||||
LatticeColourMatrix Umu(&Grid);
|
||||
LatticeColourMatrix Umu_save(&Grid);
|
||||
LatticeColourMatrix dU (&Grid);
|
||||
LatticeColourMatrix mom(&Grid);
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mom); // Traceless antihermitian momentum; gaussian in lie alg
|
||||
|
||||
|
||||
// check mom is as i expect
|
||||
LatticeColourMatrix tmpmom(&Grid);
|
||||
tmpmom = mom+adj(mom);
|
||||
std::cout << GridLogMessage << "mom anti-herm check "<< norm2(tmpmom)<<std::endl;
|
||||
std::cout << GridLogMessage << "mom tr check "<< norm2(trace(mom))<<std::endl;
|
||||
|
||||
const int mu=0;
|
||||
Umu = PeekIndex<LorentzIndex>(U,mu);
|
||||
Umu_save=Umu;
|
||||
dU = mom * Umu * dt;
|
||||
Umu= Umu+dU;
|
||||
PokeIndex<LorentzIndex>(Dw.Umu,Umu,mu);
|
||||
|
||||
Dw.M(phi,MphiPrime);
|
||||
|
||||
ComplexD Sprime = innerProduct(phi,MphiPrime);
|
||||
|
||||
std::cout << GridLogMessage << " S "<<S<<std::endl;
|
||||
std::cout << GridLogMessage << " Sprime "<<Sprime<<std::endl;
|
||||
std::cout << GridLogMessage << "dS "<<Sprime-S<<std::endl;
|
||||
|
||||
Dw.Umu=zero;
|
||||
PokeIndex<LorentzIndex>(Dw.Umu,dU,mu);
|
||||
Dw.M(phi,dMphi);
|
||||
|
||||
|
||||
ComplexD deltaS = innerProduct(phi,dMphi);
|
||||
std::cout << GridLogMessage << "deltaS "<<deltaS<<std::endl;
|
||||
|
||||
Dw.Umu=zero;
|
||||
PokeIndex<LorentzIndex>(Dw.Umu,Umu_save,mu);
|
||||
Dw.Mdir(phi,dMphi,mu,1);
|
||||
dMphi = dt*mom*dMphi;
|
||||
|
||||
deltaS = innerProduct(phi,dMphi);
|
||||
std::cout << GridLogMessage << "deltaS from inner prod of mom* M[u] "<<deltaS<<std::endl;
|
||||
|
||||
deltaS = sum(trace(outerProduct(dMphi,phi)));
|
||||
std::cout << GridLogMessage << "deltaS from trace outer prod of deltaM "<<deltaS<<std::endl;
|
||||
|
||||
/*
|
||||
LatticeComplex lip(&Grid);
|
||||
lip = localInnerProduct(phi,dMphi);
|
||||
|
||||
LatticeComplex trop(&Grid);
|
||||
trop = trace(outerProduct(dMphi,phi));
|
||||
|
||||
LatticeSpinColourMatrix op(&Grid);
|
||||
op = outerProduct(dMphi,phi);
|
||||
|
||||
LatticeSpinColourMatrix hop(&Grid);
|
||||
LatticeComplex op_cpt(&Grid);
|
||||
for(int s1=0;s1<Ns;s1++){
|
||||
for(int s2=0;s2<Ns;s2++){
|
||||
for(int c1=0;c1<Nc;c1++){
|
||||
for(int c2=0;c2<Nc;c2++){
|
||||
|
||||
op_cpt = peekColour(peekSpin(dMphi,s1),c1) * adj(peekColour(peekSpin(phi,s2),c2));
|
||||
|
||||
parallel_for(auto i=hop.begin();i<hop.end();i++){
|
||||
hop[i]()(s1,s2)(c1,c2) = op_cpt[i]()()();
|
||||
}
|
||||
|
||||
}}}}
|
||||
|
||||
LatticeSpinColourMatrix diffop(&Grid);
|
||||
|
||||
diffop = hop - op;
|
||||
std::cout << GridLogMessage << "hand outer prod diff "<<norm2(diffop)<<std::endl;
|
||||
|
||||
deltaS = sum(trace(hop));
|
||||
std::cout << GridLogMessage << "deltaS hop "<<deltaS<<std::endl;
|
||||
|
||||
std::cout << GridLogMessage<< " phi[0] : "<< phi._odata[0]<<std::endl;
|
||||
std::cout << GridLogMessage<< "dMphi[0] : "<<dMphi._odata[0]<<std::endl;
|
||||
std::cout << GridLogMessage<< "hop[0] : "<< hop._odata[0]<<std::endl;
|
||||
std::cout << GridLogMessage<< " op[0] : "<< op._odata[0]<<std::endl;
|
||||
|
||||
|
||||
std::cout << GridLogMessage << "lip "<<lip<<std::endl;
|
||||
std::cout << GridLogMessage << "trop "<<trop<<std::endl;
|
||||
|
||||
*/
|
||||
|
||||
// std::cout << GridLogMessage << " UdSdU " << UdSdU << std::endl;
|
||||
|
||||
LatticeComplex dS(&Grid); dS = zero;
|
||||
parallel_for(auto i=mom.begin();i<mom.end();i++){
|
||||
dS[i]() = trace(mom[i]() * UdSdU[i](mu) )*dt;
|
||||
}
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
std::cout << GridLogMessage << "predict dS "<< dSpred <<std::endl;
|
||||
|
||||
|
||||
cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
Reference in New Issue
Block a user