CHROMA
group_baryon_operator_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Construct group baryon operators
3  */
4 
5 
6 #include "chromabase.h"
7 
11 
14 
17 
22 
24 #include "meas/sources/zN_src.h"
27 
28 #include "util/ferm/diractodr.h"
29 #include "util/ft/sftmom.h"
30 
31 #include <map>
32 
33 using std::map;
34 
35 namespace Chroma
36 {
37 
38  void displacementSub(const multi1d<LatticeColorMatrix>& u,
39  LatticeFermion& chi,
40  int length, int dir)
41  {
42  LatticeFermion tmp;
43  if (length > 0)
44  for(int n = 0; n < length; ++n)
45  {
46  tmp = shift(chi, FORWARD, dir);
47  chi = u[dir] * tmp;
48  }
49  else // If length = or < 0. If length == 0, does nothing.
50  for(int n = 0; n > length; --n)
51  {
52  tmp = shift(adj(u[dir])*chi, BACKWARD, dir);
53  chi = tmp;
54  }
55  }
56 
57 
58 
59  //! Baryon sequential sources
60  /*! \ingroup hadron */
61  namespace GroupBaryonOperatorEnv
62  {
63  // =======
64  // Readers
65  // =======
66 
67  void read( XMLReader& xml, const std::string& path,
69  {
70  XMLReader inputtop(xml, path);
71  read(inputtop, "Soln_file_names", input.soln_file_names);
72  }
73  void read( XMLReader& xml, const std::string& path,
75  {
76  XMLReader inputtop(xml, path);
77  read(inputtop, "Quarks", input.solns);
78  }
79  void read( XMLReader& xml, const std::string& path,
81  {
82  XMLReader inputtop(xml, path);
83  input.spatial_mask_size.resize(3);
84  read(inputtop, "spatial_mask_size", input.spatial_mask_size);
85  input.spatial_mask.resize(3);
86  read(inputtop, "spatial_mask", input.spatial_mask);
87  input.spin_mask.resize(4);
88  read(inputtop, "spin_mask", input.spin_mask);
89  input.color_mask.resize(3);
90  read(inputtop, "color_mask", input.color_mask);
91  }
92  void read( XMLReader& xml, const std::string& path,
94  {
95  XMLReader inputtop(xml, path);
96  read(inputtop, "Qprops", input.qprop);
97  read(inputtop, "Cfg", input.gaugestuff.cfg);
98  read(inputtop, "DilutionScheme", input.dilution);
99  }
100  // Writer
101  void write( XMLWriter& xml, const std::string& path,
102  const GroupBaryonOperatorEnv::Params& param )
103  {
104  param.writeXML( xml, path );
105  }
106 
107  // ============
108  // Params stuff
109  // ============
110 
111  //! Initialize
113  {}
114 
115  //! Read parameters
116  Params::Params( XMLReader& xml, const std::string& path )
117  {
118  XMLReader paramtop( xml, path );
119  // ============================
120  // number of quarks fixed to 3
121  // j_decay dir is 3 (time)
122  // space-time is 4-dimensions
123  // ============================
124  int NumberofQuarks = 3;
125  j_decay = 3;
126  nrow.resize( 4 );
127  int version;
128  read( paramtop, "Param/Name", name );
129  read( paramtop, "Param/version", version );
130  QDPIO::cout<< name << " Version " << version <<std::endl;
131  switch ( version )
132  {
133  case 2:
134  break;
135  default:
136  QDPIO::cerr << name << ": parameter version " << version << " unsupported." << std::endl;
137  QDP_abort( 1 );
138  }
139  read( paramtop, "Param/LattSize", nrow );
140  read( paramtop, "Param/Baryon_type", param.baryon_operator );
141 
142  read( paramtop, "Param/SourceSmearing", source_smearing );
143  read( paramtop, "Param/SinkSmearing", sink_smearing );
144 
145  gaugestuff.link_smearing = readXMLGroup( paramtop, "Param/LinkSmearing", "LinkSmearingType" );
146  read( paramtop, "Param/InputFileName", InputFileName );
147  QDPIO::cout<< "Main input file is " << InputFileName <<std::endl;
148  read( paramtop, "Cfg", gaugestuff.cfg );
149 
150  dilution.resize( NumberofQuarks );
151  for(int i=0; i < NumberofQuarks; ++i) dilution[ i ].N = 4; // Z(4) noise
152  for(int i=0; i < NumberofQuarks; ++i) dilution[ i ].j_decay = 3; // time-direction
153 
154  } // end Params::Params
155 
156 
157  // Writer
158  void Params::writeXML( XMLWriter& xml, const std::string& path ) const
159  {
160  push( xml, path );
161  int version = 1;
162  write( xml, "version", version );
163  write( xml, "nrow", nrow );
164  //write( xml, "BaryonOperatorType", GroupBaryonOperatorEnv::name );
165  //xml << source_smearing.xml;
166  //xml << sink_smearing.xml;
167  //xml << link_smearing.xml;
168  write( xml, "InputFileName", InputFileName );
169  write( xml, "mom2_max", mom2_max );
170  write( xml, "j_decay", j_decay );
171  pop( xml );
172  } // end void Params::writeXML
173 
174 
175  // Used for hybrid list indices, NH and noise indices
176  // for indices: ( ord, i, j, k, which )
177  // for NHlimit: ( ord, NH0, NH1, NH2, which )
178  // for NoiseInd: ( ord, 0, 1, 2, which )
179  int DilSwap( int ord, int i, int j, int k, int which )
180  {
181  multi1d<int> ijk( 3 );
182  switch ( ord )
183  {
184  case 0: // [012] ijk
185  ijk[ 0 ] = i;
186  ijk[ 1 ] = j;
187  ijk[ 2 ] = k;
188  break;
189  case 1: // [210] kji
190  ijk[ 0 ] = k;
191  ijk[ 1 ] = j;
192  ijk[ 2 ] = i;
193  break;
194  case 2: // [021] ikj
195  ijk[ 0 ] = i;
196  ijk[ 1 ] = k;
197  ijk[ 2 ] = j;
198  break;
199  case 3: // [102] jik
200  ijk[ 0 ] = j;
201  ijk[ 1 ] = i;
202  ijk[ 2 ] = k;
203  break;
204  case 4: // [120] jki
205  ijk[ 0 ] = j;
206  ijk[ 1 ] = k;
207  ijk[ 2 ] = i;
208  break;
209  case 5: // [201] kij
210  ijk[ 0 ] = k;
211  ijk[ 1 ] = i;
212  ijk[ 2 ] = j;
213  break;
214  default:
215  QDPIO::cerr<<"say what? "<<ord<<" "<<i<<" "<<j<<" "<<k<<" "<<which<<std::endl;
216  exit(1);
217  }
218  return ( ijk[ which ] );
219  }
220  //
221  // index things back to [012] ordering
222  //
223  int DilSwapInv( int ord, int i, int j, int k, int which )
224  {
225  multi1d<int> ijk( 3 );
226  switch ( ord )
227  {
228  case 0: // [012] ijk
229  ijk[ 0 ] = i;
230  ijk[ 1 ] = j;
231  ijk[ 2 ] = k;
232  break;
233  case 1: // [210] kji
234  ijk[ 0 ] = k;
235  ijk[ 1 ] = j;
236  ijk[ 2 ] = i;
237  break;
238  case 2: // [021] ikj
239  ijk[ 0 ] = i;
240  ijk[ 1 ] = k;
241  ijk[ 2 ] = j;
242  break;
243  case 3: // [102] jik
244  ijk[ 0 ] = j;
245  ijk[ 1 ] = i;
246  ijk[ 2 ] = k;
247  break;
248  case 4: // [120] jki
249  ijk[ 0 ] = k;
250  ijk[ 1 ] = i;
251  ijk[ 2 ] = j;
252  break;
253  case 5: // [201] kij
254  ijk[ 0 ] = j;
255  ijk[ 1 ] = k;
256  ijk[ 2 ] = i;
257  break;
258  default:
259  QDPIO::cerr<<"Say what? "<<ord<<" "<<i<<" "<<j<<" "<<k<<" "<<which<<std::endl;
260  exit(1);
261  }
262  return ( ijk[ which ] );
263  }
264 
265  // ====================
266  // GroupBaryonQQQ stuff
267  // ====================
268 
269  //! Constructor
271  {
272  // The spin basis matrix to goto Dirac
273  //spin_rotate_mat = adj( DiracToDRMat() );
274  }
275  void GroupBaryonQQQ::init( const Params& p_ )
276  {
277  myparams = p_;
278  quark.resize(3);
279  // The spin basis matrix to goto Dirac
280  spin_rotate_mat = adj( DiracToDRMat() );
281  } // GroupBaryonQQQ::init
282 
283  //! Full constructor
285  myparams( p )
286  {
287  // The spin basis matrix to goto Dirac
288  spin_rotate_mat = adj( DiracToDRMat() );
289  // Factory constructions
290  try
291  {
292  // Create the source quark smearing object
293  {
294  std::istringstream xml_s( myparams.source_smearing.source.xml );
295  XMLReader smeartop( xml_s );
296  const std::string smear_path = "/SourceSmearing";
297  QDPIO::cout << "Source quark smearing type = "
298  << myparams.source_smearing.source.id << std::endl;
302  smeartop,
305  );
306  }
307  // Create the sink quark smearing object
308  {
309  std::istringstream xml_s( myparams.sink_smearing.sink.xml );
310  XMLReader smeartop( xml_s );
311  const std::string smear_path = "/SinkSmearing";
312  QDPIO::cout << "Sink quark smearing type = "
313  << myparams.sink_smearing.sink.id << std::endl;
317  smeartop,
320  );
321  }
322  }
323  catch ( const std::string & e )
324  {
325  QDPIO::cerr << name << ": Caught Exception smearing: " << e << std::endl;
326  QDP_abort( 1 );
327  }
328 
329  } // GroupBaryonQQQ::GroupBaryonQQQ
330 
331  //! Reader
333  multi1d<GroupBaryonOp>& AB, multi1d<GroupBaryonOp>& CB,
334  multi1d<GroupBaryonQQQ>& AQQQ, multi1d<GroupBaryonQQQ>& CQQQ )
335  {
336  QDPIO::cout << "Reading input from TEXT file : " << params.InputFileName <<std::endl;
337  TextFileReader reader( params.InputFileName );
338  // for testing
339 #ifdef REDUCETOTIMEDILUTION
340  params.NdilReduce = 12;
341 #else
342  params.NdilReduce = 1;
343 #endif
344  // Lattice sizes
345  // ------------------------------------------------------------------------------------
346  reader >> params.nrow[ 0 ] >> params.nrow[ 1 ] >> params.nrow[ 2 ] >> params.nrow[ 3 ];
347  // ------------------------------------------------------------------------------------
348 
349  params.Nmomenta = 1; // need to change this in the future when we do multiple momenta
350  params.mom2_max = 0; // this obviously needs to be changed and read in ...
351  params.j_decay = 3; // this is OK
352 
353  // Orderings are more or less hard wired for now
354  // ... to be continued later when I have the time
355 
356  //read( xml, "NumSourcePerm", params.NsrcOrderings );
357  // ------------------------------------------------------------------------------------
359  // ------------------------------------------------------------------------------------
360  // 012 factor in front is 2 2
361  // 210 factor in front is -2 2
362  // 021 factor in front is 1 -1
363  // 102 factor in front is 1 -1
364  // 120 factor in front is -1 -1
365  // 201 factor in front is -1 -1
366 
367  //read( xml, "SrcQuarkIndices", params.SrcOrderings );
369  for(int i=0; i < params.NsrcOrderings; ++i)
370  {
371  params.SrcOrderings[ i ].resize( 3 );
372  // ------------------------------------------------------------------------------------
373  reader >> params.SrcOrderings[ i ][ 0 ] >> params.SrcOrderings[ i ][ 1 ] >> params.SrcOrderings[ i ][ 2 ];
374  // ------------------------------------------------------------------------------------
375  }
376  //
377  // This again, is hard-wired to 012 case for now ...
378  //
379  //read( xml, "NumSinkPerm", params.NsnkOrderings );
380  // ------------------------------------------------------------------------------------
382  // ------------------------------------------------------------------------------------
384  //read( xml, "SnkQuarkIndices", params.SnkOrderings );
385  for(int i=0; i < params.NsnkOrderings; ++i)
386  {
387  params.SnkOrderings[ i ].resize( 3 );
388  // ------------------------------------------------------------------------------------
389  reader >> params.SnkOrderings[ i ][ 0 ] >> params.SnkOrderings[ i ][ 1 ] >> params.SnkOrderings[ i ][ 2 ];
390  // ------------------------------------------------------------------------------------
391  }
392  // Hybrid list sizes
393  params.NH.resize( params.NsrcOrderings );
394  for(int i=0; i < params.NH.size(); ++i) params.NH[ i ].resize( 3 ); // L,M,R quarks
395  // Set the hybrid list sizes
396  // { something like this would be better }
397  // { Ndil = params.named_obj.prop.op[n].soln_files.size() }
398  //XMLReader& xml;
399  //read( xml, "Ndilutions", params.NH[0] );
400  // This is the default 012 ordering
401  // ------------------------------------------------------------------------------------
402  reader >> params.NH[ 0 ][ 0 ] >> params.NH[ 0 ][ 1 ] >> params.NH[ 0 ][ 2 ];
403  // ------------------------------------------------------------------------------------
404  for(int i=1; i < params.NsrcOrderings; ++i)
405  {
406  for(int j=0; j < 3; ++j)
407  params.NH[ i ][ j ] = params.NH[ 0 ][ (params.SrcOrderings[ i ][ j ]) ];
408  }
409  //read( xml, "NumOperators", params.Noperators );
410  // ------------------------------------------------------------------------------------
412  // ------------------------------------------------------------------------------------
413  // The Baryon operator names ; G1g_L3_TDT_25 ...
414  //read( xml, "OperatorNames", params.Names );
415  params.Names.resize( params.Noperators );
416  int nameindex;
417  for(int i=0; i < params.Names.size(); ++i)
418  {
419  // ------------------------------------------------------------------------------------
420  reader >> nameindex >> params.Names[ i ];
421  // ------------------------------------------------------------------------------------
422  }
423  //read( xml, "NumDistinctQQQ", params.NQQQs );
424  // ------------------------------------------------------------------------------------
425  reader >> params.NQQQs;
426  // ------------------------------------------------------------------------------------
427 #ifdef MAKE_SINK_OPERATORS
428  AQQQ.resize( params.NQQQs );
429  for(int i=0; i < params.NQQQs; ++i)
430  {
431  AQQQ[ i ].init( params );
432  }
433 #endif
434 #ifdef MAKE_SOURCE_OPERATORS
435  CQQQ.resize( params.NQQQs );
436  for(int i=0; i < params.NQQQs; ++i)
437  {
438  CQQQ[ i ].init( params );
439  }
440 #endif
441  //
442  // GroupBaryonOperator structures
443  //
444 #ifdef MAKE_SINK_OPERATORS
445  AB.resize( params.Noperators );
446 #endif
447 #ifdef MAKE_SOURCE_OPERATORS
448  CB.resize( params.Noperators );
449 #endif
450  //
451  // Using the BaryonOperator_t structure
452  //
453  for(int n=0; n < params.Noperators; ++n)
454  {
455 #ifdef MAKE_SINK_OPERATORS
456  // This is 1 now because all the
457  // contractions are summed over
458  // AB[ n ].baryonoperator.orderings.resize( params.NsnkOrderings );
459  // for(int ord=0; ord < params.NsnkOrderings; ++ord)
460  AB[ n ].baryonoperator.orderings.resize( 1 );
461  for(int ord=0; ord < 1; ++ord)
462  {
463  AB[ n ].baryonoperator.orderings[ ord ].op.resize( params.NH[ 0 ][ 0 ]/params.NdilReduce, params.NH[ 0 ][ 1 ]/params.NdilReduce, params.NH[ 0 ][ 2 ]/params.NdilReduce );
464  for(int i=0; i < (params.NH[ 0 ][ 0 ]/params.NdilReduce); ++i)
465  for(int j=0; j < (params.NH[ 0 ][ 1 ]/params.NdilReduce); ++j)
466  for(int k=0; k < (params.NH[ 0 ][ 2 ]/params.NdilReduce); ++k)
467  {
468  AB[ n ].baryonoperator.orderings[ ord ].op( i, j, k ).ind.resize(1);
469  AB[ n ].baryonoperator.orderings[ ord ].op( i, j, k ).ind[ 0 ].elem.resize( params.Nmomenta, params.nrow[3] );
470  for(int t=0; t<params.nrow[3]; ++t)
471  AB[ n ].baryonoperator.orderings[ ord ].op( i, j, k ).ind[ 0 ].elem( 0, t ) = cmplx( Real(0), Real(0) );
472  }
473  }
474  AB[ n ].baryonoperator.version = 1;
475  AB[ n ].baryonoperator.mom2_max = params.mom2_max;
476  AB[ n ].baryonoperator.j_decay = params.j_decay;
477  //AB[ n ].baryonoperator.quarkOrderings = params.SnkOrderings;
478  AB[ n ].baryonoperator.quarkOrderings.resize(1);
479  AB[ n ].baryonoperator.quarkOrderings[0].resize(3);
480  AB[ n ].baryonoperator.quarkOrderings[0][0] = 0;
481  AB[ n ].baryonoperator.quarkOrderings[0][1] = 1;
482  AB[ n ].baryonoperator.quarkOrderings[0][2] = 2;
483 #endif
484 #ifdef MAKE_SOURCE_OPERATORS
485  //CB[ n ].baryonoperator.orderings.resize( params.NsrcOrderings );
486  //for(int ord=0; ord < params.NsrcOrderings; ++ord)
487  CB[ n ].baryonoperator.orderings.resize( 1 );
488  for(int ord=0; ord < 1; ++ord)
489  {
490  CB[ n ].baryonoperator.orderings[ ord ].op.resize( params.NH[ 0 ][ 0 ]/params.NdilReduce, params.NH[ 0 ][ 1 ]/params.NdilReduce, params.NH[ 0 ][ 2 ]/params.NdilReduce );
491  for(int i=0; i < (params.NH[ 0 ][ 0 ]/params.NdilReduce); ++i)
492  for(int j=0; j < (params.NH[ 0 ][ 1 ]/params.NdilReduce); ++j)
493  for(int k=0; k < (params.NH[ 0 ][ 2 ]/params.NdilReduce); ++k)
494  {
495  CB[ n ].baryonoperator.orderings[ ord ].op( i, j, k ).ind.resize(1);
496  CB[ n ].baryonoperator.orderings[ ord ].op( i, j, k ).ind[ 0 ].elem.resize( params.Nmomenta, params.nrow[3] );
497  for(int t=0; t<params.nrow[3]; ++t) CB[ n ].baryonoperator.orderings[ ord ].op( i, j, k ).ind[ 0 ].elem( 0, t ) = cmplx( Real(0), Real(0) );
498  }
499  }
500  CB[ n ].baryonoperator.version = 1;
501  CB[ n ].baryonoperator.mom2_max = params.mom2_max;
502  CB[ n ].baryonoperator.j_decay = params.j_decay;
503  //CB[ n ].baryonoperator.quarkOrderings = params.SrcOrderings;
504  CB[ n ].baryonoperator.quarkOrderings.resize(1);
505  CB[ n ].baryonoperator.quarkOrderings[0].resize(3);
506  CB[ n ].baryonoperator.quarkOrderings[0][0] = 0;
507  CB[ n ].baryonoperator.quarkOrderings[0][1] = 1;
508  CB[ n ].baryonoperator.quarkOrderings[0][2] = 2;
509 #endif
510  } // end n (operators)
511  for(int i=0; i < params.NQQQs; ++i)
512  {
513  int dL, hash;
514  int q0spin,q1spin,q2spin,q0disp,q1disp,q2disp,nbops;
515  reader >> hash >> q0spin >> q1spin >> q2spin >> q0disp >> q1disp >> q2disp >> dL >> nbops;
516 #ifdef MAKE_SINK_OPERATORS
517  AQQQ[ i ].quark[ 0 ].spin = q0spin -1;
518  AQQQ[ i ].quark[ 1 ].spin = q1spin -1;
519  AQQQ[ i ].quark[ 2 ].spin = q2spin -1;
520  AQQQ[ i ].quark[ 0 ].displacement = q0disp;
521  AQQQ[ i ].quark[ 1 ].displacement = q1disp;
522  AQQQ[ i ].quark[ 2 ].displacement = q2disp;
523  AQQQ[ i ].NBaryonOps = nbops;
524  for(int j=0; j < 3; ++j)
525  {
526  if ( AQQQ[ i ].quark[ j ].displacement >= 0 )
527  {
528  AQQQ[ i ].quark[ j ].disp_len = dL;
529  }
530  else
531  {
532  AQQQ[ i ].quark[ j ].disp_len = -dL;
533  }
534  }
535 #endif
536 #ifdef MAKE_SOURCE_OPERATORS
537  CQQQ[ i ].quark[ 0 ].spin = q0spin -1;
538  CQQQ[ i ].quark[ 1 ].spin = q1spin -1;
539  CQQQ[ i ].quark[ 2 ].spin = q2spin -1;
540  CQQQ[ i ].quark[ 0 ].displacement = q0disp;
541  CQQQ[ i ].quark[ 1 ].displacement = q1disp;
542  CQQQ[ i ].quark[ 2 ].displacement = q2disp;
543  CQQQ[ i ].NBaryonOps = nbops;
544  for(int j=0; j < 3; ++j)
545  {
546  if ( CQQQ[ i ].quark[ j ].displacement >= 0 )
547  {
548  CQQQ[ i ].quark[ j ].disp_len = dL;
549  }
550  else
551  {
552  CQQQ[ i ].quark[ j ].disp_len = -dL;
553  }
554  }
555 #endif
556 #ifdef MAKE_SINK_OPERATORS
557  for(int j=0; j < 3; ++j)
558  {
559  if ( AQQQ[ i ].quark[ j ].displacement == 0 )
560  {
561  AQQQ[ i ].quark[ j ].disp_dir = 0;
562  AQQQ[ i ].quark[ j ].disp_len = 0;
563  AQQQ[ i ].quark[ j ].disp_ind = 0;
564  }
565  else if ( AQQQ[ i ].quark[ j ].displacement > 0 )
566  {
567  AQQQ[ i ].quark[ j ].disp_dir = AQQQ[ i ].quark[ j ].displacement - 1;
568  AQQQ[ i ].quark[ j ].disp_ind = AQQQ[ i ].quark[ j ].displacement;
569  AQQQ[ i ].quark[ j ].disp_len = dL;
570  }
571  else
572  {
573  AQQQ[ i ].quark[ j ].disp_dir = -AQQQ[ i ].quark[ j ].displacement - 1;
574  AQQQ[ i ].quark[ j ].disp_ind = -AQQQ[ i ].quark[ j ].displacement + 3;
575  AQQQ[ i ].quark[ j ].disp_len = -dL;
576  }
577  } // end j
578  AQQQ[ i ].coef.resize( AQQQ[ i ].NBaryonOps );
579  AQQQ[ i ].whichBaryonOps.resize( AQQQ[ i ].NBaryonOps );
580  AQQQ[ i ].baryon.resize( AQQQ[ i ].NBaryonOps );
581  // name coefficient
582  // AQQQ[ <mu,nu,tau> ].whichBaryonOps[ n ] , AQQQ[ <mu,nu,tau> ].coef[ n ]
583  //
584  for(int n=0; n < AQQQ[ i ].NBaryonOps; ++n)
585  {
586  Real re, im;
587  // ------------------------------------------------------------------------------------
588  reader >> AQQQ[ i ].whichBaryonOps[ n ];
589  reader >> re >> im;
590  // ------------------------------------------------------------------------------------
591  AQQQ[ i ].coef[ n ] = cmplx( re, im );
592  //
593  // Storage will be in the GroupBaryonOp class
594  //
595  AQQQ[ i ].baryon[ n ] = &AB[ (AQQQ[ i ].whichBaryonOps[ n ]) ];
596  }
597 #endif
598 #ifdef MAKE_SOURCE_OPERATORS
599  for(int j=0; j < 3; ++j)
600  {
601  if ( CQQQ[ i ].quark[ j ].displacement == 0 )
602  {
603  CQQQ[ i ].quark[ j ].disp_dir = 0;
604  CQQQ[ i ].quark[ j ].disp_len = 0;
605  CQQQ[ i ].quark[ j ].disp_ind = 0;
606  }
607  else if ( CQQQ[ i ].quark[ j ].displacement > 0 )
608  {
609  CQQQ[ i ].quark[ j ].disp_dir = CQQQ[ i ].quark[ j ].displacement - 1;
610  CQQQ[ i ].quark[ j ].disp_ind = CQQQ[ i ].quark[ j ].displacement;
611  CQQQ[ i ].quark[ j ].disp_len = dL;
612  }
613  else
614  {
615  CQQQ[ i ].quark[ j ].disp_dir = -CQQQ[ i ].quark[ j ].displacement - 1;
616  CQQQ[ i ].quark[ j ].disp_ind = -CQQQ[ i ].quark[ j ].displacement + 3;
617  CQQQ[ i ].quark[ j ].disp_len = -dL;
618  }
619  } // end j
620  CQQQ[ i ].coef.resize( CQQQ[ i ].NBaryonOps );
621  CQQQ[ i ].whichBaryonOps.resize( CQQQ[ i ].NBaryonOps );
622  CQQQ[ i ].baryon.resize( CQQQ[ i ].NBaryonOps );
623  // name coefficient
624  // CQQQ[ <mu,nu,tau> ].whichBaryonOps[ n ] , CQQQ[ <mu,nu,tau> ].coef[ n ]
625  //
626  for(int n=0; n < CQQQ[ i ].NBaryonOps; ++n)
627  {
628  Real re, im;
629  // ------------------------------------------------------------------------------------
630  reader >> CQQQ[ i ].whichBaryonOps[ n ];
631  reader >> re >> im;
632  // ------------------------------------------------------------------------------------
633  CQQQ[ i ].coef[ n ] = cmplx( re, im );
634  //
635  // Storage will be in the GroupBaryonOp class
636  //
637  CQQQ[ i ].baryon[ n ] = &CB[ (CQQQ[ i ].whichBaryonOps[ n ]) ];
638  }
639 #endif
640  } // i loop
641  //
642  // Now for the creation operators
643  //
644  // rotate by gamma4's to get the barred coefficients
645  // index 0 1 2 3
646  // gamma4 = ( 1, 1, -1, -1 )
647  // and take the complex conjugate
648 #ifdef MAKE_SOURCE_OPERATORS
649  for(int i=0; i < params.NQQQs; ++i)
650  {
651  int spinCount, flipsign;
652  spinCount = 0;
653  flipsign = 0;
654  for(int j=0; j < 3; ++j)
655  {
656  if ( CQQQ[ i ].quark[ j ].spin > 1 ) spinCount++;
657  }
658  if ( spinCount % 2 ) flipsign = 1;
659  //
660  // name coefficient
661  // CQQQ[ <mu,nu,tau> ].whichBaryonOps[ n ] , CQQQ[ i ].coef[ n ]
662  //
663  for(int n=0; n < CQQQ[ i ].NBaryonOps; ++n)
664  {
665  if ( flipsign )
666  {
667  // cc and -sign
668  // CQQQ[ i ].coef[ n ] = cmplx( -re, im );
669  // flip sign (cc at the correlator level)
670  CQQQ[ i ].coef[ n ] *= cmplx( Real(-1), Real(0) );
671  }
672  //
673  // Storage will be in the GroupBaryonOp class
674  //
675  CQQQ[ i ].baryon[ n ] = &CB[ CQQQ[ i ].whichBaryonOps[ n ] ];
676  } // n : CQQQ[ i ].baryon[ n ] loop
677  } // i : CQQQ[] loop
678 #endif
679  // solution file names
680  params.qprop.solns.resize( 3 );
681  for(int n=0; n < 3; ++n)
682  {
683  params.qprop.solns[ n ].soln_file_names.resize( params.NH[ 0 ][ n ] );
684  for(int i=0; i < params.NH[ 0 ][ n ]; ++i)
685  {
686  // ------------------------------------------------------------------------------------
687  reader >> params.qprop.solns[ n ].soln_file_names[ i ];
688  // ------------------------------------------------------------------------------------
689  }
690  }
691  reader.close();
692 
693  QDPIO::cout << "Reading input from text file DONE " << std::endl;
694  } // void ReadTextInput
695 
696 
697  //! Construct the source
698  LatticeFermion
700  {
701  //QDPIO::cout << "Diluted random complex ZN source" << std::endl;
702  if ( diln.spatial_mask_size.size() != Nd - 1 )
703  {
704  QDPIO::cerr << name << ": spatial mask size incorrect 1" << std::endl;
705  QDP_abort( 1 );
706  }
707  if ( diln.spatial_mask.size() == 0 )
708  {
709  QDPIO::cerr << name << ": spatial mask incorrect 2" << std::endl;
710  QDP_abort( 1 );
711  }
712  multi1d<int> lookup_dir( Nd - 1 );
713  int mu = 0;
714  for(int j=0; j < diln.spatial_mask_size.size(); ++j, ++mu)
715  {
716  if ( j == diln.j_decay ) ++mu; // bump up to next dir
717  lookup_dir[ j ] = mu;
718  }
719  for(int j=0; j < diln.spatial_mask.size(); ++j)
720  {
721  if ( diln.spatial_mask[ j ].size() != Nd - 1 )
722  {
723  QDPIO::cerr << name << ": spatial mask incorrect 3" << std::endl;
724  QDP_abort( 1 );
725  }
726  }
727  for(int c=0; c < diln.color_mask.size(); ++c)
728  {
729  if ( diln.color_mask[ c ] < 0 || diln.color_mask[ c ] >= Nc )
730  {
731  QDPIO::cerr << name << ": color mask incorrect 6" << std::endl;
732  QDP_abort( 1 );
733  }
734  }
735  for(int s=0; s < diln.spin_mask.size(); ++s)
736  {
737  if ( diln.spin_mask[ s ] < 0 || diln.spin_mask[ s ] >= Ns )
738  {
739  QDPIO::cerr << name << ": spin mask incorrect 7" << std::endl;
740  QDP_abort( 1 );
741  }
742  }
743  // Save current seed
744  Seed ran_seed;
745  QDP::RNG::savern( ran_seed );
746  // Set the seed to desired value
747  QDP::RNG::setrn( diln.ran_seed );
748  // Create the noisy quark source on the entire lattice
749  LatticeFermion quark_noise;
750  zN_src( quark_noise, diln.N );
751  // This is the filtered noise source to return
752  LatticeFermion quark_source = zero;
753  // Filter over the color and spin indices first
754  for(int s=0; s < diln.spin_mask.size(); ++s)
755  {
756  int spin_source = diln.spin_mask[ s ];
757  LatticeColorVector colvec = peekSpin( quark_noise, spin_source );
758  LatticeColorVector dest = zero;
759  for(int c=0; c < diln.color_mask.size(); ++c)
760  {
761  int color_source = diln.color_mask[ c ];
762  LatticeComplex comp = peekColor( colvec, color_source );
763  pokeColor( dest, comp, color_source );
764  }
765  pokeSpin( quark_source, dest, spin_source );
766  }
767  quark_noise = quark_source; // reset
768  // Filter over the spatial sites
769  LatticeBoolean mask = false; // this is the starting mask
770  for(int n=0; n < diln.spatial_mask.size(); ++n)
771  {
772  LatticeBoolean btmp = true;
773  for(int j=0; j < diln.spatial_mask[ n ].size(); ++j)
774  btmp &= ( Layout::latticeCoordinate( lookup_dir[ j ] ) % diln.spatial_mask_size[ j ] ) == diln.spatial_mask[ n ][ j ];
775  mask |= btmp;
776  }
777  // Filter over the time slices
778  mask &= Layout::latticeCoordinate( diln.j_decay ) == diln.t_source;
779  // Zap the unused sites
780  quark_source = where( mask, quark_noise, Fermion( zero ) );
781  // Reset the seed
782  QDP::RNG::setrn( ran_seed );
783  return quark_source;
784  }
785 
786 
787  //! Construct array of std::maps of displacements
788  void
789  GroupBaryonQQQ::displaceQuarks( multi1d< std::map<int, LatticeFermion> >& disp_quarks,
790  const multi1d<LatticeFermion>& q,
791  int* qindices
792  ) const
793  {
794  START_CODE();
795  //QDPIO::cout << __PRETTY_FUNCTION__ << ": entering" << std::endl;
796  disp_quarks.resize( 3 );
797  for(int i=0; i < disp_quarks.size(); ++i)
798  {
799  // Make some shorthands to ease my brain
800  std::map<int, LatticeFermion>& disp_q = disp_quarks[ i ];
801  const QuarkTerm_t& term_q = quark[ qindices[ i ] ];
802  // If no entry, then create a displaced version of the quark
803  if ( disp_q.find( term_q.displacement ) == disp_q.end() )
804  {
805  //QDPIO::cout << __func__
806  // << ": i=" << i
807  // << " disp=" << quark[i].displacement << " disp=" << term_q.displacement
808  // << " len =" << quark[i].disp_len << " len=" << term_q.disp_len
809  // << " dir =" << quark[i].disp_dir << " dir=" << term_q.disp_dir
810  // << " spin=" << quark[i].spin << " spin=" << term_q.spin
811  // << std::endl;
812  LatticeFermion qq = q[ i ];
813  displacementSub( myparams.gaugestuff.u, qq, term_q.disp_len, term_q.disp_dir );
814  disp_q.insert( std::make_pair( term_q.displacement, qq ) );
815  }
816  } // for i
817  //QDPIO::cout << __PRETTY_FUNCTION__ << ": exiting" << std::endl;
818  END_CODE();
819  } // void GroupBaryonQQQ::displaceQuarks
820 
821 
822  //! First smear then displace the quarks
823  void
824  GroupBaryonQQQ::smearDisplaceQuarks( multi1d< std::map<int, LatticeFermion> >& disp_quarks,
825  const LatticeFermion& q1,
826  const LatticeFermion& q2,
827  const LatticeFermion& q3,
828  int* qindices
829  ) const
830  {
831  START_CODE();
832  //QDPIO::cout << __PRETTY_FUNCTION__ << ": entering" << std::endl;
833  multi1d<LatticeFermion> q( 3 );
834  // Rotate the quarks up-front.
835  // NOTE: this step assumes the spin rotation commutes with the
836  // quark smearing and the displacement
837  // However, we are careful about the ordering of the smearing and
838  // the displacement
839  // q[ 0 ] = rotateMat() * q1;
840  // q[ 1 ] = rotateMat() * q2;
841  // q[ 2 ] = rotateMat() * q3;
842  q[ 0 ] = q1;
843  q[ 1 ] = q2;
844  q[ 2 ] = q3;
845  // Displace after the smearing
846  displaceQuarks( disp_quarks, q, qindices );
847  //QDPIO::cout << __PRETTY_FUNCTION__ << ": exiting" << std::endl;
848  END_CODE();
849  } // void GroupBaryonQQQ::smearDisplaceQuarks
850 
851 
852  //! hack to avoid compiler errors
853  LatticeComplex GroupBaryonQQQ::operator() ( const LatticeFermion& q1,
854  const LatticeFermion& q2,
855  const LatticeFermion& q3
856  ) const
857  {
858  START_CODE();
859  LatticeComplex d;
860  return d;
861  END_CODE();
862  }
863  multi1d<LatticeComplex> GroupBaryonQQQ::operator() ( const LatticeFermion& q1,
864  const LatticeFermion& q2,
865  const LatticeFermion& q3,
866  enum PlusMinus isign ) const
867  {
868  START_CODE();
869  multi1d<LatticeComplex> d(1);
870  return d;
871  END_CODE();
872  }
873 
874 
875  // for the creation operator
876  //! Compute the operator
877  LatticeComplex
878  GroupBaryonQQQ::operator() ( const LatticeFermion& q1,
879  const LatticeFermion& q2,
880  const LatticeFermion& q3,
881  int* qindices
882  ) const
883  {
884  START_CODE();
885  if ( Nc != 3 ){ /* Code is specific to Ns=4 and Nc=3. */
886  QDPIO::cerr<<" code only works for Nc=3 and Ns=4\n";
887  QDP_abort(111) ;
888  }
889 #if QDP_NC == 3
890 
891 
892  // The result of displace and smearing (in some unspecified order here)
893  multi1d< std::map<int, LatticeFermion> > disp_quarks;
894  // Depending on whether this is the sink or source, do the
895  // appropriate combination of smearing and displacing
896  smearDisplaceQuarks( disp_quarks, q1, q2, q3, qindices );
897  // The return
898  LatticeComplex d;
899 
900  LatticeColorVector c0 = peekSpin( disp_quarks[ 0 ].find( quark[ qindices[ 0 ] ].displacement ) ->second,
901  quark[ qindices[ 0 ] ].spin );
902  LatticeColorVector c1 = peekSpin( disp_quarks[ 1 ].find( quark[ qindices[ 1 ] ].displacement ) ->second,
903  quark[ qindices[ 1 ] ].spin );
904  LatticeColorVector c2 = peekSpin( disp_quarks[ 2 ].find( quark[ qindices[ 2 ] ].displacement ) ->second,
905  quark[ qindices[ 2 ] ].spin );
906  /*
907  multi1d<LatticeFermion> q( 3 );
908  // Rotate the quarks up-front.
909  // NOTE: this step assumes the spin rotation commutes with the
910  // quark smearing and the displacement
911  // However, we are careful about the ordering of the smearing and
912  // the displacement
913  q[ 0 ] = rotateMat() * q1;
914  q[ 1 ] = rotateMat() * q2;
915  q[ 2 ] = rotateMat() * q3;
916  */
917  // Contract over color indices with antisym tensors
918  d = colorContract( c0, c1, c2 );
919 
920  //QDPIO::cout << __PRETTY_FUNCTION__ << ": exiting" << std::endl;
921  END_CODE();
922  return d;
923 
924 #else
925  LatticeComplex d;
926  d = zero ;
927  return d;
928 #endif
929 
930  } // LatticeComplex GroupBaryonQQQ::operator()
931 
932  // for the annihilation operator
933  multi1d<LatticeComplex>
934  GroupBaryonQQQ::operator() ( const LatticeFermion& q1,
935  const LatticeFermion& q2,
936  const LatticeFermion& q3,
937  int* qindices,
938  enum PlusMinus isign ) const
939  {
940  START_CODE();
941  if ( Nc != 3 ){ /* Code is specific to Ns=4 and Nc=3. */
942  QDPIO::cerr<<" code only works for Nc=3 and Ns=4\n";
943  QDP_abort(111) ;
944  }
945 #if QDP_NC == 3
946 
947 
948  //QDPIO::cout << __PRETTY_FUNCTION__ << ": entering" << std::endl;
949  // The result of displace and smearing (in some unspecified order here)
950  multi1d< std::map<int, LatticeFermion> > disp_quarks;
951  // Depending on whether this is the sink or source, do the
952  // appropriate combination of smearing and displacing
953  smearDisplaceQuarks( disp_quarks, q1, q2, q3, qindices );
954  // The return
955  multi1d<LatticeComplex> d( 1 ); //( 6 )
956  // Contract over color indices with antisym tensors
957 
958  LatticeColorVector c0 = peekSpin( disp_quarks[ 0 ].find( quark[ qindices[ 0 ] ].displacement ) ->second,
959  quark[ qindices[ 0 ] ].spin );
960  LatticeColorVector c1 = peekSpin( disp_quarks[ 1 ].find( quark[ qindices[ 1 ] ].displacement ) ->second,
961  quark[ qindices[ 1 ] ].spin );
962  LatticeColorVector c2 = peekSpin( disp_quarks[ 2 ].find( quark[ qindices[ 2 ] ].displacement ) ->second,
963  quark[ qindices[ 2 ] ].spin );
964  /*
965  multi1d<LatticeFermion> q( 3 );
966  // Rotate the quarks up-front.
967  // NOTE: this step assumes the spin rotation commutes with the
968  // quark smearing and the displacement
969  // However, we are careful about the ordering of the smearing and
970  // the displacement
971  q[ 0 ] = rotateMat() * q1;
972  q[ 1 ] = rotateMat() * q2;
973  q[ 2 ] = rotateMat() * q3;
974  */
975  // Contract over color indices with antisym tensors
976  d[ 0 ] = colorContract( c0, c1, c2 );
977 
978  //QDPIO::cout << __PRETTY_FUNCTION__ << ": exiting" << std::endl;
979  END_CODE();
980  return d;
981 #else
982 
983  multi1d<LatticeComplex> d( 1 );
984  return d;
985 #endif
986 
987  } // multi1d<LatticeComplex> GroupBaryonQQQ::operator()
988 
989 
990  // ===========================
991  // GroupBaryonOp stuff
992  // now only used to store data
993  // ===========================
994  //! Serialize baryon_operator object
995  multi1d<Complex>
997  {
998  int orderings_size = orderings.size();
999  int op_size3 = orderings[ 0 ].op.size3();
1000  int op_size2 = orderings[ 0 ].op.size2();
1001  int op_size1 = orderings[ 0 ].op.size1();
1002  int ind_size = orderings[ 0 ].op( 0, 0, 0 ).ind.size();
1003  int elem_size2 = orderings[ 0 ].op( 0, 0, 0 ).ind[ 0 ].elem.size2();
1004  int elem_size1 = orderings[ 0 ].op( 0, 0, 0 ).ind[ 0 ].elem.size1();
1005  Complex ord_sizes, op_sizes1, op_sizes2, elem_sizes;
1006  ord_sizes = cmplx( Real( orderings_size ), Real( zero ) );
1007  op_sizes1 = cmplx( Real( op_size2 ), Real( op_size1 ) );
1008  op_sizes2 = cmplx( Real( op_size3 ), Real( ind_size ) );
1009  elem_sizes = cmplx( Real( elem_size2 ), Real( elem_size1 ) );
1010  multi1d<Complex> baryop_1d( 4 + orderings_size * op_size3 * op_size2 * op_size1 * ind_size * elem_size2 * elem_size1 );
1011  //QDPIO::cout << "baryop_size=" << baryop_1d.size() << std::endl;
1012  int cnt = 0;
1013  baryop_1d[ cnt++ ] = ord_sizes;
1014  baryop_1d[ cnt++ ] = op_sizes1;
1015  baryop_1d[ cnt++ ] = op_sizes2;
1016  baryop_1d[ cnt++ ] = elem_sizes;
1017  for(int s=0; s < orderings.size(); ++s) // orderings
1018  {
1019  for(int i=0; i < orderings[ s ].op.size3(); ++i) // op_l
1020  for(int j=0; j < orderings[ s ].op.size2(); ++j) // op_m
1021  for(int k=0; k < orderings[ s ].op.size1(); ++k) // op_r
1022  for(int l=0; l < orderings[ s ].op( i, j, k ).ind.size(); ++l) // ind
1023  for(int a=0; a < orderings[ s ].op( i, j, k ).ind[ l ].elem.size2(); ++a) // elem_l
1024  for(int b=0; b < orderings[ s ].op( i, j, k ).ind[ l ].elem.size1(); ++b) // elem_r
1025  baryop_1d[ cnt++ ] = orderings[ s ].op( i, j, k ).ind[ l ].elem( a, b );
1026  }
1027  if ( cnt != baryop_1d.size() )
1028  {
1029  QDPIO::cerr << ": size mismatch in BaryonOperator_t serialization " << cnt << std::endl;
1030  QDP_abort( 1 );
1031  }
1032  return baryop_1d;
1033  }
1034 
1035  //! Anonymous namespace
1036  namespace
1037  {
1038 
1039  //-------------------- callback functions ---------------------------------------
1040 
1041  //! Call-back function
1042  BaryonOperator<LatticeFermion>* groupBaryon( XMLReader& xml_in,
1043  const std::string& path,
1044  const multi1d<LatticeColorMatrix>& u )
1045  {
1046  return new GroupBaryonQQQ( Params( xml_in, path ) );
1047  }
1048  //! Local registration flag
1049  bool registered = false;
1050 
1051  } // end anonymous namespace
1052 
1053  const std::string name = "GROUP_BARYON";
1054 
1055  //! Register all the factories
1057  {
1058  bool success = true;
1059  if ( ! registered )
1060  {
1061  // Required stuff
1062  success &= LinkSmearingEnv::registerAll();
1064  success &= QuarkSinkSmearingEnv::registerAll();
1065 
1066  //! Register all the factories
1067  success &= Chroma::TheWilsonBaryonOperatorFactory::Instance().registerObject(name, groupBaryon );
1068 
1069  registered = true;
1070  }
1071  return success;
1072  } // registerAll()
1073 
1074 
1075  } // namespace GroupBaryonOperatorEnv
1076 
1077 
1078 } // namespace Chroma
1079 
All baryon operators.
Factory for producing baryon operators.
Primary include file for CHROMA library code.
void smearDisplaceQuarks(multi1d< std::map< int, LatticeFermion > > &disp_quarks, const LatticeFermion &q1, const LatticeFermion &q2, const LatticeFermion &q3, int *qindices) const
First smear then displace the quarks.
multi1d< LatticeComplex > operator()(const LatticeFermion &quark1, const LatticeFermion &quark2, const LatticeFermion &quark3, int *qindices, enum PlusMinus isign) const
Compute the operator.
void displaceQuarks(multi1d< std::map< int, LatticeFermion > > &disp_quarks, const multi1d< LatticeFermion > &q, int *qindices) const
Construct array of std::maps of displacements.
Class for counted reference semantics.
Definition: handle.h:33
static T & Instance()
Definition: singleton.h:432
int mu
Definition: cool.cc:24
Random Z(N) source construction using dilution.
Basis rotation matrix from Dirac to Degrand-Rossi (and reverse)
Parallel transport a lattice field.
Construct group baryon operators.
SpinMatrixD DiracToDRMat()
The Dirac to Degrand-Rossi spin transformation matrix (and reverse)
Definition: diractodr.cc:22
void read(XMLReader &xml, const std::string &path, GroupBaryonOperatorEnv::Params::Qprop_t::Solutions_t &input)
Reader.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
LatticePropagator displacement(const multi1d< LatticeColorMatrix > &u, const LatticePropagator &chi, int length, int dir)
Apply a displacement operator to a lattice field.
void zN_src(LatticeFermion &a, int N)
Volume source of Z(N) noise.
Definition: zN_src.cc:41
Params params
unsigned j
Definition: ldumul_w.cc:35
unsigned n
Definition: ldumul_w.cc:36
void setrn(int iseed[4])
Definition: make_seeds.cc:38
void savern(int iseed[4])
Definition: make_seeds.cc:46
int t
Definition: meslate.cc:37
Nd
Definition: meslate.cc:74
Double q
Definition: mesq.cc:17
static bool registered
Local registration flag.
int DilSwapInv(int ord, int i, int j, int k, int which)
void ReadTextInput(Params &params, multi1d< GroupBaryonOp > &AB, multi1d< GroupBaryonOp > &CB, multi1d< GroupBaryonQQQ > &AQQQ, multi1d< GroupBaryonQQQ > &CQQQ)
Reader.
bool registerAll()
Register all the factories.
void write(XMLWriter &xml, const std::string &path, const GroupBaryonOperatorEnv::Params &param)
int DilSwap(int ord, int i, int j, int k, int which)
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
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
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
Double c
Definition: invbicg.cc:108
int i
Definition: pbg5p_w.cc:55
multi1d< LatticeFermion > chi(Ncb)
Complex a
Definition: invbicg.cc:95
pop(xml_out)
DComplex d
Definition: invbicg.cc:99
void displacementSub(const multi1d< LatticeColorMatrix > &u, LatticeFermion &chi, int length, int dir)
START_CODE()
Complex b
Definition: invbicg.cc:96
Double zero
Definition: invbicg.cc:106
int k
Definition: invbicg.cc:119
multi1d< LatticeFermion > s(Ncb)
::std::string string
Definition: gtest.h:1979
int l
Definition: pade_trln_w.cc:111
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
All quark smearing constructors.
Factory for producing quark smearing objects.
Quark source or sink smearing.
Fourier transform phase factor support.
All make sink constructors.
Factory for producing quark prop sinks.
All source smearing.
Factory for producing quark smearing objects.
multi1d< BaryonOperatorInsertion_t > orderings
multi1d< Complex > serialize()
Serialize generalized operator object.
struct Chroma::GroupBaryonOperatorEnv::Params::Qprop_t qprop
struct Chroma::GroupBaryonOperatorEnv::Params::param_t param
struct Chroma::GroupBaryonOperatorEnv::Params::gaugestuff_t gaugestuff
void writeXML(XMLWriter &in, const std::string &path) const
Volume source of Z(N) noise.