From bb7d8535aa52b5f0fe0c11c1b4f44337963ad4ec Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Sat, 1 Aug 2015 22:07:05 +0900 Subject: [PATCH] Test for DWF force term passes --- tests/Test_cheby.cc | 61 +++++++++++++++++++ tests/Test_dwf_force.cc | 126 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 tests/Test_cheby.cc create mode 100644 tests/Test_dwf_force.cc diff --git a/tests/Test_cheby.cc b/tests/Test_cheby.cc new file mode 100644 index 00000000..08897c90 --- /dev/null +++ b/tests/Test_cheby.cc @@ -0,0 +1,61 @@ +#include + +using namespace std; +using namespace Grid; +using namespace Grid::QCD; + +RealD InverseApproximation(RealD x){ + return 1.0/x; +} +RealD SqrtApproximation(RealD x){ + return std::sqrt(x); +} +RealD StepFunction(RealD x){ + if ( x<0.1 ) return 1.0; + else return 0.0; +} + + +int main (int argc, char ** argv) +{ + Grid_init(&argc,&argv); + + GridCartesian *grid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), + GridDefaultSimd(Nd,vComplex::Nsimd()), + GridDefaultMpi()); + + double lo=0.1; + double hi=64.0; + + Chebyshev ChebyInv(lo,hi,2000,InverseApproximation); + + + { + std::ofstream of("chebyinv"); + ChebyInv.csv(of); + } + + ChebyInv.JacksonSmooth(); + + { + std::ofstream of("chebyinvjack"); + ChebyInv.csv(of); + } + + + Chebyshev ChebyStep(lo,hi,200,StepFunction); + { + std::ofstream of("chebystep"); + ChebyStep.csv(of); + } + + + ChebyStep.JacksonSmooth(); + + { + std::ofstream of("chebystepjack"); + ChebyStep.csv(of); + } + + Grid_finalize(); +} diff --git a/tests/Test_dwf_force.cc b/tests/Test_dwf_force.cc new file mode 100644 index 00000000..a3dbb0f2 --- /dev/null +++ b/tests/Test_dwf_force.cc @@ -0,0 +1,126 @@ +#include + +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 latt_size = GridDefaultLatt(); + std::vector simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); + std::vector 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 seeds4({1,2,3,4}); + std::vector seeds5({5,6,7,8}); + GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5); + GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); + + int threads = GridThread::GetThreads(); + std::cout<(mom,mommu,mu); + + // fourth order exponential approx + parallel_for(auto i=mom.begin();i(UdSdU,mu); + mommu=Ta(mommu)*2.0; + PokeIndex(UdSdU,mommu,mu); + } + + for(int mu=0;mu(UdSdU,mu); + mommu = PeekIndex(mom,mu); + + // Update PF action density + dS = dS+trace(mommu*forcemu)*dt; + + } + + Complex dSpred = sum(dS); + + std::cout << GridLogMessage << " S "<