CHROMA
lcm_sts_force_grad_recursive.cc
Go to the documentation of this file.
1 #include "chromabase.h"
6 #include "io/xmllog_io.h"
7 
8 #include <string>
9 
10 namespace Chroma
11 {
12 
13  namespace LatColMatSTSForceGradRecursiveIntegratorEnv
14  {
15  namespace
16  {
18  multi1d<LatticeColorMatrix> >*
19  createMDIntegrator(
20  XMLReader& xml,
21  const std::string& path)
22  {
23  // Read the integrator params
25 
27  }
28 
29  //! Local registration flag
30  bool registered = false;
31  }
32 
33  const std::string name = "LCM_STS_FORCE_GRAD";
34 
35  //! Register all the factories
36  bool registerAll()
37  {
38  bool success = true;
39  if (! registered)
40  {
41  success &= TheMDComponentIntegratorFactory::Instance().registerObject(name, createMDIntegrator);
42  registered = true;
43  }
44  return success;
45  }
46  }
47 
48 
50  {
51  XMLReader paramtop(xml_in, path);
52  try {
53  read(paramtop, "./n_steps", n_steps);
54  read(paramtop, "./monomial_ids", monomial_ids);
55 
56  if( paramtop.count("./SubIntegrator") == 0 ) {
57  // BASE CASE: User does not supply sub-integrator
58  //
59  // Sneaky way - create an XML document for EXP_T
60  XMLBufferWriter subintegrator_writer;
61  int one_sub_step=1;
62 
63  push(subintegrator_writer, "SubIntegrator");
64  write(subintegrator_writer, "Name", "LCM_EXP_T");
65  write(subintegrator_writer, "n_steps", one_sub_step);
66  pop(subintegrator_writer);
67 
68  subintegrator_xml = subintegrator_writer.str();
69 
70  }
71  else {
72  // RECURSIVE CASE: User Does Supply Sub Integrator
73  //
74  // Read it
75  XMLReader subint_reader(paramtop, "./SubIntegrator");
76  std::ostringstream subintegrator_os;
77  subint_reader.print(subintegrator_os);
78  subintegrator_xml = subintegrator_os.str();
79  QDPIO::cout << "Subintegrator XML is: " << std::endl;
80  QDPIO::cout << subintegrator_xml << std::endl;
81  }
82  }
83  catch ( const std::string& e ) {
84  QDPIO::cout << "Error reading XML in LatColMatSTSForceGradRecursiveIntegratorParams " << e << std::endl;
85  QDP_abort(1);
86  }
87  }
88 
89  void read(XMLReader& xml,
90  const std::string& path,
93  p = tmp;
94  }
95 
96  void write(XMLWriter& xml,
97  const std::string& path,
99  push(xml, path);
100  write(xml, "n_steps", p.n_steps);
101  write(xml, "monomial_ids", p.monomial_ids);
102  xml << p.subintegrator_xml;
103  pop(xml);
104  }
105 
106 
107  // Force-gradient evolution
108  // The code will update momentum P in state s
110  AbsFieldState<multi1d<LatticeColorMatrix>,
111  multi1d<LatticeColorMatrix> >& s,
112  const Real& traj_length1, const Real& traj_length2) const
113  {
115 
117  multi1d<LatticeColorMatrix> >& subIntegrator = getSubIntegrator();
118 
119  // Temporary state information
120  multi1d<LatticeColorMatrix> Q_tmp(Nd);
121  multi1d<LatticeColorMatrix> P_tmp(Nd);
122 
123  // Save state
124  P_tmp = s.getP();
125  Q_tmp = s.getQ();
126 
127  // Now we will use the state s as a temporary state that will be used
128  // for force-gradient update of eqs. (2.4--5) in arXiv:111.5059
129 
130  // Calculate force term and initialize momentum P in s with the force
131  // This will evaluate p' <- p + dt1 F
132  // with p=0 it becomes p = + dt1 F
133  s.getP() = zero;
134  expSdt(s, traj_length1);
135 
136  // Update gauge field with the P calculated above;
137  // Not doing this with the sub integrator, as that would
138  // likely mess up the momenta.
139  // Instead I go straight for the leapQ.
141 
142  // restore momentum P
143  s.getP() = P_tmp;
144 
145  // Update momentum in s using the U'
146  expSdt(s, traj_length2);
147 
148  // Restore gauge field back to U
149  s.getQ() = Q_tmp;
150  }
151 
152 
153 
155  AbsFieldState<multi1d<LatticeColorMatrix>,
156  multi1d<LatticeColorMatrix> >& s,
157  const Real& traj_length) const
158  {
159 
160  START_CODE();
162 
163 
165  multi1d<LatticeColorMatrix> >& subIntegrator = getSubIntegrator();
166 
167  Real lambda = Real(1)/Real(6);
168  Real xi = Real(1)/Real(72);
169 
170  Real dtau = traj_length / Real(n_steps);
171  Real lambda_dt = dtau*lambda;
172  Real dtauby2 = dtau / Real(2);
173  Real one_minus_2lambda_dt = (Real(1)-Real(2)*lambda)*dtau;
174  Real two_lambda_dt = lambda_dt*Real(2);
175  Real xi_dtdt = Real(2)*dtau*dtau*dtau*xi / one_minus_2lambda_dt;
176 
177  expSdt(s, lambda_dt);
178  for(int i=0; i < n_steps-1; i++) { // N-1 full steps
179  subIntegrator(s, dtauby2);
180  fg_update(s, xi_dtdt, one_minus_2lambda_dt);
181  subIntegrator(s, dtauby2);
182  expSdt(s, two_lambda_dt);
183  }
184  subIntegrator(s, dtauby2);
185  fg_update(s, xi_dtdt, one_minus_2lambda_dt);
186  subIntegrator(s, dtauby2);
187  expSdt(s, lambda_dt);
188 
189 
190  END_CODE();
191 
192  }
193 
194 
195 }
Primary include file for CHROMA library code.
MD integrator that can be used as a component for other integrators.
Abstract field state.
Definition: field_state.h:27
MD integrator interface for PQP leapfrog.
Definition: lcm_exp_sdt.h:58
multi1d< IntegratorShared::MonomialPair > monomials
void operator()(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s, const Real &traj_length) const
Do an integration of lenght n*delta tau in n steps.
AbsComponentIntegrator< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > & getSubIntegrator() const
Return the next level down integrator.
void fg_update(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s, const Real &traj_length1, const Real &traj_length2) const
static T & Instance()
Definition: singleton.h:432
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 leapQ(const Real &dt, AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s)
Leap with Q (with all monomials)
Intgrator for exp(S dt)
Lat Col Mat force-gradient integrator.
Integrator factories.
Nd
Definition: meslate.cc:74
static bool registered
Local registration flag.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
pop(xml_out)
START_CODE()
Double zero
Definition: invbicg.cc:106
multi1d< LatticeFermion > s(Ncb)
::std::string string
Definition: gtest.h:1979
Singleton instances of xml output.