34 namespace InlineStochHadronEnv{
41 return new InlineMeas(Params(xml_in, path));
65 XMLReader paramtop(xml, path);
68 read(paramtop,
"version", version);
88 QDPIO::cerr <<
"Input parameter version " << version <<
" unsupported." << std::endl;
102 write(xml,
"version", version);
106 push(xml,
"Smearing");
110 push(xml,
"Displacement");
119 for(
int t(0);
t<param.
quarks.size();
t++){
126 push(xml,
"HadronOperators");
127 for(
int t(0);
t<param.
ops.size();
t++){
129 xml<<param.
ops[
t].xml;
142 XMLReader inputtop(xml, path);
169 XMLReader paramtop(xml_in, path);
171 if (paramtop.count(
"Frequency") == 1)
183 if (paramtop.count(
"xml_file") != 0)
190 QDPIO::cerr << __func__ <<
": Caught Exception reading XML: " << e << std::endl;
211 QDPIO::cout<<
"I am a meson!\n" ;
212 std::istringstream xml_l(grpXML.
xml);
213 XMLReader xmltop(xml_l);
214 XMLReader xml(xmltop,
"/elem");
215 QDPIO::cout <<
"Meson state is = " <<grpXML.
id ;
216 QDPIO::cout << std::endl;
217 QDPIO::cout <<
" XML =" <<grpXML.
xml ;
218 QDPIO::cout << std::endl;
219 read(xml,
"Gamma",
m.g);
220 read(xml,
"File",
m.file);
224 QDPIO::cout<<
"I am a Baryon!\n" ;
225 std::istringstream xml_l(grpXML.
xml);
226 XMLReader xmltop(xml_l);
227 XMLReader xml(xmltop,
"/elem");
228 QDPIO::cout <<
"Baryon state is = " <<grpXML.
id ;
229 QDPIO::cout << std::endl;
230 QDPIO::cout <<
" XML =" <<grpXML.
xml ;
231 QDPIO::cout << std::endl;
232 read(xml,
"Gamma",
m.g);
233 read(xml,
"File",
m.file);
238 const LatticeComplex& phase,
239 const LatticeFermion&
eta,
240 const LatticeFermion&
chi,
248 const LatticeComplex& phase,
249 const LatticeFermion& eta1,
250 const LatticeFermion& eta2,
251 const LatticeFermion& eta3,
255 QDPIO::cerr<<
"baryon code only works for Nc=3 and Ns=4\n";
267 SpinMatrix g_one = 1.0 ;
268 SpinMatrix
Cg5 = Gamma(g)*g_one ;
270 for(
int k=0;
k < Ns; ++
k)
274 for(
int j=0;
j < Ns; ++
j)
276 for(
int i=0;
i < Ns; ++
i)
279 LatticeComplex b_oper = colorContract(peekSpin(eta1,
i),
306 k[0]=
i ;
k[1]=
j ;
k[2]=
l ;
331 k.resize(klidi.
k.size()) ;
332 for(
int i(0);
i<
k.size();
i++)
k[
i] = klidi.
k[
i] ;
397 std::map<Key,DComplex>::iterator
it;
433 multi3d< multi1d<DComplex> >
data ;
451 for(
int i=0;
i <
n; ++
i)
453 for(
int j=0;
j <
n; ++
j)
463 int n = param.
data.size1();
465 for(
int i=0;
i <
n; ++
i)
467 for(
int j=0;
j <
n; ++
j)
483 for(
int i=0;
i <
n; ++
i)
485 for(
int j=0;
j <
n; ++
j)
487 for(
int k=0;
k <
n; ++
k)
498 int n = param.
data.size1();
500 for(
int i=0;
i <
n; ++
i)
502 for(
int j=0;
j <
n; ++
j)
504 for(
int k=0;
k <
n; ++
k)
525 push(xml_out,
"stoch_hadron");
526 write(xml_out,
"update_no", update_no);
527 write(xml_out,
"xml_file", xml_file);
530 XMLFileWriter xml(xml_file);
531 func(update_no, xml);
534 func(update_no, xml_out);
552 XMLBufferWriter UserData_xml;
554 push(UserData_xml,
"StochHadron");
558 XMLBufferWriter gauge_xml;
564 catch( std::bad_cast )
572 QDPIO::cerr <<
name <<
": std::map call failed: " << e
576 const multi1d<LatticeColorMatrix>&
u =
579 push(xml_out,
"stoch_hadron");
580 write(xml_out,
"update_no", update_no);
583 QDPIO::cout <<
name <<
": Stochastic Hadron Operator" << std::endl;
592 write(xml_out,
"Config_info", gauge_xml);
593 write(UserData_xml,
"Config_info",gauge_xml);
595 push(xml_out,
"Output_version");
596 write(xml_out,
"out_version", 1);
601 MesPlq(xml_out,
"Observables",
u);
618 QDPIO::cout <<
name <<
": Need at least 2" << std::endl;
621 bool BuildMesons(NumMesOrd>0);
623 QDPIO::cout <<
name <<
": Can build mesons" << std::endl;
624 QDPIO::cout<<
name<<
": Number of meson orderings: "<<NumMesOrd<<std::endl;
629 bool BuildBaryons(NumBarOrd>0);
631 QDPIO::cout <<
name <<
": Can build baryons" << std::endl;
632 QDPIO::cout<<
name<<
": Number of baryon orderings: "<<NumBarOrd<<std::endl;
637 multi1d< Handle< DilutionScheme<LatticeFermion> > > quarks(
N_quarks);
643 std::istringstream xml_d(dil_xml.
xml);
644 XMLReader diltop(xml_d);
645 QDPIO::cout <<
"Dilution type = " << dil_xml.
id << std::endl;
653 QDPIO::cerr <<
name <<
": Caught Exception constructing dilution scheme: " << e << std::endl;
664 multi1d<int> participating_timeslices(quarks[0]->getNumTimeSlices());
666 for (
int t0 = 0 ;
t0 < participating_timeslices.size() ; ++
t0){
667 participating_timeslices[
t0] = quarks[0]->getT0(
t0);
671 if(quarks[
n]->getNumTimeSlices() != participating_timeslices.size()){
672 QDPIO::cerr <<
name ;
673 QDPIO::cerr <<
" : Quarks do not contain the same number";
674 QDPIO::cerr <<
"of dilution timeslices: Quark " <<
n << std::endl;
678 for (
int t0 = 0 ;
t0 < participating_timeslices.size() ; ++
t0){
679 if(quarks[
n]->getT0(
t0) != participating_timeslices[
t0]){
680 QDPIO::cerr <<
name <<
" : Quarks do not contain the same";
681 QDPIO::cerr <<
"participating timeslices: Quark ";
682 QDPIO::cerr <<
n <<
" timeslice "<<
t0 << std::endl;
691 if (quarks[0]->getCfgInfo() != quarks[
n]->getCfgInfo()){
692 QDPIO::cerr <<
name <<
" : Quarks do not contain the same cfg info";
693 QDPIO::cerr <<
", quark "<<
n << std::endl;
705 write(top,
"Config_info", gauge_xml);
707 XMLReader from2(from,
"/Config_info");
708 std::ostringstream os;
713 if (cfgInfo != quarks[0]->getCfgInfo()){
714 QDPIO::cerr <<
name <<
" : Quarks do not contain the same";
715 QDPIO::cerr <<
" cfg info as the gauge field." ;
716 QDPIO::cerr <<
"gauge: XX"<<cfgInfo<<
"XX quarks: XX" ;
717 QDPIO::cerr << quarks[0]->getCfgInfo()<<
"XX"<< std::endl;
725 int decay_dir = quarks[0]->getDecayDir();
730 if (phases.
numSubsets() != QDP::Layout::lattSize()[decay_dir]){
731 QDPIO::cerr <<
name <<
": number of time slices not equal to that";
732 QDPIO::cerr <<
" in the decay direction: "
733 << QDP::Layout::lattSize()[decay_dir]
738 write(UserData_xml,
"decay_dir",decay_dir);
739 push(UserData_xml,
"Quarks");
740 for(
int k(0);
k<quarks.size();
k++){
741 push(UserData_xml,
"elem");
743 UserData_xml<<quarks[
k]->getSeed();
749 for(
int n = 1 ;
n < quarks.size(); ++
n){
750 if(toBool(quarks[
n]->getSeed()==quarks[0]->getSeed())){
751 QDPIO::cerr <<
name <<
": error, quark seeds are the same" << std::endl;
755 if(toBool(quarks[
n]->getDecayDir()!=quarks[0]->getDecayDir())){
756 QDPIO::cerr<<
name<<
": error, quark decay dirs do not match" <<std::endl;
763 multi1d<LatticeColorMatrix> u_smr =
u;
767 XMLReader linktop(xml_l);
769 QDPIO::cout << std::endl;
774 (*linkSmearing)(u_smr);
777 QDPIO::cerr<<
name<<
": Caught Exception link smearing: " << e << std::endl;
781 MesPlq(xml_out,
"Smeared_Observables", u_smr);
784 std::map<std::string, MesonOp> LocalMesonOps ;
785 std::map<std::string, BaryonOp> LocalBaryonOps ;
787 QDPIO::cout<<
"Found Hadron: "<<
params.
param.
ops[o].id<<std::endl ;
803 QDPIO::cout<<
" is unkown " <<std::endl ;
815 XMLReader smrtop(xml_l);
817 QDPIO::cout << std::endl;
822 QDPIO::cerr <<
name<<
": Caught Exception creating quark smearing object: " << e << std::endl;
826 QDPIO::cerr <<
name<<
": Caught generic exception creating smearing object" << std::endl;
830 multi1d< multi1d< multi1d<LatticeFermion> > > smearedSol(quarks.size());
831 multi1d< multi1d< multi1d<LatticeFermion> > > src(quarks.size());
832 for(
int q(0);
q< quarks.size() ;
q++){
833 smearedSol[
q].resize(participating_timeslices.size());
834 src[
q].resize(participating_timeslices.size());
835 for (
int t0 = 0 ;
t0 < participating_timeslices.size() ; ++
t0){
836 smearedSol[
q][
t0].resize(quarks[
q]->getDilSize(
t0)) ;
837 src[
q][
t0].resize(quarks[
q]->getDilSize(
t0)) ;
838 for(
int i = 0 ;
i < quarks[
q]->getDilSize(
t0) ; ++
i){
839 smearedSol[
q][
t0][
i] = quarks[
q]->dilutedSolution(
t0,
i) ;
840 src[
q][
t0][
i] = quarks[
q]->dilutedSource(
t0,
i) ;
841 (*Smearing)(smearedSol[
q][
t0][
i], u_smr);
847 QDPIO::cout<<
" Doing " << phases.
numMom()<<
" momenta "<<std::endl ;
853 std::map<std::string, MesonOp>::iterator
it ;
854 for(
it=LocalMesonOps.begin();
it!=LocalMesonOps.end();
it++){
859 qdp_db.setMaxUserInfoLen(UserData_xml.str().size());
860 qdp_db.open(op.
file, O_RDWR | O_CREAT, 0664);
861 qdp_db.insertUserdata(UserData_xml.str());
865 key.
key().gamma = op.
g ;
867 for(
int mom_num = 0 ; mom_num < phases.
numMom() ; ++mom_num){
869 for (
int t0 = 0 ;
t0 < participating_timeslices.size() ; ++
t0){
870 key.
key().t0 = participating_timeslices[
t0] ;
871 key.
key().t = key.
key().t0 ;
872 key.
key().qn.resize(2);
875 QDPIO::cout<<
" Doing MESON_SRC_SRC"<<std::endl ;
876 for(
int q(0);
q< quarks.size() ;
q++){
878 for(
int q1(0);q1< quarks.size() ;q1++)
880 key.
key().qn[1] = q1 ;
882 val.
data().resize(quarks[
q]->getDilSize(
t0));
884 QDPIO::cout<<
" quarks: "<<
q<<
" "<<q1 <<std::endl ;
885 for (
int d(0) ;
d < quarks[
q]->getDilSize(
t0);
d++){
887 LatticeFermion quark_bar = src[
q][
t0][
d];
888 quark_bar = Gamma(Ns-1)*quark_bar ;
889 for (
int d1(0) ; d1 < quarks[q1]->getDilSize(
t0); d1++){
893 LatticeFermion quark = src[q1][
t0][d1];
900 quark_bar,quark, phases.
getSet()[key.
key().t]);
903 qdp_db.insert(key, val);
908 QDPIO::cout<<
" Doing MESON_SOL_SOL"<<std::endl ;
909 for(
int q(0);
q< quarks.size() ;
q++){
911 for(
int q1(
q+1);q1< quarks.size() ;q1++){
912 key.
key().qn[1] = q1 ;
913 QDPIO::cout<<
" quarks: "<<
q<<
" "<<q1<<std::endl ;
915 val.
data().resize(quarks[
q]->getDilSize(
t0));
919 for (
int d(0) ;
d < quarks[
q]->getDilSize(
t0);
d++){
920 LatticeFermion quark_bar = smearedSol[
q][
t0][
d] ;
921 quark_bar = Gamma(Ns-1)*quark_bar ;
922 for (
int d1(0) ; d1 < quarks[q1]->getDilSize(
t0); d1++){
925 LatticeFermion quark = smearedSol[q1][
t0][d1] ;
927 quark_bar,quark, phases.
getSet()[key.
key().t]);
935 qdp_db.insert(key, val);
942 QDPIO::cout<<
" Doing MESON_SRC_SOL"<<std::endl ;
943 for(
int q(0);
q< quarks.size() ;
q++){
945 for(
int q1(0);q1< quarks.size() ;q1++){
946 key.
key().qn[1] = q1 ;
947 QDPIO::cout<<
" quarks: "<<
q<<
" "<<q1<<std::endl ;
949 val.
data().resize(quarks[
q]->getDilSize(
t0));
951 for (
int tt = 0 ; tt < participating_timeslices.size() ; ++tt){
952 int t = participating_timeslices[tt] ;
954 for (
int d(0) ;
d < quarks[
q]->getDilSize(tt);
d++){
956 LatticeFermion quark_bar = src[
q][tt][
d] ;
957 for (
int d1(0) ; d1 < quarks[q1]->getDilSize(
t0); d1++){
960 LatticeFermion quark = smearedSol[q1][
t0][d1] ;
962 meson(val.
data().data(
d,d1),op.
g,phases[mom_num],quark_bar,quark,
968 qdp_db.insert(key, val);
980 std::map<std::string, BaryonOp>::iterator
it ;
981 for(
it=LocalBaryonOps.begin();
it!=LocalBaryonOps.end();
it++){
984 qdp_db.setMaxUserInfoLen(UserData_xml.str().size());
985 qdp_db.open(op.
file, O_RDWR | O_CREAT, 0664);
986 qdp_db.insertUserdata(UserData_xml.str());
990 key.
key().gamma = op.
g ;
992 for(
int mom_num = 0 ; mom_num < phases.
numMom() ; ++mom_num){
994 for (
int t0 = 0 ;
t0 < participating_timeslices.size() ; ++
t0){
995 key.
key().t0 = participating_timeslices[
t0] ;
996 key.
key().t = key.
key().t0 ;
997 key.
key().qn.resize(3);
1000 QDPIO::cout<<
" Doing BARYON_SRC "<<std::endl ;
1001 for(
int q0(0);q0< quarks.size() ;q0++){
1003 for(
int q1(0);q1< quarks.size() ;q1++)
1006 for(
int q2(0);q2< quarks.size() ;q2++)
1007 if((q1!=q2)&&(q0!=q2)){
1008 key.
key().qn[2] = q2 ;
1009 QDPIO::cout<<
" quarks: "<<q0<<
" "<<q1<<
" "<<q2<<std::endl ;
1012 val.
data().resize(quarks[q0]->getDilSize(
t0));
1013 for (
int d0(0) ; d0 < quarks[q0]->getDilSize(
t0); d0++){
1015 LatticeFermion quark0 = src[q0][
t0][d0];
1016 for (
int d1(0) ; d1 < quarks[q1]->getDilSize(
t0); d1++){
1018 LatticeFermion quark1 = src[q1][
t0][d1];
1019 for (
int d2(0) ; d2 < quarks[q2]->getDilSize(
t0); d2++){
1023 LatticeFermion quark2 = src[q2][
t0][d2];
1024 multi1d<DComplex> cc ;
1025 baryon(cc,op.
g,phases[mom_num],quark0,quark1,quark2,
1027 val.
data().data(d0,d1,d2) = cc ;
1034 qdp_db.insert(key, val);
1042 QDPIO::cout<<
" Doing BARYON_SOL "<<std::endl ;
1043 for(
int q0(0);q0< quarks.size() ;q0++){
1045 for(
int q1(q0+1);q1< quarks.size() ;q1++){
1046 key.
key().qn[1] = q1 ;
1047 for(
int q2(q1+1);q2< quarks.size() ;q2++){
1048 key.
key().qn[2] = q2 ;
1049 QDPIO::cout<<
" quarks: "<<q0<<
" "<<q1<<
" "<<q2 <<std::endl ;
1052 val.
data().resize(quarks[q0]->getDilSize(
t0));
1055 for (
int d0(0) ; d0 < quarks[q0]->getDilSize(
t0); d0++){
1056 LatticeFermion quark0 = smearedSol[q0][
t0][d0] ;
1057 for (
int d1(0) ; d1 < quarks[q1]->getDilSize(
t0); d1++){
1058 LatticeFermion quark1 = smearedSol[q1][
t0][d1] ;
1059 for (
int d2(0) ; d2 < quarks[q2]->getDilSize(
t0); d2++){
1062 LatticeFermion quark2 = smearedSol[q2][
t0][d2] ;
1064 multi1d<DComplex> cc ;
1065 baryon(cc,op.
g,phases[mom_num],quark0,quark1,quark2,
1067 val.
data().data(d0,d1,d2) = cc ;
1074 qdp_db.insert(key, val);
1089 QDPIO::cout <<
"Operators written: time= "
1090 << swatch.getTimeInSeconds()
1091 <<
" secs" << std::endl;
1097 QDPIO::cout <<
name <<
": total time = "
1098 << snoop.getTimeInSeconds()
1099 <<
" secs" << std::endl;
1101 QDPIO::cout <<
name <<
": ran successfully" << std::endl;
Inline measurement factory.
Baryon spin and projector matrices.
Factory for producing baryon operators.
Class for counted reference semantics.
multi3d< multi1d< DComplex > > data
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.
std::map< std::string, void(*)(MesonOp &, const GroupXML_t &)> mesons
std::map< std::string, void(*)(BaryonOp &, const GroupXML_t &)> baryons
Key & set(int i, int j, int l, int s)
Key & set(int i, int j, int l)
Key(int i, int j, int l, int s)
Serializable value harness.
Serializable key harness.
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.
Random Z(N) source construction using dilution.
All dilution scheme factories.
Factory for dilution schemes.
Parallel transport a lattice field.
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.
multi1d< GroupXML_t > readXMLArrayGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Class for counted reference semantics.
Inline measurement of stochastic hadron operator (mesons and baryons).
void savern(int iseed[4])
Named object function std::map.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
SpinMatrix Cg5()
C g_5 = C gamma_5 = Gamma(5)
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
const int N_quarks
Number of quarks to be used in this construction.
void ParseMeson(MesonOp &m, const GroupXML_t &grpXML)
void baryon(multi1d< DComplex > &d, const int &g, const LatticeComplex &phase, const LatticeFermion &eta1, const LatticeFermion &eta2, const LatticeFermion &eta3, const Subset &s)
void meson(DComplex &corr, const int &g, const LatticeComplex &phase, const LatticeFermion &eta, const LatticeFermion &chi, const Subset &s)
void read(XMLReader &xml, const std::string &path, Params::Param_t ¶m)
void ParseBaryon(BaryonOp &m, const GroupXML_t &grpXML)
void write(XMLWriter &xml, const std::string &path, const Params::Param_t ¶m)
bool operator<(const Key &a, const Key &b)
bool registerAll()
Register all the factories.
LatticePropagator di_quark
Asqtad Staggered-Dirac operator.
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
multi1d< LatticeFermion > chi(Ncb)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
multi1d< LatticeFermion > s(Ncb)
Print out basic info about this program.
All quark smearing constructors.
Factory for producing quark smearing objects.
Fourier transform phase factor support.
All make sink constructors.
Factory for producing quark prop sinks.
Factory for producing quark smearing objects.
Hold group xml and type id.
std::map< Key, DComplex > data
multi1d< GroupXML_t > quarks
multi1d< GroupXML_t > ops
multi1d< GroupXML_t > displace
struct Chroma::InlineStochHadronEnv::Params::Param_t param
struct Chroma::InlineStochHadronEnv::Params::NamedObject_t named_obj
void write(XMLWriter &xml_out, const std::string &path)
Volume source of Z(N) noise.