2016-07-12 13:36:10 +01:00
|
|
|
/*************************************************************************************
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
Source file: ./lib/qcd/hmc/HmcRunner.h
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
Copyright (C) 2015
|
2016-01-02 14:51:32 +00:00
|
|
|
|
|
|
|
Author: paboyle <paboyle@ph.ed.ac.uk>
|
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
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.
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
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.
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
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.
|
2016-01-02 14:51:32 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
See the full license in the file "LICENSE" in the top level distribution
|
|
|
|
directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2015-12-22 11:19:25 +00:00
|
|
|
#ifndef HMC_RUNNER
|
|
|
|
#define HMC_RUNNER
|
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
namespace Grid {
|
|
|
|
namespace QCD {
|
2015-12-22 11:19:25 +00:00
|
|
|
|
2016-10-03 15:28:00 +01:00
|
|
|
// Class for HMC specific for gauge theories
|
2016-07-15 13:39:47 +01:00
|
|
|
template <class Gimpl, class RepresentationsPolicy = NoHirep >
|
2016-01-02 13:37:25 +00:00
|
|
|
class NerscHmcRunnerTemplate {
|
2016-07-12 13:36:10 +01:00
|
|
|
public:
|
2016-01-02 13:37:25 +00:00
|
|
|
INHERIT_GIMPL_TYPES(Gimpl);
|
|
|
|
|
2015-12-22 11:19:25 +00:00
|
|
|
enum StartType_t { ColdStart, HotStart, TepidStart, CheckpointStart };
|
|
|
|
|
2016-09-23 10:47:42 +01:00
|
|
|
ActionSet<GaugeField, RepresentationsPolicy> TheAction;
|
2015-12-22 11:19:25 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
GridCartesian *UGrid;
|
|
|
|
GridCartesian *FGrid;
|
|
|
|
GridRedBlackCartesian *UrbGrid;
|
|
|
|
GridRedBlackCartesian *FrbGrid;
|
2015-12-22 11:19:25 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
virtual void BuildTheAction(int argc, char **argv) = 0; // necessary?
|
2015-12-22 11:19:25 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
void Run(int argc, char **argv) {
|
2015-12-22 11:19:25 +00:00
|
|
|
StartType_t StartType = HotStart;
|
|
|
|
|
|
|
|
std::string arg;
|
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
if (GridCmdOptionExists(argv, argv + argc, "--StartType")) {
|
|
|
|
arg = GridCmdOptionPayload(argv, argv + argc, "--StartType");
|
|
|
|
if (arg == "HotStart") {
|
|
|
|
StartType = HotStart;
|
|
|
|
} else if (arg == "ColdStart") {
|
|
|
|
StartType = ColdStart;
|
|
|
|
} else if (arg == "TepidStart") {
|
|
|
|
StartType = TepidStart;
|
|
|
|
} else if (arg == "CheckpointStart") {
|
|
|
|
StartType = CheckpointStart;
|
|
|
|
} else {
|
|
|
|
std::cout << GridLogError << "Unrecognized option in --StartType\n";
|
|
|
|
std::cout << GridLogError << "Valid [HotStart, ColdStart, TepidStart, CheckpointStart]\n";
|
|
|
|
assert(0);
|
|
|
|
}
|
2015-12-22 11:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int StartTraj = 0;
|
2016-07-12 13:36:10 +01:00
|
|
|
if (GridCmdOptionExists(argv, argv + argc, "--StartTrajectory")) {
|
|
|
|
arg = GridCmdOptionPayload(argv, argv + argc, "--StartTrajectory");
|
2015-12-22 11:19:25 +00:00
|
|
|
std::vector<int> ivec(0);
|
2016-07-12 13:36:10 +01:00
|
|
|
GridCmdOptionIntVector(arg, ivec);
|
2015-12-22 11:19:25 +00:00
|
|
|
StartTraj = ivec[0];
|
2016-07-12 13:36:10 +01:00
|
|
|
}
|
2015-12-22 11:19:25 +00:00
|
|
|
|
|
|
|
int NumTraj = 1;
|
2016-07-12 13:36:10 +01:00
|
|
|
if (GridCmdOptionExists(argv, argv + argc, "--Trajectories")) {
|
|
|
|
arg = GridCmdOptionPayload(argv, argv + argc, "--Trajectories");
|
2015-12-22 11:19:25 +00:00
|
|
|
std::vector<int> ivec(0);
|
2016-07-12 13:36:10 +01:00
|
|
|
GridCmdOptionIntVector(arg, ivec);
|
2015-12-22 11:19:25 +00:00
|
|
|
NumTraj = ivec[0];
|
|
|
|
}
|
|
|
|
|
2016-07-05 12:03:54 +01:00
|
|
|
int NumThermalizations = 10;
|
2016-07-12 13:36:10 +01:00
|
|
|
if (GridCmdOptionExists(argv, argv + argc, "--Thermalizations")) {
|
|
|
|
arg = GridCmdOptionPayload(argv, argv + argc, "--Thermalizations");
|
2016-07-05 12:03:54 +01:00
|
|
|
std::vector<int> ivec(0);
|
2016-07-12 13:36:10 +01:00
|
|
|
GridCmdOptionIntVector(arg, ivec);
|
2016-07-05 12:03:54 +01:00
|
|
|
NumThermalizations = ivec[0];
|
|
|
|
}
|
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
GridSerialRNG sRNG;
|
|
|
|
GridParallelRNG pRNG(UGrid);
|
2016-07-18 16:36:28 +01:00
|
|
|
LatticeGaugeField U(UGrid); // change this to an extended field (smearing class)?
|
2016-04-05 08:19:30 +01:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
std::vector<int> SerSeed({1, 2, 3, 4, 5});
|
|
|
|
std::vector<int> ParSeed({6, 7, 8, 9, 10});
|
2016-04-05 08:19:30 +01:00
|
|
|
|
|
|
|
// Create integrator, including the smearing policy
|
2016-07-28 16:44:41 +01:00
|
|
|
// Smearing policy, only defined for Nc=3
|
2016-08-08 16:54:22 +01:00
|
|
|
/*
|
2016-07-04 17:28:40 +01:00
|
|
|
std::cout << GridLogDebug << " Creating the Stout class\n";
|
2016-07-12 13:36:10 +01:00
|
|
|
double rho = 0.1; // smearing parameter, now hardcoded
|
|
|
|
int Nsmear = 1; // number of smearing levels
|
2016-04-06 09:58:43 +01:00
|
|
|
Smear_Stout<Gimpl> Stout(rho);
|
2016-07-04 17:28:40 +01:00
|
|
|
std::cout << GridLogDebug << " Creating the SmearedConfiguration class\n";
|
2016-07-31 12:37:33 +01:00
|
|
|
//SmearedConfiguration<Gimpl> SmearingPolicy(UGrid, Nsmear, Stout);
|
2016-07-04 17:28:40 +01:00
|
|
|
std::cout << GridLogDebug << " done\n";
|
2016-08-08 16:54:22 +01:00
|
|
|
*/
|
2016-04-06 09:58:43 +01:00
|
|
|
//////////////
|
2016-07-31 12:37:33 +01:00
|
|
|
NoSmearing<Gimpl> SmearingPolicy;
|
2016-10-03 15:28:00 +01:00
|
|
|
typedef MinimumNorm2<Gimpl, NoSmearing<Gimpl>, RepresentationsPolicy >
|
2016-07-12 13:36:10 +01:00
|
|
|
IntegratorType; // change here to change the algorithm
|
2016-11-09 12:11:03 +00:00
|
|
|
IntegratorParameters MDpar(40, 1.0);
|
2016-04-05 08:19:30 +01:00
|
|
|
IntegratorType MDynamics(UGrid, MDpar, TheAction, SmearingPolicy);
|
2015-12-22 11:19:25 +00:00
|
|
|
|
|
|
|
// Checkpoint strategy
|
2016-07-12 13:36:10 +01:00
|
|
|
NerscHmcCheckpointer<Gimpl> Checkpoint(std::string("ckpoint_lat"),
|
|
|
|
std::string("ckpoint_rng"), 1);
|
|
|
|
PlaquetteLogger<Gimpl> PlaqLog(std::string("plaq"));
|
2015-12-22 11:19:25 +00:00
|
|
|
|
|
|
|
HMCparameters HMCpar;
|
2016-07-12 13:36:10 +01:00
|
|
|
HMCpar.StartTrajectory = StartTraj;
|
|
|
|
HMCpar.Trajectories = NumTraj;
|
2016-07-05 12:03:54 +01:00
|
|
|
HMCpar.NoMetropolisUntil = NumThermalizations;
|
2015-12-22 11:19:25 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
if (StartType == HotStart) {
|
2015-12-22 11:19:25 +00:00
|
|
|
// Hot start
|
|
|
|
HMCpar.MetropolisTest = true;
|
|
|
|
sRNG.SeedFixedIntegers(SerSeed);
|
|
|
|
pRNG.SeedFixedIntegers(ParSeed);
|
2016-07-28 16:44:41 +01:00
|
|
|
SU<Nc>::HotConfiguration(pRNG, U);
|
2016-07-12 13:36:10 +01:00
|
|
|
} else if (StartType == ColdStart) {
|
2015-12-22 11:19:25 +00:00
|
|
|
// Cold start
|
|
|
|
HMCpar.MetropolisTest = true;
|
|
|
|
sRNG.SeedFixedIntegers(SerSeed);
|
|
|
|
pRNG.SeedFixedIntegers(ParSeed);
|
2016-07-28 16:44:41 +01:00
|
|
|
SU<Nc>::ColdConfiguration(pRNG, U);
|
2016-07-12 13:36:10 +01:00
|
|
|
} else if (StartType == TepidStart) {
|
2015-12-22 11:19:25 +00:00
|
|
|
// Tepid start
|
|
|
|
HMCpar.MetropolisTest = true;
|
|
|
|
sRNG.SeedFixedIntegers(SerSeed);
|
|
|
|
pRNG.SeedFixedIntegers(ParSeed);
|
2016-07-28 16:44:41 +01:00
|
|
|
SU<Nc>::TepidConfiguration(pRNG, U);
|
2016-07-12 13:36:10 +01:00
|
|
|
} else if (StartType == CheckpointStart) {
|
2015-12-22 11:19:25 +00:00
|
|
|
HMCpar.MetropolisTest = true;
|
|
|
|
// CheckpointRestart
|
|
|
|
Checkpoint.CheckpointRestore(StartTraj, U, sRNG, pRNG);
|
|
|
|
}
|
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
// Attach the gauge field to the smearing Policy and create the fill the
|
|
|
|
// smeared set
|
2016-04-05 08:19:30 +01:00
|
|
|
// notice that the unit configuration is singular in this procedure
|
2016-07-12 13:36:10 +01:00
|
|
|
std::cout << GridLogMessage << "Filling the smeared set\n";
|
2016-10-03 15:28:00 +01:00
|
|
|
SmearingPolicy.set_Field(U);
|
2016-07-12 13:36:10 +01:00
|
|
|
|
2016-10-03 15:28:00 +01:00
|
|
|
HybridMonteCarlo<IntegratorType> HMC(HMCpar, MDynamics, sRNG, pRNG, U);
|
2015-12-22 11:19:25 +00:00
|
|
|
HMC.AddObservable(&Checkpoint);
|
|
|
|
HMC.AddObservable(&PlaqLog);
|
2016-07-12 13:36:10 +01:00
|
|
|
|
2015-12-22 11:19:25 +00:00
|
|
|
// Run it
|
|
|
|
HMC.evolve();
|
|
|
|
}
|
|
|
|
};
|
2016-01-02 13:37:25 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
typedef NerscHmcRunnerTemplate<PeriodicGimplR> NerscHmcRunner;
|
|
|
|
typedef NerscHmcRunnerTemplate<PeriodicGimplF> NerscHmcRunnerF;
|
|
|
|
typedef NerscHmcRunnerTemplate<PeriodicGimplD> NerscHmcRunnerD;
|
2016-01-02 13:37:25 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
typedef NerscHmcRunnerTemplate<PeriodicGimplR> PeriodicNerscHmcRunner;
|
|
|
|
typedef NerscHmcRunnerTemplate<PeriodicGimplF> PeriodicNerscHmcRunnerF;
|
|
|
|
typedef NerscHmcRunnerTemplate<PeriodicGimplD> PeriodicNerscHmcRunnerD;
|
2016-01-02 13:37:25 +00:00
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
typedef NerscHmcRunnerTemplate<ConjugateGimplR> ConjugateNerscHmcRunner;
|
|
|
|
typedef NerscHmcRunnerTemplate<ConjugateGimplF> ConjugateNerscHmcRunnerF;
|
|
|
|
typedef NerscHmcRunnerTemplate<ConjugateGimplD> ConjugateNerscHmcRunnerD;
|
2016-07-15 13:39:47 +01:00
|
|
|
|
|
|
|
template <class RepresentationsPolicy>
|
|
|
|
using NerscHmcRunnerHirep = NerscHmcRunnerTemplate<PeriodicGimplR, RepresentationsPolicy>;
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-12 13:36:10 +01:00
|
|
|
}
|
|
|
|
}
|
2015-12-22 11:19:25 +00:00
|
|
|
#endif
|