From db14fb30df901c5e6bb445a2c59a55bf28ac75d5 Mon Sep 17 00:00:00 2001 From: Lanny91 Date: Fri, 28 Apr 2017 16:48:00 +0100 Subject: [PATCH] Hadrons: overhaul of conserved current test --- tests/hadrons/Test_hadrons.hpp | 125 +++++++++++++++++- .../hadrons/Test_hadrons_conserved_current.cc | 54 ++++---- 2 files changed, 145 insertions(+), 34 deletions(-) diff --git a/tests/hadrons/Test_hadrons.hpp b/tests/hadrons/Test_hadrons.hpp index 26d02a5c..c4dcedaf 100644 --- a/tests/hadrons/Test_hadrons.hpp +++ b/tests/hadrons/Test_hadrons.hpp @@ -40,6 +40,7 @@ using namespace Hadrons; #define LABEL_3PT(s, t1, t2) ADD_INDEX(INIT_INDEX(s, t1), t2) #define LABEL_4PT(s, t1, t2, t3) ADD_INDEX(ADD_INDEX(INIT_INDEX(s, t1), t2), t3) #define LABEL_4PT_NOISE(s, t1, t2, t3, nn) ADD_INDEX(ADD_INDEX(ADD_INDEX(INIT_INDEX(s, t1), t2), t3), nn) +#define LABEL_5D(s) s + "_5d"; // Wall source/sink macros #define NAME_3MOM_WALL_SOURCE(t, mom) ("wall_" + std::to_string(t) + "_" + mom) @@ -123,6 +124,44 @@ inline void makeSequentialSource(Application &application, std::string srcName, } } +/******************************************************************************* + * Name: makeConservedSequentialSource + * Purpose: Construct sequential source with conserved current insertion and + * add to application module. + * Parameters: application - main application that stores modules. + * srcName - name of source module to create. + * qSrc - Input quark for sequential inversion. + * actionName - action corresponding to quark. + * tS - sequential source timeslice. + * curr - conserved current type to insert. + * mu - Lorentz index of current to insert. + * mom - momentum insertion (default is zero). + * Returns: None. + ******************************************************************************/ +inline void makeConservedSequentialSource(Application &application, + std::string &srcName, + std::string &qSrc, + std::string &actionName, + unsigned int tS, + Current curr, + unsigned int mu, + std::string mom = ZERO_MOM) +{ + // If the source already exists, don't make the module again. + if (!(Environment::getInstance().hasModule(srcName))) + { + MSource::SeqConserved::Par seqPar; + seqPar.q = qSrc; + seqPar.action = actionName; + seqPar.tA = tS; + seqPar.tB = tS; + seqPar.curr_type = curr; + seqPar.mu = mu; + seqPar.mom = mom; + application.createModule(srcName, seqPar); + } +} + /******************************************************************************* * Name: makeWallSource * Purpose: Construct wall source and add to application module. @@ -132,7 +171,7 @@ inline void makeSequentialSource(Application &application, std::string srcName, * mom - momentum insertion (default is zero). * Returns: None. ******************************************************************************/ -inline void makeWallSource(Application &application, std::string srcName, +inline void makeWallSource(Application &application, std::string &srcName, unsigned int tW, std::string mom = ZERO_MOM) { // If the source already exists, don't make the module again. @@ -154,8 +193,8 @@ inline void makeWallSource(Application &application, std::string srcName, * mom - momentum insertion (default is zero). * Returns: None. ******************************************************************************/ -inline void makeWallSink(Application &application, std::string propName, - std::string wallName, std::string mom = ZERO_MOM) +inline void makeWallSink(Application &application, std::string &propName, + std::string &wallName, std::string mom = ZERO_MOM) { // If the propagator has already been smeared, don't smear it again. // Temporarily removed, strategy for sink smearing likely to change. @@ -365,4 +404,82 @@ inline void discLoopContraction(Application &application, discPar.gamma = gamma; application.createModule(modName, discPar); } - } +} + +/******************************************************************************* + * Name: makeWITest + * Purpose: Create module to test Ward Identities for conserved current + * contractions and add to application module. + * Parameters: application - main application that stores modules. + * modName - name of module to create. + * propName - 4D quark propagator. + * actionName - action used to compute quark propagator. + * mass - mass of quark. + * Ls - length of 5th dimension (default = 1). + * Returns: None. + ******************************************************************************/ +inline void makeWITest(Application &application, std::string &modName, + std::string &propName, std::string &actionName, + double mass, unsigned int Ls = 1) +{ + if (!(Environment::getInstance().hasModule(modName))) + { + MContraction::WardIdentity::Par wiPar; + if (Ls > 1) + { + wiPar.q = LABEL_5D(propName); + } + else + { + wiPar.q = propName; + } + wiPar.q4d = propName; + wiPar.action = actionName; + wiPar.mass = mass; + application.createModule(modName, wiPar); + } +} + +/******************************************************************************* + * Name: makeSeqTest + * Purpose: Create module to test sequential insertion of conserved current + * and add to application module. + * Parameters: application - main application that stores modules. + * modName - name of module to create. + * propName - 4D quark propagator. + * seqProp - 4D quark propagator with sequential insertion of + * conserved current. + * actionName - action used to compute quark propagators. + * t_J - time at which sequential current is inserted. + * mu - Lorentz index of sequential current. + * curr - type of conserved current inserted. + * Ls - length of 5th dimension (default = 1). + * Returns: None. + ******************************************************************************/ +inline void makeSeqTest(Application &application, std::string &modName, + std::string &propName, std::string &seqName, + std::string &actionName, std::string &origin, + unsigned int t_J, unsigned int mu, Current curr, + unsigned int Ls = 1) +{ + if (!(Environment::getInstance().hasModule(modName))) + { + MUtilities::TestSeqConserved::Par seqPar; + if (Ls > 1) + { + seqPar.q = LABEL_5D(propName); + } + else + { + seqPar.q = propName; + } + seqPar.q4d = propName; + seqPar.qSeq = seqName; + seqPar.action = actionName; + seqPar.origin = origin; + seqPar.t_J = t_J; + seqPar.mu = mu; + seqPar.curr = curr; + application.createModule(modName, seqPar); + } +} diff --git a/tests/hadrons/Test_hadrons_conserved_current.cc b/tests/hadrons/Test_hadrons_conserved_current.cc index df774ac0..a11a3530 100644 --- a/tests/hadrons/Test_hadrons_conserved_current.cc +++ b/tests/hadrons/Test_hadrons_conserved_current.cc @@ -45,6 +45,7 @@ int main(int argc, char *argv[]) Application application; unsigned int nt = GridDefaultLatt()[Tp]; double mass = 0.04; + unsigned int Ls = 12; // global parameters Application::GlobalPar globalPar; @@ -65,7 +66,7 @@ int main(int argc, char *argv[]) std::string actionName = "DWF"; MAction::DWF::Par actionPar; actionPar.gauge = "gauge"; - actionPar.Ls = 12; + actionPar.Ls = Ls; actionPar.M5 = 1.8; actionPar.mass = mass; application.createModule(actionName, actionPar); @@ -83,37 +84,30 @@ int main(int argc, char *argv[]) std::string pos = "0 0 0 0"; std::string modName = "Ward Identity Test"; MAKE_POINT_PROP(pos, pointProp, solverName); - if (!(Environment::getInstance().hasModule(modName))) - { - MContraction::WardIdentity::Par wiPar; - wiPar.q = pointProp + "_5d"; - wiPar.q4d = pointProp; - wiPar.action = actionName; - wiPar.mass = mass; - application.createModule(modName, wiPar); - } + makeWITest(application, modName, pointProp, actionName, mass, Ls); - // Conserved current contractions with sequential insertion of vector + // Conserved current contractions with sequential insertion of vector/axial // current. - std::string q_x = "q_x"; - std::string q_y = "q_y"; - std::string q_z = "q_z"; - std::string q_t = "q_t"; - std::string mom = ZERO_MOM; - modName = "Sequential Ward Identity Test"; - MAKE_SEQUENTIAL_PROP(nt/2, pointProp, mom, q_x, solverName); - MAKE_SEQUENTIAL_PROP(nt/2, pointProp, mom, q_y, solverName); - MAKE_SEQUENTIAL_PROP(nt/2, pointProp, mom, q_z, solverName); - MAKE_SEQUENTIAL_PROP(nt/2, pointProp, mom, q_t, solverName); - if (!(Environment::getInstance().hasModule(modName))) - { - MContraction::WardIdentitySeq::Par wiPar; - wiPar.q_x = q_x; - wiPar.q_y = q_y; - wiPar.q_z = q_z; - wiPar.q_t = q_t; - application.createModule(modName, wiPar); - } + std::string mom = ZERO_MOM; + unsigned int t_J = nt/2; + std::string seqPropA = ADD_INDEX(pointProp + "_seq_A", t_J); + std::string seqPropV = ADD_INDEX(pointProp + "_seq_V", t_J); + std::string seqSrcA = seqPropA + "_src"; + std::string seqSrcV = seqPropV + "_src"; + std::string point5d = LABEL_5D(pointProp); + makeConservedSequentialSource(application, seqSrcA, point5d, + actionName, t_J, Current::Axial, Tp, mom); + makePropagator(application, seqPropA, seqSrcA, solverName); + makeConservedSequentialSource(application, seqSrcV, point5d, + actionName, t_J, Current::Vector, Tp, mom); + makePropagator(application, seqPropV, seqSrcV, solverName); + + std::string modNameA = "Axial Sequential Test"; + std::string modNameV = "Vector Sequential Test"; + makeSeqTest(application, modNameA, pointProp, seqPropA, + actionName, pos, t_J, Tp, Current::Axial, Ls); + makeSeqTest(application, modNameV, pointProp, seqPropV, + actionName, pos, t_J, Tp, Current::Vector, Ls); // execution application.saveParameterFile("ConservedCurrentTest.xml");