/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: Hadrons/Modules/MDistil/Baryon2pt.hpp Copyright (C) 2019 Author: Felix Erben Author: Michael Marshall This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #ifndef Hadrons_MDistil_Baryon2pt_hpp_ #define Hadrons_MDistil_Baryon2pt_hpp_ #include #include #include #include #include #include #include // These are members of Distillation #include BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Baryon2pt * ******************************************************************************/ BEGIN_MODULE_NAMESPACE(MDistil) class Baryon2ptPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(Baryon2ptPar, std::string, inputL, std::string, inputR, std::string, quarksL, std::string, quarksR, std::string, output ); }; template class TBaryon2pt: public Module { public: // constructor TBaryon2pt(const std::string name); // destructor virtual ~TBaryon2pt(void) {}; // dependency relation virtual std::vector getInput(void); virtual std::vector getOutput(void); // setup virtual void setup(void); // execution virtual void execute(void); }; class C2IO: Serializable{ public: using C2Set = Eigen::Tensor; GRID_SERIALIZABLE_CLASS_MEMBERS(C2IO, C2Set, C2 ); }; MODULE_REGISTER_TMP(Baryon2pt, TBaryon2pt, MDistil); /****************************************************************************** * TBaryon2pt implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// template TBaryon2pt::TBaryon2pt(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// template std::vector TBaryon2pt::getInput(void) { std::vector in; return in; } template std::vector TBaryon2pt::getOutput(void) { std::vector out = {getName()}; return out; } // setup /////////////////////////////////////////////////////////////////////// template void TBaryon2pt::setup(void) { } // execution /////////////////////////////////////////////////////////////////// template void TBaryon2pt::execute(void) { const std::string &inputL{par().inputL}; const std::string &inputR{par().inputR}; const std::string &quarksL{par().quarksL}; const std::string &quarksR{par().quarksR}; const std::string &output{par().output}; int Nmom=1; int Nt=32; int Nc=3; //Num colours std::vector> epsilon = {{0,1,2},{1,2,0},{2,0,1},{0,2,1},{2,1,0},{1,0,2}}; std::vector epsilon_sgn = {1,1,1,-1,-1,-1}; int Ngamma=3; int N_1=12; int N_2=12; int N_3=12; // using BaryonTensorSet = Eigen::Tensor; BFieldIO BFieldL; BFieldL.BField.resize(Nmom,Nt,N_1,N_2,N_3,4); std::string filenameL ="./" + inputL + ".h5"; std::cout << "Reading from file " << filenameL << std::endl; Hdf5Reader readerL(filenameL); read(readerL,"BaryonField",BFieldL.BField); BFieldIO BFieldR; BFieldR.BField.resize(Nmom,Nt,N_1,N_2,N_3,4); std::string filenameR ="./" + inputR + ".h5"; std::cout << "Reading from file " << filenameR << std::endl; Hdf5Reader readerR(filenameR); read(readerR,"BaryonField",BFieldR.BField); Eigen::Tensor corr(Nmom,Nt); int Npairs = 0; char left[] = "uud"; char right[] = "uud"; std::vector pairs(6); for (int ie=0, i=0 ; ie < 6 ; ie++){ if (left[0] == right[epsilon[ie][0]] && left[1] == right[epsilon[ie][1]] && left[2] == right[epsilon[ie][2]]){ pairs[i] = ie; i++; Npairs++; } } pairs.resize(Npairs); std::cout << Npairs << " pairs: " << pairs << std::endl; for (int imom=0 ; imom < Nmom ; imom++){ for (int t=0 ; t < Nt ; t++){ corr(imom,t) = 0.; } } int tsrc=0; for (int ipair=0 ; ipair < Npairs ; ipair++){ Eigen::array, 3> product_dims = { Eigen::IndexPair(0,epsilon[pairs[ipair]][0]),Eigen::IndexPair(1,epsilon[pairs[ipair]][1]) ,Eigen::IndexPair(2,epsilon[pairs[ipair]][2]) }; for (int imom=0 ; imom < Nmom ; imom++){ std::cout << imom << std::endl; Eigen::Tensor B5L = BFieldL.BField.chip(imom,0); Eigen::Tensor B5R = BFieldR.BField.chip(imom,0); for (int t=0 ; t < Nt ; t++){ Eigen::Tensor B4L = B5L.chip(t,0); Eigen::Tensor B4R = B5R.chip(tsrc,0); for (int is=0 ; is < 4 ; is++){ Eigen::Tensor B3L = B4L.chip(is,3); Eigen::Tensor B3R = B4R.chip(is,3); Eigen::Tensor C2 = B3L.contract(B3R,product_dims); corr(imom,t) += static_cast(epsilon_sgn[pairs[ipair]])*C2(0); } } } } for (int t=0 ; t < Nt ; t++){ std::cout << "C2(t=" << t << ") = " << corr(0,t) << std::endl; } /* C2IO C2_save; C2_save.C2 = corr; std::string filename ="./" + output + ".h5"; std::cout << "Writing to file " << filename << std::endl; Hdf5Writer writer(filename); write(writer,"C2",C2_save.C2); */ } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE #endif // Hadrons_MDistil_Baryon2pt_hpp_