From 496d1b914ad5745ae1956df6b722651c15440630 Mon Sep 17 00:00:00 2001 From: Alexis Provatas Date: Thu, 10 Apr 2025 15:58:04 +0100 Subject: [PATCH 1/6] Generalise Polyakov loop and overload for temporal direction --- Grid/qcd/utils/WilsonLoops.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Grid/qcd/utils/WilsonLoops.h b/Grid/qcd/utils/WilsonLoops.h index 7466f4bf..49034486 100644 --- a/Grid/qcd/utils/WilsonLoops.h +++ b/Grid/qcd/utils/WilsonLoops.h @@ -177,9 +177,11 @@ public: } ////////////////////////////////////////////////// - // average over all x,y,z the temporal loop + // average Polyakov loop in any direction (spatial or temporal) ////////////////////////////////////////////////// - static ComplexD avgPolyakovLoop(const GaugeField &Umu) { //assume Nd=4 + static ComplexD avgPolyakovLoop(const GaugeField &Umu, const int mu) { //assume Nd=4 + + // TODO: Protect against mu<0 || mu>=4 GaugeMat Ut(Umu.Grid()), P(Umu.Grid()); ComplexD out; int T = Umu.Grid()->GlobalDimensions()[3]; @@ -187,15 +189,25 @@ public: int Y = Umu.Grid()->GlobalDimensions()[1]; int Z = Umu.Grid()->GlobalDimensions()[2]; - Ut = peekLorentz(Umu,3); //Select temporal direction + // Number of sites in mu direction + int L = Umu.Grid()->GlobalDimensions()[mu]; + + Ut = peekLorentz(Umu, mu); //Select direction P = Ut; - for (int t=1;t Date: Thu, 10 Apr 2025 16:35:49 +0100 Subject: [PATCH 2/6] Create Spatial Polyakov Observable Module --- Grid/qcd/modules/ObservableModules.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Grid/qcd/modules/ObservableModules.h b/Grid/qcd/modules/ObservableModules.h index 87fcbb92..cda86185 100644 --- a/Grid/qcd/modules/ObservableModules.h +++ b/Grid/qcd/modules/ObservableModules.h @@ -103,6 +103,18 @@ class PolyakovMod: public ObservableModule, NoParameters>{ PolyakovMod(): ObsBase(NoParameters()){} }; +template < class Impl > +class SpatialPolyakovMod: public ObservableModule, NoParameters>{ + typedef ObservableModule, NoParameters> ObsBase; + using ObsBase::ObsBase; // for constructors + + // acquire resource + virtual void initialize(){ + this->ObservablePtr.reset(new SpatialPolyakovLogger()); + } + public: + SpatialPolyakovMod(): ObsBase(NoParameters()){} +}; template < class Impl > class TopologicalChargeMod: public ObservableModule, TopologyObsParameters>{ From cb7110f4923c88f19320aa6ead82021c8d2f699a Mon Sep 17 00:00:00 2001 From: Alexis Provatas Date: Thu, 10 Apr 2025 16:38:13 +0100 Subject: [PATCH 3/6] Add Spatial Polyakov Loop observable --- Grid/qcd/observables/spatial_polyakov_loop.h | 74 ++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Grid/qcd/observables/spatial_polyakov_loop.h diff --git a/Grid/qcd/observables/spatial_polyakov_loop.h b/Grid/qcd/observables/spatial_polyakov_loop.h new file mode 100644 index 00000000..1c9db17b --- /dev/null +++ b/Grid/qcd/observables/spatial_polyakov_loop.h @@ -0,0 +1,74 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: ./lib/qcd/modules/polyakov_line.h + +Copyright (C) 2017 + +Author: David Preti + +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 */ + +#pragma once + +NAMESPACE_BEGIN(Grid); + +// this is only defined for a gauge theory +template +class SpatialPolyakovLogger : public HmcObservable { + public: + // here forces the Impl to be of gauge fields + // if not the compiler will complain + INHERIT_GIMPL_TYPES(Impl); + + // necessary for HmcObservable compatibility + typedef typename Impl::Field Field; + + void TrajectoryComplete(int traj, + Field &U, + GridSerialRNG &sRNG, + GridParallelRNG &pRNG) { + + // Save current numerical output precision + int def_prec = std::cout.precision(); + + // Assume that the dimensions are D=3+1 + int Ndim = 3; + ComplexD polyakov; + + // Iterate over the spatial directions and print the average spatial polyakov loop + // over them + for (int idx=0; idx::avgPolyakovLoop(U, idx); + + std::cout << GridLogMessage + << std::setprecision(std::numeric_limits::digits10 + 1) + << "Polyakov Loop in the " << idx << " spatial direction : [ " << traj << " ] "<< polyakov << std::endl; + + } + + // Return to original output precision + std::cout.precision(def_prec); + + } +}; + +NAMESPACE_END(Grid); From 7b9415c08844331b8371bbd968f5888d42354834 Mon Sep 17 00:00:00 2001 From: Alexis Provatas Date: Fri, 11 Apr 2025 16:55:46 +0100 Subject: [PATCH 4/6] Move observable logger to Polyakov Loop file and fix docstring --- Grid/qcd/observables/polyakov_loop.h | 44 ++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/Grid/qcd/observables/polyakov_loop.h b/Grid/qcd/observables/polyakov_loop.h index 0b59f549..57812ff6 100644 --- a/Grid/qcd/observables/polyakov_loop.h +++ b/Grid/qcd/observables/polyakov_loop.h @@ -2,11 +2,12 @@ Grid physics library, www.github.com/paboyle/Grid -Source file: ./lib/qcd/modules/polyakov_line.h +Source file: ./Grid/qcd/observables/polyakov_loop.h -Copyright (C) 2017 +Copyright (C) 2025 Author: David Preti +Author: Alexis Verney-Provatas <2414441@swansea.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 @@ -60,4 +61,43 @@ class PolyakovLogger : public HmcObservable { } }; +template +class SpatialPolyakovLogger : public HmcObservable { + public: + // here forces the Impl to be of gauge fields + // if not the compiler will complain + INHERIT_GIMPL_TYPES(Impl); + + // necessary for HmcObservable compatibility + typedef typename Impl::Field Field; + + void TrajectoryComplete(int traj, + Field &U, + GridSerialRNG &sRNG, + GridParallelRNG &pRNG) { + + // Save current numerical output precision + int def_prec = std::cout.precision(); + + // Assume that the dimensions are D=3+1 + int Ndim = 3; + ComplexD polyakov; + + // Iterate over the spatial directions and print the average spatial polyakov loop + // over them + for (int idx=0; idx::avgPolyakovLoop(U, idx); + + std::cout << GridLogMessage + << std::setprecision(std::numeric_limits::digits10 + 1) + << "Polyakov Loop in the " << idx << " spatial direction : [ " << traj << " ] "<< polyakov << std::endl; + + } + + // Return to original output precision + std::cout.precision(def_prec); + + } +}; + NAMESPACE_END(Grid); From a2b98d82e1c6a3cb31e0aae1bfb583b83284a89f Mon Sep 17 00:00:00 2001 From: Alexis Provatas Date: Fri, 11 Apr 2025 16:56:46 +0100 Subject: [PATCH 5/6] remove obsolete spatial polyakov observable file --- Grid/qcd/observables/spatial_polyakov_loop.h | 74 -------------------- 1 file changed, 74 deletions(-) delete mode 100644 Grid/qcd/observables/spatial_polyakov_loop.h diff --git a/Grid/qcd/observables/spatial_polyakov_loop.h b/Grid/qcd/observables/spatial_polyakov_loop.h deleted file mode 100644 index 1c9db17b..00000000 --- a/Grid/qcd/observables/spatial_polyakov_loop.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************************* - -Grid physics library, www.github.com/paboyle/Grid - -Source file: ./lib/qcd/modules/polyakov_line.h - -Copyright (C) 2017 - -Author: David Preti - -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 */ - -#pragma once - -NAMESPACE_BEGIN(Grid); - -// this is only defined for a gauge theory -template -class SpatialPolyakovLogger : public HmcObservable { - public: - // here forces the Impl to be of gauge fields - // if not the compiler will complain - INHERIT_GIMPL_TYPES(Impl); - - // necessary for HmcObservable compatibility - typedef typename Impl::Field Field; - - void TrajectoryComplete(int traj, - Field &U, - GridSerialRNG &sRNG, - GridParallelRNG &pRNG) { - - // Save current numerical output precision - int def_prec = std::cout.precision(); - - // Assume that the dimensions are D=3+1 - int Ndim = 3; - ComplexD polyakov; - - // Iterate over the spatial directions and print the average spatial polyakov loop - // over them - for (int idx=0; idx::avgPolyakovLoop(U, idx); - - std::cout << GridLogMessage - << std::setprecision(std::numeric_limits::digits10 + 1) - << "Polyakov Loop in the " << idx << " spatial direction : [ " << traj << " ] "<< polyakov << std::endl; - - } - - // Return to original output precision - std::cout.precision(def_prec); - - } -}; - -NAMESPACE_END(Grid); From c646d915270a76c7967b367e4c3d913cecd5f52b Mon Sep 17 00:00:00 2001 From: Alexis Provatas Date: Fri, 11 Apr 2025 17:15:36 +0100 Subject: [PATCH 6/6] Fix names, protect against bad index values, clean docstrings --- Grid/qcd/utils/WilsonLoops.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Grid/qcd/utils/WilsonLoops.h b/Grid/qcd/utils/WilsonLoops.h index 49034486..a6ebe80c 100644 --- a/Grid/qcd/utils/WilsonLoops.h +++ b/Grid/qcd/utils/WilsonLoops.h @@ -177,12 +177,18 @@ public: } ////////////////////////////////////////////////// - // average Polyakov loop in any direction (spatial or temporal) + // average Polyakov loop in mu direction over all directions != mu ////////////////////////////////////////////////// static ComplexD avgPolyakovLoop(const GaugeField &Umu, const int mu) { //assume Nd=4 - // TODO: Protect against mu<0 || mu>=4 - GaugeMat Ut(Umu.Grid()), P(Umu.Grid()); + // Protect against bad value of mu [0, 3] + if ((mu < 0 ) || (mu > 3)) { + std::cout << GridLogError << "Index is not an integer inclusively between 0 and 3." << std::endl; + exit(1); + } + + // U_loop is U_{mu} + GaugeMat U_loop(Umu.Grid()), P(Umu.Grid()); ComplexD out; int T = Umu.Grid()->GlobalDimensions()[3]; int X = Umu.Grid()->GlobalDimensions()[0]; @@ -190,12 +196,12 @@ public: int Z = Umu.Grid()->GlobalDimensions()[2]; // Number of sites in mu direction - int L = Umu.Grid()->GlobalDimensions()[mu]; + int N_mu = Umu.Grid()->GlobalDimensions()[mu]; - Ut = peekLorentz(Umu, mu); //Select direction - P = Ut; - for (int t=1;t