CHROMA
kyuqprop_io.cc
Go to the documentation of this file.
1 /*!
2  * @file
3  * @brief Read/write a Kentucky quark propagator
4  */
5 
6 #include "chromabase.h"
7 #include "io/kyuqprop_io.h"
8 #include "util/ferm/transf.h"
9 #include "util/ferm/diractodr.h"
10 #include "util/ft/sftmom.h"
11 
12 namespace Chroma {
13 
14 //! Read a Kentucky quark propagator
15 /*!
16  * \ingroup io
17  *
18  * \param q propagator ( Modify )
19  * \param file path ( Read )
20  */
21 
22 void readKYUQprop(LatticePropagator& q, const std::string& file)
23 {
24  START_CODE();
25 
26  if (Nc != 3)
27  {
28  QDPIO::cerr << "readKYUQprop - only supports Nc=3" << std::endl;
29  QDP_abort(1);
30  }
31 
32  if (Ns != 4)
33  {
34  QDPIO::cerr << "readKYUQprop - only supports Ns=4" << std::endl;
35  QDP_abort(1);
36  }
37 
38  BinaryFileReader bin(file);
39 
40  /* KY Indices:
41  x,y,z,t,snk_col,snk_spin,ri,src_col,src_spin
42  x is fastest (Fortran Order)
43  */
44  // KYU always uses 64 bits
45  LatticePropagatorD q_old;
46  multi2d<LatticeFermionD> source(Nc,Ns);
47  multi2d<LatticeRealD> re(Nc,Ns);
48  multi2d<LatticeRealD> im(Nc,Ns);
49  LatticeFermionD f;
50  LatticeColorVectorD cv;
51 
52  for(int src_spin=0; src_spin < Ns; ++src_spin)
53  for(int src_color=0; src_color < Nc; ++src_color)
54  {
55  for(int snk_spin=0; snk_spin < Ns; ++snk_spin)
56  for(int snk_color=0; snk_color < Nc; ++snk_color)
57  {
58  read(bin, re(snk_color,snk_spin));
59  }
60 
61  for(int snk_spin=0; snk_spin < Ns; ++snk_spin)
62  for(int snk_color=0; snk_color < Nc; ++snk_color)
63  {
64  read(bin, im(snk_color,snk_spin));
65  }
66 
67  // Stuff into a fermion
68  for(int snk_spin=0; snk_spin < Ns; ++snk_spin)
69  {
70  for(int snk_color=0; snk_color < Nc; ++snk_color)
71  {
72  pokeColor(cv,
73  cmplx(re(snk_color,snk_spin), im(snk_color,snk_spin)),
74  snk_color);
75  }
76 
77  pokeSpin(f, cv, snk_spin);
78  }
79 
80  // Hold temporarily in a multi2d - will need to rearrange src_spin later
81  source(src_color,src_spin) = f;
82  }
83 
84  bin.close();
85 
86  // Now rotate the src_spin indices back to original Dirac basis
87  // The source spin had to be in a chiral-like basis to use the
88  // source chirality trick of overlap.
89  // Finally, stuff the rotated result into the propagator
90  for(int src_color=0; src_color < Nc; ++src_color)
91  {
92  FermToProp(LatticeFermionD(source(src_color,0)+source(src_color,2)),
93  q_old, src_color, 0);
94  FermToProp(LatticeFermionD(source(src_color,1)+source(src_color,3)),
95  q_old, src_color, 1);
96  FermToProp(LatticeFermionD(source(src_color,2)-source(src_color,0)),
97  q_old, src_color, 2);
98  FermToProp(LatticeFermionD(source(src_color,3)-source(src_color,1)),
99  q_old, src_color, 3);
100  }
101 
102  // Rescale
103  q_old *= RealD(1.0) / sqrt(RealD(2));
104 
105  // Now that we have read the prop, need to change the spin basis
106  SpinMatrixD U = DiracToDRMat();
107 
108  // And finally...
109  q = U * q_old * adj(U);
110 
111 
112 #if 1
113  {
114  // HACK - compute rho correlator like thingy
115  ComplexD i = cmplx(RealD(0), RealD(1));
116  ComplexD mi = -i;
117  ComplexD one = cmplx(RealD(1), RealD(0));
118 
119  SpinMatrixD gamma_1 = zero;
120  pokeSpin(gamma_1, one, 0, 3);
121  pokeSpin(gamma_1, one, 1, 2);
122  pokeSpin(gamma_1, one, 2, 1);
123  pokeSpin(gamma_1, one, 3, 0);
124 
125  SpinMatrixD gamma_5 = zero;
126  pokeSpin(gamma_5, mi, 0, 2);
127  pokeSpin(gamma_5, mi, 1, 3);
128  pokeSpin(gamma_5, i, 2, 0);
129  pokeSpin(gamma_5, i, 3, 1);
130 
131 
132  LatticeComplex ps_rho = trace(adj(gamma_5 * q_old * gamma_5) * gamma_1 * q_old * gamma_1);
133 
134  LatticeComplex dr_rho = trace(adj(Gamma(15) * q * Gamma(15)) * Gamma(1) * q * Gamma(1));
135 
136  QDPIO::cout << "readKYUQprop: norm2(ps_rho) = " << RealD(norm2(ps_rho)) << std::endl;
137  QDPIO::cout << "readKYUQprop: norm2(dr_rho) = " << RealD(norm2(dr_rho)) << std::endl;
138  QDPIO::cout << "readKYUQprop: norm2(ps_rho - dr_rho) = " << RealD(norm2(ps_rho-dr_rho)) << std::endl;
139  QDPIO::cout << "readKYUQprop: norm2(ps_rho + dr_rho) = " << RealD(norm2(ps_rho+dr_rho)) << std::endl;
140 
141 #if 1
142  {
143  // Keep a copy of the phases with NO momenta
144  int j_decay = Nd-1;
145  SftMom phases(0, true, j_decay);
146 
147  multi1d<DComplex> ps_hsum = sumMulti(ps_rho, phases.getSet());
148  multi1d<DComplex> dr_hsum = sumMulti(dr_rho, phases.getSet());
149 
150  // Initial group
151  XMLFileWriter xml_out("kyuqprop.xml");
152 
153  push(xml_out, "kyuqprop");
154  write(xml_out, "norm_diff", RealD(norm2(ps_rho-dr_rho)));
155  write(xml_out, "ps_hsum", ps_hsum);
156  write(xml_out, "dr_hsum", ps_hsum);
157  pop(xml_out);
158 
159  xml_out.close();
160  }
161 #endif
162 
163  }
164 #endif
165 
166 
167  END_CODE();
168 }
169 
170 } // end namespace Chroma
Primary include file for CHROMA library code.
Fourier transform phase factor support.
Definition: sftmom.h:35
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
Basis rotation matrix from Dirac to Degrand-Rossi (and reverse)
SpinMatrixD DiracToDRMat()
The Dirac to Degrand-Rossi spin transformation matrix (and reverse)
Definition: diractodr.cc:22
void FermToProp(const LatticeFermionF &a, LatticePropagatorF &b, int color_index, int spin_index)
Insert a LatticeFermion into a LatticePropagator.
Definition: transf.cc:98
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 readKYUQprop(LatticePropagator &q, const std::string &file)
Read a Kentucky quark propagator.
Definition: kyuqprop_io.cc:22
Read/write a KYU propagator.
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
Double q
Definition: mesq.cc:17
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
Double one
Definition: invbicg.cc:105
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
pop(xml_out)
START_CODE()
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979
Fourier transform phase factor support.
multi1d< LatticeColorMatrix > U