CHROMA
seoprec_logdet_diag_monomial_w.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Symmetric even-odd preconditioned log(det(A_ee)) and log(det(A_oo))
4  */
5 
6 #ifndef __seoprec_logdet_diag_monomial_h__
7 #define __seoprec_logdet_diag_monomial_h__
8 
13 #include "io/xmllog_io.h"
14 
15 
16 namespace Chroma
17 {
18 
19  //! A Monomial For Just the diagonal parts of SymEvenOddPrecLogDetWilsonTypeFermActs
20  /*! @ingroup monomial
21  *
22  * Monomial is expected to be the same for these fermacts
23  */
24  template<typename P, typename Q, typename Phi>
26  {
27  public:
29 
30  void dsdq(P& F, const AbsFieldState<P,Q>& s)
31  {
32  START_CODE();
33 
34  XMLWriter& xml_out = TheXMLLogWriter::Instance();
35  push(xml_out, "SymEvenOddPrecLogDetDiagMonomial");
36 
37  // Create FermAct
39 
40  // Create a state for linop
42 
43  //Create LinOp
45 
46  // The derivative of each term
47  P F_tmp;
48  lin->derivLogDetEvenEvenLinOp(F, PLUS);
49  lin->derivLogDetOddOddLinOp(F_tmp, PLUS);
50  F += F_tmp;
51 
52  for(int mu=0; mu < Nd; mu++) {
53  F[mu] *= Real(-getNumFlavors());
54  }
55 
56  state->deriv(F);
57 
58  monitorForces(xml_out, "Forces", F);
59  pop(xml_out);
60 
61  END_CODE();
62  }
63 
64 
65  //! Gauge action value
67  {
68  START_CODE();
69 
70  XMLWriter& xml_out = TheXMLLogWriter::Instance();
71 
72  push(xml_out, "SymEvenOddPrecLogDetDiagMonomial");
74  Handle< FermState<Phi,P,Q> > bc_g_state = FA.createState(s.getQ());
75 
76  // Need way to get gauge state from AbsFieldState<P,Q>
78 
79  Double S_ee = (Double(-getNumFlavors())*lin->logDetEvenEvenLinOp());
80  Double S_oo = (Double(-getNumFlavors())*lin->logDetOddOddLinOp());
81  Double S = S_ee + S_oo;
82 
83  write(xml_out, "S", S);
84  pop(xml_out);
85 
86  END_CODE();
87 
88  return S;
89  }
90 
91 
92  void refreshInternalFields(const AbsFieldState<multi1d<LatticeColorMatrix>,
93  multi1d<LatticeColorMatrix> >& s) {
94  //No internal fields to refresh => Nop
95  }
96 
97  void setInternalFields(const Monomial<multi1d<LatticeColorMatrix>,
98  multi1d<LatticeColorMatrix> >& m) {
99  // No internal fields to refresh => Nop
100  }
101 
102  protected:
104  virtual const int getNumFlavors() const = 0;
105  };
106 
107 
108  /*! @ingroup monomial */
109  namespace SymEvenOddPrecLogDetDiagMonomial4DEnv
110  {
111  bool registerAll();
112  }
113 
114  // Parameter structure
115  /*! @ingroup monomial */
117  {
118  // Base Constructor
120 
121  // Read monomial from some root path
122  SymEvenOddPrecLogDetDiagMonomialParams(XMLReader& in, const std::string& path);
123 
126  };
127 
128  /*! @ingroup monomial */
129  void read(XMLReader& r, const std::string& path, SymEvenOddPrecLogDetDiagMonomialParams& p);
130 
131  /*! @ingroup monomial */
132  void write(XMLWriter& xml, const std::string& path, const SymEvenOddPrecLogDetDiagMonomialParams& p);
133 
134 
135  //! A Monomial For Just the Diag part of SymEvenOddPrecLogDetWilsonTypeFermActs -- concretely a 4D one
136  /*! @ingroup monomial
137  *
138  * Monomial is expected to be the same for these fermacts
139  */
141  public SymEvenOddPrecLogDetDiagMonomial<multi1d<LatticeColorMatrix>,
142  multi1d<LatticeColorMatrix>,
143  LatticeFermion>
144  {
145  public:
146  // Typedefs to save typing
147  typedef LatticeFermion T;
148  typedef multi1d<LatticeColorMatrix> P;
149  typedef multi1d<LatticeColorMatrix> Q;
150 
151  //! Construct from param struct
153 
154  //! Copy Constructor
156 
157  //! Destructor is automagic
159 
160 
161  protected:
163  return *fermact;
164  }
165 
166  const int getNumFlavors() const {
167  return num_flavors;
168  }
169 
170  private:
173  };
174 
175 } //end namespace chroma
176 
177 #endif
Monomials - gauge action or fermion binlinear contributions for HMC.
Abstract field state.
Definition: field_state.h:27
Abstract monomial class, for exact algorithms.
Definition: abs_monomial.h:75
virtual FermState< T, P, Q > * createState(const Q &q) const
Given links (coordinates Q) create the state needed for the linear operators.
Definition: fermact.h:59
Class for counted reference semantics.
Definition: handle.h:33
An abstract monomial class, for inexact algorithms.
Definition: abs_monomial.h:43
static T & Instance()
Definition: singleton.h:432
A Monomial For Just the Diag part of SymEvenOddPrecLogDetWilsonTypeFermActs – concretely a 4D one.
Handle< SymEvenOddPrecLogDetWilsonTypeFermAct< T, P, Q > > fermact
const SymEvenOddPrecLogDetWilsonTypeFermAct< T, P, Q > & getFermAct(void) const
SymEvenOddPrecLogDetDiagMonomial4D(const SymEvenOddPrecLogDetDiagMonomialParams &p)
Construct from param struct.
SymEvenOddPrecLogDetDiagMonomial4D(const SymEvenOddPrecLogDetDiagMonomial4D &m)
Copy Constructor.
A Monomial For Just the diagonal parts of SymEvenOddPrecLogDetWilsonTypeFermActs.
Double S(const AbsFieldState< P, Q > &s)
Gauge action value.
virtual const SymEvenOddPrecLogDetWilsonTypeFermAct< Phi, P, Q > & getFermAct() const =0
void refreshInternalFields(const AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s)
Refresh pseudofermion fields if any.
virtual const int getNumFlavors() const =0
void dsdq(P &F, const AbsFieldState< P, Q > &s)
Compute dsdq for the system... Not specified how to actually do this.
void setInternalFields(const Monomial< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &m)
Copy pseudofermions if any.
Symmetric even-odd preconditioned Wilson-like fermion action, specialised to clover like (gauge depen...
virtual SymEvenOddPrecLogDetLinearOperator< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const =0
Override to produce an even-odd prec. linear operator for this action.
int mu
Definition: cool.cc:24
Field state.
Helper function for calculating forces.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void monitorForces(XMLWriter &xml_out, const std::string &path, const multi1d< LatticeColorMatrix > &F)
Calculate and write out forces.
static int m[4]
Definition: make_seeds.cc:16
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
push(xml_out,"Condensates")
@ PLUS
Definition: chromabase.h:45
pop(xml_out)
START_CODE()
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
Definition: pbg5p_w.cc:28
static QDP_ColorVector * in
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Symmetric even-odd const determinant Wilson-like fermact.
Hold group xml and type id.
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13
Singleton instances of xml output.
static INTERNAL_PRECISION F