mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 21:50:45 +01:00
Adding external file support in the Mobius example (JSON)
This commit is contained in:
parent
74f451715f
commit
7bd31e3f7c
@ -29,6 +29,52 @@ directory
|
|||||||
/* END LEGAL */
|
/* END LEGAL */
|
||||||
#include <Grid/Grid.h>
|
#include <Grid/Grid.h>
|
||||||
|
|
||||||
|
namespace Grid{
|
||||||
|
struct FermionParameters: Serializable {
|
||||||
|
GRID_SERIALIZABLE_CLASS_MEMBERS(FermionParameters,
|
||||||
|
int, Ls,
|
||||||
|
double, mass,
|
||||||
|
double, M5,
|
||||||
|
double, b,
|
||||||
|
double, c,
|
||||||
|
double, StoppingCondition,
|
||||||
|
int, MaxCGIterations,
|
||||||
|
bool, ApplySmearing);
|
||||||
|
|
||||||
|
//template <class ReaderClass >
|
||||||
|
//FermionParameters(Reader<ReaderClass>& Reader){
|
||||||
|
// read(Reader, "Mobius", *this);
|
||||||
|
//}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct MobiusHMCParameters: Serializable {
|
||||||
|
GRID_SERIALIZABLE_CLASS_MEMBERS(MobiusHMCParameters,
|
||||||
|
double, gauge_beta,
|
||||||
|
FermionParameters, Mobius)
|
||||||
|
|
||||||
|
template <class ReaderClass >
|
||||||
|
MobiusHMCParameters(Reader<ReaderClass>& Reader){
|
||||||
|
read(Reader, "Action", *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SmearingParameters: Serializable {
|
||||||
|
GRID_SERIALIZABLE_CLASS_MEMBERS(SmearingParameters,
|
||||||
|
double, rho,
|
||||||
|
Integer, Nsmear)
|
||||||
|
|
||||||
|
template <class ReaderClass >
|
||||||
|
SmearingParameters(Reader<ReaderClass>& Reader){
|
||||||
|
read(Reader, "StoutSmearing", *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@ -46,8 +92,15 @@ int main(int argc, char **argv) {
|
|||||||
typedef MobiusFermionR FermionAction;
|
typedef MobiusFermionR FermionAction;
|
||||||
typedef typename FermionAction::FermionField FermionField;
|
typedef typename FermionAction::FermionField FermionField;
|
||||||
|
|
||||||
|
// Serialiser
|
||||||
|
//typedef Grid::XmlReader Serialiser;
|
||||||
|
typedef Grid::JSONReader Serialiser;
|
||||||
|
// Reader, file should come from command line
|
||||||
|
Serialiser Reader("input.json");
|
||||||
|
|
||||||
|
MobiusHMCParameters MyParams(Reader);
|
||||||
// Apply smearing to the fermionic action
|
// Apply smearing to the fermionic action
|
||||||
bool ApplySmearing = false;
|
bool ApplySmearing = MyParams.Mobius.ApplySmearing;
|
||||||
|
|
||||||
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
HMCWrapper TheHMC;
|
HMCWrapper TheHMC;
|
||||||
@ -58,18 +111,25 @@ int main(int argc, char **argv) {
|
|||||||
// hardcoding parameters or using a Reader
|
// hardcoding parameters or using a Reader
|
||||||
|
|
||||||
|
|
||||||
// Checkpointer definition
|
// Checkpointer definition (Name: Checkpointer)
|
||||||
CheckpointerParameters CPparams;
|
CheckpointerParameters CPparams(Reader);
|
||||||
|
// Commenting out since we are using the reader
|
||||||
|
/*
|
||||||
CPparams.config_prefix = "ckpoint_EODWF_lat";
|
CPparams.config_prefix = "ckpoint_EODWF_lat";
|
||||||
CPparams.rng_prefix = "ckpoint_EODWF_rng";
|
CPparams.rng_prefix = "ckpoint_EODWF_rng";
|
||||||
CPparams.saveInterval = 5;
|
CPparams.saveInterval = 5;
|
||||||
CPparams.format = "IEEE64BIG";
|
CPparams.format = "IEEE64BIG";
|
||||||
|
*/
|
||||||
|
|
||||||
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
|
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
|
||||||
|
|
||||||
RNGModuleParameters RNGpar;
|
// RNG definition (Name: RandomNumberGenerator)
|
||||||
|
RNGModuleParameters RNGpar(Reader);
|
||||||
|
// Commenting out since we are using the reader
|
||||||
|
/*
|
||||||
RNGpar.serial_seeds = "1 2 3 4 5";
|
RNGpar.serial_seeds = "1 2 3 4 5";
|
||||||
RNGpar.parallel_seeds = "6 7 8 9 10";
|
RNGpar.parallel_seeds = "6 7 8 9 10";
|
||||||
|
*/
|
||||||
TheHMC.Resources.SetRNGSeeds(RNGpar);
|
TheHMC.Resources.SetRNGSeeds(RNGpar);
|
||||||
|
|
||||||
// Construct observables
|
// Construct observables
|
||||||
@ -83,11 +143,13 @@ int main(int argc, char **argv) {
|
|||||||
// need wrappers of the fermionic classes
|
// need wrappers of the fermionic classes
|
||||||
// that have a complex construction
|
// that have a complex construction
|
||||||
// standard
|
// standard
|
||||||
RealD beta = 5.6 ;
|
|
||||||
WilsonGaugeActionR Waction(beta);
|
//RealD beta = 5.6 ;
|
||||||
|
WilsonGaugeActionR Waction(MyParams.gauge_beta);
|
||||||
|
|
||||||
|
|
||||||
const int Ls = 8;
|
//const int Ls = 8;
|
||||||
|
const int Ls = MyParams.Mobius.Ls;
|
||||||
auto GridPtr = TheHMC.Resources.GetCartesian();
|
auto GridPtr = TheHMC.Resources.GetCartesian();
|
||||||
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
|
auto GridRBPtr = TheHMC.Resources.GetRBCartesian();
|
||||||
auto FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
|
auto FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,GridPtr);
|
||||||
@ -97,19 +159,19 @@ int main(int argc, char **argv) {
|
|||||||
// temporarily need a gauge field
|
// temporarily need a gauge field
|
||||||
LatticeGaugeField U(GridPtr);
|
LatticeGaugeField U(GridPtr);
|
||||||
|
|
||||||
Real mass = 0.04;
|
Real mass = MyParams.Mobius.mass; //0.04;
|
||||||
Real pv = 1.0;
|
Real pv = 1.0;
|
||||||
RealD M5 = 1.5;
|
RealD M5 = MyParams.Mobius.M5; //1.5;
|
||||||
// Note: IroIro and Grid notation for b and c differ
|
// Note: IroIro and Grid notation for b and c differ
|
||||||
RealD b = 2.;//3./2.;
|
RealD b = MyParams.Mobius.b; // 3./2.;
|
||||||
RealD c = 1.;//1./2.;
|
RealD c = MyParams.Mobius.c; // 1./2.;
|
||||||
|
|
||||||
FermionAction DenOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,mass,M5,b,c);
|
FermionAction DenOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,mass,M5,b,c);
|
||||||
FermionAction NumOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,pv, M5,b,c);
|
FermionAction NumOp(U,*FGrid,*FrbGrid,*GridPtr,*GridRBPtr,pv, M5,b,c);
|
||||||
|
|
||||||
double StoppingCondition = 1.0e-8;
|
//double StoppingCondition = 1e-8;
|
||||||
double MaxCGIterations = 10000;
|
//double MaxCGIterations = 10000;
|
||||||
ConjugateGradient<FermionField> CG(StoppingCondition,MaxCGIterations);
|
ConjugateGradient<FermionField> CG(MyParams.Mobius.StoppingCondition,MyParams.Mobius.MaxCGIterations);
|
||||||
TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
|
TwoFlavourEvenOddRatioPseudoFermionAction<FermionImplPolicy> Nf2(NumOp, DenOp,CG,CG);
|
||||||
|
|
||||||
// Set smearing (true/false), default: false
|
// Set smearing (true/false), default: false
|
||||||
@ -126,20 +188,24 @@ int main(int argc, char **argv) {
|
|||||||
TheHMC.TheAction.push_back(Level2);
|
TheHMC.TheAction.push_back(Level2);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// HMC parameters are serialisable
|
// HMC parameters are serialisable
|
||||||
|
TheHMC.Parameters.initialize(Reader);
|
||||||
|
/*
|
||||||
TheHMC.Parameters.MD.MDsteps = 20;
|
TheHMC.Parameters.MD.MDsteps = 20;
|
||||||
TheHMC.Parameters.MD.trajL = 1.0;
|
TheHMC.Parameters.MD.trajL = 1.0;
|
||||||
|
*/
|
||||||
|
|
||||||
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
|
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
|
||||||
// Reset performance counters
|
// Reset performance counters
|
||||||
NumOp.ZeroCounters();
|
NumOp.ZeroCounters();
|
||||||
DenOp.ZeroCounters();
|
DenOp.ZeroCounters();
|
||||||
|
|
||||||
if (0){
|
if (ApplySmearing){
|
||||||
double rho = 0.1; // smearing parameter
|
SmearingParameters SmPar(Reader);
|
||||||
int Nsmear = 3; // number of smearing levels
|
//double rho = 0.1; // smearing parameter
|
||||||
Smear_Stout<HMCWrapper::ImplPolicy> Stout(rho);
|
//int Nsmear = 3; // number of smearing levels
|
||||||
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(GridPtr, Nsmear, Stout);
|
Smear_Stout<HMCWrapper::ImplPolicy> Stout(SmPar.rho);
|
||||||
|
SmearedConfiguration<HMCWrapper::ImplPolicy> SmearingPolicy(GridPtr, SmPar.Nsmear, Stout);
|
||||||
TheHMC.Run(SmearingPolicy); // for smearing
|
TheHMC.Run(SmearingPolicy); // for smearing
|
||||||
} else {
|
} else {
|
||||||
TheHMC.Run(); // no smearing
|
TheHMC.Run(); // no smearing
|
||||||
@ -153,3 +219,55 @@ int main(int argc, char **argv) {
|
|||||||
Grid_finalize();
|
Grid_finalize();
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Examples for input files
|
||||||
|
|
||||||
|
JSON
|
||||||
|
|
||||||
|
{
|
||||||
|
"Checkpointer": {
|
||||||
|
"config_prefix": "ckpoint_json_lat",
|
||||||
|
"rng_prefix": "ckpoint_json_rng",
|
||||||
|
"saveInterval": 1,
|
||||||
|
"format": "IEEE64BIG"
|
||||||
|
},
|
||||||
|
"RandomNumberGenerator": {
|
||||||
|
"serial_seeds": "1 2 3 4 6",
|
||||||
|
"parallel_seeds": "6 7 8 9 11"
|
||||||
|
},
|
||||||
|
"Action":{
|
||||||
|
"gauge_beta": 5.6,
|
||||||
|
"Mobius": {
|
||||||
|
"Ls" : 10,
|
||||||
|
"mass": 0.01,
|
||||||
|
"M5" : 1.0,
|
||||||
|
"b" : 1.5,
|
||||||
|
"c" : 0.5,
|
||||||
|
"StoppingCondition": 1e-8,
|
||||||
|
"MaxCGIterations": 10000,
|
||||||
|
"ApplySmearing": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"HMC":{
|
||||||
|
"StartTrajectory": 0,
|
||||||
|
"Trajectories": 100,
|
||||||
|
"MetropolisTest": true,
|
||||||
|
"NoMetropolisUntil": 10,
|
||||||
|
"StartingType": "HotStart",
|
||||||
|
"MD":{
|
||||||
|
"name": "MinimumNorm2",
|
||||||
|
"MDsteps": 15,
|
||||||
|
"trajL": 2.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"StoutSmearing":{
|
||||||
|
"rho": 0.1,
|
||||||
|
"Nsmear": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XML example not provided yet
|
||||||
|
|
||||||
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user