mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Cleaning up files for HMC
This commit is contained in:
parent
0f21c38ff8
commit
97afe4125f
@ -1,15 +1,16 @@
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
/*! @file HMC.h
|
/*! @file HMC.h
|
||||||
* @brief Declaration of classes for Hybrid Monte Carlo update
|
* @brief Classes for Hybrid Monte Carlo update
|
||||||
*
|
*
|
||||||
* @author Guido Cossu
|
* @author Guido Cossu
|
||||||
|
* Time-stamp: <2015-07-07 14:58:13 neo>
|
||||||
*/
|
*/
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
#ifndef HMC_INCLUDED
|
#ifndef HMC_INCLUDED
|
||||||
#define HMC_INCLUDED
|
#define HMC_INCLUDED
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Grid{
|
namespace Grid{
|
||||||
namespace QCD{
|
namespace QCD{
|
||||||
@ -20,7 +21,7 @@ namespace Grid{
|
|||||||
Integer ThermalizationSteps;
|
Integer ThermalizationSteps;
|
||||||
Integer StartingConfig;
|
Integer StartingConfig;
|
||||||
Integer SaveInterval; //Setting to 0 does not save configurations
|
Integer SaveInterval; //Setting to 0 does not save configurations
|
||||||
std::string Filename_prefix; // To save configurations
|
std::string Filename_prefix; // To save configurations and rng seed
|
||||||
|
|
||||||
HMCparameters();
|
HMCparameters();
|
||||||
};
|
};
|
||||||
@ -49,8 +50,7 @@ namespace Grid{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RealD evolve_step(LatticeLorentzColourMatrix& U){
|
RealD evolve_step(LatticeGaugeField& U){
|
||||||
|
|
||||||
MD.init(U); // set U and initialize P and phi's
|
MD.init(U); // set U and initialize P and phi's
|
||||||
RealD H0 = MD.S(U); // initial state action
|
RealD H0 = MD.S(U); // initial state action
|
||||||
std::cout<<"Total H before = "<< H0 << "\n";
|
std::cout<<"Total H before = "<< H0 << "\n";
|
||||||
@ -74,9 +74,7 @@ namespace Grid{
|
|||||||
}
|
}
|
||||||
~HybridMonteCarlo(){};
|
~HybridMonteCarlo(){};
|
||||||
|
|
||||||
|
void evolve(LatticeGaugeField& Uin){
|
||||||
|
|
||||||
void evolve(LatticeLorentzColourMatrix& Uin){
|
|
||||||
Real DeltaH;
|
Real DeltaH;
|
||||||
|
|
||||||
// Thermalizations
|
// Thermalizations
|
||||||
@ -88,7 +86,7 @@ namespace Grid{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actual updates (evolve a copy Ucopy then copy back eventually)
|
// Actual updates (evolve a copy Ucopy then copy back eventually)
|
||||||
LatticeLorentzColourMatrix Ucopy(Uin._grid);
|
LatticeGaugeField Ucopy(Uin._grid);
|
||||||
for(int iter=Params.StartingConfig;
|
for(int iter=Params.StartingConfig;
|
||||||
iter < Params.Nsweeps+Params.StartingConfig; ++iter){
|
iter < Params.Nsweeps+Params.StartingConfig; ++iter){
|
||||||
std::cout << "-- # Sweep = "<< iter << "\n";
|
std::cout << "-- # Sweep = "<< iter << "\n";
|
||||||
@ -97,7 +95,8 @@ namespace Grid{
|
|||||||
DeltaH = evolve_step(Ucopy);
|
DeltaH = evolve_step(Ucopy);
|
||||||
|
|
||||||
if(metropolis_test(DeltaH)) Uin = Ucopy;
|
if(metropolis_test(DeltaH)) Uin = Ucopy;
|
||||||
//need sync?
|
|
||||||
|
// here save config and RNG seed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
/*! @file Integrator.h
|
/*! @file Integrator.h
|
||||||
* @brief Declaration of classes for the Molecular Dynamics integrator
|
* @brief Classes for the Molecular Dynamics integrator
|
||||||
*
|
*
|
||||||
* @author Guido Cossu
|
* @author Guido Cossu
|
||||||
|
* Time-stamp: <2015-07-07 14:58:40 neo>
|
||||||
*/
|
*/
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ class Observer;
|
|||||||
namespace Grid{
|
namespace Grid{
|
||||||
namespace QCD{
|
namespace QCD{
|
||||||
|
|
||||||
typedef Action<LatticeLorentzColourMatrix>* ActPtr; // now force the same colours as the rest of the code
|
typedef Action<LatticeGaugeField>* ActPtr; // now force the same colours as the rest of the code
|
||||||
struct ActionLevel{
|
struct ActionLevel{
|
||||||
int multiplier;
|
int multiplier;
|
||||||
public:
|
public:
|
||||||
@ -43,8 +44,8 @@ namespace Grid{
|
|||||||
|
|
||||||
|
|
||||||
namespace MDutils{
|
namespace MDutils{
|
||||||
void generate_momenta(LatticeLorentzColourMatrix&,GridParallelRNG&);
|
void generate_momenta(LatticeGaugeField&,GridParallelRNG&);
|
||||||
void generate_momenta_su3(LatticeLorentzColourMatrix&,GridParallelRNG&);
|
void generate_momenta_su3(LatticeGaugeField&,GridParallelRNG&);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @brief Class for Molecular Dynamics management */
|
/*! @brief Class for Molecular Dynamics management */
|
||||||
@ -53,7 +54,7 @@ namespace Grid{
|
|||||||
private:
|
private:
|
||||||
IntegratorParameters Params;
|
IntegratorParameters Params;
|
||||||
const ActionSet as;
|
const ActionSet as;
|
||||||
std::unique_ptr<LatticeLorentzColourMatrix> P;
|
std::unique_ptr<LatticeGaugeField> P;
|
||||||
GridParallelRNG pRNG;
|
GridParallelRNG pRNG;
|
||||||
//ObserverList observers; // not yet
|
//ObserverList observers; // not yet
|
||||||
|
|
||||||
@ -62,16 +63,16 @@ namespace Grid{
|
|||||||
void register_observers();
|
void register_observers();
|
||||||
void notify_observers();
|
void notify_observers();
|
||||||
|
|
||||||
void update_P(LatticeLorentzColourMatrix&U, int level,double ep){
|
void update_P(LatticeGaugeField&U, int level,double ep){
|
||||||
for(int a=0; a<as[level].actions.size(); ++a){
|
for(int a=0; a<as[level].actions.size(); ++a){
|
||||||
LatticeLorentzColourMatrix force(U._grid);
|
LatticeGaugeField force(U._grid);
|
||||||
as[level].actions.at(a)->deriv(U,force);
|
as[level].actions.at(a)->deriv(U,force);
|
||||||
*P -= force*ep;
|
*P -= force*ep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void update_U(LatticeLorentzColourMatrix&U, double ep){
|
void update_U(LatticeGaugeField&U, double ep){
|
||||||
//rewrite exponential to deal automatically with the lorentz index?
|
//rewrite exponential to deal automatically with the lorentz index?
|
||||||
LatticeColourMatrix Umu(U._grid);
|
LatticeColourMatrix Umu(U._grid);
|
||||||
LatticeColourMatrix Pmu(U._grid);
|
LatticeColourMatrix Pmu(U._grid);
|
||||||
@ -86,13 +87,13 @@ namespace Grid{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
friend void IntegratorAlgorithm::step (LatticeLorentzColourMatrix& U,
|
friend void IntegratorAlgorithm::step (LatticeGaugeField& U,
|
||||||
int level, std::vector<int>& clock,
|
int level, std::vector<int>& clock,
|
||||||
Integrator<IntegratorAlgorithm>* Integ);
|
Integrator<IntegratorAlgorithm>* Integ);
|
||||||
public:
|
public:
|
||||||
Integrator(GridBase* grid, IntegratorParameters Par,
|
Integrator(GridBase* grid, IntegratorParameters Par,
|
||||||
ActionSet& Aset):
|
ActionSet& Aset):
|
||||||
Params(Par),as(Aset),P(new LatticeLorentzColourMatrix(grid)),pRNG(grid){
|
Params(Par),as(Aset),P(new LatticeGaugeField(grid)),pRNG(grid){
|
||||||
pRNG.SeedRandomDevice();
|
pRNG.SeedRandomDevice();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ namespace Grid{
|
|||||||
|
|
||||||
|
|
||||||
//Initialization of momenta and actions
|
//Initialization of momenta and actions
|
||||||
void init(LatticeLorentzColourMatrix& U){
|
void init(LatticeGaugeField& U){
|
||||||
std::cout<< "Integrator init\n";
|
std::cout<< "Integrator init\n";
|
||||||
|
|
||||||
MDutils::generate_momenta(*P,pRNG);
|
MDutils::generate_momenta(*P,pRNG);
|
||||||
@ -113,7 +114,7 @@ namespace Grid{
|
|||||||
|
|
||||||
|
|
||||||
// Calculate action
|
// Calculate action
|
||||||
RealD S(LatticeLorentzColourMatrix& U){
|
RealD S(LatticeGaugeField& U){
|
||||||
LatticeComplex Hloc(U._grid);
|
LatticeComplex Hloc(U._grid);
|
||||||
Hloc = zero;
|
Hloc = zero;
|
||||||
// Momenta
|
// Momenta
|
||||||
@ -135,7 +136,7 @@ namespace Grid{
|
|||||||
return H;
|
return H;
|
||||||
}
|
}
|
||||||
|
|
||||||
void integrate(LatticeLorentzColourMatrix& U){
|
void integrate(LatticeGaugeField& U){
|
||||||
std::vector<int> clock;
|
std::vector<int> clock;
|
||||||
clock.resize(as.size(),0);
|
clock.resize(as.size(),0);
|
||||||
for(int step=0; step< Params.MDsteps; ++step) // MD step
|
for(int step=0; step< Params.MDsteps; ++step) // MD step
|
||||||
|
Loading…
Reference in New Issue
Block a user