CHROMA
lcm_integrator_leaps.cc
Go to the documentation of this file.
1 #include "lcm_integrator_leaps.h"
2 #include "util/gauge/taproj.h"
3 #include "util/gauge/reunit.h"
4 #include "util/gauge/expmat.h"
6 
7 namespace Chroma
8 {
9 
10  namespace LCMMDIntegratorSteps
11  {
12 
13  //! LeapP for just a selected list of monomials
14  void leapP(const multi1d< IntegratorShared::MonomialPair >& monomials,
15 
16  const Real& dt,
17 
18  AbsFieldState<multi1d<LatticeColorMatrix>,
19  multi1d<LatticeColorMatrix> >& s)
20  {
21  START_CODE();
22  StopWatch swatch;
23 
24 
25  XMLWriter& xml_out = TheXMLLogWriter::Instance();
26  // Self Description rule
27  push(xml_out, "leapP");
28  write(xml_out, "dt", dt);
29  multi1d<Real> real_step_size(Nd);
30 
31  // Work out the array of step sizes (including all scaling factors
32  for(int mu =0; mu < Nd; mu++)
33  {
34  real_step_size[mu] = dt * theAnisoStepSizeArray::Instance().getStepSizeFactor(mu);
35  }
36  write(xml_out, "dt_actual_per_dir", real_step_size);
37 
38  // Force Term
39  multi1d<LatticeColorMatrix> dsdQ(Nd);
40  push(xml_out, "AbsHamiltonianForce"); // Backward compatibility
41  write(xml_out, "num_terms", monomials.size());
42  push(xml_out, "ForcesByMonomial");
43 
44  if( monomials.size() > 0 ) {
45  push(xml_out, "elem");
46  swatch.reset(); swatch.start();
47  monomials[0].mon->dsdq(dsdQ,s);
48  swatch.stop();
49  QDPIO::cout << "FORCE TIME: " << monomials[0].id << " : " << swatch.getTimeInSeconds() << std::endl;
50  pop(xml_out); //elem
51  for(int i=1; i < monomials.size(); i++) {
52  push(xml_out, "elem");
53  multi1d<LatticeColorMatrix> cur_F(Nd);
54  swatch.reset(); swatch.start();
55  monomials[i].mon->dsdq(cur_F, s);
56  swatch.stop();
57  dsdQ += cur_F;
58 
59  QDPIO::cout << "FORCE TIME: " << monomials[i].id << " : " << swatch.getTimeInSeconds() << "\n";
60 
61  pop(xml_out); // elem
62  }
63  }
64  pop(xml_out); // ForcesByMonomial
65  //monitorForces(xml_out, "TotalForcesThisLevel", dsdQ);
66  pop(xml_out); // AbsHamiltonianForce
67 
68 
69  for(int mu =0; mu < Nd; mu++) {
70 
71  (s.getP())[mu] += real_step_size[mu] * dsdQ[mu];
72 
73  // taproj it...
74  taproj( (s.getP())[mu] );
75  }
76 
77  pop(xml_out); // pop("leapP");
78 
79  END_CODE();
80  }
81 
82  void leapQ(const Real& dt,
83  AbsFieldState<multi1d<LatticeColorMatrix>,
84  multi1d<LatticeColorMatrix> >& s)
85  {
86  START_CODE();
87 
88  LatticeColorMatrix tmp_1;
89  LatticeColorMatrix tmp_2;
90 
91  XMLWriter& xml_out= TheXMLLogWriter::Instance();
92  // Self description rule
93  push(xml_out, "leapQ");
94  write(xml_out, "dt", dt);
95  multi1d<Real> real_step_size(Nd);
96 
97  // Work out the array of step sizes (including all scaling factors
98  for(int mu =0; mu < Nd; mu++)
99  {
100  real_step_size[mu] = dt * theAnisoStepSizeArray::Instance().getStepSizeFactor(mu);
101  }
102  write(xml_out, "dt_actual_per_dir", real_step_size);
103 
104  // Constant
105  const multi1d<LatticeColorMatrix>& p_mom = s.getP();
106 
107  // Mutable
108  multi1d<LatticeColorMatrix>& u = s.getQ();
109 
110  for(int mu = 0; mu < Nd; mu++)
111  {
112  // dt*p[mu]
113  tmp_1 = real_step_size[mu]*(s.getP())[mu];
114 
115  // tmp_1 = exp(dt*p[mu])
116  // expmat(tmp_1, EXP_TWELFTH_ORDER);
118 
119  // tmp_2 = exp(dt*p[mu]) u[mu] = tmp_1 * u[mu]
120  tmp_2 = tmp_1*(s.getQ())[mu];
121 
122  // u[mu] = tmp_1 * u[mu] = tmp_2
123  (s.getQ())[mu] = tmp_2;
124 
125  // Reunitarize u[mu]
126  int numbad;
127  reunit((s.getQ())[mu], numbad, REUNITARIZE_ERROR);
128  }
129 
130  pop(xml_out);
131 
132  END_CODE();
133  }
134 
135  }
136 }
Abstract field state.
Definition: field_state.h:27
static T & Instance()
Definition: singleton.h:432
EXTERN Real dt
int numbad
Definition: cool.cc:28
int mu
Definition: cool.cc:24
Exponentiate a SU(n) lie algebra element by some method,.
Helper function for calculating forces.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void taproj(LatticeColorMatrix &a)
Take the traceless antihermitian projection of a color matrix.
Definition: taproj.cc:31
void expmat(LatticeColorMatrix &a, enum ExpMat_t opt)
Exponentiate a SU(n) lie algebra element by some method.
Definition: expmat.cc:39
void leapQ(const Real &dt, AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s)
Leap with Q (with all monomials)
LatticeColorMatrix tmp_2
Definition: meslate.cc:51
LatticeColorMatrix tmp_1
Definition: meslate.cc:50
Nd
Definition: meslate.cc:74
void leapP(const multi1d< IntegratorShared::MonomialPair > &monomials, const Real &dt, AbsFieldState< multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > &s)
LeapP for just a selected list of monomials.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
void reunit(LatticeColorMatrixF3 &xa)
Definition: reunit.cc:467
@ REUNITARIZE_ERROR
Definition: reunit.h:29
pop(xml_out)
START_CODE()
@ EXP_EXACT
Definition: expmat.h:11
multi1d< LatticeFermion > s(Ncb)
Reunitarize in place a color matrix to SU(N)
Take the traceless antihermitian projection of a color matrix.