CHROMA
lcm_hmc.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief HMC trajectory
4  *
5  * HMC trajectory
6  */
7 
8 #ifndef LAT_COL_MAT_HMC_NEW_H
9 #define LAT_COL_MAT_HMC_NEW_H
10 
11 #include "chromabase.h"
16 #include "handle.h"
17 // The accept Reject
19 
20 #include "util/gauge/taproj.h"
21 
22 
23 namespace Chroma
24 {
25 
26  //! HMC trajectory
27  /*! @ingroup hmc */
28  class LatColMatHMCTrj : public AbsHMCTrj<multi1d<LatticeColorMatrix>,
29  multi1d<LatticeColorMatrix> >
30  {
31  public:
32 
33  // Destructor
34  ~LatColMatHMCTrj(void) {}
35 
36  // Constructor
37  LatColMatHMCTrj( Handle< AbsHamiltonian< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >& _H_MC,
38  Handle< AbsMDIntegrator< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> > >& _MD_int)
39  : the_MD(_MD_int), the_H_MC(_H_MC) {}
40 
41  private:
43 
45  protected:
46 
47  AbsHamiltonian< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& getMCHamiltonian(void) {
48  return *the_H_MC;
49  }
50 
51  AbsMDIntegrator< multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& getMDIntegrator(void) {
52  return *the_MD;
53  }
54 
55  bool acceptReject( const Double& DeltaH ) const {
56  return globalMetropolisAcceptReject(DeltaH);
57  }
58 
59 
60  void refreshP(AbsFieldState<multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& s) const
61  {
62  START_CODE();
63 
64  // Loop over direcsions
65  for(int mu = 0; mu < Nd; mu++)
66  {
67  // Pull the gaussian noise
68  gaussian(s.getP()[mu]);
69 
70  // Old conventions
71  //s.getP()[mu] *= sqrt(0.5); // Gaussian Normalisation
72 
73  // Normalisation factor in variance of momenta
74  // one factor of sqrt(2) to move the variance of the noise
75  // one factor of sqrt(2) to account for Taproj normalisation
76  // => sqrt(1/2)*sqrt(1/2) = sqrt(1/4) = 1/2
77  s.getP()[mu] *= sqrt(Real(0.5));
78 
79  // Make traceless and antihermitian
80  taproj(s.getP()[mu]);
81  }
82 
83  END_CODE();
84  }
85 
86 
87  void flipMomenta(AbsFieldState<multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& s) const {
88 
89  multi1d<LatticeColorMatrix>& p = s.getP();
90  for(int mu=0; mu < Nd; mu++) {
91  p[mu] *= Real(-1);
92  }
93  }
94 
95  void reverseCheckMetrics(Double& deltaQ, Double& deltaP,
96  const AbsFieldState<multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& s,
97  const AbsFieldState<multi1d<LatticeColorMatrix>, multi1d<LatticeColorMatrix> >& s_old
98  ) const {
99 
100  multi1d<LatticeColorMatrix> DelQ(Nd);
101  multi1d<LatticeColorMatrix> DelP(Nd);
102  for(int mu=0; mu < Nd; mu++) {
103  DelQ[mu]=s.getQ()[mu] - s_old.getQ()[mu];
104  DelP[mu]=s.getP()[mu] - s_old.getP()[mu];
105  }
106 
107  deltaQ = sqrt(norm2(DelQ[0]));
108  deltaP = sqrt(norm2(DelP[0]));
109  for(int mu=1; mu < Nd; mu++) {
110  deltaQ += sqrt(norm2(DelQ[mu]));
111  deltaP += sqrt(norm2(DelP[mu]));
112  }
113 
114  deltaQ /= Double(Nd*Layout::vol());
115  deltaP /= Double(Nd*Layout::vol());
116 
117 
118  }
119 
120  };
121 }
122 
123 #endif
Abstract Hamiltonian.
Abstract HMC trajectory Using the new structure.
Integrators.
Primary include file for CHROMA library code.
Abstract field state.
Definition: field_state.h:27
Abstract HMC trajectory.
Definition: abs_hmc.h:25
New Abstract Hamiltonian.
New MD integrator interface.
Class for counted reference semantics.
Definition: handle.h:33
HMC trajectory.
Definition: lcm_hmc.h:30
AbsMDIntegrator< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > & getMDIntegrator(void)
Definition: lcm_hmc.h:51
bool acceptReject(const Double &DeltaH) const
Definition: lcm_hmc.h:55
void refreshP(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s) const
Definition: lcm_hmc.h:60
Handle< AbsHamiltonian< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > the_H_MC
Definition: lcm_hmc.h:44
LatColMatHMCTrj(Handle< AbsHamiltonian< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > &_H_MC, Handle< AbsMDIntegrator< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > &_MD_int)
Definition: lcm_hmc.h:37
Handle< AbsMDIntegrator< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > the_MD
Definition: lcm_hmc.h:42
AbsHamiltonian< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > & getMCHamiltonian(void)
Definition: lcm_hmc.h:47
void flipMomenta(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s) const
Definition: lcm_hmc.h:87
void reverseCheckMetrics(Double &deltaQ, Double &deltaP, const AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s, const AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s_old) const
Definition: lcm_hmc.h:95
int mu
Definition: cool.cc:24
Field state.
Global metropolis.
void taproj(LatticeColorMatrix &a)
Take the traceless antihermitian projection of a color matrix.
Definition: taproj.cc:31
bool globalMetropolisAcceptReject(const Double &DeltaH)
Class for counted reference semantics.
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
START_CODE()
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
Definition: gtest.h:7351
Take the traceless antihermitian projection of a color matrix.