CHROMA
lcm_sts_min_norm2_recursive.cc
Go to the documentation of this file.
1 #include "chromabase.h"
5 #include "io/xmllog_io.h"
6 
7 #include <string>
8 
9 namespace Chroma
10 {
11 
12  namespace LatColMatSTSMinNorm2RecursiveIntegratorEnv
13  {
14  namespace
15  {
17  multi1d<LatticeColorMatrix> >*
18  createMDIntegrator(
19  XMLReader& xml,
20  const std::string& path)
21  {
22  // Read the integrator params
24 
26  }
27 
28  //! Local registration flag
29  bool registered = false;
30  }
31 
32  const std::string name = "LCM_STS_MIN_NORM_2";
33 
34  //! Register all the factories
35  bool registerAll()
36  {
37  bool success = true;
38  if (! registered)
39  {
40  success &= TheMDComponentIntegratorFactory::Instance().registerObject(name, createMDIntegrator);
41  registered = true;
42  }
43  return success;
44  }
45  }
46 
47 
49  {
50  XMLReader paramtop(xml_in, path);
51  try {
52  read(paramtop, "./n_steps", n_steps);
53  read(paramtop, "./monomial_ids", monomial_ids);
54  if( paramtop.count("./lambda") == 1 ) {
55  read(paramtop, "./lambda", lambda );
56  }
57  else {
58  lambda = 0.1931833275037836;
59 
60  QDPIO::cout << "Warning no lambda param found for minimum norm integrator" << std::endl;
61  QDPIO::cout << "Using default value lambda_c="<< lambda << std::endl;
62  }
63  if( paramtop.count("./SubIntegrator") == 0 ) {
64  // BASE CASE: User does not supply sub-integrator
65  //
66  // Sneaky way - create an XML document for EXP_T
67  XMLBufferWriter subintegrator_writer;
68  int one_sub_step=1;
69 
70  push(subintegrator_writer, "SubIntegrator");
71  write(subintegrator_writer, "Name", "LCM_EXP_T");
72  write(subintegrator_writer, "n_steps", one_sub_step);
73  pop(subintegrator_writer);
74 
75  subintegrator_xml = subintegrator_writer.str();
76 
77  }
78  else {
79  // RECURSIVE CASE: User Does Supply Sub Integrator
80  //
81  // Read it
82  XMLReader subint_reader(paramtop, "./SubIntegrator");
83  std::ostringstream subintegrator_os;
84  subint_reader.print(subintegrator_os);
85  subintegrator_xml = subintegrator_os.str();
86  QDPIO::cout << "Subintegrator XML is: " << std::endl;
87  QDPIO::cout << subintegrator_xml << std::endl;
88  }
89  }
90  catch ( const std::string& e ) {
91  QDPIO::cout << "Error reading XML in LatColMatSTSMinNorm2RecursiveIntegratorParams " << e << std::endl;
92  QDP_abort(1);
93  }
94  }
95 
96  void read(XMLReader& xml,
97  const std::string& path,
100  p = tmp;
101  }
102 
103  void write(XMLWriter& xml,
104  const std::string& path,
106  push(xml, path);
107  write(xml, "n_steps", p.n_steps);
108  write(xml, "monomial_ids", p.monomial_ids);
109  write(xml, "lambda", p.lambda);
110  xml << p.subintegrator_xml;
111  pop(xml);
112  }
113 
114 
115 
117  AbsFieldState<multi1d<LatticeColorMatrix>,
118  multi1d<LatticeColorMatrix> >& s,
119  const Real& traj_length) const
120  {
121 
122  START_CODE();
123  LatColMatExpSdtIntegrator expSdt(1,
124  monomials);
125 
126 
128  multi1d<LatticeColorMatrix> >& subIntegrator = getSubIntegrator();
129 
130 
131  Real dtau = traj_length / Real(n_steps);
132  Real lambda_dt = dtau*lambda;
133  Real dtauby2 = dtau / Real(2);
134  Real one_minus_2lambda_dt = (Real(1)-Real(2)*lambda)*dtau;
135  Real two_lambda_dt = lambda_dt*Real(2);
136 
137  // Its sts so:
138  expSdt(s, lambda_dt);
139  for(int i=0; i < n_steps-1; i++) { // N-1 full steps
140  // Roll the exp(lambda_dt T) here and start
141  // Next iter into one
142  subIntegrator(s, dtauby2);
143  expSdt(s, one_minus_2lambda_dt);
144  subIntegrator(s, dtauby2);
145  expSdt(s, two_lambda_dt);
146  }
147  // Last step, can't roll the first and last exp(lambda_dt T)
148  // together.
149  subIntegrator(s, dtauby2);
150  expSdt(s, one_minus_2lambda_dt);
151  subIntegrator(s, dtauby2);
152  expSdt(s, lambda_dt);
153 
154 
155  END_CODE();
156 
157 
158  }
159 
160 
161 }
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
MD integrator interface for PQP leapfrog.
AbsComponentIntegrator< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > & getSubIntegrator() const
Return the next level down integrator.
void operator()(AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s, const Real &traj_length) const
Do an integration of lenght n*delta tau in n steps.
multi1d< IntegratorShared::MonomialPair > monomials
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.
Intgrator for exp(S dt)
Intgrator for exp(S dt)
Integrator factories.
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()
multi1d< LatticeFermion > s(Ncb)
::std::string string
Definition: gtest.h:1979
Singleton instances of xml output.