mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-31 03:54:33 +00:00 
			
		
		
		
	unsmeared sinks can now be computed - new test program available
This commit is contained in:
		| @@ -4,4 +4,4 @@ using namespace Grid; | |||||||
| using namespace Hadrons; | using namespace Hadrons; | ||||||
| using namespace MDistil; | using namespace MDistil; | ||||||
|  |  | ||||||
| template class Grid::Hadrons::MDistil::TPerambLight<GIMPL>; | template class Grid::Hadrons::MDistil::TPerambLight<FIMPL>; | ||||||
|   | |||||||
| @@ -56,11 +56,11 @@ public: | |||||||
|                                     SolverParameters, Solver); |                                     SolverParameters, Solver); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| class TPerambLight: public Module<PerambLightPar> | class TPerambLight: public Module<PerambLightPar> | ||||||
| { | { | ||||||
| public: | public: | ||||||
|     GAUGE_TYPE_ALIASES(GImpl,); |     FERM_TYPE_ALIASES(FImpl,); | ||||||
|     // constructor |     // constructor | ||||||
|     TPerambLight(const std::string name); |     TPerambLight(const std::string name); | ||||||
|     // destructor |     // destructor | ||||||
| @@ -81,27 +81,27 @@ protected: | |||||||
|     virtual void Cleanup(void); |     virtual void Cleanup(void); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| MODULE_REGISTER_TMP(PerambLight, TPerambLight<GIMPL>, MDistil); | MODULE_REGISTER_TMP(PerambLight, TPerambLight<FIMPL>, MDistil); | ||||||
|  |  | ||||||
| /****************************************************************************** | /****************************************************************************** | ||||||
|  *                 TPerambLight implementation                             * |  *                 TPerambLight implementation                             * | ||||||
|  ******************************************************************************/ |  ******************************************************************************/ | ||||||
| // constructor ///////////////////////////////////////////////////////////////// | // constructor ///////////////////////////////////////////////////////////////// | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| TPerambLight<GImpl>::TPerambLight(const std::string name) | TPerambLight<FImpl>::TPerambLight(const std::string name) | ||||||
| : grid3d{nullptr}, grid4d{nullptr}, Module<PerambLightPar>(name) | : grid3d{nullptr}, grid4d{nullptr}, Module<PerambLightPar>(name) | ||||||
| {} | {} | ||||||
|  |  | ||||||
| // destructor | // destructor | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| TPerambLight<GImpl>::~TPerambLight(void) | TPerambLight<FImpl>::~TPerambLight(void) | ||||||
| { | { | ||||||
|   Cleanup(); |   Cleanup(); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // dependencies/products /////////////////////////////////////////////////////// | // dependencies/products /////////////////////////////////////////////////////// | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| std::vector<std::string> TPerambLight<GImpl>::getInput(void) | std::vector<std::string> TPerambLight<FImpl>::getInput(void) | ||||||
| { | { | ||||||
|     std::vector<std::string> in; |     std::vector<std::string> in; | ||||||
|  |  | ||||||
| @@ -110,29 +110,35 @@ std::vector<std::string> TPerambLight<GImpl>::getInput(void) | |||||||
|     return in; |     return in; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| std::vector<std::string> TPerambLight<GImpl>::getOutput(void) | std::vector<std::string> TPerambLight<FImpl>::getOutput(void) | ||||||
| { | { | ||||||
|     std::vector<std::string> out = {getName() + "_perambulator_light",getName() + "_noise"}; |     std::vector<std::string> out = {getName() + "_perambulator_light",getName() + "_noise",getName() + "_unsmeared_sink"}; | ||||||
|      |      | ||||||
|     return out; |     return out; | ||||||
| } | } | ||||||
|  |  | ||||||
| // setup /////////////////////////////////////////////////////////////////////// | // setup /////////////////////////////////////////////////////////////////////// | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| void TPerambLight<GImpl>::setup(void) | void TPerambLight<FImpl>::setup(void) | ||||||
| { | { | ||||||
|     Cleanup(); |     Cleanup(); | ||||||
|  |  | ||||||
|     // auto &noise = envGet(std::vector<std::vector<std::vector<SpinVector>>>, par().noise); |     // auto &noise = envGet(std::vector<std::vector<std::vector<SpinVector>>>, par().noise); | ||||||
|     const int nvec{par().nvec}; |     const int nvec{par().nvec}; | ||||||
|     const DistilParameters & Distil{par().Distil}; |     const DistilParameters & Distil{par().Distil}; | ||||||
|  |     const int LI{Distil.LI}; | ||||||
|  |     const int nnoise{Distil.nnoise}; | ||||||
|  |     const int Nt_inv{Distil.Nt_inv}; // TODO: PROBABLY BETTER: if (full_tdil) Nt_inv=1; else Nt_inv = TI; | ||||||
|  |     const int Ns{Distil.Ns}; | ||||||
|  |  | ||||||
|     //envCreate(Perambulator<SpinVector, 6>, getName() + "_perambulator_light", 1, |     //envCreate(Perambulator<SpinVector, 6>, getName() + "_perambulator_light", 1, | ||||||
|     env().template createObject<Perambulator<SpinVector, 6> >(getName() + "_perambulator_light", Environment::Storage::object, 1, |     env().template createObject<Perambulator<SpinVector, 6> >(getName() + "_perambulator_light", Environment::Storage::object, 1, | ||||||
|               Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI); |               Distil.Nt,nvec,Distil.LI,Distil.nnoise,Distil.Nt_inv,Distil.SI); | ||||||
|     envCreate(std::vector<Complex>, getName() + "_noise", 1, |     envCreate(std::vector<Complex>, getName() + "_noise", 1, | ||||||
|               nvec*Distil.Ns*Distil.Nt*Distil.nnoise); |               nvec*Distil.Ns*Distil.Nt*Distil.nnoise); | ||||||
|  |     envCreate(std::vector<FermionField>, getName() + "_unsmeared_sink", 1,  | ||||||
|  |             nnoise*LI*Ns*Nt_inv, envGetGrid(FermionField)); | ||||||
|  |  | ||||||
|     grid4d = env().getGrid(); |     grid4d = env().getGrid(); | ||||||
|     grid3d = MakeLowerDimGrid(grid4d);//new GridCartesian(latt_size,simd_layout_3,mpi_layout,*grid4d); |     grid3d = MakeLowerDimGrid(grid4d);//new GridCartesian(latt_size,simd_layout_3,mpi_layout,*grid4d); | ||||||
| @@ -152,8 +158,8 @@ void TPerambLight<GImpl>::setup(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| // clean up any temporaries created by setup (that aren't stored in the environment) | // clean up any temporaries created by setup (that aren't stored in the environment) | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| void TPerambLight<GImpl>::Cleanup(void) | void TPerambLight<FImpl>::Cleanup(void) | ||||||
| { | { | ||||||
|   if( grid3d != nullptr ) { |   if( grid3d != nullptr ) { | ||||||
|     delete grid3d; |     delete grid3d; | ||||||
| @@ -163,8 +169,8 @@ void TPerambLight<GImpl>::Cleanup(void) | |||||||
| } | } | ||||||
|  |  | ||||||
| // execution /////////////////////////////////////////////////////////////////// | // execution /////////////////////////////////////////////////////////////////// | ||||||
| template <typename GImpl> | template <typename FImpl> | ||||||
| void TPerambLight<GImpl>::execute(void) | void TPerambLight<FImpl>::execute(void) | ||||||
| { | { | ||||||
|     const int nvec{par().nvec}; |     const int nvec{par().nvec}; | ||||||
|     const DistilParameters & Distil{par().Distil}; |     const DistilParameters & Distil{par().Distil}; | ||||||
| @@ -187,6 +193,7 @@ void TPerambLight<GImpl>::execute(void) | |||||||
|                                 *env().template getObject<Perambulator<SpinVector,6> >( |                                 *env().template getObject<Perambulator<SpinVector,6> >( | ||||||
|                                     getName() + "_perambulator_light"); |                                     getName() + "_perambulator_light"); | ||||||
|     auto        &epack   = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack); |     auto        &epack   = envGet(Grid::Hadrons::EigenPack<LatticeColourVector>, par().eigenPack); | ||||||
|  |     auto        &unsmeared_sink       = envGet(std::vector<FermionField>, getName() + "_unsmeared_sink"); | ||||||
|  |  | ||||||
|     envGetTmp(GaugeField, Umu); |     envGetTmp(GaugeField, Umu); | ||||||
|   FieldMetaData header; |   FieldMetaData header; | ||||||
| @@ -315,8 +322,8 @@ void TPerambLight<GImpl>::execute(void) | |||||||
|             SchurSolver(Dop,src5,sol5); |             SchurSolver(Dop,src5,sol5); | ||||||
|             Dop.ExportPhysicalFermionSolution(sol5,result); //These are the meson sinks |             Dop.ExportPhysicalFermionSolution(sol5,result); //These are the meson sinks | ||||||
|             // TODO: Can we inherit something from MContraction to compute the fourier-transformed sinks??? |             // TODO: Can we inherit something from MContraction to compute the fourier-transformed sinks??? | ||||||
|             //if (compute_current_sink) |             if ((1)) // comment out if unsmeared sink is too large??? | ||||||
|             //  current_sink[inoise+nnoise*(dk+LI*(dt+Nt_inv*ds))] = result; |               unsmeared_sink[inoise+nnoise*(dk+LI*(dt+Nt_inv*ds))] = result; | ||||||
|             std::cout <<  "Contraction of perambulator from noise " << inoise << " and dilution component (d_k,d_t,d_alpha) : (" << dk << ","<< dt << "," << ds << ")" << std::endl; |             std::cout <<  "Contraction of perambulator from noise " << inoise << " and dilution component (d_k,d_t,d_alpha) : (" << dk << ","<< dt << "," << ds << ")" << std::endl; | ||||||
|             for (int is = 0; is < Ns; is++) { |             for (int is = 0; is < Ns; is++) { | ||||||
|               result_nospin = peekSpin(result,is); |               result_nospin = peekSpin(result,is); | ||||||
| @@ -341,7 +348,7 @@ void TPerambLight<GImpl>::execute(void) | |||||||
|     perambulator.SliceShare( grid3d, grid4d ); |     perambulator.SliceShare( grid3d, grid4d ); | ||||||
|  |  | ||||||
|     // THIS IS WHERE WE WANT TO SAVE THE PERAMBULATORS TO DISK |     // THIS IS WHERE WE WANT TO SAVE THE PERAMBULATORS TO DISK | ||||||
|     perambulator.WriteTemporary(std::string("perambulators/file")); |     perambulator.WriteTemporary(std::string("perambulators/file")); // TODO: Specify the file name in the xml | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -169,22 +169,21 @@ void test_DistilVectorsS(Application &application) | |||||||
|   application.createModule<MDistil::DistilVectors>("DistilVecsS",DistilVecPar); |   application.createModule<MDistil::DistilVectors>("DistilVecsS",DistilVecPar); | ||||||
| } | } | ||||||
| ///////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////// | ||||||
| // MesonFields | // MesonSink | ||||||
| ///////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////// | ||||||
|  |  | ||||||
| void test_MesonField(Application &application) | void test_MesonSink(Application &application) | ||||||
| { | { | ||||||
|   // DistilVectors parameters |   // DistilVectors parameters | ||||||
|   MContraction::A2AMesonField::Par A2AMesonFieldPar; |   MContraction::A2AMesonField::Par A2AMesonFieldPar; | ||||||
|   A2AMesonFieldPar.left="DistilVecs_phi"; |   A2AMesonFieldPar.left="Peramb_unsmeared_sink"; | ||||||
|   //A2AMesonFieldPar.right="DistilVecs_rho"; |   A2AMesonFieldPar.right="Peramb_unsmeared_sink"; | ||||||
|   A2AMesonFieldPar.right="DistilVecs_phi"; |  | ||||||
|   A2AMesonFieldPar.output="DistilFields"; |   A2AMesonFieldPar.output="DistilFields"; | ||||||
|   A2AMesonFieldPar.gammas="all"; |   A2AMesonFieldPar.gammas="all"; | ||||||
|   A2AMesonFieldPar.mom={"0 0 0"}; |   A2AMesonFieldPar.mom={"0 0 0"}; | ||||||
|   A2AMesonFieldPar.cacheBlock=2; |   A2AMesonFieldPar.cacheBlock=2; | ||||||
|   A2AMesonFieldPar.block=4; |   A2AMesonFieldPar.block=4; | ||||||
|   application.createModule<MContraction::A2AMesonField>("DistilMesonField",A2AMesonFieldPar); |   application.createModule<MContraction::A2AMesonField>("DistilMesonSink",A2AMesonFieldPar); | ||||||
| } | } | ||||||
| ///////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////// | ||||||
| // MesonFields | // MesonFields | ||||||
| @@ -197,7 +196,25 @@ void test_MesonFieldSL(Application &application) | |||||||
|   A2AMesonFieldPar.left="DistilVecsS_phi"; |   A2AMesonFieldPar.left="DistilVecsS_phi"; | ||||||
|   //A2AMesonFieldPar.right="DistilVecs_rho"; |   //A2AMesonFieldPar.right="DistilVecs_rho"; | ||||||
|   A2AMesonFieldPar.right="DistilVecs_phi"; |   A2AMesonFieldPar.right="DistilVecs_phi"; | ||||||
|   A2AMesonFieldPar.output="DistilFields"; |   A2AMesonFieldPar.output="DistilFieldsS"; | ||||||
|  |   A2AMesonFieldPar.gammas="all"; | ||||||
|  |   A2AMesonFieldPar.mom={"0 0 0"}; | ||||||
|  |   A2AMesonFieldPar.cacheBlock=2; | ||||||
|  |   A2AMesonFieldPar.block=4; | ||||||
|  |   application.createModule<MContraction::A2AMesonField>("DistilMesonFieldS",A2AMesonFieldPar); | ||||||
|  | } | ||||||
|  | ///////////////////////////////////////////////////////////// | ||||||
|  | // MesonFields | ||||||
|  | ///////////////////////////////////////////////////////////// | ||||||
|  |  | ||||||
|  | void test_MesonField(Application &application) | ||||||
|  | { | ||||||
|  |   // DistilVectors parameters | ||||||
|  |   MContraction::A2AMesonField::Par A2AMesonFieldPar; | ||||||
|  |   A2AMesonFieldPar.left="DistilVecs_phi"; | ||||||
|  |   //A2AMesonFieldPar.right="DistilVecs_rho"; | ||||||
|  |   A2AMesonFieldPar.right="DistilVecs_phi"; | ||||||
|  |   A2AMesonFieldPar.output="MesonSinks"; | ||||||
|   A2AMesonFieldPar.gammas="all"; |   A2AMesonFieldPar.gammas="all"; | ||||||
|   A2AMesonFieldPar.mom={"0 0 0"}; |   A2AMesonFieldPar.mom={"0 0 0"}; | ||||||
|   A2AMesonFieldPar.cacheBlock=2; |   A2AMesonFieldPar.cacheBlock=2; | ||||||
| @@ -360,6 +377,12 @@ int main(int argc, char *argv[]) | |||||||
|       test_DistilVectorsS( application ); |       test_DistilVectorsS( application ); | ||||||
|       test_MesonFieldSL( application ); |       test_MesonFieldSL( application ); | ||||||
|       break; |       break; | ||||||
|  |     case 6: // 3 | ||||||
|  |       test_Global( application ); | ||||||
|  |       test_LapEvec( application ); | ||||||
|  |       test_Perambulators( application ); | ||||||
|  |       test_MesonSink( application ); | ||||||
|  |       break; | ||||||
|   } |   } | ||||||
|   LOG(Message) << "====== XML creation for test " << iTestNum << " complete ======" << std::endl; |   LOG(Message) << "====== XML creation for test " << iTestNum << " complete ======" << std::endl; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user