abs_monomial.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: abs_monomial.h,v 3.2 2006/12/28 17:34:00 bjoo Exp $
00003 
00004 /*! @file
00005  * @brief Monomials - gauge action or fermion binlinear contributions for HMC
00006  */
00007 
00008 #ifndef __abs_monomial_h__
00009 #define __abs_monomial_h__
00010 
00011 #include "wilstype_fermact_w.h"
00012 #include "gaugeact.h"
00013 
00014 #include "update/molecdyn/field_state.h"
00015 #include "io/xmllog_io.h"
00016 
00017 namespace Chroma
00018 {
00019   //! An abstract monomial class, for inexact algorithms
00020   /*! @ingroup monomial
00021    *
00022    * Inexact in this case means energy computation is not supported,
00023    * (in an inexact algorithm sense -- obviously it is weird to have
00024    * a hamiltonian where you cannot compute the energy. We may need
00025    * to think more about this)
00026    * 
00027    * This serves the following purpose. It definees 
00028    * an interface for computing the total force 
00029    * and can refresh the momenta,
00030    * 
00031    * 
00032    * We don't specify how the momenta is refreshed. It is "virtual".
00033    * HMD type algorithms will porbably use gaussian noise. 
00034    * GHMD type algorithms will mix the previous momenta some. How
00035    * to do that will be encoded in the derived class, probably 
00036    * through the constructor.
00037    * 
00038    * 
00039    * For this it needs to know the types of coordinates and the momenta
00040    * so that it can act on the right kind of state.
00041    */
00042   template<typename P, typename Q>
00043   class Monomial
00044   {
00045   public:
00046     //! virtual destructor:
00047     virtual ~Monomial() {}
00048 
00049     //! Compute dsdq for the system... 
00050     /*! Not specified how to actually do this s is the state, F is the computed force */
00051     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s)  = 0;
00052 
00053     //! Refresh pseudofermion fields if any
00054     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) =0 ;
00055 
00056     //! Copy pseudofermion fields from another monomial...
00057     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00058 
00059     //! Reset predictors
00060     virtual void resetPredictors(void) { /* Nop for most */ }
00061   };
00062 
00063 
00064   //-------------------------------------------------------------------------------------------
00065   //! Abstract monomial class, for exact algorithms
00066   /*! @ingroup monomial
00067    *
00068    * Now define similar classes for exact algorithms.
00069    * These are basically the same as before but they can compute
00070    * energies too. Do these need to inerit?
00071    * Yes. Reason: We can always give it to an inexact algorithm through
00072    * a downcast. In that case the energy calculations would be hidden.
00073    */
00074   template<typename P, typename Q>
00075   class ExactMonomial : public Monomial<P, Q> 
00076   {
00077   public:
00078     //! virtual destructor:
00079     virtual ~ExactMonomial() {}
00080 
00081     //! Compute dsdq for the system... Not specified how to actually do this
00082     //  s is the state, F is the computed force
00083     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s)  = 0;
00084 
00085     // Compute the energies 
00086 
00087     //! Compute the total action
00088     virtual Double S(const AbsFieldState<P,Q>& s)  = 0;
00089 
00090     //! Refresh pseudofermion fields if any
00091     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
00092 
00093     //! Copy pseudofermions if any
00094     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00095 
00096     //! Reset predictors
00097     virtual void resetPredictors(void) { /* Nop for most */ }
00098   };
00099 
00100   //-------------------------------------------------------------------------------------------
00101   //! Fermionic monomials (binlinears in fermion fields)
00102   /*! @ingroup monomial
00103    *
00104    * The fermion hierachy would splits at the very top into
00105    * inexact and exact monomials. An exact monomial can be used
00106    * for an inexact algorithm, but not vice-versa.
00107    */
00108  
00109   /* Unfortunately we need to template on the Phi-s because
00110      we need that template for the FermActs */
00111   template<typename P, typename Q, typename Phi>
00112   class FermMonomial : public Monomial<P,Q>
00113   {
00114   public:
00115     //! virtual destructor:
00116     ~FermMonomial() {}
00117 
00118     //! Compute dsdq for the system... Not specified how to actually do this
00119     //  s is the state, F is the computed force
00120     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s) = 0;
00121 
00122     // Refresh all pseudofermions
00123     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0 ;
00124 
00125     //! Copy pseudofermions if any
00126     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00127 
00128     //! Reset predictors
00129     virtual void resetPredictors(void) { /* Nop for most */ }
00130   };
00131 
00132 
00133   //-------------------------------------------------------------------------------------------
00134   //! Fermionic monomials (binlinears in fermion fields)
00135   /*! @ingroup monomial
00136    *
00137    * The fermion hierachy would splits at the very top into
00138    * inexact and exact monomials. An exact monomial can be used
00139    * for an inexact algorithm, but not vice-versa.
00140    *
00141    * Unfortunately we need to template on the Phi-s because
00142    *  we need that template for the FermActs 
00143    */
00144   template<typename P, typename Q, typename Phi>
00145   class ExactFermMonomial : public ExactMonomial<P,Q>
00146   {
00147   public:
00148     //! virtual destructor:
00149     ~ExactFermMonomial() {}
00150 
00151     //! Compute the total action
00152     virtual Double S(const AbsFieldState<P,Q>& s)  = 0;
00153 
00154     //! Compute dsdq for the system... Not specified how to actually do this
00155     /*! s is the state, F is the computed force */
00156     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s)  = 0;
00157 
00158     //! Refresh pseudofermions
00159     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
00160 
00161     //! Copy pseudofermions if any
00162     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00163 
00164     //! Reset predictors
00165     virtual void resetPredictors(void) { /* Nop for most */ }
00166   };
00167 
00168 
00169   //-------------------------------------------------------------------------------------------
00170   //! Fermionic monomials (binlinears in fermion fields)
00171   /*! @ingroup monomial
00172    *
00173    * Exact fermionic monomials with pseudofermions living in 4D
00174    *
00175    * We need to template on the Phi-s because of the fermacts
00176    */
00177   template<typename P, typename Q, typename Phi>
00178   class ExactFermMonomial4D : public ExactFermMonomial<P,Q,Phi>
00179   {
00180   public:
00181     //! virtual destructor:
00182     ~ExactFermMonomial4D() {}
00183 
00184     //! Compute the total action
00185     virtual Double S(const AbsFieldState<P,Q>& s)  = 0;
00186 
00187     //! Compute dsdq for the system... Not specified how to actually do this
00188     /*! s is the state, F is the computed force */
00189     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s)  = 0;
00190 
00191     //! Refresh pseudofermions
00192     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
00193 
00194     //! Copy pseudofermions if any
00195     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00196 
00197     //! Reset predictors
00198     virtual void resetPredictors(void) { /* Nop for most */ }
00199   };
00200 
00201 
00202   //-------------------------------------------------------------------------------------------
00203   //! Fermionic monomials (binlinears in fermion fields)
00204   /*! @ingroup monomial
00205    *
00206    * Exact fermionic monomials with pseudofermions living in 4D
00207    *
00208    * We need to template on the Phi-s because of the fermacts
00209    */
00210   template<typename P, typename Q, typename Phi>
00211   class ExactFermMonomial5D : public ExactFermMonomial<P,Q,Phi>
00212   {
00213   public:
00214     //! virtual destructor:
00215     ~ExactFermMonomial5D() {}
00216 
00217     //! Compute the total action
00218     virtual Double S(const AbsFieldState<P,Q>& s)  = 0;
00219 
00220     //! Compute dsdq for the system... Not specified how to actually do this
00221     //  s is the state, F is the computed force
00222     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s)  = 0;
00223 
00224     //! Refresh pseudofermions
00225     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
00226 
00227     //! Copy pseudofermions if any
00228     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00229 
00230     //! Reset predictors
00231     virtual void resetPredictors(void) { /* Nop for most */ }
00232   };
00233 
00234 
00235   //-------------------------------------------------------------------------------------------
00236   //! Fermionic monomials (binlinears in fermion fields)
00237   /*! @ingroup monomial
00238    *
00239    * Wilson-like fermion monomials. Not sure what these really do that
00240    * is new. There can be a staggered version.
00241    */
00242   template<typename P, typename Q, typename Phi>
00243   class ExactWilsonTypeFermMonomial : public ExactFermMonomial4D<P,Q,Phi>
00244   {
00245   public:
00246      //! virtual destructor:
00247     ~ExactWilsonTypeFermMonomial() {}
00248 
00249     //! Compute the total action
00250     virtual Double S(const AbsFieldState<P,Q>& s)  = 0;
00251 
00252     //! Compute dsdq for the system... Not specified how to actually do this
00253     /*! s is the state, F is the computed force */
00254     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s)  = 0;
00255 
00256     //! Refresh pseudofermions
00257     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
00258 
00259     //! Copy pseudofermions if any
00260     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00261 
00262     //! Reset predictors
00263     virtual void resetPredictors(void) { /* Nop for most */ }
00264 
00265   protected:
00266     //! Get at fermion action for pseudofermion field i
00267     virtual const WilsonTypeFermAct<Phi,P,Q>& getFermAct(void) const = 0;
00268 
00269   };
00270 
00271 
00272   //-------------------------------------------------------------------------------------------
00273   //! Fermionic monomials (binlinears in fermion fields)
00274   /*! @ingroup monomial
00275    *
00276    * Wilson-like fermion monomials. Not sure what these really do that
00277    * is new. There can be a staggered version.
00278    */
00279   template<typename P, typename Q, typename Phi>
00280   class ExactWilsonTypeFermMonomial5D : public ExactFermMonomial5D<P,Q,Phi>
00281   {
00282   public:
00283      //! virtual destructor:
00284     ~ExactWilsonTypeFermMonomial5D() {}
00285 
00286     //! Compute the total action
00287     virtual Double S(const AbsFieldState<P,Q>& s)  = 0;
00288 
00289     //! Compute dsdq for the system... Not specified how to actually do this
00290     /*! s is the state, F is the computed force */
00291     virtual void dsdq(P& F, const AbsFieldState<P,Q>& s)  = 0;
00292 
00293     //! Refresh pseudofermions
00294     virtual void refreshInternalFields(const AbsFieldState<P,Q>& field_state) = 0;
00295 
00296     //! Copy pseudofermions if any
00297     virtual void setInternalFields(const Monomial<P,Q>& m) = 0;
00298 
00299     //! Reset predictors
00300     virtual void resetPredictors(void) { /* Nop for most */ }
00301 
00302   protected:
00303     //! Get at fermion action for pseudofermion field i
00304     virtual const WilsonTypeFermAct5D<Phi,P,Q>& getFermAct(void) const = 0;
00305 
00306   };
00307 
00308 }
00309 
00310 
00311 #endif

Generated on Sun Nov 22 04:28:48 2009 for CHROMA by  doxygen 1.4.7