1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-15 10:15:36 +00:00
Grid/tests/smearing/Test_WilsonFlow.cc

156 lines
4.7 KiB
C++
Raw Normal View History

2017-03-21 07:11:35 +00:00
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: ./tests/hmc/Test_WilsonFlow.cc
Copyright (C) 2017
Author: Guido Cossu <guido.cossu@ed.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
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 */
#include <Grid/Grid.h>
2017-05-27 18:03:49 +01:00
namespace Grid{
struct WFParameters: Serializable {
GRID_SERIALIZABLE_CLASS_MEMBERS(WFParameters,
int, steps,
double, step_size,
int, meas_interval,
double, maxTau); // for the adaptive algorithm
2017-05-27 18:03:49 +01:00
template <class ReaderClass >
WFParameters(Reader<ReaderClass>& Reader){
read(Reader, "WilsonFlow", *this);
}
};
struct ConfParameters: Serializable {
GRID_SERIALIZABLE_CLASS_MEMBERS(ConfParameters,
std::string, conf_prefix,
std::string, rng_prefix,
int, StartConfiguration,
int, EndConfiguration,
int, Skip);
template <class ReaderClass >
ConfParameters(Reader<ReaderClass>& Reader){
read(Reader, "Configurations", *this);
}
};
}
2017-03-21 07:11:35 +00:00
int main(int argc, char **argv) {
using namespace Grid;
;
2017-03-21 07:11:35 +00:00
Grid_init(&argc, &argv);
GridLogLayout();
auto latt_size = GridDefaultLatt();
auto simd_layout = GridDefaultSimd(Nd, vComplex::Nsimd());
auto mpi_layout = GridDefaultMpi();
2017-03-21 07:11:35 +00:00
GridCartesian Grid(latt_size, simd_layout, mpi_layout);
2017-06-22 08:14:34 +01:00
GridRedBlackCartesian RBGrid(&Grid);
2017-03-21 07:11:35 +00:00
std::vector<int> seeds({1, 2, 3, 4, 5});
GridSerialRNG sRNG;
2017-03-21 07:11:35 +00:00
GridParallelRNG pRNG(&Grid);
pRNG.SeedFixedIntegers(seeds);
LatticeGaugeField Umu(&Grid), Uflow(&Grid);
SU<Nc>::HotConfiguration(pRNG, Umu);
2017-05-27 18:03:49 +01:00
typedef Grid::XmlReader Serialiser;
Serialiser Reader("input.xml");
2017-05-27 18:03:49 +01:00
WFParameters WFPar(Reader);
ConfParameters CPar(Reader);
CheckpointerParameters CPPar(CPar.conf_prefix, CPar.rng_prefix);
BinaryHmcCheckpointer<PeriodicGimplR> CPBin(CPPar);
2017-05-27 18:03:49 +01:00
for (int conf = CPar.StartConfiguration; conf <= CPar.EndConfiguration; conf+= CPar.Skip){
CPBin.CheckpointRestore(conf, Umu, sRNG, pRNG);
2017-03-21 07:11:35 +00:00
std::cout << std::setprecision(15);
2017-05-27 18:03:49 +01:00
std::cout << GridLogMessage << "Initial plaquette: "
2017-03-21 07:11:35 +00:00
<< WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
2022-11-17 01:15:51 +00:00
int t=WFPar.maxTau;
WilsonFlowAdaptive<PeriodicGimplR> WF(WFPar.step_size, WFPar.maxTau,
1.0e-4,
WFPar.meas_interval);
2017-03-21 07:11:35 +00:00
2022-11-17 01:15:51 +00:00
WF.smear(Uflow, Umu);
2017-03-21 07:11:35 +00:00
RealD WFlow_plaq = WilsonLoops<PeriodicGimplR>::avgPlaquette(Uflow);
RealD WFlow_TC = WilsonLoops<PeriodicGimplR>::TopologicalCharge(Uflow);
2022-11-17 01:15:51 +00:00
RealD WFlow_T0 = WF.energyDensityPlaquette(t,Uflow);
2017-05-27 18:03:49 +01:00
std::cout << GridLogMessage << "Plaquette "<< conf << " " << WFlow_plaq << std::endl;
std::cout << GridLogMessage << "T0 "<< conf << " " << WFlow_T0 << std::endl;
2017-05-27 18:03:49 +01:00
std::cout << GridLogMessage << "TopologicalCharge "<< conf << " " << WFlow_TC << std::endl;
2017-03-21 07:11:35 +00:00
std::cout<< GridLogMessage << " Admissibility check:\n";
const double sp_adm = 0.067; // admissible threshold
const double pl_adm = 1.0-sp_adm/Nc;
std::cout << GridLogMessage << " (pl_adm =" << pl_adm << ")\n";
// Need min and reduce min for this function
//double sp_max = NC_*(1.0-stpl.plaq_min(U,pl_adm));
double sp_ave = Nc*(1.0-WFlow_plaq);
//std::cout<< GridLogMessage << " sp_max = " << sp_max <<"\n";
std::cout<< GridLogMessage << " sp_ave = " << sp_ave <<"\n";
std::cout<< GridLogMessage << " (sp_admissible = "<< sp_adm <<")\n";
//std::cout<< GridLogMessage << " sp_admissible - sp_max = "<<sp_adm-sp_max <<"\n";
std::cout<< GridLogMessage << " sp_admissible - sp_ave = "<<sp_adm-sp_ave <<"\n";
2017-05-27 18:03:49 +01:00
}
2017-03-21 07:11:35 +00:00
Grid_finalize();
} // main
/*
Input file example
JSON
{
"WilsonFlow":{
"steps": 200,
"step_size": 0.01,
"meas_interval": 50,
"maxTau": 2.0
},
"Configurations":{
"conf_prefix": "ckpoint_lat",
"rng_prefix": "ckpoint_rng",
"StartConfiguration": 3000,
"EndConfiguration": 3000,
"Skip": 5
}
}
2017-06-22 08:14:34 +01:00
*/