1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 01:05:38 +01:00
Grid/tests/Test_meson_field.cc
2021-07-05 14:41:52 +01:00

101 lines
3.1 KiB
C++

/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Source file: tests/core/Test_meson_field.cc
Copyright (C) 2015-2018
Author: Felix Erben <felix.erben@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
*************************************************************************************/
#include <Grid/Grid.h>
#include <Grid/qcd/utils/A2Autils.h>
using namespace Grid;
typedef typename DomainWallFermionR::ComplexField ComplexField;
typedef typename DomainWallFermionR::FermionField FermionField;
int main(int argc, char *argv[])
{
// initialization
Grid_init(&argc, &argv);
std::cout << GridLogMessage << "Grid initialized" << std::endl;
Coordinate latt_size = GridDefaultLatt();
Coordinate simd_layout = GridDefaultSimd(4, vComplex::Nsimd());
Coordinate mpi_layout = GridDefaultMpi();
GridCartesian grid(latt_size,simd_layout,mpi_layout);
// MesonField lhs and rhs vectors
int mfDim = 3;
std::vector<FermionField> phi(mfDim,&grid);
std::vector<FermionField> rho(mfDim,&grid);
std::vector<int> seeds({1,2,3,4});
GridParallelRNG pRNG(&grid);
pRNG.SeedFixedIntegers(seeds);
for (unsigned int i = 0; i < mfDim; ++i){
random(pRNG,phi[i]);
random(pRNG,rho[i]); //ideally only nonzero on t=0
}
// Gamma matrices used in the contraction
std::vector<Gamma::Algebra> Gmu = {
Gamma::Algebra::GammaX,
Gamma::Algebra::GammaY,
Gamma::Algebra::GammaZ,
Gamma::Algebra::GammaT
};
// momentum phases e^{ipx}
std::vector<std::vector<double>> momenta = {
{0.,0.,0.},
{1.,0.,0.},
{1.,1.,0.},
{1.,1.,1.},
{2.,0.,0.}
};
std::vector<ComplexField> phases(momenta.size(),&grid);
ComplexField coor(&grid);
Complex Ci(0.0,1.0);
for (unsigned int j = 0; j < momenta.size(); ++j)
{
phases[j] = Zero();
for(unsigned int mu = 0; mu < momenta[j].size(); mu++)
{
LatticeCoordinate(coor, mu);
phases[j] = phases[j] + momenta[j][mu]/GridDefaultLatt()[mu]*coor;
}
phases[j] = exp((Real)(2*M_PI)*Ci*phases[j]);
}
Eigen::Tensor<ComplexD,5, Eigen::RowMajor> mf(momenta.size(),Gmu.size(),GridDefaultLatt()[3],mfDim,mfDim);
//execute meson field routine
A2Autils<WilsonImplR>::MesonField(mf,&phi[0],&phi[0],Gmu,phases,3);
std::cout << mf << std::endl;
// epilogue
std::cout << GridLogMessage << "Grid is finalizing now" << std::endl;
Grid_finalize();
return EXIT_SUCCESS;
}