11 #include "qdp_map_obj.h"
12 #include "qdp_map_obj_disk.h"
13 #include "qdp_disk_map_slice.h"
35 StandardOutputStream&
operator<<(StandardOutputStream& os,
const multi1d<int>&
d)
41 for(
int i=1;
i <
d.size(); ++
i)
50 namespace InlinePropDistillationStochEnv
55 XMLReader inputtop(xml, path);
80 XMLReader inputtop(xml, path);
111 XMLReader inputtop(xml, path);
113 read(inputtop,
"Propagator", input.
prop);
151 namespace InlinePropDistillationStochEnv
157 typedef QDP::MapObjectDisk<KeyPropDistillation_t, TimeSliceIO<LatticeColorVectorF> >
MOD_t;
178 LatticeColorVector getSrc(
MOD_t& source_obj,
int t_source,
int colorvec_src)
180 QDPIO::cout << __func__ <<
": on t_source= " <<
t_source <<
" colorvec_src= " << colorvec_src << std::endl;
184 LatticeColorVectorF vec_srce =
zero;
186 TimeSliceIO<LatticeColorVectorF> time_slice_io(vec_srce,
t_source);
187 source_obj.get(src_key, time_slice_io);
195 std::vector<bool> getActiveTSlices(
int t_source,
int Nt_forward,
int Nt_backward)
198 const int decay_dir =
Nd-1;
199 const int Lt = Layout::lattSize()[decay_dir];
201 std::vector<bool> active_t_slices(Lt);
202 for(
int t=0;
t < Lt; ++
t)
204 active_t_slices[
t] =
false;
208 for(
int dt=0;
dt < Nt_forward; ++
dt)
211 active_t_slices[
t % Lt] =
true;
215 for(
int dt=0;
dt < Nt_backward; ++
dt)
218 while (
t < 0) {
t += Lt;}
220 active_t_slices[
t % Lt] =
true;
223 return active_t_slices;
229 std::list<KeyPropDistillation_t> getSrcKeys(
int t_source,
int colorvec_src)
231 std::list<KeyPropDistillation_t> keys;
233 keys.push_back(getSrcKey(
t_source,colorvec_src));
241 std::list<KeyPropDistillation_t> getSnkKeys(
int t_source,
int colorvec_src,
int Nt_forward,
int Nt_backward,
const std::string mass)
243 std::list<KeyPropDistillation_t> keys;
245 std::vector<bool> active_t_slices = getActiveTSlices(
t_source, Nt_forward, Nt_backward);
247 const int decay_dir =
Nd-1;
248 const int Lt = Layout::lattSize()[decay_dir];
250 for(
int spin_source=0; spin_source < Ns; ++spin_source)
252 for(
int spin_sink=0; spin_sink < Ns; ++spin_sink)
254 for(
int t=0;
t < Lt; ++
t)
256 if (! active_t_slices[
t]) {
continue;}
281 multi2d<LatticeColorVector> ferm_out(Ns,Ns);
283 const int decay_dir =
Nd-1;
284 const int Lt = Layout::lattSize()[decay_dir];
286 for(
int spin_source=0; spin_source < Ns; ++spin_source)
288 for(
int spin_sink=0; spin_sink < Ns; ++spin_sink)
300 LatticeColorVectorF vec_srce =
zero;
302 TimeSliceIO<LatticeColorVectorF> time_slice_io(vec_srce,
t_source);
303 source_obj.get(key, time_slice_io);
305 ferm_out(spin_sink, spin_source) = vec_srce;
315 void doTrace(multi2d<ComplexD>& trace_mom,
316 const LatticeColorVector& vec_srce,
317 const multi2d<LatticeColorVector>& fred_out,
int t_source,
int colorvec_src,
318 const std::vector<MatrixSpinRep_t>& diracToDrMatPlus,
319 const std::vector<MatrixSpinRep_t>& diracToDrMatMinus,
326 Double ddd = norm2(vec_srce);
327 QDPIO::cout << __func__ <<
": colorvec_src= " << colorvec_src <<
" norm(left_vec)= " << ddd <<
"\n";
331 multi2d<LatticeColorVector> ferm_out;
333 multi2d<LatticeColorVector> ferm_tmp;
335 multiplyRep(ferm_tmp, diracToDrMatMinus, fred_out);
339 for(
int spin_source = 0; spin_source < Ns; ++spin_source)
341 LatticeComplex lop =
localInnerProduct(vec_srce, ferm_out(spin_source,spin_source));
344 for(
int mom_num = 0; mom_num < phases.
numMom(); ++mom_num)
346 multi1d<ComplexD> op_sum = sumMulti(phases[mom_num] * lop, phases.
getSet());
349 for(
int ttt = 0; ttt < op_sum.size(); ++ttt)
351 QDPIO::cout <<
"OP_SUM: "
352 <<
" t_source= " << ttt
353 <<
" colorvec_src= " << colorvec_src
354 <<
" spin_source= " << spin_source
355 <<
" mom_num= " << mom_num
356 <<
" mom= " << phases.
numToMom(mom_num)
357 <<
" op_sum[ " << ttt <<
" ]= " << op_sum[ttt]
366 for(
int mom_num = 0 ; mom_num < phases.
numMom() ; ++mom_num)
368 QDPIO::cout <<
"TRACE: "
370 <<
" colorvec_src= " << colorvec_src
371 <<
" num_vecs= " << num_vecs
372 <<
" mom= " << phases.
numToMom(mom_num)
373 <<
" trace( " << mom_num <<
" )= " << trace_mom(
t_source,mom_num)
383 namespace InlinePropDistillationStochEnv
390 return new InlineMeas(Params(xml_in, path));
421 XMLReader paramtop(xml_in, path);
423 if (paramtop.count(
"Frequency") == 1)
435 if (paramtop.count(
"xml_file") != 0)
442 QDPIO::cerr << __func__ <<
": Caught Exception reading XML: " << e << std::endl;
460 push(xml_out,
"PropDistillation");
461 write(xml_out,
"update_no", update_no);
462 write(xml_out,
"xml_file", xml_file);
465 XMLFileWriter xml(xml_file);
466 func(update_no, xml);
470 func(update_no, xml_out);
487 multi1d<LatticeColorMatrix>
u;
488 XMLBufferWriter gauge_xml;
494 catch( std::bad_cast )
496 QDPIO::cerr <<
name <<
": caught dynamic cast error" << std::endl;
501 QDPIO::cerr <<
name <<
": std::map call failed: " << e << std::endl;
505 push(xml_out,
"PropDistillation");
506 write(xml_out,
"update_no", update_no);
508 QDPIO::cout <<
name <<
": propagator calculation" << std::endl;
516 write(xml_out,
"Config_info", gauge_xml);
518 push(xml_out,
"Output_version");
519 write(xml_out,
"out_version", 1);
523 MesPlq(xml_out,
"Observables",
u);
527 const int Lt = Layout::lattSize()[decay_dir];
530 if (decay_dir !=
Nd-1)
532 QDPIO::cerr << __func__ <<
": TimeSliceIO only supports decay_dir= " <<
Nd-1 <<
"\n";
544 QDPIO::cerr <<
name <<
": param.contract.spatial mask size incorrect 1" << std::endl;
552 QDPIO::cerr <<
name <<
": not valid param.contract.spatial mask" << std::endl;
558 QDPIO::cerr <<
name <<
": lattice size not divisible by param.contract.spatial mask size" << std::endl;
567 std::list<int> source_list;
573 for(
int colorvec_src = 0; colorvec_src < num_vecs; ++colorvec_src)
574 source_list.push_back(colorvec_src);
587 for(
int ipos=1; ipos <= num_sites; ++ipos)
589 for(
int ipos = num_sites; ipos > 0; --ipos)
590 source_list.push_back(-ipos);
597 QDP::MapObjectDisk<KeyPropDistillation_t, TimeSliceIO<LatticeColorVectorF> > source_obj;
598 source_obj.setDebug(0);
600 QDPIO::cout <<
"Open source file" << std::endl;
612 QDPIO::cout <<
"Finished opening solution file" << std::endl;
618 QDP::MapObjectDisk<KeyPropDistillation_t, TimeSliceIO<LatticeColorVectorF> > soln_obj;
619 soln_obj.setDebug(0);
621 QDPIO::cout <<
"Open solution file" << std::endl;
633 QDPIO::cout <<
"Finished opening solution file" << std::endl;
639 QDP::MapObjectDisk<KeyPropDistillation_t, TimeSliceIO<LatticeColorVectorF> > prop_obj;
640 prop_obj.setDebug(0);
642 QDPIO::cout <<
"Open solution file" << std::endl;
646 XMLBufferWriter file_xml;
648 push(file_xml,
"MODMetaData");
650 write(file_xml,
"lattSize", QDP::Layout::lattSize());
651 write(file_xml,
"decay_dir", decay_dir);
658 write(file_xml,
"Config_info", gauge_xml);
663 prop_obj.insertUserdata(file_xml.str());
671 QDPIO::cout <<
"Finished opening prop file" << std::endl;
688 SftMom phases(2,
false, decay_dir);
700 QDPIO::cout <<
"Try the various factories" << std::endl;
703 typedef LatticeFermion
T;
704 typedef multi1d<LatticeColorMatrix>
P;
705 typedef multi1d<LatticeColorMatrix>
Q;
711 XMLReader fermacttop(xml_s);
725 QDPIO::cout <<
"Suitable factory found: compute all the quark props" << std::endl;
737 for(
int tt=0; tt < t_sources.size(); ++tt)
740 QDPIO::cout <<
"t_source = " <<
t_source << std::endl;
745 for(
int colorvec_src = 0; colorvec_src < num_vecs; ++colorvec_src)
748 getSrc(source_obj,
t_source, colorvec_src),
763 for(
auto col_src = source_list.begin(); col_src != source_list.end(); ++col_src)
765 const int colorvec_src = *col_src;
770 QDPIO::cout <<
"colorvec_src = " << colorvec_src << std::endl;
773 LatticeColorVector vec_srce = getSrc(source_obj,
t_source, colorvec_src);
778 Double ddd = norm2(vec_srce);
779 QDPIO::cout << __func__ <<
": colorvec_src= " << colorvec_src <<
" norm(source_vec)= " << ddd <<
"\n";
786 multi2d<LatticeColorVector> ferm_out(Ns,Ns);
788 for(
int spin_source=0; spin_source < Ns; ++spin_source)
790 QDPIO::cout <<
"spin_source = " << spin_source << std::endl;
797 LatticeFermion quark_soln =
zero;
804 for(
int spin_sink=0; spin_sink < Ns; ++spin_sink)
806 ferm_out(spin_sink,spin_source) = peekSpin(quark_soln, spin_sink);
818 multi2d<LatticeColorVector> ferm_tmp;
820 multiplyRep(ferm_tmp, diracToDrMatMinus, ferm_out);
826 QDPIO::cout <<
"Time to assemble and transmogrify propagators for colorvec_src= " << colorvec_src <<
" time = "
827 << sniss1.getTimeInSeconds()
828 <<
" secs" << std::endl;
832 QDPIO::cout <<
"Write propagator solutions to disk" << std::endl;
838 QDPIO::cout <<
"Write propagator solution to disk" << std::endl;
839 std::list<KeyPropDistillation_t> snk_keys(getSnkKeys(
t_source, colorvec_src,
844 for(std::list<KeyPropDistillation_t>::const_iterator key= snk_keys.begin();
845 key != snk_keys.end();
848 LatticeColorVectorF tmptmp = ferm_out(key->spin_snk,key->spin_src);
850 prop_obj.insert(*key, TimeSliceIO<LatticeColorVectorF>(tmptmp, key->t_slice));
861 if (colorvec_src < 0)
863 int orig_vec = (-colorvec_src) | (1 << 15);
864 vec_srce = getSrc(source_obj,
t_source, -orig_vec);
879 QDPIO::cout <<
"Time to write propagators for colorvec_src= " << colorvec_src <<
" time = "
880 << sniss2.getTimeInSeconds()
881 <<
" secs" << std::endl;
887 QDPIO::cout <<
"Propagators computed: time= "
888 << swatch.getTimeInSeconds()
889 <<
" secs" << std::endl;
893 QDPIO::cout <<
name <<
": caught exception around qprop: " << e << std::endl;
897 push(xml_out,
"Relaxation_Iterations");
898 write(xml_out,
"ncg_had", ncg_had);
904 QDPIO::cout <<
name <<
": total time = "
905 << snoop.getTimeInSeconds()
906 <<
" secs" << std::endl;
908 QDPIO::cout <<
name <<
": ran successfully" << std::endl;
Inline measurement factory.
Class for counted reference semantics.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Fourier transform phase factor support.
int numSubsets() const
Number of subsets - length in decay direction.
multi1d< int > numToMom(int mom_num) const
Convert momenta id to actual array of momenta.
int numMom() const
Number of momenta.
const Set & getSet() const
The set to be used in sumMulti.
Builds time slice subsets.
Basis rotation matrix from Dirac to Degrand-Rossi (and reverse)
Class structure for fermion actions.
Fermion action factories.
All Wilson-type fermion actions.
SpinMatrixD DiracToDRMat()
The Dirac to Degrand-Rossi spin transformation matrix (and reverse)
void CvToFerm(const LatticeColorVectorF &a, LatticeFermionF &b, int spin_index)
Convert (insert) a LatticeColorVector into a LatticeFermion.
void proginfo(XMLWriter &xml)
Print out basic information about this program.
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
TimeSliceSet time_slice_set
Compute the propagator from distillation.
Key for vanilla distillation propagator sources and solutions.
Named object function std::map.
static bool registered
Local registration flag.
multi1d< LatticeColorMatrix > P
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
bool registerAll()
Register all the factories.
void read(XMLReader &xml, const std::string &path, Params::NamedObject_t &input)
Propagator input.
void write(XMLWriter &xml, const std::string &path, const Params::NamedObject_t &input)
Propagator output.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
QDP::StandardOutputStream & operator<<(QDP::StandardOutputStream &s, const multi1d< int > &d)
static multi1d< LatticeColorMatrix > u
LinOpSysSolverMGProtoClover::Q Q
push(xml_out,"Condensates")
LinOpSysSolverMGProtoClover::T T
std::vector< MatrixSpinRep_t > convertTwoQuarkSpin(const SpinMatrix &in)
Convert a generic spin matrix into a sparse spin representation.
multi1d< LatticeFermion > chi(Ncb)
QDP::MapObjectDisk< KeyPropDistillution_t, TimeSliceIO< LatticeColorVectorF > > MOD_t
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
static QDP_ColorVector * out
Constructor.
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
const WilsonTypeFermAct< multi1d< LatticeFermion > > & S_f
void multiplyRep(multi2d< LatticeColorVector > &dist_rep, const std::vector< MatrixSpinRep_t > &spin, const multi2d< LatticeColorVector > &prop_rep)
Dist(t2) = SpinMatrix*Prop(t2)
static QDP_ColorVector * in
FloatingPoint< double > Double
Print out basic info about this program.
Fourier transform phase factor support.
Sparse matrix representation of spin matrices.
multi1d< int > spatial_mask_size
Distillation propagators.
Holds return info from SystemSolver call.
Convenience for building time-slice subsets.
Contraction operators for two quarks.