mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-31 20:14:32 +00:00 
			
		
		
		
	Merge branch 'develop' of github.com:paboyle/Grid into develop
This commit is contained in:
		| @@ -42,6 +42,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk> | |||||||
| #include <Grid/GridQCDcore.h> | #include <Grid/GridQCDcore.h> | ||||||
| #include <Grid/qcd/action/Action.h> | #include <Grid/qcd/action/Action.h> | ||||||
| #include <Grid/qcd/utils/GaugeFix.h> | #include <Grid/qcd/utils/GaugeFix.h> | ||||||
|  | #include <Grid/qcd/utils/CovariantSmearing.h> | ||||||
| #include <Grid/qcd/smearing/Smearing.h> | #include <Grid/qcd/smearing/Smearing.h> | ||||||
| #include <Grid/parallelIO/MetaData.h> | #include <Grid/parallelIO/MetaData.h> | ||||||
| #include <Grid/qcd/hmc/HMC_aggregate.h> | #include <Grid/qcd/hmc/HMC_aggregate.h> | ||||||
|   | |||||||
							
								
								
									
										87
									
								
								Grid/qcd/utils/CovariantSmearing.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								Grid/qcd/utils/CovariantSmearing.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,87 @@ | |||||||
|  | /************************************************************************************* | ||||||
|  |  | ||||||
|  | Grid physics library, www.github.com/paboyle/Grid | ||||||
|  |  | ||||||
|  | Source file: ./lib/qcd/action/scalar/CovariantLaplacian.h | ||||||
|  |  | ||||||
|  | Copyright (C) 2016 | ||||||
|  |  | ||||||
|  | Author: Azusa Yamaguchi | ||||||
|  |  | ||||||
|  | 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 | ||||||
|  | *************************************************************************************/ | ||||||
|  | #pragma once | ||||||
|  |  | ||||||
|  | namespace Grid { | ||||||
|  | namespace QCD { | ||||||
|  |  | ||||||
|  | template <class Gimpl> class CovariantSmearing : public Gimpl  | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |   INHERIT_GIMPL_TYPES(Gimpl); | ||||||
|  |  | ||||||
|  |   typedef typename Gimpl::GaugeLinkField GaugeMat; | ||||||
|  |   typedef typename Gimpl::GaugeField GaugeLorentz; | ||||||
|  |  | ||||||
|  |   template<typename T> | ||||||
|  |   static void GaussianSmear(const std::vector<LatticeColourMatrix>& U,  | ||||||
|  | 			    T& chi,  | ||||||
|  | 			    const Real& width, int Iterations, int orthog) | ||||||
|  |   { | ||||||
|  |     GridBase *grid = chi._grid; | ||||||
|  |     T psi(grid); | ||||||
|  |  | ||||||
|  |     //////////////////////////////////////////////////////////////////////////////////// | ||||||
|  |     // Follow Chroma conventions for width to keep compatibility with previous data | ||||||
|  |     // Free field iterates  | ||||||
|  |     //   chi = (1 - w^2/4N p^2)^N chi | ||||||
|  |     // | ||||||
|  |     //       ~ (e^(-w^2/4N p^2)^N chi | ||||||
|  |     //       ~ (e^(-w^2/4 p^2) chi | ||||||
|  |     //       ~ (e^(-w'^2/2 p^2) chi          [ w' = w/sqrt(2) ] | ||||||
|  |     // | ||||||
|  |     // Which in coordinate space is proportional to | ||||||
|  |     // | ||||||
|  |     //   e^(-x^2/w^2) = e^(-x^2/2w'^2)  | ||||||
|  |     // | ||||||
|  |     // The 4 is a bit unconventional from Gaussian width perspective, but... it's Chroma convention. | ||||||
|  |     // 2nd derivative approx d^2/dx^2  =  x+mu + x-mu - 2x | ||||||
|  |     // | ||||||
|  |     // d^2/dx^2 = - p^2 | ||||||
|  |     // | ||||||
|  |     // chi = ( 1 + w^2/4N d^2/dx^2 )^N chi | ||||||
|  |     // | ||||||
|  |     //////////////////////////////////////////////////////////////////////////////////// | ||||||
|  |     Real coeff = (width*width) / Real(4*Iterations); | ||||||
|  |    | ||||||
|  |     int dims = Nd; | ||||||
|  |     if( orthog < Nd ) dims=Nd-1; | ||||||
|  |  | ||||||
|  |     for(int n = 0; n < Iterations; ++n) { | ||||||
|  |       psi = (-2.0*dims)*chi; | ||||||
|  |       for(int mu=0;mu<Nd;mu++) { | ||||||
|  | 	if ( mu != orthog ) {  | ||||||
|  | 	  psi = psi + Gimpl::CovShiftForward(U[mu],mu,chi);     | ||||||
|  | 	  psi = psi + Gimpl::CovShiftBackward(U[mu],mu,chi);     | ||||||
|  | 	} | ||||||
|  |       } | ||||||
|  |       chi = chi + coeff*psi; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  | }} | ||||||
							
								
								
									
										73
									
								
								tests/smearing/Test_smearing.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								tests/smearing/Test_smearing.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | |||||||
|  | /* | ||||||
|  |  * | ||||||
|  |  | ||||||
|  |     Grid physics library, www.github.com/paboyle/Grid | ||||||
|  |  | ||||||
|  |     Source file: ./tests/Test_wilson_cg_prec.cc | ||||||
|  |  | ||||||
|  |     Copyright (C) 2015 | ||||||
|  |  | ||||||
|  | Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||||
|  |  | ||||||
|  |     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 */ | ||||||
|  | #include <Grid/Grid.h> | ||||||
|  |  | ||||||
|  | using namespace std; | ||||||
|  | using namespace Grid; | ||||||
|  | using namespace Grid::QCD; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | int main (int argc, char ** argv) | ||||||
|  | { | ||||||
|  |   Grid_init(&argc,&argv); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   std::vector<int> latt_size   = GridDefaultLatt(); | ||||||
|  |   std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); | ||||||
|  |   std::vector<int> mpi_layout  = GridDefaultMpi(); | ||||||
|  |   GridCartesian               Grid(latt_size,simd_layout,mpi_layout); | ||||||
|  |  | ||||||
|  |   std::vector<int> seeds({1,2,3,4}); | ||||||
|  |   GridParallelRNG          pRNG(&Grid);  pRNG.SeedFixedIntegers(seeds); | ||||||
|  |  | ||||||
|  |   LatticeFermion src(&Grid); random(pRNG,src); | ||||||
|  |   RealD nrm = norm2(src); | ||||||
|  |   LatticeFermion result(&Grid); result=zero; | ||||||
|  |   LatticeGaugeField Umu(&Grid); | ||||||
|  |   //  SU3::HotConfiguration(pRNG,Umu); | ||||||
|  |   SU3::ColdConfiguration(Umu); | ||||||
|  |   std::vector<LatticeColourMatrix> U(4,&Grid); | ||||||
|  |  | ||||||
|  |   for(int mu=0;mu<Nd;mu++){ | ||||||
|  |     U[mu] = PeekIndex<LorentzIndex>(Umu,mu); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   std::vector<int> site({4,4,0,0}); | ||||||
|  |   src=zero; | ||||||
|  |   SpinColourVector scv; | ||||||
|  |   scv=zero; | ||||||
|  |   scv()(0)(0) = 1.0; | ||||||
|  |   pokeSite(scv,src,site); | ||||||
|  |  | ||||||
|  |   CovariantSmearing<PeriodicGimplR>::GaussianSmear(U, src, 2.0, 50, Tdir); | ||||||
|  |  | ||||||
|  |   std::cout << src <<std::endl; | ||||||
|  |    | ||||||
|  | } | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user