From b07ccf3d5e7801490526d82284c61827a005961f Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Fri, 2 Oct 2026 12:02:54 -0400 Subject: [PATCH] Force test reorg --- tests/forces/Test_bdy.cc | 84 +---------------------- tests/forces/Test_double_ratio.cc | 81 ++-------------------- tests/forces/Test_dwf_ratio_4dpf_force.cc | 66 +----------------- tests/forces/Test_dwf_ratio_leftprec.cc | 64 +---------------- 4 files changed, 11 insertions(+), 284 deletions(-) diff --git a/tests/forces/Test_bdy.cc b/tests/forces/Test_bdy.cc index d328b49fb..106a73f31 100644 --- a/tests/forces/Test_bdy.cc +++ b/tests/forces/Test_bdy.cc @@ -99,91 +99,12 @@ Author: Peter Boyle using namespace std; using namespace Grid; +#include "ForceTest.h" + typedef MobiusFermionD FermionAction; typedef WilsonImplD FimplD; typedef WilsonImplD FermionImplPolicy; -template -void ForceTest(Action &action,LatticeGaugeField & U,MomentumFilterBase &Filter) -{ - GridBase *UGrid = U.Grid(); - - std::vector seeds({1,2,3,5}); - GridSerialRNG sRNG; sRNG.SeedFixedIntegers(seeds); - GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds); - - LatticeColourMatrix Pmu(UGrid); - LatticeGaugeField P(UGrid); - LatticeGaugeField UdSdU(UGrid); - - std::cout << GridLogMessage << "*********************************************************"<(UdSdU,mu); - Pmu= PeekIndex(P,mu); - dS = dS - trace(Pmu*UdSdUmu)*eps*2.0*2.0; - } - ComplexD dSpred = sum(dS); - RealD diff = S2-S1-dSpred.real(); - - std::cout<< GridLogMessage << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"< -void ForceTest(Action &action,LatticeGaugeField & U,MomentumFilterBase &Filter) -{ - GridBase *UGrid = U.Grid(); - - std::vector seeds({1,2,3,5}); - GridSerialRNG sRNG; sRNG.SeedFixedIntegers(seeds); - GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds); - - LatticeColourMatrix Pmu(UGrid); - LatticeGaugeField P(UGrid); - LatticeGaugeField UdSdU(UGrid); - - std::cout << GridLogMessage << "*********************************************************"<(UdSdU,mu); - Pmu= PeekIndex(P,mu); - dS = dS - trace(Pmu*UdSdUmu)*eps*2.0*2.0; - } - ComplexD dSpred = sum(dS); - RealD diff = S2-S1-dSpred.real(); - - std::cout<< GridLogMessage << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"< // composition identity [P M^-1 V Pdag][P V^-1 M Pdag] = 1 for the chosen // (P,Pdag) wall pair. NO PREDICTION is made about which convention // passes -- that is what the test decides. -// T2 ForceTest (idiom from Test_double_ratio.cc) : midpoint-derivative +// T2 ForceTest (tests/forces/ForceTest.h) : midpoint-derivative // check of deriv against S. Should PASS for BOTH conventions (S and // deriv use the same literal-adjoint pair by construction). // T3 Trivial-ratio control (V == M) : T1 with NumOp = DenOp. The solve @@ -124,69 +124,7 @@ RealD HeatbathIdentityTest(TwoFlavourRatio4DPseudoFermionAction &action, return defect; } -//////////////////////////////////////////////////////////////////// -// T2 : ForceTest idiom from Test_double_ratio.cc (midpoint derivative) -//////////////////////////////////////////////////////////////////// -template -void ForceTest(Action &action,LatticeGaugeField & U,MomentumFilterBase &Filter) -{ - GridBase *UGrid = U.Grid(); - - std::vector seeds({1,2,3,5}); - GridSerialRNG sRNG; sRNG.SeedFixedIntegers(seeds); - GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds); - - LatticeColourMatrix Pmu(UGrid); - LatticeGaugeField P(UGrid); - LatticeGaugeField UdSdU(UGrid); - - std::cout << GridLogMessage << "*********************************************************"<(UdSdU,mu); - Pmu= PeekIndex(P,mu); - dS = dS - trace(Pmu*UdSdUmu)*eps*2.0*2.0; - } - ComplexD dSpred = sum(dS); - RealD diff = S2-S1-dSpred.real(); - - std::cout<< GridLogMessage << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"< // BOTH classes (E0a also validates the twin-eta capture). // E1 : S_classic == S_leftprec (relative, ~1e-8) // E2 : deriv_classic == deriv_leftprec (pointwise field norm, ~1e-8) -// F1 : ForceTest (Test_double_ratio.cc idiom) on the LeftPrec class. +// F1 : ForceTest (tests/forces/ForceTest.h) on the LeftPrec class. // // All asserts are hard: this is the regression gate for the new class. // Run small, e.g.: ./Test_dwf_ratio_leftprec --grid 8.8.8.8 @@ -138,67 +138,7 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// ForceTest idiom from Test_double_ratio.cc (midpoint derivative) -//////////////////////////////////////////////////////////////////// -template -void ForceTest(Action &action,LatticeGaugeField & U,MomentumFilterBase &Filter) -{ - GridBase *UGrid = U.Grid(); - - std::vector seeds({1,2,3,5}); - GridSerialRNG sRNG; sRNG.SeedFixedIntegers(seeds); - GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds); - - LatticeColourMatrix Pmu(UGrid); - LatticeGaugeField P(UGrid); - LatticeGaugeField UdSdU(UGrid); - - std::cout << GridLogMessage << "*********************************************************"<(UdSdU,mu); - Pmu= PeekIndex(P,mu); - dS = dS - trace(Pmu*UdSdUmu)*eps*2.0*2.0; - } - ComplexD dSpred = sum(dS); - RealD diff = S2-S1-dSpred.real(); - - std::cout<< GridLogMessage << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<