mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-24 20:55:55 +01:00
Checking in fixed adaptive WilsonFlow
This commit is contained in:
parent
92def28bd3
commit
b284d50863
@ -6,7 +6,8 @@ Source file: ./lib/qcd/modules/plaquette.h
|
|||||||
|
|
||||||
Copyright (C) 2017
|
Copyright (C) 2017
|
||||||
|
|
||||||
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
||||||
|
Author: Chulwoo Jung <chulwoo@bnl.gov>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -35,7 +36,7 @@ template <class Gimpl>
|
|||||||
class WilsonFlow: public Smear<Gimpl>{
|
class WilsonFlow: public Smear<Gimpl>{
|
||||||
unsigned int Nstep;
|
unsigned int Nstep;
|
||||||
unsigned int measure_interval;
|
unsigned int measure_interval;
|
||||||
mutable RealD epsilon, taus;
|
mutable RealD epsilon, taus,tolerance;
|
||||||
|
|
||||||
|
|
||||||
mutable WilsonGaugeAction<Gimpl> SG;
|
mutable WilsonGaugeAction<Gimpl> SG;
|
||||||
@ -47,13 +48,15 @@ class WilsonFlow: public Smear<Gimpl>{
|
|||||||
public:
|
public:
|
||||||
INHERIT_GIMPL_TYPES(Gimpl)
|
INHERIT_GIMPL_TYPES(Gimpl)
|
||||||
|
|
||||||
explicit WilsonFlow(unsigned int Nstep, RealD epsilon, unsigned int interval = 1):
|
explicit WilsonFlow(unsigned int Nstep, RealD epsilon, unsigned int interval = 1, RealD tol = 1e-3):
|
||||||
Nstep(Nstep),
|
Nstep(Nstep),
|
||||||
epsilon(epsilon),
|
epsilon(epsilon),
|
||||||
|
tolerance(tol),
|
||||||
measure_interval(interval),
|
measure_interval(interval),
|
||||||
SG(WilsonGaugeAction<Gimpl>(3.0)) {
|
SG(WilsonGaugeAction<Gimpl>(3.0)) {
|
||||||
// WilsonGaugeAction with beta 3.0
|
// WilsonGaugeAction with beta 3.0
|
||||||
assert(epsilon > 0.0);
|
assert(epsilon > 0.0);
|
||||||
|
assert(tolerance > 0.0);
|
||||||
LogMessage();
|
LogMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +67,8 @@ public:
|
|||||||
<< "[WilsonFlow] epsilon : " << epsilon << std::endl;
|
<< "[WilsonFlow] epsilon : " << epsilon << std::endl;
|
||||||
std::cout << GridLogMessage
|
std::cout << GridLogMessage
|
||||||
<< "[WilsonFlow] full trajectory : " << Nstep * epsilon << std::endl;
|
<< "[WilsonFlow] full trajectory : " << Nstep * epsilon << std::endl;
|
||||||
|
std::cout << GridLogMessage
|
||||||
|
<< "[WilsonFlow] tolerance : " << tolerance << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void smear(GaugeField&, const GaugeField&) const;
|
virtual void smear(GaugeField&, const GaugeField&) const;
|
||||||
@ -106,11 +111,14 @@ void WilsonFlow<Gimpl>::evolve_step_adaptive(typename Gimpl::GaugeField &U, Real
|
|||||||
if (maxTau - taus < epsilon){
|
if (maxTau - taus < epsilon){
|
||||||
epsilon = maxTau-taus;
|
epsilon = maxTau-taus;
|
||||||
}
|
}
|
||||||
//std::cout << GridLogMessage << "Integration epsilon : " << epsilon << std::endl;
|
std::cout << GridLogMessage << "Integration epsilon : " << epsilon << std::endl;
|
||||||
GaugeField Z(U.Grid());
|
GaugeField Z(U.Grid());
|
||||||
GaugeField Zprime(U.Grid());
|
GaugeField Zprime(U.Grid());
|
||||||
GaugeField tmp(U.Grid()), Uprime(U.Grid());
|
GaugeField tmp(U.Grid()), Uprime(U.Grid()),Usave(U.Grid());
|
||||||
|
|
||||||
Uprime = U;
|
Uprime = U;
|
||||||
|
Usave = U;
|
||||||
|
|
||||||
SG.deriv(U, Z);
|
SG.deriv(U, Z);
|
||||||
Zprime = -Z;
|
Zprime = -Z;
|
||||||
Z *= 0.25; // Z0 = 1/4 * F(U)
|
Z *= 0.25; // Z0 = 1/4 * F(U)
|
||||||
@ -128,18 +136,33 @@ void WilsonFlow<Gimpl>::evolve_step_adaptive(typename Gimpl::GaugeField &U, Real
|
|||||||
Z *= 3.0/4.0; // Z = 17/36*Z0 -8/9*Z1 +3/4*Z2
|
Z *= 3.0/4.0; // Z = 17/36*Z0 -8/9*Z1 +3/4*Z2
|
||||||
Gimpl::update_field(Z, U, -2.0*epsilon); // V(t+e) = exp(ep*Z)*W2
|
Gimpl::update_field(Z, U, -2.0*epsilon); // V(t+e) = exp(ep*Z)*W2
|
||||||
|
|
||||||
// Ramos
|
// Ramos arXiv:1301.4388
|
||||||
Gimpl::update_field(Zprime, Uprime, -2.0*epsilon); // V'(t+e) = exp(ep*Z')*W0
|
Gimpl::update_field(Zprime, Uprime, -2.0*epsilon); // V'(t+e) = exp(ep*Z')*W0
|
||||||
// Compute distance as norm^2 of the difference
|
// Compute distance as norm^2 of the difference
|
||||||
GaugeField diffU = U - Uprime;
|
GaugeField diffU = U - Uprime;
|
||||||
RealD diff = norm2(diffU);
|
// Wrong
|
||||||
// adjust integration step
|
// RealD diff = norm2(diffU);
|
||||||
|
// std::cout << GridLogMessage << "norm2: " << diff << std::endl;
|
||||||
|
|
||||||
|
// RealD tol=1e-3;
|
||||||
|
|
||||||
|
RealD diff = real(rankInnerMax(diffU,diffU));
|
||||||
|
diff = sqrt(diff)/18.; // distance defined in Ramos
|
||||||
|
|
||||||
|
GridBase *grid = diffU.Grid();
|
||||||
|
std::cout << GridLogMessage << "max: " << diff << std::endl;
|
||||||
|
grid->GlobalMax(diff);
|
||||||
|
std::cout << GridLogMessage << "max: " << diff << std::endl;
|
||||||
|
|
||||||
|
if(diff < tolerance) {
|
||||||
taus += epsilon;
|
taus += epsilon;
|
||||||
//std::cout << GridLogMessage << "Adjusting integration step with distance: " << diff << std::endl;
|
// std::cout << GridLogMessage << "Adjusting integration step with distance: " << diff << std::endl;
|
||||||
|
} else {
|
||||||
|
U = Usave;
|
||||||
|
}
|
||||||
|
|
||||||
epsilon = epsilon*0.95*std::pow(1e-4/diff,1./3.);
|
epsilon = epsilon*0.95*std::pow(tolerance/diff,1./3.);
|
||||||
//std::cout << GridLogMessage << "New epsilon : " << epsilon << std::endl;
|
std::cout << GridLogMessage << "Distance : "<<diff<<"New epsilon : " << epsilon << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,8 +207,11 @@ void WilsonFlow<Gimpl>::smear(GaugeField& out, const GaugeField& in) const {
|
|||||||
template <class Gimpl>
|
template <class Gimpl>
|
||||||
void WilsonFlow<Gimpl>::smear_adaptive(GaugeField& out, const GaugeField& in, RealD maxTau){
|
void WilsonFlow<Gimpl>::smear_adaptive(GaugeField& out, const GaugeField& in, RealD maxTau){
|
||||||
out = in;
|
out = in;
|
||||||
taus = epsilon;
|
// taus = epsilon;
|
||||||
|
taus = 0.;
|
||||||
unsigned int step = 0;
|
unsigned int step = 0;
|
||||||
|
double measTau = epsilon*measure_interval;
|
||||||
|
std::cout << GridLogMessage << "measTau :"<< measTau << std::endl;
|
||||||
do{
|
do{
|
||||||
step++;
|
step++;
|
||||||
//std::cout << GridLogMessage << "Evolution time :"<< taus << std::endl;
|
//std::cout << GridLogMessage << "Evolution time :"<< taus << std::endl;
|
||||||
@ -193,10 +219,12 @@ void WilsonFlow<Gimpl>::smear_adaptive(GaugeField& out, const GaugeField& in, Re
|
|||||||
std::cout << GridLogMessage << "[WilsonFlow] Energy density (plaq) : "
|
std::cout << GridLogMessage << "[WilsonFlow] Energy density (plaq) : "
|
||||||
<< step << " " << taus << " "
|
<< step << " " << taus << " "
|
||||||
<< energyDensityPlaquette(out) << std::endl;
|
<< energyDensityPlaquette(out) << std::endl;
|
||||||
if( step % measure_interval == 0){
|
// if( step % measure_interval == 0){
|
||||||
|
if( taus > measTau ) {
|
||||||
std::cout << GridLogMessage << "[WilsonFlow] Top. charge : "
|
std::cout << GridLogMessage << "[WilsonFlow] Top. charge : "
|
||||||
<< step << " "
|
<< step << " "
|
||||||
<< WilsonLoops<PeriodicGimplR>::TopologicalCharge(out) << std::endl;
|
<< WilsonLoops<PeriodicGimplR>::TopologicalCharge(out) << std::endl;
|
||||||
|
measTau += epsilon*measure_interval;
|
||||||
}
|
}
|
||||||
} while (taus < maxTau);
|
} while (taus < maxTau);
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ namespace Grid{
|
|||||||
GRID_SERIALIZABLE_CLASS_MEMBERS(WFParameters,
|
GRID_SERIALIZABLE_CLASS_MEMBERS(WFParameters,
|
||||||
int, steps,
|
int, steps,
|
||||||
double, step_size,
|
double, step_size,
|
||||||
|
double, tol,
|
||||||
int, meas_interval,
|
int, meas_interval,
|
||||||
double, maxTau); // for the adaptive algorithm
|
double, maxTau); // for the adaptive algorithm
|
||||||
|
|
||||||
@ -82,13 +83,27 @@ int main(int argc, char **argv) {
|
|||||||
SU<Nc>::HotConfiguration(pRNG, Umu);
|
SU<Nc>::HotConfiguration(pRNG, Umu);
|
||||||
|
|
||||||
typedef Grid::XmlReader Serialiser;
|
typedef Grid::XmlReader Serialiser;
|
||||||
Serialiser Reader("input.xml");
|
// Serialiser Reader("input.xml");
|
||||||
WFParameters WFPar(Reader);
|
// WFParameters WFPar(Reader);
|
||||||
ConfParameters CPar(Reader);
|
// ConfParameters CPar(Reader);
|
||||||
CheckpointerParameters CPPar(CPar.conf_prefix, CPar.rng_prefix);
|
// WFParameters WFPar;
|
||||||
|
int steps = 800;
|
||||||
|
double step_size=0.02;
|
||||||
|
double tol=1e-4;
|
||||||
|
int meas_interval=50;
|
||||||
|
double maxTau = 16;
|
||||||
|
// ConfParameters CPar;
|
||||||
|
// CPar. conf_prefix="configurations/ckpoint_lat";
|
||||||
|
// CPar. rng_prefix="rngs/ckpoint_rng";
|
||||||
|
// CPar. StartConfiguration=100,
|
||||||
|
// CPar. EndConfiguration=110,
|
||||||
|
// CPar. Skip=1;
|
||||||
|
// CheckpointerParameters CPPar(CPar.conf_prefix, CPar.rng_prefix);
|
||||||
|
CheckpointerParameters CPPar("configurations/ckpoint_lat","rngs/ckpoint_rng");
|
||||||
BinaryHmcCheckpointer<PeriodicGimplR> CPBin(CPPar);
|
BinaryHmcCheckpointer<PeriodicGimplR> CPBin(CPPar);
|
||||||
|
|
||||||
for (int conf = CPar.StartConfiguration; conf <= CPar.EndConfiguration; conf+= CPar.Skip){
|
// for (int conf = CPar.StartConfiguration; conf <= CPar.EndConfiguration; conf+= CPar.Skip){
|
||||||
|
for (int conf = 100; conf <= 110; conf+= 1){
|
||||||
|
|
||||||
CPBin.CheckpointRestore(conf, Umu, sRNG, pRNG);
|
CPBin.CheckpointRestore(conf, Umu, sRNG, pRNG);
|
||||||
|
|
||||||
@ -96,9 +111,10 @@ int main(int argc, char **argv) {
|
|||||||
std::cout << GridLogMessage << "Initial plaquette: "
|
std::cout << GridLogMessage << "Initial plaquette: "
|
||||||
<< WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
|
<< WilsonLoops<PeriodicGimplR>::avgPlaquette(Umu) << std::endl;
|
||||||
|
|
||||||
WilsonFlow<PeriodicGimplR> WF(WFPar.steps, WFPar.step_size, WFPar.meas_interval);
|
WilsonFlow<PeriodicGimplR> WF(steps, step_size, meas_interval);
|
||||||
|
|
||||||
WF.smear_adaptive(Uflow, Umu, WFPar.maxTau);
|
// WF.smear_adaptive(Uflow, Umu, maxTau);
|
||||||
|
WF.smear(Uflow, Umu);
|
||||||
|
|
||||||
RealD WFlow_plaq = WilsonLoops<PeriodicGimplR>::avgPlaquette(Uflow);
|
RealD WFlow_plaq = WilsonLoops<PeriodicGimplR>::avgPlaquette(Uflow);
|
||||||
RealD WFlow_TC = WilsonLoops<PeriodicGimplR>::TopologicalCharge(Uflow);
|
RealD WFlow_TC = WilsonLoops<PeriodicGimplR>::TopologicalCharge(Uflow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user