Grid 0.7.0
topological_charge.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/modules/topological_charge.h
6
7Copyright (C) 2017
8
9Author: Guido Cossu <guido.cossu@ed.ac.uk>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
29
30#pragma once
31
33
34
35struct TopologySmearingParameters : Serializable {
37 int, meas_interval,
38 float, init_step_size,
39 float, maxTau,
40 float, tolerance);
41
42 TopologySmearingParameters(float ss = 0.0f, int mi = 0, float mT = 0.0f, float tol = 1e-4):
43 init_step_size(ss), meas_interval(mi), maxTau(mT), tolerance(tol){}
44
45 template < class ReaderClass >
46 TopologySmearingParameters(Reader<ReaderClass>& Reader){
47 read(Reader, "Smearing", *this);
48 }
49};
50
51
52
53struct TopologyObsParameters : Serializable {
55 int, interval,
56 bool, do_smearing,
58
59 TopologyObsParameters(int interval = 1, bool smearing = false):
60 interval(interval), Smearing(smearing){}
61
62 template <class ReaderClass >
63 TopologyObsParameters(Reader<ReaderClass>& Reader){
64 read(Reader, "TopologyMeasurement", *this);
65 }
66};
67
68
69// this is only defined for a gauge theory
70template <class Impl>
71class TopologicalCharge : public HmcObservable<typename Impl::Field> {
73
74public:
75 // here forces the Impl to be of gauge fields
76 // if not the compiler will complain
78
79 // necessary for HmcObservable compatibility
80 typedef typename Impl::Field Field;
81
82 TopologicalCharge(int interval = 1, bool do_smearing = false):
83 Pars(interval, do_smearing){}
84
86 std::cout << GridLogDebug << "Creating TopologicalCharge " << std::endl;
87 }
88
89 void TrajectoryComplete(int traj,
90 Field &U,
91 GridSerialRNG &sRNG,
92 GridParallelRNG &pRNG) {
93
94 if (traj%Pars.interval == 0){
95 // Smearing
96 Field Usmear = U;
97 int def_prec = std::cout.precision();
98
99 if (Pars.do_smearing){
100 // using wilson flow by default here
101 WilsonFlowAdaptive<PeriodicGimplR> WF(Pars.Smearing.init_step_size, Pars.Smearing.maxTau, Pars.Smearing.tolerance, Pars.Smearing.meas_interval);
102 WF.smear(Usmear, U);
103 Real T0 = WF.energyDensityPlaquette(Pars.Smearing.maxTau, Usmear);
104 std::cout << GridLogMessage << std::setprecision(std::numeric_limits<Real>::digits10 + 1)
105 << "T0 : [ " << traj << " ] "<< T0 << std::endl;
106 }
107
109 std::cout << GridLogMessage
110 << std::setprecision(std::numeric_limits<Real>::digits10 + 1)
111 << "Topological Charge: [ " << traj << " ] "<< q << std::endl;
112
113 std::cout.precision(def_prec);
114 }
115 }
116
117};
118
120
121
GridLogger GridLogDebug(1, "Debug", GridLogColours, "PURPLE")
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
RealF Real
Definition Simd.h:65
#define T0
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
TopologyObsParameters Pars
TopologicalCharge(int interval=1, bool do_smearing=false)
void TrajectoryComplete(int traj, Field &U, GridSerialRNG &sRNG, GridParallelRNG &pRNG)
TopologicalCharge(TopologyObsParameters P)
void smear(GaugeField &out, const GaugeField &in) const override
Definition WilsonFlow.h:347
static RealD energyDensityPlaquette(const RealD t, const GaugeField &U)
Definition WilsonFlow.h:156
static Real TopologicalCharge(const GaugeLorentz &U)
TopologyObsParameters(Reader< ReaderClass > &Reader)
GRID_SERIALIZABLE_CLASS_MEMBERS(TopologyObsParameters, int, interval, bool, do_smearing, TopologySmearingParameters, Smearing)
TopologyObsParameters(int interval=1, bool smearing=false)
TopologySmearingParameters(float ss=0.0f, int mi=0, float mT=0.0f, float tol=1e-4)
TopologySmearingParameters(Reader< ReaderClass > &Reader)
GRID_SERIALIZABLE_CLASS_MEMBERS(TopologySmearingParameters, int, meas_interval, float, init_step_size, float, maxTau, float, tolerance)