CHROMA
inline_stoch_baryon_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline measurement of stochastic baryon operator
3  *
4  */
5 
6 #include "handle.h"
10 #include "meas/sources/zN_src.h"
14 #include "meas/glue/mesplq.h"
15 #include "util/ft/sftmom.h"
16 #include "util/info/proginfo.h"
18 
20 
21 namespace Chroma
22 {
23  namespace InlineStochBaryonEnv
24  {
25  namespace
26  {
27  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
28  const std::string& path)
29  {
30  return new InlineStochBaryon(InlineStochBaryonParams(xml_in, path));
31  }
32 
33  //! Local registration flag
34  bool registered = false;
35  }
36 
37  const std::string name = "STOCH_BARYON";
38 
39  //! Register all the factories
40  bool registerAll()
41  {
42  bool success = true;
43  if (! registered)
44  {
45  success &= BaryonOperatorEnv::registerAll();
46  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
47  registered = true;
48  }
49  return success;
50  }
51  }
52 
53 
54 
55  // Operator parameters
56  void read(XMLReader& xml, const std::string& path, InlineStochBaryonParams::Prop_t::Operator_t& input)
57  {
58  XMLReader inputtop(xml, path);
59 
60  read(inputtop, "soln_files", input.soln_files);
61  }
62 
63 
64  // Operator parameters
65  void write(XMLWriter& xml, const std::string& path, const InlineStochBaryonParams::Prop_t::Operator_t& input)
66  {
67  push(xml, path);
68  write(xml, "soln_files", input.soln_files);
69  pop(xml);
70  }
71 
72 
73  // Propagator parameters
74  void read(XMLReader& xml, const std::string& path, InlineStochBaryonParams::Prop_t& input)
75  {
76  XMLReader inputtop(xml, path);
77 
78  read(inputtop, "operator_file", input.op_file);
79  read(inputtop, "operator", input.op);
80  }
81 
82 
83  // Propagator parameters
84  void write(XMLWriter& xml, const std::string& path, const InlineStochBaryonParams::Prop_t& input)
85  {
86  push(xml, path);
87 
88  write(xml, "operator_file", input.op_file);
89  write(xml, "operator", input.op);
90 
91  pop(xml);
92  }
93 
94 
95  // Reader for input parameters
96  void read(XMLReader& xml, const std::string& path, InlineStochBaryonParams::Param_t& param)
97  {
98  XMLReader paramtop(xml, path);
99 
100  int version;
101  read(paramtop, "version", version);
102 
103  switch (version)
104  {
105  case 2:
106  /**************************************************************************/
107  break;
108 
109  default :
110  /**************************************************************************/
111 
112  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
113  QDP_abort(1);
114  }
115 
116  read(paramtop, "mom2_max", param.mom2_max);
117 
118  {
119  XMLReader xml_tmp(paramtop, "BaryonOperator");
120  std::ostringstream os;
121  xml_tmp.print(os);
122  read(xml_tmp, "BaryonOperatorType", param.baryon_operator_type);
123  param.baryon_operator = os.str();
124  }
125 
126  }
127 
128 
129  // Reader for input parameters
130  void write(XMLWriter& xml, const std::string& path, const InlineStochBaryonParams::Param_t& param)
131  {
132  push(xml, path);
133 
134  int version = 1;
135 
136  write(xml, "version", version);
137  write(xml, "mom2_max", param.mom2_max);
138 
139  pop(xml);
140  }
141 
142 
143  //! Propagator parameters
144  void read(XMLReader& xml, const std::string& path, InlineStochBaryonParams::NamedObject_t& input)
145  {
146  XMLReader inputtop(xml, path);
147 
148  read(inputtop, "gauge_id", input.gauge_id);
149  read(inputtop, "Prop", input.prop);
150  }
151 
152  //! Propagator parameters
153  void write(XMLWriter& xml, const std::string& path, const InlineStochBaryonParams::NamedObject_t& input)
154  {
155  push(xml, path);
156 
157  write(xml, "gauge_id", input.gauge_id);
158  write(xml, "Prop", input.prop);
159 
160  pop(xml);
161  }
162 
163 
164  // Param stuff
166  {
167  frequency = 0;
168  }
169 
171  {
172  try
173  {
174  XMLReader paramtop(xml_in, path);
175 
176  if (paramtop.count("Frequency") == 1)
177  read(paramtop, "Frequency", frequency);
178  else
179  frequency = 1;
180 
181  // Read program parameters
182  read(paramtop, "Param", param);
183 
184  // Read in the output propagator/source configuration info
185  read(paramtop, "NamedObject", named_obj);
186 
187  // Possible alternate XML file pattern
188  if (paramtop.count("xml_file") != 0)
189  {
190  read(paramtop, "xml_file", xml_file);
191  }
192  }
193  catch(const std::string& e)
194  {
195  QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << std::endl;
196  QDP_abort(1);
197  }
198  }
199 
200 
201  void
202  InlineStochBaryonParams::write(XMLWriter& xml_out, const std::string& path)
203  {
204  push(xml_out, path);
205 
206  // Parameters for source construction
207  Chroma::write(xml_out, "Param", param);
208 
209  // Write out the output propagator/source configuration info
210  Chroma::write(xml_out, "NamedObject", named_obj);
211 
212  pop(xml_out);
213  }
214 
215 
216 
217  //--------------------------------------------------------------
218 
219  //! Structure holding a source and its solutions
221  {
222  //! Structure holding solutions
224  {
225  LatticeFermion source;
226  LatticeFermion soln;
229  };
230 
231  int j_decay;
232  Seed seed;
233  multi1d<QuarkSolution_t> dilutions;
234  };
235 
236 
237  //! Baryon operator
239  {
240 
241  //! Baryon operator
243  {
244  //! Possible operator index
246  {
247  //! Baryon operator element
249  {
250  multi2d<DComplex> elem; /*!< time slice and momenta number */
251  };
252 
253  multi1d<BaryonOperatorElement_t> ind;
254  };
255 
256  multi3d<BaryonOperatorIndex_t> op; /*!< hybrid list indices */
257 
258  };
259 
260  multi1d< multi1d<int> > perms; /*!< Permutations of quark enumeration */
261 
262  Seed seed_l; /*!< Id of left quark */
263  Seed seed_m; /*!< Id of middle quark */
264  Seed seed_r; /*!< Id of right quark */
265 
266  int mom2_max;
267  int j_decay;
268  multi1d<BaryonOperatorInsertion_t> orderings; /*!< Array is over quark orderings */
269  };
270 
271 
272  //! BaryonOperator binary writer
273  void write(BinaryWriter& bin,
275  write(bin, p.elem);
276  }
277 
278  //! BaryonOperator binary writer
279  void write(BinaryWriter& bin,
281  write(bin, p.ind);
282  }
283 
284  //! BaryonOperator binary writer
285  void write(BinaryWriter& bin,
287  write(bin, p.op);
288  }
289 
290  //! BaryonOperator binary writer
291  void write(BinaryWriter& bin, const BaryonOperator_t& param){
292  write(bin, param.seed_l);
293  write(bin, param.seed_m);
294  write(bin, param.seed_r);
295  write(bin, param.mom2_max);
296  write(bin, param.j_decay);
297  write(bin, param.perms);
298  write(bin, param.orderings);
299  }
300 
301  //! BaryonOperator header writer
302  void write(XMLWriter& xml, const std::string& path, const BaryonOperator_t& param)
303  {
304  if( path != "." )
305  push(xml, path);
306 
307  int version = 1;
308  write(xml, "version", version);
309  write(xml, "mom2_max", param.mom2_max);
310  write(xml, "j_decay", param.j_decay);
311  write(xml, "seed_l", param.seed_l);
312  write(xml, "seed_m", param.seed_m);
313  write(xml, "seed_r", param.seed_r);
314  write(xml, "perms", param.perms);
315 
316  if( path != "." )
317  pop(xml);
318  }
319 
320 
321 
322  //--------------------------------------------------------------
323  // Function call
324  void
325  InlineStochBaryon::operator()(unsigned long update_no,
326  XMLWriter& xml_out)
327  {
328  // If xml file not empty, then use alternate
329  if (params.xml_file != "")
330  {
331  std::string xml_file = makeXMLFileName(params.xml_file, update_no);
332 
333  push(xml_out, "stoch_baryon");
334  write(xml_out, "update_no", update_no);
335  write(xml_out, "xml_file", xml_file);
336  pop(xml_out);
337 
338  XMLFileWriter xml(xml_file);
339  func(update_no, xml);
340  }
341  else
342  {
343  func(update_no, xml_out);
344  }
345  }
346 
347 
348  // Function call
349  void
350  InlineStochBaryon::func(unsigned long update_no,
351  XMLWriter& xml_out)
352  {
353  START_CODE();
354 
355  StopWatch snoop;
356  snoop.reset();
357  snoop.start();
358 
359  // Test and grab a reference to the gauge field
360  XMLBufferWriter gauge_xml;
361  try
362  {
363  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
364  TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
365  }
366  catch( std::bad_cast )
367  {
368  QDPIO::cerr << InlineStochBaryonEnv::name << ": caught dynamic cast error"
369  << std::endl;
370  QDP_abort(1);
371  }
372  catch (const std::string& e)
373  {
374  QDPIO::cerr << InlineStochBaryonEnv::name << ": std::map call failed: " << e
375  << std::endl;
376  QDP_abort(1);
377  }
378  const multi1d<LatticeColorMatrix>& u =
379  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
380 
381  push(xml_out, "stoch_baryon");
382  write(xml_out, "update_no", update_no);
383 
384  QDPIO::cout << InlineStochBaryonEnv::name << ": Stochastic Baryon Operator" << std::endl;
385 
386  proginfo(xml_out); // Print out basic program info
387 
388  // Write out the input
389  params.write(xml_out, "Input");
390 
391  // Write out the config info
392  write(xml_out, "Config_info", gauge_xml);
393 
394  push(xml_out, "Output_version");
395  write(xml_out, "out_version", 1);
396  pop(xml_out);
397 
398  // First calculate some gauge invariant observables just for info.
399  // This is really cheap.
400  MesPlq(xml_out, "Observables", u);
401 
402  // Save current seed
403  Seed ran_seed;
404  QDP::RNG::savern(ran_seed);
405 
406  //
407  // Read the source and solutions
408  //
409  StopWatch swatch;
410  swatch.reset();
411  swatch.start();
412 
413  multi1d<QuarkSourceSolutions_t> quarks(params.named_obj.prop.op.size());
414  QDPIO::cout << "num_quarks= " << params.named_obj.prop.op.size() << std::endl;
415 
416  try
417  {
418  QDPIO::cout << "quarks.size= " << quarks.size() << std::endl;
419  for(int n=0; n < quarks.size(); ++n)
420  {
421  QDPIO::cout << "Attempt to read solutions for source number=" << n << std::endl;
422  quarks[n].dilutions.resize(params.named_obj.prop.op[n].soln_files.size());
423 
424  QDPIO::cout << "dilutions.size= " << quarks[n].dilutions.size() << std::endl;
425  for(int i=0; i < quarks[n].dilutions.size(); ++i)
426  {
427  XMLReader file_xml, record_xml;
428 
429  QDPIO::cout << "reading file= " << params.named_obj.prop.op[n].soln_files[i] << std::endl;
430  QDPFileReader from(file_xml, params.named_obj.prop.op[n].soln_files[i], QDPIO_SERIAL);
431  read(from, record_xml, quarks[n].dilutions[i].soln);
432  close(from);
433 
434  read(record_xml, "/Propagator/PropSource", quarks[n].dilutions[i].source_header);
435  read(record_xml, "/Propagator/ForwardProp", quarks[n].dilutions[i].prop_header);
436  }
437  }
438  }
439  catch (const std::string& e)
440  {
441  QDPIO::cerr << "Error extracting headers: " << e << std::endl;
442  QDP_abort(1);
443  }
444  swatch.stop();
445 
446  QDPIO::cout << "Sources and solutions successfully read: time= "
447  << swatch.getTimeInSeconds()
448  << " secs" << std::endl;
449 
450 
451 
452  //
453  // Check for each quark source that the solutions have their diluted
454  // on every site only once
455  //
456  swatch.start();
457 
458  try
459  {
460  push(xml_out, "Norms");
461  for(int n=0; n < quarks.size(); ++n)
462  {
463  bool first = true;
464  int N;
465  LatticeFermion quark_noise; // noisy source on entire lattice
466 
467  for(int i=0; i < quarks[n].dilutions.size(); ++i)
468  {
469  std::istringstream xml_s(quarks[n].dilutions[i].source_header.source.xml);
470  XMLReader sourcetop(xml_s);
471 // QDPIO::cout << "Source = " << quarks[n].dilutions[i].source_header.source.id << std::endl;
472 
473  if (quarks[n].dilutions[i].source_header.source.id != DiluteZNQuarkSourceConstEnv::getName())
474  {
475  QDPIO::cerr << "Expected source_type = " << DiluteZNQuarkSourceConstEnv::getName() << std::endl;
476  QDP_abort(1);
477  }
478 
479  QDPIO::cout << "Quark num= " << n << " dilution num= " << i << std::endl;
480 
481  // Manually create the params so I can peek into them and use the source constructor
482  DiluteZNQuarkSourceConstEnv::Params srcParams(sourcetop,
483  quarks[n].dilutions[i].source_header.source.path);
485 
486  if (first)
487  {
488  first = false;
489 
490  quarks[0].j_decay = srcParams.j_decay;
491 
492  // Grab N
493  N = srcParams.N;
494 
495  // Set the seed to desired value
496  quarks[n].seed = srcParams.ran_seed;
497  QDP::RNG::setrn(quarks[n].seed);
498 
499  // Create the noisy quark source on the entire lattice
500  zN_src(quark_noise, N);
501  }
502 
503  // The seeds must always agree - here the seed is the unique id of the source
504  if ( toBool(srcParams.ran_seed != quarks[n].seed) )
505  {
506  QDPIO::cerr << "quark source=" << n << " dilution=" << i << " seed does not match" << std::endl;
507  QDP_abort(1);
508  }
509 
510  // The N's must always agree
511  if ( toBool(srcParams.N != N) )
512  {
513  QDPIO::cerr << "quark source=" << n << " dilution=" << i << " N does not match" << std::endl;
514  QDP_abort(1);
515  }
516 
517  // Use a trick here, create the source and subtract it from the global noisy
518  // Check at the end that the global noisy is zero everywhere.
519  // NOTE: the seed will be set every call
520  quarks[n].dilutions[i].source = srcConst(u);
521  quark_noise -= quarks[n].dilutions[i].source;
522 
523 #if 0
524  // Diagnostic
525  {
526  // Keep a copy of the phases with NO momenta
527  SftMom phases_nomom(0, true, quarks[n].dilutions[i].source_header.j_decay);
528 
529  multi1d<Double> source_corr = sumMulti(localNorm2(quarks[n].dilutions[i].source),
530  phases_nomom.getSet());
531 
532  multi1d<Double> soln_corr = sumMulti(localNorm2(quarks[n].dilutions[i].soln),
533  phases_nomom.getSet());
534 
535  push(xml_out, "elem");
536  write(xml_out, "n", n);
537  write(xml_out, "i", i);
538  write(xml_out, "source_corr", source_corr);
539  write(xml_out, "soln_corr", soln_corr);
540  pop(xml_out);
541  }
542 #endif
543  } // end for i
544 
545  Double dcnt = norm2(quark_noise);
546  if (toDouble(dcnt) != 0.0) // problematic - seems to work with unnormalized sources
547  {
548  QDPIO::cerr << "Noise not saturated by all potential solutions: dcnt=" << dcnt << std::endl;
549  QDP_abort(1);
550  }
551 
552  } // end for n
553 
554  pop(xml_out); // norms
555  } // end try
556  catch(const std::string& e)
557  {
558  QDPIO::cerr << ": Caught Exception creating source: " << e << std::endl;
559  QDP_abort(1);
560  }
561 
562  swatch.stop();
563 
564  QDPIO::cout << "Sources saturated: time= "
565  << swatch.getTimeInSeconds()
566  << " secs" << std::endl;
567 
568 
569  //
570  // Baryon operators
571  //
572  int j_decay = quarks[0].j_decay;
573 
574  // Initialize the slow Fourier transform phases
575  SftMom phases(params.param.mom2_max, false, j_decay);
576 
577  // Length of lattice in decay direction
578  int length = phases.numSubsets();
579 
580  if (quarks.size() != 3)
581  {
582  QDPIO::cerr << "expecting 3 quarks but have num quarks= " << quarks.size() << std::endl;
583  QDP_abort(1);
584  }
585 
586  //
587  // Create the baryon operator object
588  //
589  std::istringstream xml_op(params.param.baryon_operator);
590  XMLReader optop(xml_op);
591  const std::string operator_path = "/BaryonOperator";
592 
595  optop,
596  operator_path,
597  u));
598 
599  //
600  // Permutations of quarks within an operator
601  //
602  int num_orderings = 6; // number of permutations of the numbers 0,1,2
603  multi1d< multi1d<int> > perms(num_orderings);
604  {
605  multi1d<int> p(3);
606 
607  if (num_orderings >= 1)
608  {
609  p[0] = 0; p[1] = 1; p[2] = 2;
610  perms[0] = p;
611  }
612 
613  if (num_orderings >= 2)
614  {
615  p[0] = 0; p[1] = 2; p[2] = 1;
616  perms[1] = p;
617  }
618 
619  if (num_orderings >= 3)
620  {
621  p[0] = 1; p[1] = 0; p[2] = 2;
622  perms[2] = p;
623  }
624 
625  if (num_orderings >= 4)
626  {
627  p[0] = 1; p[1] = 2; p[2] = 0;
628  perms[3] = p;
629  }
630 
631  if (num_orderings >= 5)
632  {
633  p[0] = 2; p[1] = 1; p[2] = 0;
634  perms[4] = p;
635  }
636 
637  if (num_orderings >= 6)
638  {
639  p[0] = 2; p[1] = 0; p[2] = 1;
640  perms[5] = p;
641  }
642  }
643 
644  // Operator A
645  swatch.start();
646  BaryonOperator_t baryon_opA;
647  baryon_opA.mom2_max = params.param.mom2_max;
648  baryon_opA.j_decay = j_decay;
649  baryon_opA.seed_l = quarks[0].seed;
650  baryon_opA.seed_m = quarks[1].seed;
651  baryon_opA.seed_r = quarks[2].seed;
652  baryon_opA.orderings.resize(num_orderings);
653  baryon_opA.perms.resize(num_orderings);
654 
655  push(xml_out, "OperatorA");
656 
657  // Sanity check
658  if ( toBool(baryon_opA.seed_l == baryon_opA.seed_m) )
659  {
660  QDPIO::cerr << "baryon op seeds are the same" << std::endl;
661  QDP_abort(1);
662  }
663 
664  // Sanity check
665  if ( toBool(baryon_opA.seed_l == baryon_opA.seed_r) )
666  {
667  QDPIO::cerr << "baryon op seeds are the same" << std::endl;
668  QDP_abort(1);
669  }
670 
671  // Sanity check
672  if ( toBool(baryon_opA.seed_m == baryon_opA.seed_r) )
673  {
674  QDPIO::cerr << "baryon op seeds are the same" << std::endl;
675  QDP_abort(1);
676  }
677 
678 
679  // Construct operator A
680  try
681  {
682  for(int ord=0; ord < baryon_opA.orderings.size(); ++ord)
683  {
684  QDPIO::cout << "Operator A: ordering = " << ord << std::endl;
685 
686  baryon_opA.perms[ord] = perms[ord];
687 
688  // Operator construction
689  const QuarkSourceSolutions_t& q0 = quarks[perms[ord][0]];
690  const QuarkSourceSolutions_t& q1 = quarks[perms[ord][1]];
691  const QuarkSourceSolutions_t& q2 = quarks[perms[ord][2]];
692 
693  baryon_opA.orderings[ord].op.resize(q0.dilutions.size(),
694  q1.dilutions.size(),
695  q2.dilutions.size());
696 
697 
698  for(int i=0; i < q0.dilutions.size(); ++i)
699  {
700  for(int j=0; j < q1.dilutions.size(); ++j)
701  {
702  for(int k=0; k < q2.dilutions.size(); ++k)
703  {
704  multi1d<LatticeComplex> bar = (*baryonOperator)(q0.dilutions[i].source,
705  q1.dilutions[j].source,
706  q2.dilutions[k].source,
707  MINUS);
708 
709  baryon_opA.orderings[ord].op(i,j,k).ind.resize(bar.size());
710  for(int l=0; l < bar.size(); ++l)
711  baryon_opA.orderings[ord].op(i,j,k).ind[l].elem = phases.sft(bar[l]);
712 
713  } // end for k
714  } // end for j
715  } // end for i
716  } // end for ord
717  } // end try
718  catch(const std::string& e)
719  {
720  QDPIO::cerr << ": Caught Exception creating source operator: " << e << std::endl;
721  QDP_abort(1);
722  }
723  catch(...)
724  {
725  QDPIO::cerr << ": Caught generic exception creating source operator" << std::endl;
726  QDP_abort(1);
727  }
728 
729  pop(xml_out); // OperatorA
730 
731  swatch.stop();
732 
733  QDPIO::cout << "Operator A computed: time= "
734  << swatch.getTimeInSeconds()
735  << " secs" << std::endl;
736 
737 
738  // Operator B
739  swatch.start();
740  BaryonOperator_t baryon_opB;
741  baryon_opB.mom2_max = params.param.mom2_max;
742  baryon_opB.j_decay = j_decay;
743  baryon_opB.seed_l = quarks[0].seed;
744  baryon_opB.seed_m = quarks[1].seed;
745  baryon_opB.seed_r = quarks[2].seed;
746  baryon_opB.orderings.resize(num_orderings);
747  baryon_opB.perms.resize(num_orderings);
748 
749  push(xml_out, "OperatorB");
750 
751  // Sanity check
752  if ( toBool(baryon_opB.seed_l == baryon_opB.seed_m) )
753  {
754  QDPIO::cerr << "baryon op seeds are the same" << std::endl;
755  QDP_abort(1);
756  }
757 
758  // Sanity check
759  if ( toBool(baryon_opB.seed_l == baryon_opB.seed_r) )
760  {
761  QDPIO::cerr << "baryon op seeds are the same" << std::endl;
762  QDP_abort(1);
763  }
764 
765  // Sanity check
766  if ( toBool(baryon_opB.seed_m == baryon_opB.seed_r) )
767  {
768  QDPIO::cerr << "baryon op seeds are the same" << std::endl;
769  QDP_abort(1);
770  }
771 
772 
773  // Construct operator B
774  try
775  {
776  for(int ord=0; ord < baryon_opB.orderings.size(); ++ord)
777  {
778  QDPIO::cout << "Operator B: ordering = " << ord << std::endl;
779 
780  baryon_opB.perms[ord] = perms[ord];
781 
782  // Operator construction
783  const QuarkSourceSolutions_t& q0 = quarks[perms[ord][0]];
784  const QuarkSourceSolutions_t& q1 = quarks[perms[ord][1]];
785  const QuarkSourceSolutions_t& q2 = quarks[perms[ord][2]];
786 
787  baryon_opB.orderings[ord].op.resize(q0.dilutions.size(),
788  q1.dilutions.size(),
789  q2.dilutions.size());
790 
791  for(int i=0; i < q0.dilutions.size(); ++i)
792  {
793  for(int j=0; j < q1.dilutions.size(); ++j)
794  {
795  for(int k=0; k < q2.dilutions.size(); ++k)
796  {
797  multi1d<LatticeComplex> bar = (*baryonOperator)(q0.dilutions[i].soln,
798  q1.dilutions[j].soln,
799  q2.dilutions[k].soln,
800  PLUS);
801 
802  baryon_opB.orderings[ord].op(i,j,k).ind.resize(bar.size());
803  for(int l=0; l < bar.size(); ++l)
804  baryon_opB.orderings[ord].op(i,j,k).ind[l].elem = phases.sft(bar[l]);
805 
806  } // end for k
807  } // end for j
808  } // end for i
809  } // end for ord
810  } // end try
811  catch(const std::string& e)
812  {
813  QDPIO::cerr << ": Caught Exception creating sink operator: " << e << std::endl;
814  QDP_abort(1);
815  }
816  catch(...)
817  {
818  QDPIO::cerr << ": Caught generic exception creating sink operator" << std::endl;
819  QDP_abort(1);
820  }
821 
822  pop(xml_out); // OperatorB
823 
824  swatch.stop();
825 
826  QDPIO::cout << "Operator B computed: time= "
827  << swatch.getTimeInSeconds()
828  << " secs" << std::endl;
829 
830 
831  // Save the operators
832  // ONLY SciDAC output format is supported!
833  swatch.start();
834  {
835  XMLBufferWriter file_xml;
836  push(file_xml, "baryon_operator");
837  file_xml << params.param.baryon_operator;
838  write(file_xml, "Config_info", gauge_xml);
839  pop(file_xml);
840 
841  QDPFileWriter to(file_xml, params.named_obj.prop.op_file,
842  QDPIO_SINGLEFILE, QDPIO_SERIAL, QDPIO_OPEN);
843 
844  // Write the scalar data
845  {
846  XMLBufferWriter record_xml;
847  BinaryBufferWriter record_bin;
848  write(record_xml, "SourceBaryonOperator", baryon_opA);
849  write(record_bin, baryon_opA);
850  write(to, record_xml, record_bin);
851  }
852 
853  // Write the scalar data
854  {
855  XMLBufferWriter record_xml;
856  BinaryBufferWriter record_bin;
857  write(record_xml, "SinkBaryonOperator", baryon_opB);
858  write(record_bin, baryon_opB);
859  write(to, record_xml, record_bin);
860  }
861 
862  close(to);
863  }
864 
865  swatch.stop();
866 
867  QDPIO::cout << "Operators written: time= "
868  << swatch.getTimeInSeconds()
869  << " secs" << std::endl;
870 
871  // Close the namelist output file XMLDAT
872  pop(xml_out); // StochBaryon
873 
874  snoop.stop();
875  QDPIO::cout << InlineStochBaryonEnv::name << ": total time = "
876  << snoop.getTimeInSeconds()
877  << " secs" << std::endl;
878 
879  QDPIO::cout << InlineStochBaryonEnv::name << ": ran successfully" << std::endl;
880 
881  END_CODE();
882  }
883 
884 }
Inline measurement factory.
Baryon spin and projector matrices.
All baryon operators.
Factory for producing baryon operators.
Random complex Z(N) sources using dilution.
Class for counted reference semantics.
Definition: handle.h:33
Inline measurement of stochastic baryon operators.
InlineStochBaryonParams params
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Fourier transform phase factor support.
Definition: sftmom.h:35
int numSubsets() const
Number of subsets - length in decay direction.
Definition: sftmom.h:63
multi2d< DComplex > sft(const LatticeComplex &cf) const
Do a sumMulti(cf*phases,getSet())
Definition: sftmom.cc:524
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
static T & Instance()
Definition: singleton.h:432
Random Z(N) source construction using dilution.
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 proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
void zN_src(LatticeFermion &a, int N)
Volume source of Z(N) noise.
Definition: zN_src.cc:41
Class for counted reference semantics.
ForwardProp_t prop_header
Inline measurement of stochastic baryon operator.
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
Make xml file writer.
int j_decay
Definition: meslate.cc:22
Named object function std::map.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
std::string getName()
Return the name.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
START_CODE()
int k
Definition: invbicg.cc:119
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
int l
Definition: pade_trln_w.cc:111
Print out basic info about this program.
Fourier transform phase factor support.
multi1d< BaryonOperatorInsertion_t > orderings
multi1d< multi1d< int > > perms
Propagator parameters.
Definition: qprop_io.h:75
Random complex Z(N) sources using dilution.
void write(XMLWriter &xml_out, const std::string &path)
struct Chroma::InlineStochBaryonParams::NamedObject_t named_obj
struct Chroma::InlineStochBaryonParams::Param_t param
Propagator source construction parameters.
Definition: qprop_io.h:27
Structure holding a source and its solutions.
multi1d< QuarkSolution_t > dilutions
Volume source of Z(N) noise.