CHROMA
lcm_sts_min_norm2_recursive_dtau.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 LatColMatSTSMinNorm2DTauRecursiveIntegratorEnv
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_DTAU";
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, "./delta_tau_max", delta_tau_max);
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 LatColMatSTSMinNorm2DTauRecursiveIntegratorParams " << 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, "delta_tau_max", p.delta_tau_max);
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  Real dtau;
131  int n_steps;
132 
133  // Set up dtau and n_steps to do the minimum amount of
134  // work without exceeding a step-size of delta_tau_max
135 
136 
137  if( toBool(traj_length > delta_tau_max) ) {
138  // delta_tau_max is SHORTER than traj_length => multiple steps.
139  // pick n = ceiling of traj_length/delta_tau_max.
140  // Then find dtau = traj_length / n
141  n_steps =toInt(ceil( traj_length/delta_tau_max ));
142  dtau = traj_length/Real(n_steps);
143  }
144  else {
145  // delta_tau_max is BIGGER or EQUAL to traj_length.
146  // In either case the best we can do is one step of
147  // dtau = traj_length
148  n_steps = 1;
149  dtau = traj_length;
150  }
151 
152  // Real dtau = traj_length / Real(n_steps);
153  Real lambda_dt = dtau*lambda;
154  Real dtauby2 = dtau / Real(2);
155  Real one_minus_2lambda_dt = (Real(1)-Real(2)*lambda)*dtau;
156  Real two_lambda_dt = lambda_dt*Real(2);
157 
158  // Its sts so:
159  expSdt(s, lambda_dt);
160  for(int i=0; i < n_steps-1; i++) { // N-1 full steps
161  // Roll the exp(lambda_dt T) here and start
162  // Next iter into one
163  subIntegrator(s, dtauby2);
164  expSdt(s, one_minus_2lambda_dt);
165  subIntegrator(s, dtauby2);
166  expSdt(s, two_lambda_dt);
167  }
168  // Last step, can't roll the first and last exp(lambda_dt T)
169  // together.
170  subIntegrator(s, dtauby2);
171  expSdt(s, one_minus_2lambda_dt);
172  subIntegrator(s, dtauby2);
173  expSdt(s, lambda_dt);
174 
175 
176  END_CODE();
177 
178 
179  }
180 
181 
182 }
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
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.
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.