CHROMA
lcm_tst_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 
13  namespace LatColMatTSTMinNorm2DTauRecursiveIntegratorEnv
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_TST_MIN_NORM_2_DTAU";
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, "./delta_tau_max", delta_tau_max);
54  read(paramtop, "./monomial_ids", monomial_ids);
55  if( paramtop.count("./lambda") == 1 ) {
56  read(paramtop, "./lambda", lambda );
57  }
58  else {
59  lambda = 0.1931833275037836;
60 
61  QDPIO::cout << "Warning no lambda param found for minimum norm integrator" << std::endl;
62  QDPIO::cout << "Using default value lambda_c="<< lambda << std::endl;
63  }
64  if( paramtop.count("./SubIntegrator") == 0 ) {
65  // BASE CASE: User does not supply sub-integrator
66  //
67  // Sneaky way - create an XML document for EXP_T
68  XMLBufferWriter subintegrator_writer;
69  int one_sub_step=1;
70 
71  push(subintegrator_writer, "SubIntegrator");
72  write(subintegrator_writer, "Name", "LCM_EXP_T");
73  write(subintegrator_writer, "n_steps", one_sub_step);
74  pop(subintegrator_writer);
75 
76  subintegrator_xml = subintegrator_writer.str();
77 
78  }
79  else {
80  // RECURSIVE CASE: User Does Supply Sub Integrator
81  //
82  // Read it
83  XMLReader subint_reader(paramtop, "./SubIntegrator");
84  std::ostringstream subintegrator_os;
85  subint_reader.print(subintegrator_os);
86  subintegrator_xml = subintegrator_os.str();
87  QDPIO::cout << "Subintegrator XML is: " << std::endl;
88  QDPIO::cout << subintegrator_xml << std::endl;
89  }
90  }
91  catch ( const std::string& e ) {
92  QDPIO::cout << "Error reading XML in LatColMatTSTMinNorm2DTauRecursiveIntegratorParams " << e << std::endl;
93  QDP_abort(1);
94  }
95  }
96 
97  void read(XMLReader& xml,
98  const std::string& path,
101  p = tmp;
102  }
103 
104  void write(XMLWriter& xml,
105  const std::string& path,
107  push(xml, path);
108  write(xml, "delta_tau_max", p.delta_tau_max);
109  write(xml, "monomial_ids", p.monomial_ids);
110  write(xml, "lambda", p.lambda);
111  xml << p.subintegrator_xml;
112  pop(xml);
113  }
114 
115 
116 
118  AbsFieldState<multi1d<LatticeColorMatrix>,
119  multi1d<LatticeColorMatrix> >& s,
120  const Real& traj_length) const
121  {
122 
123  START_CODE();
124  LatColMatExpSdtIntegrator expSdt(1,
125  monomials);
126 
127 
129  multi1d<LatticeColorMatrix> >& subIntegrator = getSubIntegrator();
130 
131  Real dtau;
132  int n_steps;
133 
134  // Set up dtau and n_steps to do the minimum amount of
135  // work without exceeding a step-size of delta_tau
136  if( toBool(traj_length > delta_tau_max) ) {
137  // delta_tau is SHORTER than traj_length => multiple steps.
138  // pick n = ceiling of traj_length/delta_tau.
139  // Then find dtau = traj_length / n
140  n_steps =toInt(ceil( traj_length/delta_tau_max ));
141  dtau = traj_length/Real(n_steps);
142  }
143  else {
144  // delta_tau is BIGGER or EQUAL to traj_length.
145  // In either case the best we can do is one step of
146  // dtau = traj_length
147  n_steps = 1;
148  dtau = traj_length;
149  }
150 
151 
152  Real lambda_dt = dtau*lambda;
153  Real dtauby2 = dtau / Real(2);
154  Real one_minus_2lambda_dt = (Real(1)-Real(2)*lambda)*dtau;
155  Real two_lambda_dt = lambda_dt*Real(2);
156 
157  // Its TST so:
158  subIntegrator(s, lambda_dt);
159  for(int i=0; i < n_steps-1; i++) { // N-1 full steps
160  // Roll the exp(lambda_dt T) here and start
161  // Next iter into one
162  expSdt(s, dtauby2);
163  subIntegrator(s, one_minus_2lambda_dt);
164  expSdt(s, dtauby2);
165  subIntegrator(s, two_lambda_dt);
166  }
167  // Last step, can't roll the first and last exp(lambda_dt T)
168  // together.
169  expSdt(s, dtauby2);
170  subIntegrator(s, one_minus_2lambda_dt);
171  expSdt(s, dtauby2);
172  subIntegrator(s, lambda_dt);
173 
174 
175  END_CODE();
176 
177 
178  }
179 
180 
181 }
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.