CHROMA
t_ovlap_bj.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include <sstream>
4 #include <iomanip>
5 #include <string>
6 
7 #include <cstdio>
8 
9 #include <stdlib.h>
10 #include <sys/time.h>
11 #include <math.h>
12 
13 #include "chroma.h"
14 //#include "state.h"
15 //#include "actions/ferm/linop/lovlapms_w.h"
16 //#include "actions/ferm/fermacts/zolotarev_state.h"
17 //#include "actions/ferm/fermacts/zolotarev4d_fermact_bj_w.h"
18 //#include "actions/ferm/linop/lovlapms_w.h"
19 //#include "meas/eig/eig_w.h"
20 //#include "meas/hadron/srcfil.h"
21 //#include "actions/ferm/invert/invcg1.h"
22 //#include "util/ft/sftmom.h"
23 
24 using namespace Chroma;
25 
28 
29 
30 
31 // Struct for test parameters
32 //
33 typedef struct {
34  multi1d<int> nrow;
35  multi1d<int> boundary;
36  multi1d<int> rng_seed;
37  multi1d<Real> lambda;
38  Real lambda_max;
39  bool szin_eig;
40  int gauge_start_type;
41  int gauge_file_format;
42  std::string gauge_filename;
43 
44  Real wilson_mass;
45  Real quark_mass;
46  int approx_order;
47  double approx_min;
48  double approx_max;
49  Real rsd_cg;
50  Real rsd_cg_inner;
51 
52  int max_cg;
53  int max_cg_inner;
54  multi1d<Real> szin_pion;
55 
56 } Param_t;
57 
58 
59 // Declare routine to read the parameters
60 void readParams(const std::string& filename, Param_t& params)
61 {
62  XMLReader reader(filename);
63 
64  try {
65  // Read Params
66  read(reader, "/params/lattice/nrow", params.nrow);
67  read(reader, "/params/lattice/boundary", params.boundary);
68  read(reader, "/params/RNG/seed", params.rng_seed);
69  read(reader, "/params/zolotarev/wilsonMass", params.wilson_mass);
70 
71  // Read EigenValues:
72  //
73 
74  if ( reader.count("/params/SZINEValues") > 0 ) {
75 
76  // SZIN EValues
77  read(reader, "/params/SZINEValues/lambda", params.lambda);
78  read(reader, "/params/SZINEValues/lambdaMax", params.lambda_max);
79  for(int i=0; i < params.lambda.size(); i++) {
80  params.lambda[i] *= Real(Nd) + params.wilson_mass;
81  }
82  params.lambda_max *= Real(Nd) + params.wilson_mass;
83  params.szin_eig = true;
84  }
85  else if ( reader.count("/params/eValues") > 0 ) {
86 
87  // Chroma EValues
88  read(reader, "/params/eValues/lambda", params.lambda);
89  read(reader, "/params/eValues/lambdaMax", params.lambda_max);
90  params.szin_eig = false;
91  }
92  else {
93 
94  // No EValues
95  params.lambda.resize(0);
96  params.szin_eig = false;
97  }
98 
99  read(reader, "/params/Cfg/startType", params.gauge_start_type);
100  if( params.gauge_start_type == FILE_START ) {
101  read(reader, "/params/Cfg/gaugeFilename", params.gauge_filename);
102  read(reader, "/params/Cfg/gaugeFileFormat", params.gauge_file_format);
103  }
104 
105 
106  read(reader, "/params/zolotarev/approxOrder", params.approx_order);
107 
108  if( reader.count("/params/zolotarev/approxMin") == 1 ) {
109  read(reader, "/params/zolotarev/approxMin", params.approx_min);
110  }
111  else {
112  params.approx_min = -1;
113  }
114 
115  if( reader.count("/params/zolotarev/approxMax") == 1 ) {
116  read(reader, "/params/zolotarev/approxMax", params.approx_max);
117  } else {
118  params.approx_max = -1;
119  }
120 
121 
122  read(reader, "/params/zolotarev/quarkMass", params.quark_mass);
123  read(reader, "/params/zolotarev/RsdCG", params.rsd_cg_inner);
124  read(reader, "/params/zolotarev/MaxCG", params.max_cg_inner);
125 
126  read(reader, "/params/qprop/RsdCG", params.rsd_cg);
127  read(reader, "/params/qprop/MaxCG", params.max_cg);
128 
129 
130  if( reader.count("/params/checking/szinPion") == 1 ) {
131  read(reader, "/params/checking/szinPion", params.szin_pion);
132  if( params.szin_pion.size() != params.nrow[3] ) {
133  QDP_error_exit("Comparison pion has wrong no of timeslices. Nrow[3] = %d szin_pion.size() = %d", params.nrow[3], params.szin_pion.size());
134  }
135 
136  }
137  else {
138  params.szin_pion.resize(0);
139  }
140 
141  }
142  catch(const std::string& e) {
143  throw e;
144  }
145 }
146 
147 void dumpParams(XMLWriter& writer, Param_t& params)
148 {
149  push(writer, "params");
150  push(writer, "lattice");
151  write(writer, "nrow", params.nrow);
152  write(writer, "boundary", params.boundary);
153  pop(writer); // lattice
154  push(writer, "RNG");
155  write(writer, "seed", params.rng_seed);
156  pop(writer); // RNG
157 
158  if( params.lambda.size() > 0 ) {
159  if ( params.szin_eig ) {
160 
161  push(writer, "eValues");
162  write(writer, "lambda", params.lambda);
163  write(writer, "lambdaMax", params.lambda_max);
164  pop(writer); // eValues
165 
166  push(writer, "SZINEValues");
167  multi1d<Real> szin_lambda(params.lambda);
168  Real szin_lambda_max = params.lambda_max;
169 
170  for(int i = 0; i < params.lambda.size(); i++) {
171  szin_lambda[i] /= (Real(Nd) + params.wilson_mass);
172  }
173  szin_lambda_max /= (Real(Nd) + params.wilson_mass);
174 
175  write(writer, "lambda", szin_lambda);
176  write(writer, "lambdaMax", szin_lambda_max);
177  pop(writer); // SZINEValues
178  }
179  else {
180  push(writer, "eValues");
181  write(writer, "lambda", params.lambda);
182  write(writer, "lambdaMax", params.lambda_max);
183  pop(writer); // eValues
184  }
185  }
186  push(writer, "Cfg");
187  write(writer, "startType", params.gauge_start_type);
188  if( params.gauge_start_type == FILE_START ) {
189  write(writer, "gaugeFileFormat", params.gauge_file_format);
190  write(writer, "gaugeFilename", params.gauge_filename);
191  }
192  pop(writer); // Cfg
193 
194  push(writer, "zolotarev");
195  write(writer, "approxOrder", params.approx_order);
196  if( params.approx_min > 0 ) {
197  write(writer, "approxMin", params.approx_min);
198  }
199 
200  if( params.approx_max > 0 ) {
201  write(writer, "approxMax", params.approx_max);
202  }
203 
204  write(writer, "wilsonMass", params.wilson_mass);
205  write(writer, "quarkMass", params.quark_mass);
206  write(writer, "RsdCG", params.rsd_cg_inner);
207  write(writer, "MaxCG", params.max_cg_inner);
208  pop(writer); // zolotarev
209 
210  push(writer, "qprop");
211  write(writer, "RsdCG", params.rsd_cg);
212  write(writer, "MaxCG", params.max_cg);
213  pop(writer);
214 
215  if( params.szin_pion.size() > 0 ) {
216  push(writer, "checking");
217  write(writer, "szinPion", params.szin_pion);
218  pop(writer);
219  }
220 
221  pop(writer); // params
222 }
223 
224 //! Read in the old SZIN eigenvectors.
225 // Not only do we read the eigenvectors but we also check them
226 // by computing the norm:
227 //
228 // || gamma_5 D_wils e_i - lambda_i e_i ||
229 //
230 // Since D_wils = (Nd + m_wils) D_wils_szin, we expect this
231 // norm to be
232 //
233 // (Nd + m_wils) || gamma_5 D_wils_szin e_i - lambda_i e_i ||
234 //
235 // We also compute the old SZIN norm:
236 //
237 // || gamma_5 D_wils_szin e_i - lambda_i e_i ||
238 //
239 // by dividing our original eigen nom by (Nd + m_wils)
240 //
241 // This latter norm can be checked against SZIN NMLDAT files.
242 //
243 void readEigenVecs(const multi1d<LatticeColorMatrix>& u,
244  const UnprecWilsonFermAct& S_aux,
245  const multi1d<Real>& lambda_lo,
246  multi1d<LatticeFermion>& eigen_vec,
247  const Real wilson_mass,
248  const bool szin_eig,
249  XMLWriter& xml_out,
250  const std::string& root_prefix)
251 {
252 
253 
254  // Create a connect State
255  // This is where the boundary conditions are applied.
256 
259 
260 
261  // Create Space for the eigen vecs
262  eigen_vec.resize(lambda_lo.size());
263 
264  // Create Space for the eigenstd::vector norms
265  multi1d<Real> e_norms(lambda_lo.size());
266  multi1d<Real> evec_norms(lambda_lo.size());
267 
268  for(int i = 0; i < lambda_lo.size(); i++) {
269 
270  // Make up the filename
271  std::ostringstream filename;
272 
273  // this will produce eigenvector_XXX
274  // where XXX is a 0 padded integer -- eg 001, 002, 010 etc
275  filename << root_prefix << "eigenvector_" << std::setw(3) << std::setfill('0') << i;
276 
277 
278  std::cout << "Reading eigenstd::vector: " << filename.str() << std::endl;
279  readSzinFerm(eigen_vec[i], filename.str());
280 
281  // Check e-vectors are normalized
282  evec_norms[i] = (Real)sqrt(norm2(eigen_vec[i]));
283 
284  // Check the norm || Gamma_5 D e_v - lambda
285  LatticeFermion D_ev, tmp_ev, lambda_e;
286 
287  // D_ew = D ev(i)
288  (*D_w)(tmp_ev, eigen_vec[i], PLUS);
289 
290  D_ev = Gamma(15)*tmp_ev;
291 
292  // Lambda_e
293  lambda_e = lambda_lo[i]*eigen_vec[i];
294 
295  D_ev -= lambda_e;
296 
297  e_norms[i] = (Real)sqrt(norm2(D_ev));
298  }
299  push(xml_out, "Eigenstd::vectorTest");
300  push(xml_out, "EigenVecNorms");
301  write(xml_out, "evec_norms", evec_norms);
302  pop(xml_out);
303  push(xml_out, "EigenTestNorms");
304  write(xml_out, "e_norms", e_norms);
305  pop(xml_out);
306 
307  if( szin_eig ) {
308  multi1d<Real> szin_enorms(e_norms);
309  for(int i=0; i < lambda_lo.size(); i++) {
310  szin_enorms[i] /= (Real(Nd)+wilson_mass);
311  }
312  push(xml_out, "SZINEigenTestNorms");
313  write(xml_out, "szin_enorms",szin_enorms);
314  pop(xml_out);
315  }
316  pop(xml_out); // eigenstd::vector test
317 }
318 
319 int main(int argc, char **argv)
320 {
321  // Put the machine into a known state
322  Chroma::initialize(&argc, &argv);
323 
324  std::string root_prefix="";
325 
326  if( argc == 2 ) {
327  root_prefix += argv[1];
328  root_prefix += "/";
329  }
330 
331  // Read the parameters
332  Param_t params;
333 
334  try {
335  readParams(root_prefix+"DATA", params);
336  }
337  catch(const std::string& s) {
338  QDPIO::cerr << "Caught exception " << s << std::endl;
339  exit(1);
340  }
341 
342 
343  // Setup the lattice
344  Layout::setLattSize(params.nrow);
345  Layout::create();
346 
347  // Write out the params
348  XMLFileWriter xml_out(root_prefix+"t_ovlap.xml");
349  push(xml_out, "overlapTest");
350 
351  dumpParams(xml_out, params);
352 
353 
354  // Create a FermBC
356 
357  // The Gauge Field
358  multi1d<LatticeColorMatrix> u(Nd);
359 
360  switch ((GaugeStartType)params.gauge_start_type) {
361  case COLD_START:
362  for(int j = 0; j < Nd; j++) {
363  u(j) = Real(1);
364  }
365  break;
366  case HOT_START:
367  // Hot (disordered) start
368  for(int j=0; j < Nd; j++) {
369  random(u(j));
370  reunit(u(j));
371  }
372  break;
373  case FILE_START:
374 
375  // Start from File
376  switch( (GaugeFormat)params.gauge_file_format) {
377  case SZIN_GAUGE_FORMAT:
378  {
379  XMLReader szin_xml;
380  readSzin(szin_xml, u, params.gauge_filename);
381  try {
382  push(xml_out, "GaugeInfo");
383  xml_out << szin_xml;
384  pop(xml_out);
385 
386  }
387  catch(const std::string& e) {
388  std::cerr << "Error: " << e << std::endl;
389  }
390 
391  }
392  break;
393 
394  case NERSC_GAUGE_FORMAT:
395  {
396  XMLReader nersc_xml;
397  readArchiv(nersc_xml, u, params.gauge_filename);
398 
399  try {
400  push(xml_out, "GaugeInfo");
401  xml_out << nersc_xml;
402  pop(xml_out);
403 
404  }
405  catch(const std::string& e) {
406  std::cerr << "Error: " << e << std::endl;
407  }
408  }
409  break;
410 
411  default:
412  std::ostringstream file_read_error;
413  file_read_error << "Unknown gauge file format" << params.gauge_file_format ;
414  throw file_read_error.str();
415  }
416  break;
417  default:
418  std::ostringstream startup_error;
419  startup_error << "Unknown start type " << params.gauge_start_type <<std::endl;
420  throw startup_error.str();
421  }
422 
423 
424  // Measure the plaquette on the gauge
425  MesPlq(xml_out, "Observables", u);
426  xml_out.flush();
427 
428  //! Wilsoniums;
429  // Put this puppy into a handle to allow Zolo to copy it around as a **BASE** class
430  // WARNING: the handle now owns the data. The use of a bare S_w below is legal,
431  // but just don't delete it.
433 
434 
435  XMLBufferWriter my_writer;
436 
437  //! N order Zolo approx, with wilson action.
438  Zolotarev4DFermAct S(fbc, S_w,
439  params.quark_mass,
440  params.approx_order,
441  params.rsd_cg_inner,
442  params.max_cg_inner,
443  my_writer);
444 
445 
446  const ConnectState* connect_state_ptr;
447  multi1d<LatticeFermion> eigen_vecs;
448 
449 
450  // Flick on BC's - do not do this. Now let it be down in createState
451 // phfctr(u);
452 
453  if( params.lambda.size() == 0 ) {
454 
455  // Connect State with no eigenvectors
456  connect_state_ptr = S.createState(u,
457  Real(params.approx_min),
458  Real(params.approx_max));
459  }
460  else {
461 
462  // Connect State with eigenvectors
463  if( params.szin_eig ) {
464  readEigenVecs(u,
465  dynamic_cast<UnprecWilsonFermAct&>(*S_w),
466  params.lambda,
467  eigen_vecs,
468  params.wilson_mass,
469  params.szin_eig,
470  xml_out,
471  root_prefix);
472  }
473  else {
474  QDP_error_exit("Non SZIN e-values not yet implmeneted");
475  }
476 
477  connect_state_ptr = S.createState(u,
478  params.lambda,
479  eigen_vecs,
480  params.lambda_max);
481  }
482 
483 
484  // Stuff the pointer into a handle. Now, the handle owns the data.
485  Handle<const ConnectState> connect_state(connect_state_ptr);
486 
487 
488  // Make me a linop (this callls the initialise function)
489  Handle<const LinearOperator<LatticeFermion> > D_op(S.linOp(connect_state));
490 
491 
492  // Check GW Relation.
493  //
494  // In massless case GWR is: D^{dag}(0) + D(0) = 2 D^{dag}(0) D(0)
495  //
496  // To derive for arbitrary mass case, use D(m) = m + (1-m)D(0)
497  // => D(0) = (1/m)[ D(m) - m ]
498  //
499  //
500  // LHS is: (1/(1-m)) [ D(m) + D^{dag}(m) - 2m ]
501  // = (1/(1-m)) [ D(m) + D^{dag}(m) ] - 2m/(1-m)
502  //
503  // RHS is: (2/(1-m)^2) [ D^{dag}(m)D(m) - mD(m) - mD^{dag}(m) + m^2 ]
504  // =(1/(1-m)^2) [ 2D^{dag}(m)D(m) -2m(D(m) + D^{dag}(m)) + 2 m^2 ]
505  //
506  // Multiply both sides by (1-m)^2
507  //
508  // LHS is: (1 - m)[D(m) + D^{dag}(m) ] - 2m(1-m)
509  // = (1 - m)[D(m) + D^{dag}(m} ] - 2m + 2m^2
510  //
511  // RHS is: 2D^{dag}(m)D(m) - 2m(D(m) + D^{dag}(m)) + 2 m^2
512  //
513  // Add 2m( D(m) + D^{dag}(m) - 2m^2 to both sides:
514  //
515  // LHS is: (1 + m)[ D(m) + D^{dag}(m) ] - 2m
516  // RHS is: 2D^{dag}(m) D(m)
517  //
518  //
519  // Divide both sides by 2 to get a massive version of the GWR:
520  //
521  // ***********************************************************
522  //
523  // ((1 + m)/2) [ D(m) + D^{dag}(m) ] - m = D^{dag}(m)D(m)
524  //
525  // ***********************************************************
526  //
527  // This is what we check.
528 
529  LatticeFermion psi;
530 
531  // Create some source with unit norm
532  gaussian(psi);
533  Double n2 = sqrt(norm2(psi));
534  psi /= n2;
535 
536 
537  LatticeFermion s1, s2, s3, tmp2;
538  s1 = s2 = s3 = tmp2 = zero;
539 
540  (*D_op)(s1,psi,PLUS); // s1 = D(m) psi
541  (*D_op)(s2,psi,MINUS); // s2 = D^{dag}(m) psi
542 
543  (*D_op)(tmp2, psi, PLUS); // s3 = D^{dag}(m) D(m) psi
544  (*D_op)(s3, tmp2, MINUS); // = RHS psi
545 
546  tmp2 = s1 + s2; // tmp2 = [ D(m) + D^{dag}(m) ] psi
547 
548 
549  // tmp2 = (1 + m) [ D(m) + D^{dag}(m) ] psi
550  tmp2 *= ( Real(1) + params.quark_mass )/Real(2);
551 
552  // tmp2 = (1 + m ) [ D(m) + D^{dag}(m) - m ] psi = LHS psi
553  tmp2 -= params.quark_mass * psi;
554 
555  // RHS - LHS
556  s3 -= tmp2;
557 
558  // Should be zero
559  Double gwr_norm = sqrt(norm2(s3));
560  std::cout << "GWR Norm: " << gwr_norm << std::endl;
561  write(xml_out, "gwr_norm", gwr_norm);
562 
563  // Now test Naive MdagM
564  Handle< const LinearOperator<LatticeFermion> > MdagM( S.lMdagM(connect_state));
565 
566  // MdagM created.
567  std::cout << "MdagM created" << std::endl;
568  // Apply MdagM to psi
569  (*MdagM)(s1, psi, PLUS);
570 
571  // Apply MdagM on its own
572  (*D_op)(tmp2, psi, PLUS);
573  (*D_op)(s2, tmp2, MINUS);
574 
575  s3 = s2 - s1;
576  // Time to bolt
577  Double internal_norm = sqrt(norm2(s3));
578  std::cout << " || MdagM - M^{dag}M || = " << internal_norm << std::endl;
579  write(xml_out, "internal_norm", internal_norm);
580 
581 
582 
583 
584  // Make a Source
585  LatticeFermion source;
586  multi1d<int> coord(Nd);
587  coord[0]=0; coord[1] = 0; coord[2] = 0; coord[3] = 0;
588 
589  for(int i = 0; i < Ns; i++) {
590  source = zero;
591  srcfil(source, coord, 0, i);
592  Chirality c = isChiralVector(source);
593  switch ( c ) {
594  case CH_NONE:
595  std::cout << "Ns = " << i <<" : No definite chirality" <<std::endl;
596  break;
597  case CH_PLUS:
598  std::cout << "Ns = " << i << " : Chirality is positive " << std::endl;
599  break;
600  case CH_MINUS:
601  std::cout << "Ns = " << i << " : Chirality is negative " << std::endl;
602  break;
603  default:
604  QDP_error_exit("What the heck?: %d\n", (int)c);
605  break;
606  }
607  }
608 
609  // Zero the source
610  source = zero;
611 
612 
613  ColorVector c=zero;
614  Complex cone = cmplx(Real(1), Real(0));
615 
616  // Set one element of the color vec to Cmplx(1)
617  pokeColor(c, cone, 0);
618 
619  // Poke it into two locations of opposite chirality
620  Fermion f=zero;
621  pokeSpin(f, c, 0);
622  pokeSpin(f, c, 2);
623 
624  // Poke the site into source
625  pokeSite(source, f, coord);
626 
627  std::cout << "(1,0,1,0) has chirality " << isChiralVector(source) << std::endl;
628 
629  gaussian(source);
630  std::cout << "Gaussian source has chirality: " << isChiralVector(source) << std::endl;
631 
632  int G5 = Ns * Ns - 1;
633 
634  s1 = 0.5*(source + Gamma(G5)*source);
635  s2 = 0.5*(source - Gamma(G5)*source);
636 
637  std::cout << "+ve chirality projection has chirality: " << isChiralVector(s1) << std::endl;
638  std::cout << "-ve chirality projection has chirality: " << isChiralVector(s2) << std::endl;
639 
640 
641 
642  for(int i = 0; i < Ns; i++ ) {
643  source = zero;
644  srcfil(source, coord, 0, i);
645 
647  MdagM_ch( S.lMdagM(connect_state, isChiralVector(source)) );
648 
649  (*MdagM)(s1, source, PLUS);
650  (*MdagM_ch)(s2, source, PLUS);
651 
652  s3 = s1 - s2;
653  std::cout << "Spin Comp: " << i << ": || M dag M - lovddag || = " << sqrt(norm2(s3)) << std::endl;
654  }
655 
656 
657  std::cout << "Now non chiral work. Should get back Normal MdagM" << std::endl;
658  source = zero;
659  gaussian(source);
660 
662  MdagM2 ( S.lMdagM(connect_state, isChiralVector(source)) );
663 
664  (*MdagM)(s1, source, PLUS);
665  (*MdagM2)(s2, source, PLUS);
666  s3 = s1 - s2;
667  std::cout << "Non Chiral Source: || M dag M - MdagM(chi=0) || = " << sqrt(norm2(s3)) << std::endl;
668 
669 
670  std::cout << "Beginning qprop test" << std::endl;
671  std::cout << "Chiral Sources" << std::endl;
672 
673  /*
674  try {
675  push(xml_out, "QpropTest");
676  } catch( std::string& e) {
677  std::cerr << e << std::endl;
678  throw;
679  }
680 
681  source = zero;
682  std::cout << "No chirality" << std::endl;
683  gaussian(source);
684 
685  // D_dag source
686  int n_count=0;
687  S.qprop(s2, connect_state, source, CG_INVERTER, Real(1.0e-7), 500, n_count);
688 
689  s2 *= (Real(1) - params.quark_mass );
690  s2 += source;
691 
692  // s2 = D D^{-1} source = source
693  (*D_op)(s3, s2, PLUS);
694  s3 -= source;
695 
696  Real r = sqrt(norm2(s3)/norm2(source));
697 
698  std::cout << " || source - M solution || / || source || = " << r << std::endl;
699  push(xml_out, "NonChiralInv2");
700  write(xml_out, "r", r);
701  pop(xml_out);
702 
703 
704  for(int i=0; i < Ns; i++) {
705  source = zero;
706  srcfil(source, coord, 0, i);
707 
708 
709  S.qprop(s2, connect_state, source, CG_INVERTER, Real(1.0e-7), 500, n_count);
710  s2 *= Real(1) - params.quark_mass;
711  s2 += source;
712 
713  // s2 = D D^{-1} source = source
714  (*D_op)(s3, s2, PLUS);
715  s3 -= source;
716 
717  Real r = sqrt(norm2(s3)/norm2(source));
718  std::cout << "Chiral:" << i << " || source - M solution || / || source || = " <<r << std::endl;
719 
720  push(xml_out, "ChiralInv1");
721  write(xml_out, "spin", i);
722  write(xml_out, "r", r);
723  pop(xml_out);
724 
725  }
726 
727 
728 
729  */
730 
731  /*
732  // Try and reproduce the SZIN pion
733  // Source and solution props
734  LatticePropagator q_src, q_sol;
735 
736  // Fill out the source. Point source on each one.
737  // Shurely there musht be shome convenience for this.
738  for(int spin=0; spin < Ns; spin++) {
739  for(int col=0; col < Nc; col++) {
740  s1 = zero;
741 
742  srcfil(s1, coord, col, spin);
743  FermToProp(s1, q_src, col, spin);
744  }
745  }
746 
747 
748  int qprop_ncount = 0;
749 
750  // Do this. The function came for free as it was written for
751  // all wilson type fermacts.
752  quarkProp4(q_sol, xml_out, q_src, S, connect_state, CG_INVERTER,
753  params.rsd_cg, params.max_cg, qprop_ncount);
754 
755  // Get the pion
756  LatticeComplex corr_fn = trace(adj(q_sol)*q_sol);
757 
758  // Funky new way to get the sum and phases
759  SftMom phases(0,true,3);
760  multi2d<DComplex> hsum = phases.sft(corr_fn);
761 
762  // Check and dump
763  push(xml_out, "pions");
764  write(xml_out, "hsum0",hsum[0]);
765  pop(xml_out);
766 
767  // Check against SZIN pion
768  if( params.szin_pion.size() > 0 ) {
769  multi1d<Real> difference(params.nrow[3]);
770  for(int t = 0; t < params.nrow[3]; t++) {
771  difference[t] = fabs(Real(real(hsum[0][t])) - params.szin_pion[t]);
772  }
773  write(xml_out, "absPionSZINdifference", difference);
774 
775  for(int t = 0; t < params.nrow[3]; t++) {
776  difference[t] /= fabs(params.szin_pion[t]);
777  }
778  write(xml_out, "relPionSZINdifference", difference);
779  }
780  */
781 
782  multi1d<Real> shifts(3);
783  shifts[0] = 0.04;
784  shifts[1] = 0.05;
785  shifts[2] = 0.06;
786 
787  int multi_n_count=0;
788 
789  // Source propagator
790  LatticePropagator multi_q_src;
791 
792  // Solution propagator
793  multi1d<LatticePropagator> multi_q_sol(3);
794 
795  for(int spin=0; spin < Ns; spin++) {
796  for(int col=0; col < Nc; col++) {
797 
798  // Put a point source in q_src
799  s1 = zero;
800  srcfil(s1, coord, col, spin);
801  FermToProp(s1, multi_q_src, col, spin);
802 
803  // Zero out q_sol
804  s1 = zero;
805  for(int mass=0; mass < 3; mass++) {
806  FermToProp(s1, multi_q_sol[mass], col, spin);
807  }
808  }
809  }
810 
811 
812  // Do the solves with multi mass.
813  //! N order Zolo approx, with wilson action.
814  Zolotarev4DFermAct S_multi(fbc, S_w,
815  Real(0),
816  params.approx_order,
817  params.rsd_cg_inner,
818  params.max_cg_inner,
819  my_writer);
820 
821 
822 
823 
824  int qprop_ncount = 0;
825 
826  // Do this. The function came for free as it was written for
827  // all wilson type fermacts.
828  multi1d<Real> rsd_cg_array(shifts.size());
829  rsd_cg_array = params.rsd_cg;
830 
831  multiQuarkProp4(multi_q_sol, xml_out, multi_q_src, S_multi,
832  connect_state, CG_INVERTER,
833  shifts, rsd_cg_array, params.max_cg, qprop_ncount);
834 
835 
836  // Get the pion
837  // Funky new way to get the sum and phases
838  SftMom phases(0,true,3);
839 
840  for(int i = 0; i < shifts.size(); i++) {
841  LatticeComplex corr_fn = trace(adj(multi_q_sol[i])*multi_q_sol[i]);
842 
843 
844  multi2d<DComplex> hsum = phases.sft(corr_fn);
845 
846  // Check and dump
847  push(xml_out, "pion");
848  write(xml_out, "shifts_i", shifts[i]);
849  write(xml_out, "hsum", hsum[0]);
850  pop(xml_out);
851  }
852 
853  pop(xml_out);
854  xml_out.close();
855 
857 
858  exit(0);
859 }
Primary include file for CHROMA in application codes.
Support class for fermion actions and linear operators.
Definition: state.h:28
virtual FermState< T, P, Q > * createState(const Q &q) const
Given links (coordinates Q) create the state needed for the linear operators.
Definition: fermact.h:59
Class for counted reference semantics.
Definition: handle.h:33
Fourier transform phase factor support.
Definition: sftmom.h:35
multi2d< DComplex > sft(const LatticeComplex &cf) const
Do a sumMulti(cf*phases,getSet())
Definition: sftmom.cc:524
Concrete class for all gauge actions with simple boundary conditions.
Definition: simple_fermbc.h:42
Unpreconditioned Wilson fermion action.
UnprecLinearOperator< T, P, Q > * linOp(Handle< FermState< T, P, Q > > state) const
Produce a linear operator for this action.
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 readSzinFerm(LatticeFermion &q, const std::string &file)
Read a SZIN fermion. This is a simple memory dump reader.
void readSzin(SzinGauge_t &header, multi1d< LatticeColorMatrix > &u, const std::string &cfg_file)
Read a SZIN configuration file.
Definition: readszin.cc:31
void srcfil(LatticeFermion &a, const multi1d< int > &coord, int color_index, int spin_index)
Fill a specific color and spin index with 1.0.
Definition: srcfil.cc:23
Params params
unsigned j
Definition: ldumul_w.cc:35
multi1d< int > coord(Nd)
Nd
Definition: meslate.cc:74
Double tmp2
Definition: mesq.cc:30
Handle< FermBC< LatticeStaggeredFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > reader(XMLReader &xml_in, const std::string &path)
Helper function for the FermionAction readers.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
gaussian(aux)
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
int G5
Definition: pbg5p_w.cc:57
Chirality
Definition: ischiral_w.h:8
@ CH_NONE
Definition: ischiral_w.h:8
@ CH_PLUS
Definition: ischiral_w.h:8
@ CH_MINUS
Definition: ischiral_w.h:8
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
Double c
Definition: invbicg.cc:108
int i
Definition: pbg5p_w.cc:55
Double mass
Definition: pbg5p_w.cc:54
void initialize(int *argc, char ***argv)
Chroma initialisation routine.
Definition: chroma_init.cc:114
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
void finalize(void)
Chroma finalization routine.
Definition: chroma_init.cc:308
Chirality isChiralVector(const LatticeFermion &chi)
Definition: ischiral_w.cc:6
void reunit(LatticeColorMatrixF3 &xa)
Definition: reunit.cc:467
LatticeFermion psi
Definition: mespbg5p_w.cc:35
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
Double zero
Definition: invbicg.cc:106
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Parameters for running program.
Definition: qpropadd.cc:17
Real quark_mass
Definition: t_ovlap_bj.cc:45
multi1d< Real > szin_pion
Definition: t_ovlap_bj.cc:54
Handle< LinearOperator< T > > MdagM
GaugeStartType
GaugeFormat
Definition: t_ov_pbp.cc:18
@ NERSC_GAUGE_FORMAT
Definition: t_ovlap_bj.cc:27
@ SZIN_GAUGE_FORMAT
Definition: t_ovlap_bj.cc:27
void readParams(const std::string &filename, Param_t &params)
Definition: t_ovlap_bj.cc:60
int main(int argc, char **argv)
Definition: t_ovlap_bj.cc:319
void dumpParams(XMLWriter &writer, Param_t &params)
Definition: t_ovlap_bj.cc:147
@ HOT_START
Definition: t_ovlap_bj.cc:26
@ FILE_START
Definition: t_ovlap_bj.cc:26
@ COLD_START
Definition: t_ovlap_bj.cc:26
void readEigenVecs(const multi1d< LatticeColorMatrix > &u, const UnprecWilsonFermAct &S_aux, const multi1d< Real > &lambda_lo, multi1d< LatticeFermion > &eigen_vec, const Real wilson_mass, const bool szin_eig, XMLWriter &xml_out, const std::string &root_prefix)
Read in the old SZIN eigenvectors.
Definition: t_ovlap_bj.cc:243