CHROMA
abs_hamiltonian.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Abstract Hamiltonian
4  *
5  * Abstract Hamiltonian
6  */
7 
8 #ifndef abs_hamiltonian_h
9 #define abs_hamiltonian_h
10 
11 #include "chromabase.h"
14 #include "io/xmllog_io.h"
15 
16 namespace Chroma
17 {
18 
19 
20  //! New Abstract Hamiltonian
21  /*! @ingroup hamilton
22  *
23  * Abstraction for Hamiltonians. They can refresh Internal
24  * fields and measure energies.
25  */
26  template<typename P, typename Q>
28  {
29  public:
30 
31  //! virtual descructor:
32  virtual ~AbsHamiltonian() {}
33 
34  //! Refresh pseudofermsions (if any)
35  virtual void refreshInternalFields(const AbsFieldState<P,Q>& s) =0;
36 
37  //! Compute the energies
38  //! The total energy
39  virtual void mesE(const AbsFieldState<P,Q>& s, Double& KE, Double& PE) const
40  {
41  START_CODE();
42 
43  // Self Description Rule
44  XMLWriter& xml_out = TheXMLLogWriter::Instance();
45  push(xml_out, "mesE");
46 
47  KE = mesKE(s);
48  PE = mesPE(s);
49 
50  pop(xml_out);
51 
52  END_CODE();
53  }
54 
55  //! The Kinetic Energy
56  virtual Double mesKE(const AbsFieldState<P,Q>& s) const
57  {
58  START_CODE();
59 
60  XMLWriter& xml_out = TheXMLLogWriter::Instance();
61  push(xml_out, "mesKE");
62 
63  // Return 1/2 sum pi^2
64  // may need to loop over the indices of P?
65  Double KE=norm2(s.getP());
66 
67  write(xml_out, "KE", KE);
68  pop(xml_out); // pop(mesKE);
69 
70  END_CODE();
71  return KE;
72  }
73 
74  //! The Potential Energy
75  virtual Double mesPE(const AbsFieldState<P,Q>& s) const = 0;
76 
77  };
78 
79 } // End namespace Chroma
80 #endif
Monomials - gauge action or fermion binlinear contributions for HMC.
Primary include file for CHROMA library code.
Abstract field state.
Definition: field_state.h:27
New Abstract Hamiltonian.
virtual Double mesKE(const AbsFieldState< P, Q > &s) const
The Kinetic Energy.
virtual ~AbsHamiltonian()
virtual descructor:
virtual void mesE(const AbsFieldState< P, Q > &s, Double &KE, Double &PE) const
virtual Double mesPE(const AbsFieldState< P, Q > &s) const =0
The Potential Energy.
virtual void refreshInternalFields(const AbsFieldState< P, Q > &s)=0
Refresh pseudofermsions (if any)
static T & Instance()
Definition: singleton.h:432
Field state.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
Definition: gtest.h:7351
Singleton instances of xml output.