CHROMA
abs_monomial.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*! @file
4  * @brief Monomials - gauge action or fermion binlinear contributions for HMC
5  */
6 
7 #ifndef __abs_monomial_h__
8 #define __abs_monomial_h__
9 
10 #include "wilstype_fermact_w.h"
11 #include "gaugeact.h"
12 
14 #include "io/xmllog_io.h"
15 
16 namespace Chroma
17 {
18  //! An abstract monomial class, for inexact algorithms
19  /*! @ingroup monomial
20  *
21  * Inexact in this case means energy computation is not supported,
22  * (in an inexact algorithm sense -- obviously it is weird to have
23  * a hamiltonian where you cannot compute the energy. We may need
24  * to think more about this)
25  *
26  * This serves the following purpose. It definees
27  * an interface for computing the total force
28  * and can refresh the momenta,
29  *
30  *
31  * We don't specify how the momenta is refreshed. It is "virtual".
32  * HMD type algorithms will porbably use gaussian noise.
33  * GHMD type algorithms will mix the previous momenta some. How
34  * to do that will be encoded in the derived class, probably
35  * through the constructor.
36  *
37  *
38  * For this it needs to know the types of coordinates and the momenta
39  * so that it can act on the right kind of state.
40  */
41  template<typename P, typename Q>
42  class Monomial
43  {
44  public:
45  //! virtual destructor:
46  virtual ~Monomial() {}
47 
48  //! Compute dsdq for the system...
49  /*! Not specified how to actually do this s is the state, F is the computed force */
50  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
51 
52  //! Refresh pseudofermion fields if any
53  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) =0 ;
54 
55  //! Copy pseudofermion fields from another monomial...
56  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
57 
58  //! Reset predictors
59  virtual void resetPredictors(void) { /* Nop for most */ }
60  };
61 
62 
63  //-------------------------------------------------------------------------------------------
64  //! Abstract monomial class, for exact algorithms
65  /*! @ingroup monomial
66  *
67  * Now define similar classes for exact algorithms.
68  * These are basically the same as before but they can compute
69  * energies too. Do these need to inerit?
70  * Yes. Reason: We can always give it to an inexact algorithm through
71  * a downcast. In that case the energy calculations would be hidden.
72  */
73  template<typename P, typename Q>
74  class ExactMonomial : public Monomial<P, Q>
75  {
76  public:
77  //! virtual destructor:
78  virtual ~ExactMonomial() {}
79 
80  //! Compute dsdq for the system... Not specified how to actually do this
81  // s is the state, F is the computed force
82  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
83 
84  // Compute the energies
85 
86  //! Compute the total action
87  virtual Double S(const AbsFieldState<P,Q>& s) = 0;
88 
89  //! Refresh pseudofermion fields if any
90  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
91 
92  //! Copy pseudofermions if any
93  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
94 
95  //! Reset predictors
96  virtual void resetPredictors(void) { /* Nop for most */ }
97  };
98 
99  //-------------------------------------------------------------------------------------------
100  //! Fermionic monomials (binlinears in fermion fields)
101  /*! @ingroup monomial
102  *
103  * The fermion hierachy would splits at the very top into
104  * inexact and exact monomials. An exact monomial can be used
105  * for an inexact algorithm, but not vice-versa.
106  */
107 
108  /* Unfortunately we need to template on the Phi-s because
109  we need that template for the FermActs */
110  template<typename P, typename Q, typename Phi>
111  class FermMonomial : public Monomial<P,Q>
112  {
113  public:
114  //! virtual destructor:
116 
117  //! Compute dsdq for the system... Not specified how to actually do this
118  // s is the state, F is the computed force
119  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
120 
121  // Refresh all pseudofermions
122  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0 ;
123 
124  //! Copy pseudofermions if any
125  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
126 
127  //! Reset predictors
128  virtual void resetPredictors(void) { /* Nop for most */ }
129  };
130 
131 
132  //-------------------------------------------------------------------------------------------
133  //! Fermionic monomials (binlinears in fermion fields)
134  /*! @ingroup monomial
135  *
136  * The fermion hierachy would splits at the very top into
137  * inexact and exact monomials. An exact monomial can be used
138  * for an inexact algorithm, but not vice-versa.
139  *
140  * Unfortunately we need to template on the Phi-s because
141  * we need that template for the FermActs
142  */
143  template<typename P, typename Q, typename Phi>
144  class ExactFermMonomial : public ExactMonomial<P,Q>
145  {
146  public:
147  //! virtual destructor:
149 
150  //! Compute the total action
151  virtual Double S(const AbsFieldState<P,Q>& s) = 0;
152 
153  //! Compute dsdq for the system... Not specified how to actually do this
154  /*! s is the state, F is the computed force */
155  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
156 
157  //! Refresh pseudofermions
158  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
159 
160  //! Copy pseudofermions if any
161  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
162 
163  //! Reset predictors
164  virtual void resetPredictors(void) { /* Nop for most */ }
165  };
166 
167 
168  //-------------------------------------------------------------------------------------------
169  //! Fermionic monomials (binlinears in fermion fields)
170  /*! @ingroup monomial
171  *
172  * Exact fermionic monomials with pseudofermions living in 4D
173  *
174  * We need to template on the Phi-s because of the fermacts
175  */
176  template<typename P, typename Q, typename Phi>
177  class ExactFermMonomial4D : public ExactFermMonomial<P,Q,Phi>
178  {
179  public:
180  //! virtual destructor:
182 
183  //! Compute the total action
184  virtual Double S(const AbsFieldState<P,Q>& s) = 0;
185 
186  //! Compute dsdq for the system... Not specified how to actually do this
187  /*! s is the state, F is the computed force */
188  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
189 
190  //! Refresh pseudofermions
191  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
192 
193  //! Copy pseudofermions if any
194  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
195 
196  //! Reset predictors
197  virtual void resetPredictors(void) { /* Nop for most */ }
198  };
199 
200 
201  //-------------------------------------------------------------------------------------------
202  //! Fermionic monomials (binlinears in fermion fields)
203  /*! @ingroup monomial
204  *
205  * Exact fermionic monomials with pseudofermions living in 4D
206  *
207  * We need to template on the Phi-s because of the fermacts
208  */
209  template<typename P, typename Q, typename Phi>
210  class ExactFermMonomial5D : public ExactFermMonomial<P,Q,Phi>
211  {
212  public:
213  //! virtual destructor:
215 
216  //! Compute the total action
217  virtual Double S(const AbsFieldState<P,Q>& s) = 0;
218 
219  //! Compute dsdq for the system... Not specified how to actually do this
220  // s is the state, F is the computed force
221  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
222 
223  //! Refresh pseudofermions
224  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
225 
226  //! Copy pseudofermions if any
227  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
228 
229  //! Reset predictors
230  virtual void resetPredictors(void) { /* Nop for most */ }
231  };
232 
233 
234  //-------------------------------------------------------------------------------------------
235  //! Fermionic monomials (binlinears in fermion fields)
236  /*! @ingroup monomial
237  *
238  * Wilson-like fermion monomials. Not sure what these really do that
239  * is new. There can be a staggered version.
240  */
241  template<typename P, typename Q, typename Phi>
243  {
244  public:
245  //! virtual destructor:
247 
248  //! Compute the total action
249  virtual Double S(const AbsFieldState<P,Q>& s) = 0;
250 
251  //! Compute dsdq for the system... Not specified how to actually do this
252  /*! s is the state, F is the computed force */
253  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
254 
255  //! Refresh pseudofermions
256  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
257 
258  //! Copy pseudofermions if any
259  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
260 
261  //! Reset predictors
262  virtual void resetPredictors(void) { /* Nop for most */ }
263 
264  protected:
265  //! Get at fermion action for pseudofermion field i
266  virtual const WilsonTypeFermAct<Phi,P,Q>& getFermAct(void) const = 0;
267 
268  };
269 
270 
271  //-------------------------------------------------------------------------------------------
272  //! Fermionic monomials (binlinears in fermion fields)
273  /*! @ingroup monomial
274  *
275  * Wilson-like fermion monomials. Not sure what these really do that
276  * is new. There can be a staggered version.
277  */
278  template<typename P, typename Q, typename Phi>
280  {
281  public:
282  //! virtual destructor:
284 
285  //! Compute the total action
286  virtual Double S(const AbsFieldState<P,Q>& s) = 0;
287 
288  //! Compute dsdq for the system... Not specified how to actually do this
289  /*! s is the state, F is the computed force */
290  virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
291 
292  //! Refresh pseudofermions
293  virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
294 
295  //! Copy pseudofermions if any
296  virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
297 
298  //! Reset predictors
299  virtual void resetPredictors(void) { /* Nop for most */ }
300 
301  protected:
302  //! Get at fermion action for pseudofermion field i
303  virtual const WilsonTypeFermAct5D<Phi,P,Q>& getFermAct(void) const = 0;
304 
305  };
306 
307 }
308 
309 
310 #endif
Abstract field state.
Definition: field_state.h:27
Fermionic monomials (binlinears in fermion fields)
Definition: abs_monomial.h:178
virtual Double S(const AbsFieldState< P, Q > &s)=0
Compute the total action.
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:197
~ExactFermMonomial4D()
virtual destructor:
Definition: abs_monomial.h:181
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermions if any.
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermions.
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system... Not specified how to actually do this.
Fermionic monomials (binlinears in fermion fields)
Definition: abs_monomial.h:211
~ExactFermMonomial5D()
virtual destructor:
Definition: abs_monomial.h:214
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:230
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermions.
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system... Not specified how to actually do this.
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermions if any.
virtual Double S(const AbsFieldState< P, Q > &s)=0
Compute the total action.
Fermionic monomials (binlinears in fermion fields)
Definition: abs_monomial.h:145
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:164
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermions if any.
virtual Double S(const AbsFieldState< P, Q > &s)=0
Compute the total action.
~ExactFermMonomial()
virtual destructor:
Definition: abs_monomial.h:148
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermions.
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system... Not specified how to actually do this.
Abstract monomial class, for exact algorithms.
Definition: abs_monomial.h:75
virtual ~ExactMonomial()
virtual destructor:
Definition: abs_monomial.h:78
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermion fields if any.
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:96
virtual Double S(const AbsFieldState< P, Q > &s)=0
Compute the total action.
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system... Not specified how to actually do this.
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermions if any.
Fermionic monomials (binlinears in fermion fields)
Definition: abs_monomial.h:280
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermions.
virtual Double S(const AbsFieldState< P, Q > &s)=0
Compute the total action.
~ExactWilsonTypeFermMonomial5D()
virtual destructor:
Definition: abs_monomial.h:283
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system... Not specified how to actually do this.
virtual const WilsonTypeFermAct5D< Phi, P, Q > & getFermAct(void) const =0
Get at fermion action for pseudofermion field i.
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermions if any.
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:299
Fermionic monomials (binlinears in fermion fields)
Definition: abs_monomial.h:243
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system... Not specified how to actually do this.
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermions if any.
virtual const WilsonTypeFermAct< Phi, P, Q > & getFermAct(void) const =0
Get at fermion action for pseudofermion field i.
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:262
virtual Double S(const AbsFieldState< P, Q > &s)=0
Compute the total action.
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermions.
~ExactWilsonTypeFermMonomial()
virtual destructor:
Definition: abs_monomial.h:246
Fermionic monomials (binlinears in fermion fields)
Definition: abs_monomial.h:112
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermion fields if any.
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermions if any.
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:128
~FermMonomial()
virtual destructor:
Definition: abs_monomial.h:115
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system... Not specified how to actually do this.
An abstract monomial class, for inexact algorithms.
Definition: abs_monomial.h:43
virtual void resetPredictors(void)
Reset predictors.
Definition: abs_monomial.h:59
virtual ~Monomial()
virtual destructor:
Definition: abs_monomial.h:46
virtual void setInternalFields(const Monomial< P, Q > &m)=0
Copy pseudofermion fields from another monomial...
virtual void dsdq(P &F, const AbsFieldState< P, Q > &s)=0
Compute dsdq for the system...
virtual void refreshInternalFields(const AbsFieldState< P, Q > &field_state)=0
Refresh pseudofermion fields if any.
Wilson-like fermion actions.
Definition: fermact.orig.h:403
Wilson-like fermion actions.
Definition: fermact.orig.h:344
Field state.
Class structure for gauge actions.
static int m[4]
Definition: make_seeds.cc:16
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
Definition: gtest.h:7351
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13
Wilson-like fermion actions.
Singleton instances of xml output.
static INTERNAL_PRECISION F