1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 01:05:38 +01:00

Cleaning up files for HMC

This commit is contained in:
neo 2015-07-07 14:59:37 +09:00
parent 0f21c38ff8
commit 97afe4125f
2 changed files with 23 additions and 23 deletions

View File

@ -1,15 +1,16 @@
//--------------------------------------------------------------------
/*! @file HMC.h
* @brief Declaration of classes for Hybrid Monte Carlo update
* @brief Classes for Hybrid Monte Carlo update
*
* @author Guido Cossu
* Time-stamp: <2015-07-07 14:58:13 neo>
*/
//--------------------------------------------------------------------
#ifndef HMC_INCLUDED
#define HMC_INCLUDED
#include <string>
#include <memory>
namespace Grid{
namespace QCD{
@ -20,7 +21,7 @@ namespace Grid{
Integer ThermalizationSteps;
Integer StartingConfig;
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();
};
@ -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
RealD H0 = MD.S(U); // initial state action
std::cout<<"Total H before = "<< H0 << "\n";
@ -74,9 +74,7 @@ namespace Grid{
}
~HybridMonteCarlo(){};
void evolve(LatticeLorentzColourMatrix& Uin){
void evolve(LatticeGaugeField& Uin){
Real DeltaH;
// Thermalizations
@ -88,7 +86,7 @@ namespace Grid{
}
// Actual updates (evolve a copy Ucopy then copy back eventually)
LatticeLorentzColourMatrix Ucopy(Uin._grid);
LatticeGaugeField Ucopy(Uin._grid);
for(int iter=Params.StartingConfig;
iter < Params.Nsweeps+Params.StartingConfig; ++iter){
std::cout << "-- # Sweep = "<< iter << "\n";
@ -97,7 +95,8 @@ namespace Grid{
DeltaH = evolve_step(Ucopy);
if(metropolis_test(DeltaH)) Uin = Ucopy;
//need sync?
// here save config and RNG seed
}
}
};

View File

@ -1,8 +1,9 @@
//--------------------------------------------------------------------
/*! @file Integrator.h
* @brief Declaration of classes for the Molecular Dynamics integrator
* @brief Classes for the Molecular Dynamics integrator
*
* @author Guido Cossu
* Time-stamp: <2015-07-07 14:58:40 neo>
*/
//--------------------------------------------------------------------
@ -16,7 +17,7 @@ class Observer;
namespace Grid{
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{
int multiplier;
public:
@ -43,8 +44,8 @@ namespace Grid{
namespace MDutils{
void generate_momenta(LatticeLorentzColourMatrix&,GridParallelRNG&);
void generate_momenta_su3(LatticeLorentzColourMatrix&,GridParallelRNG&);
void generate_momenta(LatticeGaugeField&,GridParallelRNG&);
void generate_momenta_su3(LatticeGaugeField&,GridParallelRNG&);
}
/*! @brief Class for Molecular Dynamics management */
@ -53,7 +54,7 @@ namespace Grid{
private:
IntegratorParameters Params;
const ActionSet as;
std::unique_ptr<LatticeLorentzColourMatrix> P;
std::unique_ptr<LatticeGaugeField> P;
GridParallelRNG pRNG;
//ObserverList observers; // not yet
@ -62,16 +63,16 @@ namespace Grid{
void register_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){
LatticeLorentzColourMatrix force(U._grid);
LatticeGaugeField force(U._grid);
as[level].actions.at(a)->deriv(U,force);
*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?
LatticeColourMatrix Umu(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,
Integrator<IntegratorAlgorithm>* Integ);
public:
Integrator(GridBase* grid, IntegratorParameters Par,
ActionSet& Aset):
Params(Par),as(Aset),P(new LatticeLorentzColourMatrix(grid)),pRNG(grid){
Params(Par),as(Aset),P(new LatticeGaugeField(grid)),pRNG(grid){
pRNG.SeedRandomDevice();
};
@ -100,7 +101,7 @@ namespace Grid{
//Initialization of momenta and actions
void init(LatticeLorentzColourMatrix& U){
void init(LatticeGaugeField& U){
std::cout<< "Integrator init\n";
MDutils::generate_momenta(*P,pRNG);
@ -113,7 +114,7 @@ namespace Grid{
// Calculate action
RealD S(LatticeLorentzColourMatrix& U){
RealD S(LatticeGaugeField& U){
LatticeComplex Hloc(U._grid);
Hloc = zero;
// Momenta
@ -135,7 +136,7 @@ namespace Grid{
return H;
}
void integrate(LatticeLorentzColourMatrix& U){
void integrate(LatticeGaugeField& U){
std::vector<int> clock;
clock.resize(as.size(),0);
for(int step=0; step< Params.MDsteps; ++step) // MD step