diff --git a/Grid/algorithms/iterative/ConjugateGradient.h b/Grid/algorithms/iterative/ConjugateGradient.h index ff4ba8ac..8a6a4bae 100644 --- a/Grid/algorithms/iterative/ConjugateGradient.h +++ b/Grid/algorithms/iterative/ConjugateGradient.h @@ -150,13 +150,13 @@ class ConjugateGradient : public OperatorFunction { std::cout << GridLogMessage << "\tTrue residual " << true_residual< using iSinglet = iScalar > >; - template using iSpinMatrix = iScalar, Ns> >; - template using iColourMatrix = iScalar > > ; - template using iSpinColourMatrix = iScalar, Ns> >; - template using iLorentzColourMatrix = iVector >, Nd > ; - template using iDoubleStoredColourMatrix = iVector >, Nds > ; - template using iSpinVector = iScalar, Ns> >; - template using iColourVector = iScalar > >; - template using iSpinColourVector = iScalar, Ns> >; - template using iHalfSpinVector = iScalar, Nhs> >; - template using iHalfSpinColourVector = iScalar, Nhs> >; + + template using iSinglet = iScalar > >; + template using iSpinMatrix = iScalar, Ns> >; + template using iColourMatrix = iScalar > > ; + template using iSpinColourMatrix = iScalar, Ns> >; + template using iLorentzColourMatrix = iVector >, Nd > ; + template using iDoubleStoredColourMatrix = iVector >, Nds > ; + template using iSpinVector = iScalar, Ns> >; + template using iColourVector = iScalar > >; + template using iSpinColourVector = iScalar, Ns> >; + template using iHalfSpinVector = iScalar, Nhs> >; + template using iHalfSpinColourVector = iScalar, Nhs> >; + template using iSpinColourSpinColourMatrix = iScalar, Ns>, Nc>, Ns> >; + template using iGparitySpinColourVector = iVector, Ns>, Ngp >; template using iGparityHalfSpinColourVector = iVector, Nhs>, Ngp >; @@ -127,10 +130,28 @@ namespace QCD { typedef iSpinColourMatrix SpinColourMatrix; typedef iSpinColourMatrix SpinColourMatrixF; typedef iSpinColourMatrix SpinColourMatrixD; - + typedef iSpinColourMatrix vSpinColourMatrix; typedef iSpinColourMatrix vSpinColourMatrixF; typedef iSpinColourMatrix vSpinColourMatrixD; + + // SpinColourSpinColour matrix + typedef iSpinColourSpinColourMatrix SpinColourSpinColourMatrix; + typedef iSpinColourSpinColourMatrix SpinColourSpinColourMatrixF; + typedef iSpinColourSpinColourMatrix SpinColourSpinColourMatrixD; + + typedef iSpinColourSpinColourMatrix vSpinColourSpinColourMatrix; + typedef iSpinColourSpinColourMatrix vSpinColourSpinColourMatrixF; + typedef iSpinColourSpinColourMatrix vSpinColourSpinColourMatrixD; + + // SpinColourSpinColour matrix + typedef iSpinColourSpinColourMatrix SpinColourSpinColourMatrix; + typedef iSpinColourSpinColourMatrix SpinColourSpinColourMatrixF; + typedef iSpinColourSpinColourMatrix SpinColourSpinColourMatrixD; + + typedef iSpinColourSpinColourMatrix vSpinColourSpinColourMatrix; + typedef iSpinColourSpinColourMatrix vSpinColourSpinColourMatrixF; + typedef iSpinColourSpinColourMatrix vSpinColourSpinColourMatrixD; // LorentzColour typedef iLorentzColourMatrix LorentzColourMatrix; @@ -229,6 +250,9 @@ namespace QCD { typedef Lattice LatticeSpinColourMatrixF; typedef Lattice LatticeSpinColourMatrixD; + typedef Lattice LatticeSpinColourSpinColourMatrix; + typedef Lattice LatticeSpinColourSpinColourMatrixF; + typedef Lattice LatticeSpinColourSpinColourMatrixD; typedef Lattice LatticeLorentzColourMatrix; typedef Lattice LatticeLorentzColourMatrixF; diff --git a/Grid/qcd/action/fermion/CayleyFermion5D.cc b/Grid/qcd/action/fermion/CayleyFermion5D.cc index d4ed5a7c..a95ea4a0 100644 --- a/Grid/qcd/action/fermion/CayleyFermion5D.cc +++ b/Grid/qcd/action/fermion/CayleyFermion5D.cc @@ -68,6 +68,26 @@ void CayleyFermion5D::ExportPhysicalFermionSolution(const FermionField &so ExtractSlice(exported4d, tmp, 0, 0); } template +void CayleyFermion5D::P(const FermionField &psi, FermionField &chi) +{ + int Ls= this->Ls; + chi=zero; + for(int s=0;s +void CayleyFermion5D::Pdag(const FermionField &psi, FermionField &chi) +{ + int Ls= this->Ls; + chi=zero; + for(int s=0;s void CayleyFermion5D::ExportPhysicalFermionSource(const FermionField &solution5d,FermionField &exported4d) { int Ls = this->Ls; @@ -465,9 +485,13 @@ void CayleyFermion5D::SetCoefficientsInternal(RealD zolo_hi,std::vector _gamma; + RealD _zolo_hi; + RealD _b; + RealD _c; + // Cayley form Moebius (tanh and zolotarev) std::vector omega; std::vector bs; // S dependent coeffs diff --git a/Grid/qcd/action/fermion/Fermion.h b/Grid/qcd/action/fermion/Fermion.h index 2a008cb7..77a4681f 100644 --- a/Grid/qcd/action/fermion/Fermion.h +++ b/Grid/qcd/action/fermion/Fermion.h @@ -80,12 +80,24 @@ Author: Peter Boyle /////////////////////////////////////////////////////////////////////////////// #include +/////////////////////////////////////////////////////////////////////////////// +// Fourier accelerated Pauli Villars inverse support +/////////////////////////////////////////////////////////////////////////////// +#include + +//////////////////////////////////////////////////////////////////////////////// +// Move this group to a DWF specific tools/algorithms subdir? +//////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include + //////////////////////////////////////////////////////////////////////////////////////////////////// // More maintainable to maintain the following typedef list centrally, as more "impl" targets // are added, (e.g. extension for gparity, half precision project in comms etc..) //////////////////////////////////////////////////////////////////////////////////////////////////// - // Cayley 5d namespace Grid { namespace QCD { diff --git a/Grid/qcd/action/fermion/FermionOperatorImpl.h b/Grid/qcd/action/fermion/FermionOperatorImpl.h index e6f6e136..b0ffa90e 100644 --- a/Grid/qcd/action/fermion/FermionOperatorImpl.h +++ b/Grid/qcd/action/fermion/FermionOperatorImpl.h @@ -141,6 +141,7 @@ namespace QCD { //////////////////////////////////////////////////////////////////////// #define INHERIT_FIMPL_TYPES(Impl)\ + typedef Impl Impl_t; \ typedef typename Impl::FermionField FermionField; \ typedef typename Impl::PropagatorField PropagatorField; \ typedef typename Impl::DoubledGaugeField DoubledGaugeField; \ diff --git a/Grid/qcd/action/fermion/FourierAcceleratedPV.h b/Grid/qcd/action/fermion/FourierAcceleratedPV.h new file mode 100644 index 00000000..d6196eee --- /dev/null +++ b/Grid/qcd/action/fermion/FourierAcceleratedPV.h @@ -0,0 +1,237 @@ + + /************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./lib/qcd/action/fermion/FourierAcceleratedPV.h + + Copyright (C) 2015 + +Author: Christoph Lehner (lifted with permission by Peter Boyle, brought back to Grid) +Author: Peter Boyle + + 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 */ +#pragma once +namespace Grid { +namespace QCD { + + template + void get_real_const_bc(M& m, RealD& _b, RealD& _c) { + ComplexD b,c; + b=m.bs[0]; + c=m.cs[0]; + std::cout << GridLogMessage << "b=" << b << ", c=" << c << std::endl; + for (size_t i=1;i +class FourierAcceleratedPV { + public: + + ConjugateGradient &cg; + M& dwfPV; + G& Umu; + GridCartesian* grid5D; + GridRedBlackCartesian* gridRB5D; + int group_in_s; + + FourierAcceleratedPV(M& _dwfPV, G& _Umu, ConjugateGradient &_cg, int _group_in_s = 2) + : dwfPV(_dwfPV), Umu(_Umu), cg(_cg), group_in_s(_group_in_s) + { + assert( dwfPV.FermionGrid()->_fdimensions[0] % (2*group_in_s) == 0); + grid5D = QCD::SpaceTimeGrid::makeFiveDimGrid(2*group_in_s, (GridCartesian*)Umu._grid); + gridRB5D = QCD::SpaceTimeGrid::makeFiveDimRedBlackGrid(2*group_in_s, (GridCartesian*)Umu._grid); + } + + void rotatePV(const Vi& _src, Vi& dst, bool forward) const { + + GridStopWatch gsw1, gsw2; + + typedef typename Vi::scalar_type Coeff_t; + int Ls = dst._grid->_fdimensions[0]; + + Vi _tmp(dst._grid); + double phase = M_PI / (double)Ls; + Coeff_t bzero(0.0,0.0); + + FFT theFFT((GridCartesian*)dst._grid); + + if (!forward) { + gsw1.Start(); + for (int s=0;s_fdimensions[0]; + + GridStopWatch gswT; + gswT.Start(); + + RealD b,c; + get_real_const_bc(dwfPV,b,c); + RealD M5 = dwfPV.M5; + + // U(true) Rightinv TMinv U(false) = Minv + + Vi _src_diag(_dst._grid); + Vi _src_diag_slice(dwfPV.GaugeGrid()); + Vi _dst_diag_slice(dwfPV.GaugeGrid()); + Vi _src_diag_slices(grid5D); + Vi _dst_diag_slices(grid5D); + Vi _dst_diag(_dst._grid); + + rotatePV(_src,_src_diag,false); + + // now do TM solves + Gamma G5(Gamma::Algebra::Gamma5); + + GridStopWatch gswA, gswB; + + gswA.Start(); + + typedef typename M::Impl_t Impl; + //WilsonTMFermion tm(x.Umu,*x.UGridF,*x.UrbGridF,0.0,0.0,solver_outer.parent.par.wparams_f); + std::vector vmass(grid5D->_fdimensions[0],0.0); + std::vector vmu(grid5D->_fdimensions[0],0.0); + + WilsonTMFermion5D tm(Umu,*grid5D,*gridRB5D, + *(GridCartesian*)dwfPV.GaugeGrid(), + *(GridRedBlackCartesian*)dwfPV.GaugeRedBlackGrid(), + vmass,vmu); + + //SchurRedBlackDiagTwoSolve sol(cg); + SchurRedBlackDiagMooeeSolve sol(cg); // same performance as DiagTwo + gswA.Stop(); + + gswB.Start(); + + for (int sgroup=0;sgroup + + 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 */ +#pragma once + +namespace Grid { +namespace QCD { + +template X=0> +inline void convert(const Fieldi &from,Fieldo &to) +{ + precisionChange(to,from); +} +template X=0> +inline void convert(const Fieldi &from,Fieldo &to) +{ + to=from; +} + +template +class MADWF +{ + private: + typedef typename Matrixo::FermionField FermionFieldo; + typedef typename Matrixi::FermionField FermionFieldi; + + PVinverter & PauliVillarsSolvero;// For the outer field + SchurSolver & SchurSolveri; // For the inner approx field + Guesser & Guesseri; // To deflate the inner approx solves + + Matrixo & Mato; // Action object for outer + Matrixi & Mati; // Action object for inner + + RealD target_resid; + int maxiter; + public: + + MADWF(Matrixo &_Mato, + Matrixi &_Mati, + PVinverter &_PauliVillarsSolvero, + SchurSolver &_SchurSolveri, + Guesser & _Guesseri, + RealD resid, + int _maxiter) : + + Mato(_Mato),Mati(_Mati), + SchurSolveri(_SchurSolveri), + PauliVillarsSolvero(_PauliVillarsSolvero),Guesseri(_Guesseri) + { + target_resid=resid; + maxiter =_maxiter; + }; + + void operator() (const FermionFieldo &src4,FermionFieldo &sol5) + { + std::cout << GridLogMessage<< " ************************************************" << std::endl; + std::cout << GridLogMessage<< " MADWF-like algorithm " << std::endl; + std::cout << GridLogMessage<< " ************************************************" << std::endl; + + FermionFieldi c0i(Mati.GaugeGrid()); // 4d + FermionFieldi y0i(Mati.GaugeGrid()); // 4d + FermionFieldo c0 (Mato.GaugeGrid()); // 4d + FermionFieldo y0 (Mato.GaugeGrid()); // 4d + + FermionFieldo A(Mato.FermionGrid()); // Temporary outer + FermionFieldo B(Mato.FermionGrid()); // Temporary outer + FermionFieldo b(Mato.FermionGrid()); // 5d source + + FermionFieldo c(Mato.FermionGrid()); // PVinv source; reused so store + FermionFieldo defect(Mato.FermionGrid()); // 5d source + + FermionFieldi ci(Mati.FermionGrid()); + FermionFieldi yi(Mati.FermionGrid()); + FermionFieldi xi(Mati.FermionGrid()); + FermionFieldi srci(Mati.FermionGrid()); + FermionFieldi Ai(Mati.FermionGrid()); + + RealD m=Mati.Mass(); + + /////////////////////////////////////// + //Import source, include Dminus factors + /////////////////////////////////////// + Mato.ImportPhysicalFermionSource(src4,b); + std::cout << GridLogMessage << " src4 " < + + 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 */ +#pragma once + +namespace Grid { +namespace QCD { + +template +class PauliVillarsSolverUnprec +{ + public: + ConjugateGradient & CG; + PauliVillarsSolverUnprec( ConjugateGradient &_CG) : CG(_CG){}; + + template + void operator() (Matrix &_Matrix,const Field &src,Field &sol) + { + RealD m = _Matrix.Mass(); + Field A (_Matrix.FermionGrid()); + + MdagMLinearOperator HermOp(_Matrix); + + _Matrix.SetMass(1.0); + _Matrix.Mdag(src,A); + CG(HermOp,A,sol); + _Matrix.SetMass(m); + }; +}; + +template +class PauliVillarsSolverRBprec +{ + public: + SchurSolverType & SchurSolver; + PauliVillarsSolverRBprec( SchurSolverType &_SchurSolver) : SchurSolver(_SchurSolver){}; + + template + void operator() (Matrix &_Matrix,const Field &src,Field &sol) + { + RealD m = _Matrix.Mass(); + Field A (_Matrix.FermionGrid()); + + _Matrix.SetMass(1.0); + SchurSolver(_Matrix,src,sol); + _Matrix.SetMass(m); + }; +}; + +template +class PauliVillarsSolverFourierAccel +{ + public: + GaugeField & Umu; + ConjugateGradient & CG; + + PauliVillarsSolverFourierAccel(GaugeField &_Umu,ConjugateGradient &_CG) : Umu(_Umu), CG(_CG) + { + }; + + template + void operator() (Matrix &_Matrix,const Field &src,Field &sol) + { + FourierAcceleratedPV faPV(_Matrix,Umu,CG) ; + faPV.pvInv(src,sol); + }; +}; + + +} +} diff --git a/Grid/qcd/action/fermion/Reconstruct5Dprop.h b/Grid/qcd/action/fermion/Reconstruct5Dprop.h new file mode 100644 index 00000000..6862c5ee --- /dev/null +++ b/Grid/qcd/action/fermion/Reconstruct5Dprop.h @@ -0,0 +1,135 @@ + /************************************************************************************* + + Grid physics library, www.github.com/paboyle/Grid + + Source file: ./lib/algorithms/iterative/SchurRedBlack.h + + Copyright (C) 2015 + +Author: Peter Boyle + + 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 */ +#pragma once + +namespace Grid { +namespace QCD { + +template class Reconstruct5DfromPhysical { + private: + PVinverter & PauliVillarsSolver; + public: + + ///////////////////////////////////////////////////// + // First cut works, 10 Oct 2018. + // + // Must form a plan to get this into production for Zmobius acceleration + // of the Mobius exact AMA corrections. + // + // TODO : understand absence of contact term in eqns in Hantao's thesis + // sol4 is contact term subtracted, but thesis & Brower's paper suggests not. + // + // Step 1: Localise PV inverse in a routine. [DONE] + // Step 2: Schur based PV inverse [DONE] + // Step 3: Fourier accelerated PV inverse [DONE] + // + ///////////////////////////////////////////////////// + + Reconstruct5DfromPhysical(PVinverter &_PauliVillarsSolver) + : PauliVillarsSolver(_PauliVillarsSolver) + { + }; + + + template + void PV(Matrix &_Matrix,const Field &src,Field &sol) + { + RealD m = _Matrix.Mass(); + _Matrix.SetMass(1.0); + _Matrix.M(src,sol); + _Matrix.SetMass(m); + } + template + void PVdag(Matrix &_Matrix,const Field &src,Field &sol) + { + RealD m = _Matrix.Mass(); + _Matrix.SetMass(1.0); + _Matrix.Mdag(src,sol); + _Matrix.SetMass(m); + } + template + void operator() (Matrix & _Matrix,const Field &sol4,const Field &src4, Field &sol5){ + + int Ls = _Matrix.Ls; + + Field psi4(_Matrix.GaugeGrid()); + Field psi(_Matrix.FermionGrid()); + Field A (_Matrix.FermionGrid()); + Field B (_Matrix.FermionGrid()); + Field c (_Matrix.FermionGrid()); + + typedef typename Matrix::Coeff_t Coeff_t; + + std::cout << GridLogMessage<< " ************************************************" << std::endl; + std::cout << GridLogMessage<< " Reconstruct5Dprop: c.f. MADWF algorithm " << std::endl; + std::cout << GridLogMessage<< " ************************************************" << std::endl; + + /////////////////////////////////////// + //Import source, include Dminus factors + /////////////////////////////////////// + _Matrix.ImportPhysicalFermionSource(src4,B); + + /////////////////////////////////////// + // Set up c from src4 + /////////////////////////////////////// + PauliVillarsSolver(_Matrix,B,A); + _Matrix.Pdag(A,c); + + ////////////////////////////////////// + // Build Pdag PV^-1 Dm P [-sol4,c2,c3... cL] + ////////////////////////////////////// + psi4 = - sol4; + InsertSlice(psi4, psi, 0 , 0); + for (int s=1;s ; NB Christoph did similar in GPT + + 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 */ +#pragma once + +#include +#include + + +namespace Grid { + + namespace QCD { + + template + class WilsonTMFermion5D : public WilsonFermion5D + { + public: + INHERIT_IMPL_TYPES(Impl); + public: + + virtual void Instantiatable(void) {}; + + // Constructors + WilsonTMFermion5D(GaugeField &_Umu, + GridCartesian &Fgrid, + GridRedBlackCartesian &Frbgrid, + GridCartesian &Ugrid, + GridRedBlackCartesian &Urbgrid, + const std::vector _mass, + const std::vector _mu, + const ImplParams &p= ImplParams() + ) : + WilsonFermion5D(_Umu, + Fgrid, + Frbgrid, + Ugrid, + Urbgrid, + 4.0,p) + + { + update(_mass,_mu); + } + + virtual void Meooe(const FermionField &in, FermionField &out) { + if (in.checkerboard == Odd) { + this->DhopEO(in, out, DaggerNo); + } else { + this->DhopOE(in, out, DaggerNo); + } + } + + virtual void MeooeDag(const FermionField &in, FermionField &out) { + if (in.checkerboard == Odd) { + this->DhopEO(in, out, DaggerYes); + } else { + this->DhopOE(in, out, DaggerYes); + } + } + + // allow override for twisted mass and clover + virtual void Mooee(const FermionField &in, FermionField &out) { + out.checkerboard = in.checkerboard; + //axpibg5x(out,in,a,b); // out = a*in + b*i*G5*in + for (int s=0;s<(int)this->mass.size();s++) { + ComplexD a = 4.0+this->mass[s]; + ComplexD b(0.0,this->mu[s]); + axpbg5y_ssp(out,a,in,b,in,s,s); + } + } + + virtual void MooeeDag(const FermionField &in, FermionField &out) { + out.checkerboard = in.checkerboard; + for (int s=0;s<(int)this->mass.size();s++) { + ComplexD a = 4.0+this->mass[s]; + ComplexD b(0.0,-this->mu[s]); + axpbg5y_ssp(out,a,in,b,in,s,s); + } + } + virtual void MooeeInv(const FermionField &in, FermionField &out) { + for (int s=0;s<(int)this->mass.size();s++) { + RealD m = this->mass[s]; + RealD tm = this->mu[s]; + RealD mtil = 4.0+this->mass[s]; + RealD sq = mtil*mtil+tm*tm; + ComplexD a = mtil/sq; + ComplexD b(0.0, -tm /sq); + axpbg5y_ssp(out,a,in,b,in,s,s); + } + } + virtual void MooeeInvDag(const FermionField &in, FermionField &out) { + for (int s=0;s<(int)this->mass.size();s++) { + RealD m = this->mass[s]; + RealD tm = this->mu[s]; + RealD mtil = 4.0+this->mass[s]; + RealD sq = mtil*mtil+tm*tm; + ComplexD a = mtil/sq; + ComplexD b(0.0,tm /sq); + axpbg5y_ssp(out,a,in,b,in,s,s); + } + } + + virtual RealD M(const FermionField &in, FermionField &out) { + out.checkerboard = in.checkerboard; + this->Dhop(in, out, DaggerNo); + FermionField tmp(out._grid); + for (int s=0;s<(int)this->mass.size();s++) { + ComplexD a = 4.0+this->mass[s]; + ComplexD b(0.0,this->mu[s]); + axpbg5y_ssp(tmp,a,in,b,in,s,s); + } + return axpy_norm(out, 1.0, tmp, out); + } + + // needed for fast PV + void update(const std::vector& _mass, const std::vector& _mu) { + assert(_mass.size() == _mu.size()); + assert(_mass.size() == this->FermionGrid()->_fdimensions[0]); + this->mass = _mass; + this->mu = _mu; + } + + private: + std::vector mu; + std::vector mass; + + }; + + typedef WilsonTMFermion5D WilsonTMFermion5DF; + typedef WilsonTMFermion5D WilsonTMFermion5DD; + +}} diff --git a/Hadrons/A2AVectors.hpp b/Hadrons/A2AVectors.hpp index 423a5f08..ff32ff5e 100644 --- a/Hadrons/A2AVectors.hpp +++ b/Hadrons/A2AVectors.hpp @@ -36,7 +36,7 @@ See the full license in the file "LICENSE" in the top level distribution directo BEGIN_HADRONS_NAMESPACE /****************************************************************************** - * Classes to generate V & W all-to-all vectors * + * Class to generate V & W all-to-all vectors * ******************************************************************************/ template class A2AVectorsSchurDiagTwo @@ -70,6 +70,42 @@ private: SchurDiagTwoOperator op_; }; +/****************************************************************************** + * Methods for V & W all-to-all vectors I/O * + ******************************************************************************/ +class A2AVectorsIo +{ +public: + struct Record: Serializable + { + GRID_SERIALIZABLE_CLASS_MEMBERS(Record, + unsigned int, index); + Record(void): index(0) {} + }; +public: + template + static void write(const std::string fileStem, std::vector &vec, + const bool multiFile, const int trajectory = -1); + template + static void read(std::vector &vec, const std::string fileStem, + const bool multiFile, const int trajectory = -1); +private: + static inline std::string vecFilename(const std::string stem, const int traj, + const bool multiFile) + { + std::string t = (traj < 0) ? "" : ("." + std::to_string(traj)); + + if (multiFile) + { + return stem + t; + } + else + { + return stem + t + ".bin"; + } + } +}; + /****************************************************************************** * A2AVectorsSchurDiagTwo template implementation * ******************************************************************************/ @@ -217,6 +253,90 @@ void A2AVectorsSchurDiagTwo::makeHighModeW5D(FermionField &wout_4d, } } +/****************************************************************************** + * all-to-all vectors I/O template implementation * + ******************************************************************************/ +template +void A2AVectorsIo::write(const std::string fileStem, std::vector &vec, + const bool multiFile, const int trajectory) +{ + Record record; + GridBase *grid = vec[0]._grid; + ScidacWriter binWriter(grid->IsBoss()); + std::string filename = vecFilename(fileStem, multiFile, trajectory); + + if (multiFile) + { + std::string fullFilename; + + for (unsigned int i = 0; i < vec.size(); ++i) + { + fullFilename = filename + "/elem" + std::to_string(i) + ".bin"; + + LOG(Message) << "Writing vector " << i << std::endl; + makeFileDir(fullFilename, grid); + binWriter.open(fullFilename); + record.index = i; + binWriter.writeScidacFieldRecord(vec[i], record); + binWriter.close(); + } + } + else + { + makeFileDir(filename, grid); + binWriter.open(filename); + for (unsigned int i = 0; i < vec.size(); ++i) + { + LOG(Message) << "Writing vector " << i << std::endl; + record.index = i; + binWriter.writeScidacFieldRecord(vec[i], record); + } + binWriter.close(); + } +} + +template +void A2AVectorsIo::read(std::vector &vec, const std::string fileStem, + const bool multiFile, const int trajectory) +{ + Record record; + ScidacReader binReader; + std::string filename = vecFilename(fileStem, multiFile, trajectory); + + if (multiFile) + { + std::string fullFilename; + + for (unsigned int i = 0; i < vec.size(); ++i) + { + fullFilename = filename + "/elem" + std::to_string(i) + ".bin"; + + LOG(Message) << "Reading vector " << i << std::endl; + binReader.open(fullFilename); + binReader.readScidacFieldRecord(vec[i], record); + binReader.close(); + if (record.index != i) + { + HADRONS_ERROR(Io, "vector index mismatch"); + } + } + } + else + { + binReader.open(filename); + for (unsigned int i = 0; i < vec.size(); ++i) + { + LOG(Message) << "Reading vector " << i << std::endl; + binReader.readScidacFieldRecord(vec[i], record); + if (record.index != i) + { + HADRONS_ERROR(Io, "vector index mismatch"); + } + } + binReader.close(); + } +} + END_HADRONS_NAMESPACE #endif // A2A_Vectors_hpp_ diff --git a/Hadrons/DiskVector.hpp b/Hadrons/DiskVector.hpp index f3023a6e..1fddbe36 100644 --- a/Hadrons/DiskVector.hpp +++ b/Hadrons/DiskVector.hpp @@ -151,6 +151,12 @@ class EigenDiskVector: public DiskVectorBase> public: using DiskVectorBase>::DiskVectorBase; typedef EigenDiskVectorMat Matrix; +public: + T operator()(const unsigned int i, const Eigen::Index j, + const Eigen::Index k) const + { + return (*this)[i](j, k); + } private: virtual void load(EigenDiskVectorMat &obj, const std::string filename) const { diff --git a/Hadrons/Modules.hpp b/Hadrons/Modules.hpp index 6d56ea2d..a866c5cd 100644 --- a/Hadrons/Modules.hpp +++ b/Hadrons/Modules.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +42,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -60,6 +65,7 @@ #include #include #include +#include #include #include #include diff --git a/Hadrons/Modules/MAction/DWF.cc b/Hadrons/Modules/MAction/DWF.cc index 6cda84ac..38d25cb9 100644 --- a/Hadrons/Modules/MAction/DWF.cc +++ b/Hadrons/Modules/MAction/DWF.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MAction; template class Grid::Hadrons::MAction::TDWF; +#ifdef GRID_DEFAULT_PRECISION_DOUBLE template class Grid::Hadrons::MAction::TDWF; +#endif diff --git a/Hadrons/Modules/MAction/DWF.hpp b/Hadrons/Modules/MAction/DWF.hpp index 67cfeb1b..257782a1 100644 --- a/Hadrons/Modules/MAction/DWF.hpp +++ b/Hadrons/Modules/MAction/DWF.hpp @@ -73,7 +73,9 @@ protected: }; MODULE_REGISTER_TMP(DWF, TDWF, MAction); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE MODULE_REGISTER_TMP(DWFF, TDWF, MAction); +#endif /****************************************************************************** * DWF template implementation * diff --git a/Hadrons/Modules/MAction/MobiusDWF.cc b/Hadrons/Modules/MAction/MobiusDWF.cc index 41683920..879452d8 100644 --- a/Hadrons/Modules/MAction/MobiusDWF.cc +++ b/Hadrons/Modules/MAction/MobiusDWF.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MAction; template class Grid::Hadrons::MAction::TMobiusDWF; +#ifdef GRID_DEFAULT_PRECISION_DOUBLE template class Grid::Hadrons::MAction::TMobiusDWF; +#endif diff --git a/Hadrons/Modules/MAction/MobiusDWF.hpp b/Hadrons/Modules/MAction/MobiusDWF.hpp index 22964c9a..01223267 100644 --- a/Hadrons/Modules/MAction/MobiusDWF.hpp +++ b/Hadrons/Modules/MAction/MobiusDWF.hpp @@ -72,7 +72,9 @@ public: }; MODULE_REGISTER_TMP(MobiusDWF, TMobiusDWF, MAction); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE MODULE_REGISTER_TMP(MobiusDWFF, TMobiusDWF, MAction); +#endif /****************************************************************************** * TMobiusDWF implementation * diff --git a/Hadrons/Modules/MAction/ScaledDWF.cc b/Hadrons/Modules/MAction/ScaledDWF.cc index 70eafac5..7008bf5d 100644 --- a/Hadrons/Modules/MAction/ScaledDWF.cc +++ b/Hadrons/Modules/MAction/ScaledDWF.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MAction; template class Grid::Hadrons::MAction::TScaledDWF; +#ifdef GRID_DEFAULT_PRECISION_DOUBLE template class Grid::Hadrons::MAction::TScaledDWF; +#endif diff --git a/Hadrons/Modules/MAction/ScaledDWF.hpp b/Hadrons/Modules/MAction/ScaledDWF.hpp index c890f0e9..f7a09eef 100644 --- a/Hadrons/Modules/MAction/ScaledDWF.hpp +++ b/Hadrons/Modules/MAction/ScaledDWF.hpp @@ -71,7 +71,9 @@ public: }; MODULE_REGISTER_TMP(ScaledDWF, TScaledDWF, MAction); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE MODULE_REGISTER_TMP(ScaledDWFF, TScaledDWF, MAction); +#endif /****************************************************************************** * TScaledDWF implementation * diff --git a/Hadrons/Modules/MAction/Wilson.cc b/Hadrons/Modules/MAction/Wilson.cc index 4ce3e7ef..1e801ed6 100644 --- a/Hadrons/Modules/MAction/Wilson.cc +++ b/Hadrons/Modules/MAction/Wilson.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MAction; template class Grid::Hadrons::MAction::TWilson; +#ifdef GRID_DEFAULT_PRECISION_DOUBLE template class Grid::Hadrons::MAction::TWilson; +#endif diff --git a/Hadrons/Modules/MAction/Wilson.hpp b/Hadrons/Modules/MAction/Wilson.hpp index a9327c2f..093449e6 100644 --- a/Hadrons/Modules/MAction/Wilson.hpp +++ b/Hadrons/Modules/MAction/Wilson.hpp @@ -71,7 +71,9 @@ protected: }; MODULE_REGISTER_TMP(Wilson, TWilson, MAction); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE MODULE_REGISTER_TMP(WilsonF, TWilson, MAction); +#endif /****************************************************************************** * TWilson template implementation * diff --git a/Hadrons/Modules/MAction/WilsonClover.cc b/Hadrons/Modules/MAction/WilsonClover.cc index 2c5c0e66..eed1582c 100644 --- a/Hadrons/Modules/MAction/WilsonClover.cc +++ b/Hadrons/Modules/MAction/WilsonClover.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MAction; template class Grid::Hadrons::MAction::TWilsonClover; +#ifdef GRID_DEFAULT_PRECISION_DOUBLE template class Grid::Hadrons::MAction::TWilsonClover; +#endif diff --git a/Hadrons/Modules/MAction/WilsonClover.hpp b/Hadrons/Modules/MAction/WilsonClover.hpp index 349abe84..0b78bb55 100644 --- a/Hadrons/Modules/MAction/WilsonClover.hpp +++ b/Hadrons/Modules/MAction/WilsonClover.hpp @@ -75,7 +75,9 @@ public: }; MODULE_REGISTER_TMP(WilsonClover, TWilsonClover, MAction); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE MODULE_REGISTER_TMP(WilsonCloverF, TWilsonClover, MAction); +#endif /****************************************************************************** * TWilsonClover template implementation * diff --git a/Hadrons/Modules/MAction/ZMobiusDWF.cc b/Hadrons/Modules/MAction/ZMobiusDWF.cc index ef8e4799..609b76cc 100644 --- a/Hadrons/Modules/MAction/ZMobiusDWF.cc +++ b/Hadrons/Modules/MAction/ZMobiusDWF.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MAction; template class Grid::Hadrons::MAction::TZMobiusDWF; +#ifdef GRID_DEFAULT_PRECISION_DOUBLE template class Grid::Hadrons::MAction::TZMobiusDWF; +#endif diff --git a/Hadrons/Modules/MAction/ZMobiusDWF.hpp b/Hadrons/Modules/MAction/ZMobiusDWF.hpp index f7959127..40b04d7f 100644 --- a/Hadrons/Modules/MAction/ZMobiusDWF.hpp +++ b/Hadrons/Modules/MAction/ZMobiusDWF.hpp @@ -73,7 +73,9 @@ public: }; MODULE_REGISTER_TMP(ZMobiusDWF, TZMobiusDWF, MAction); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE MODULE_REGISTER_TMP(ZMobiusDWFF, TZMobiusDWF, MAction); +#endif /****************************************************************************** * TZMobiusDWF implementation * diff --git a/Hadrons/Modules/MContraction/A2AAslashField.cc b/Hadrons/Modules/MContraction/A2AAslashField.cc index eb76932e..65c49198 100644 --- a/Hadrons/Modules/MContraction/A2AAslashField.cc +++ b/Hadrons/Modules/MContraction/A2AAslashField.cc @@ -1,3 +1,30 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MContraction/A2AAslashField.cc + +Copyright (C) 2015-2018 + +Author: Antonin Portelli + +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 using namespace Grid; diff --git a/Hadrons/Modules/MContraction/A2AAslashField.hpp b/Hadrons/Modules/MContraction/A2AAslashField.hpp index a1d64d3d..8b99692b 100644 --- a/Hadrons/Modules/MContraction/A2AAslashField.hpp +++ b/Hadrons/Modules/MContraction/A2AAslashField.hpp @@ -1,3 +1,30 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MContraction/A2AAslashField.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli + +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_MContraction_A2AAslashField_hpp_ #define Hadrons_MContraction_A2AAslashField_hpp_ diff --git a/Hadrons/Modules/MGauge/GaugeFix.cc b/Hadrons/Modules/MGauge/GaugeFix.cc new file mode 100644 index 00000000..53aa16da --- /dev/null +++ b/Hadrons/Modules/MGauge/GaugeFix.cc @@ -0,0 +1,36 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MGauge/GaugeFix.cc + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Peter Boyle + +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 + +using namespace Grid; +using namespace Hadrons; +using namespace MGauge; + +template class Grid::Hadrons::MGauge::TGaugeFix; diff --git a/Hadrons/Modules/MGauge/GaugeFix.hpp b/Hadrons/Modules/MGauge/GaugeFix.hpp new file mode 100644 index 00000000..ece8c19d --- /dev/null +++ b/Hadrons/Modules/MGauge/GaugeFix.hpp @@ -0,0 +1,135 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MGauge/GaugeFix.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Peter Boyle + +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_MGaugeFix_hpp_ +#define Hadrons_MGaugeFix_hpp_ + +#include +#include +#include +#include +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Fix gauge * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MGauge) + +class GaugeFixPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(GaugeFixPar, + std::string, gauge, + Real, alpha, + int, maxiter, + Real, Omega_tol, + Real, Phi_tol, + bool, Fourier); +}; + +template +class TGaugeFix: public Module +{ +public: + GAUGE_TYPE_ALIASES(GImpl,); +public: + // constructor + TGaugeFix(const std::string name); + // destructor + virtual ~TGaugeFix(void) {}; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_TMP(GaugeFix, TGaugeFix, MGauge); + +/****************************************************************************** +* TGaugeFix implementation * +******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TGaugeFix::TGaugeFix(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TGaugeFix::getInput(void) +{ + std::vector in = {par().gauge}; + return in; +} + +template +std::vector TGaugeFix::getOutput(void) +{ + std::vector out = {getName()}; + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TGaugeFix::setup(void) +{ + envCreateLat(GaugeField, getName()); +} + + +// execution /////////////////////////////////////////////////////////////////// +template +void TGaugeFix::execute(void) +//Loads the gauge and fixes it +{ + std::cout << "executing" << std::endl; + LOG(Message) << "Fixing the Gauge" << std::endl; + LOG(Message) << par().gauge << std::endl; + auto &U = envGet(GaugeField, par().gauge); + auto &Umu = envGet(GaugeField, getName()); + LOG(Message) << "Gauge Field fetched" << std::endl; + //do we allow maxiter etc to be user set? + Real alpha = par().alpha; + int maxiter = par().maxiter; + Real Omega_tol = par().Omega_tol; + Real Phi_tol = par().Phi_tol; + bool Fourier = par().Fourier; + FourierAcceleratedGaugeFixer::SteepestDescentGaugeFix(U,alpha,maxiter,Omega_tol,Phi_tol,Fourier); + Umu = U; + LOG(Message) << "Gauge Fixed" << std::endl; +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MGaugeFix_hpp_ diff --git a/Hadrons/Modules/MIO/LoadA2AVectors.cc b/Hadrons/Modules/MIO/LoadA2AVectors.cc new file mode 100644 index 00000000..7a40a6f5 --- /dev/null +++ b/Hadrons/Modules/MIO/LoadA2AVectors.cc @@ -0,0 +1,34 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MIO/LoadA2AVectors.cc + +Copyright (C) 2015-2018 + +Author: Antonin Portelli + +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 + +using namespace Grid; +using namespace Hadrons; +using namespace MIO; + +template class Grid::Hadrons::MIO::TLoadA2AVectors; diff --git a/Hadrons/Modules/MIO/LoadA2AVectors.hpp b/Hadrons/Modules/MIO/LoadA2AVectors.hpp new file mode 100644 index 00000000..5b194c16 --- /dev/null +++ b/Hadrons/Modules/MIO/LoadA2AVectors.hpp @@ -0,0 +1,120 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MIO/LoadA2AVectors.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli + +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_MIO_LoadA2AVectors_hpp_ +#define Hadrons_MIO_LoadA2AVectors_hpp_ + +#include +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Module to load all-to-all vectors * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MIO) + +class LoadA2AVectorsPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(LoadA2AVectorsPar, + std::string, filestem, + bool, multiFile, + unsigned int, size); +}; + +template +class TLoadA2AVectors: public Module +{ +public: + FERM_TYPE_ALIASES(FImpl,); +public: + // constructor + TLoadA2AVectors(const std::string name); + // destructor + virtual ~TLoadA2AVectors(void) {}; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_TMP(LoadA2AVectors, TLoadA2AVectors, MIO); + +/****************************************************************************** + * TLoadA2AVectors implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TLoadA2AVectors::TLoadA2AVectors(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TLoadA2AVectors::getInput(void) +{ + std::vector in; + + return in; +} + +template +std::vector TLoadA2AVectors::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TLoadA2AVectors::setup(void) +{ + envCreate(std::vector, getName(), 1, par().size, + envGetGrid(FermionField)); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TLoadA2AVectors::execute(void) +{ + auto &vec = envGet(std::vector, getName()); + + A2AVectorsIo::read(vec, par().filestem, par().multiFile, vm().getTrajectory()); +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MIO_LoadA2AVectors_hpp_ diff --git a/Hadrons/Modules/MIO/LoadEigenPack.cc b/Hadrons/Modules/MIO/LoadEigenPack.cc index f0ae63c3..28fdeb01 100644 --- a/Hadrons/Modules/MIO/LoadEigenPack.cc +++ b/Hadrons/Modules/MIO/LoadEigenPack.cc @@ -32,4 +32,6 @@ using namespace Hadrons; using namespace MIO; template class Grid::Hadrons::MIO::TLoadEigenPack>; +#ifdef GRID_DEFAULT_PRECISION_DOUBLE template class Grid::Hadrons::MIO::TLoadEigenPack>; +#endif diff --git a/Hadrons/Modules/MIO/LoadEigenPack.hpp b/Hadrons/Modules/MIO/LoadEigenPack.hpp index 2302b15d..016675c9 100644 --- a/Hadrons/Modules/MIO/LoadEigenPack.hpp +++ b/Hadrons/Modules/MIO/LoadEigenPack.hpp @@ -72,7 +72,9 @@ public: }; MODULE_REGISTER_TMP(LoadFermionEigenPack, TLoadEigenPack>, MIO); +#ifdef GRID_DEFAULT_PRECISION_DOUBLE MODULE_REGISTER_TMP(LoadFermionEigenPackIo32, ARG(TLoadEigenPack>), MIO); +#endif /****************************************************************************** * TLoadEigenPack implementation * diff --git a/Hadrons/Modules/MNPR/Amputate.cc b/Hadrons/Modules/MNPR/Amputate.cc new file mode 100644 index 00000000..ec7c5940 --- /dev/null +++ b/Hadrons/Modules/MNPR/Amputate.cc @@ -0,0 +1,36 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MNPR/Amputate.cc + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Peter Boyle + +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 + +using namespace Grid; +using namespace Hadrons; +using namespace MNPR; + +template class Grid::Hadrons::MNPR::TAmputate; + diff --git a/Hadrons/Modules/MNPR/Amputate.hpp b/Hadrons/Modules/MNPR/Amputate.hpp new file mode 100644 index 00000000..953bb354 --- /dev/null +++ b/Hadrons/Modules/MNPR/Amputate.hpp @@ -0,0 +1,200 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MNPR/Amputate.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Julia Kettle J.R.Kettle-2@sms.ed.ac.uk +Author: Peter Boyle + +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_Amputate_hpp_ +#define Hadrons_Amputate_hpp_ + +#include +#include +#include +#include +//#include +//#include +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * TAmputate * + Performs bilinear contractions of the type tr[g5*adj(Sout)*g5*G*Sin] + Suitable for non exceptional momenta +******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MNPR) + +class AmputatePar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(AmputatePar, + std::string, Sin, //need to make this a propogator type? + std::string, Sout, //same + std::string, vertex, + std::string, pin, + std::string, pout, + std::string, output, + std::string, input); +}; + +template +class TAmputate: public Module +{ +public: + FERM_TYPE_ALIASES(FImpl1, 1); + FERM_TYPE_ALIASES(FImpl2, 2); + class Result: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(Result, + std::vector, Vamp, + ); + }; +public: + // constructor + TAmputate(const std::string name); + // destructor + virtual ~TAmputate(void) {}; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + virtual SpinColourMatrix invertspincolmat(SpinColourMatrix &scmat); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_TMP(Amputate, ARG(TAmputate), MNPR); + +/****************************************************************************** + * TAmputate implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TAmputate::TAmputate(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TAmputate::getInput(void) +{ + std::vector input = {par().Sin, par().Sout, par().vertex}; + + return input; +} + +template +std::vector TAmputate::getOutput(void) +{ + std::vector output = {getName()}; + + + return output; +} + +// Invert spin colour matrix using Eigen +template +SpinColourMatrix TAmputate::invertspincolmat(SpinColourMatrix &scmat) +{ + Eigen::MatrixXcf scmat_2d(Ns*Nc,Ns*Nc); + for(int ic=0; ic +void TAmputate::execute(void) +{ + LOG(Message) << "Computing bilinear amputations '" << getName() << "' using" + << " momentum '" << par().Sin << "' and '" << par().Sout << "'" + << std::endl; + BinaryWriter writer(par().output); + PropagatorField1 &Sin = *env().template getObject(par().Sin); //Do these have the phases taken into account?? Don't think so. FIX + PropagatorField2 &Sout = *env().template getObject(par().Sout); + std::vector pin = strToVec(par().pin), pout = strToVec(par().pout); + std::vector latt_size(pin.begin(), pin.end()); + LatticeComplex pdotxin(env().getGrid()), pdotxout(env().getGrid()), coor(env().getGrid()); + LOG(Message) << "Propagators set up " << std::endl; + std::vector vertex; // Let's read from file here + Gamma g5(Gamma::Algebra::Gamma5); + Result result; + LOG(Message) << "reading file - " << par().input << std::endl; + BinaryReader reader(par().input); + Complex Ci(0.0,1.0); + + std::string svertex; + read(reader,"vertex", vertex); + LOG(Message) << "vertex read" << std::endl; + + pdotxin=zero; + pdotxout=zero; + for (unsigned int mu = 0; mu < 4; ++mu) + { + Real TwoPiL = M_PI * 2.0/ latt_size[mu]; + LatticeCoordinate(coor,mu); + pdotxin = pdotxin +(TwoPiL * pin[mu]) * coor; + pdotxout= pdotxout +(TwoPiL * pout[mu]) * coor; + } + Sin = Sin*exp(-Ci*pdotxin); //phase corrections + Sout = Sout*exp(-Ci*pdotxout); + + SpinColourMatrix Sin_mom = sum(Sin); + SpinColourMatrix Sout_mom = sum(Sout); + LOG(Message) << "summed over lattice" << std::endl; + + LOG(Message) << "Lattice -> spincolourmatrix conversion" << std::endl; + + SpinColourMatrix Sin_inv = invertspincolmat(Sin_mom); + SpinColourMatrix Sout_inv = invertspincolmat(Sout_mom); + LOG(Message) << "Inversions done" << std::endl; + + result.Vamp.resize(Gamma::nGamma/2); + for( int mu=0; mu < Gamma::nGamma/2; mu++){ + Gamma::Algebra gam = mu; + result.Vamp[mu] = 1/12.0*trace(adj(Gamma(mu*2+1))*g5*Sout_inv*g5*vertex[mu]*Sin_inv); + LOG(Message) << "Vamp[" << mu << "] - " << result.Vamp[mu] << std::endl; + } +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_Amputate_hpp_ diff --git a/Hadrons/Modules/MNPR/Bilinear.cc b/Hadrons/Modules/MNPR/Bilinear.cc new file mode 100644 index 00000000..c5b38d37 --- /dev/null +++ b/Hadrons/Modules/MNPR/Bilinear.cc @@ -0,0 +1,36 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MNPR/Bilinear.cc + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Peter Boyle + +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 + +using namespace Grid; +using namespace Hadrons; +using namespace MNPR; + +template class Grid::Hadrons::MNPR::TBilinear; + diff --git a/Hadrons/Modules/MNPR/Bilinear.hpp b/Hadrons/Modules/MNPR/Bilinear.hpp new file mode 100644 index 00000000..66cd22a6 --- /dev/null +++ b/Hadrons/Modules/MNPR/Bilinear.hpp @@ -0,0 +1,225 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MNPR/Bilinear.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Julia Kettle J.R.Kettle-2@sms.ed.ac.uk +Author: Peter Boyle + +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_Bilinear_hpp_ +#define Hadrons_Bilinear_hpp_ + +#include +#include +#include +#include +//#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * TBilinear * + Performs bilinear contractions of the type tr[g5*adj(Sout)*g5*G*Sin] + Suitable for non exceptional momenta in Rome-Southampton NPR +******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MNPR) + +class BilinearPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(BilinearPar, + std::string, Sin, + std::string, Sout, + std::string, pin, + std::string, pout, + std::string, output); +}; + +template +class TBilinear: public Module +{ +public: + FERM_TYPE_ALIASES(FImpl1, 1); + FERM_TYPE_ALIASES(FImpl2, 2); + class Result: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(Result, + std::vector, bilinear); + }; +public: + // constructor + TBilinear(const std::string name); + // destructor + virtual ~TBilinear(void) {}; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + //LatticeSpinColourMatrix PhaseProps(LatticeSpinColourMatrix S, std::vector p); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_TMP(Bilinear, ARG(TBilinear), MNPR); + +/****************************************************************************** + * TBilinear implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TBilinear::TBilinear(const std::string name) +: Module(name) +{} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TBilinear::setup(void) +{ + //env().template registerLattice(getName()); + //env().template registerObject(getName()); +} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TBilinear::getInput(void) +{ + std::vector input = {par().Sin, par().Sout}; + + return input; +} + +template +std::vector TBilinear::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +/* +/////Phase propagators////////////////////////// +template +LatticeSpinColourMatrix TBilinear::PhaseProps(LatticeSpinColourMatrix S, std::vector p) +{ + GridBase *grid = S._grid; + LatticeComplex pdotx(grid), coor(grid); + std::vector latt_size = grid->_fdimensions; + Complex Ci(0.0,1.0); + pdotx=zero; + for (unsigned int mu = 0; mu < 4; ++mu) + { + Real TwoPiL = M_PI * 2.0/ latt_size[mu]; + LatticeCoordinate(coor,mu); + pdotx = pdotx +(TwoPiL * p[mu]) * coor; + } + S = S*exp(-Ci*pdotx); + return S; +} +*/ +// execution /////////////////////////////////////////////////////////////////// +template +void TBilinear::execute(void) +{ +/************************************************************************** + +Compute the bilinear vertex needed for the NPR. +V(G) = sum_x [ g5 * adj(S'(x,p2)) * g5 * G * S'(x,p1) ]_{si,sj,ci,cj} +G is one of the 16 gamma vertices [I,gmu,g5,g5gmu,sig(mu,nu)] + + * G + / \ + p1/ \p2 + / \ + / \ + +Returns a spin-colour matrix, with indices si,sj, ci,cj + +Conventions: +p1 - incoming momenta +p2 - outgoing momenta +q = (p1-p2) +**************************************************************************/ + + LOG(Message) << "Computing bilinear contractions '" << getName() << "' using" + << " momentum '" << par().Sin << "' and '" << par().Sout << "'" + << std::endl; + + BinaryWriter writer(par().output); + + + // Propogators + LatticeSpinColourMatrix &Sin = *env().template getObject(par().Sin); + LatticeSpinColourMatrix &Sout = *env().template getObject(par().Sout); + LatticeComplex pdotxin(env().getGrid()), pdotxout(env().getGrid()), coor(env().getGrid()); + // momentum on legs + std::vector pin = strToVec(par().pin), pout = strToVec(par().pout); + std::vector latt_size(pin.begin(), pin.end()); + //bilinears + LatticeSpinColourMatrix bilinear_x(env().getGrid()); + SpinColourMatrix bilinear; + Gamma g5(Gamma::Algebra::Gamma5); + Result result; + Complex Ci(0.0,1.0); + + // + + pdotxin=zero; + pdotxout=zero; + for (unsigned int mu = 0; mu < 4; ++mu) + { + Real TwoPiL = M_PI * 2.0/ latt_size[mu]; + LatticeCoordinate(coor,mu); + pdotxin = pdotxin +(TwoPiL * pin[mu]) * coor; + pdotxout= pdotxout +(TwoPiL * pout[mu]) * coor; + } + Sin = Sin*exp(-Ci*pdotxin); //phase corrections + Sout = Sout*exp(-Ci*pdotxout); + + ////Set up gamma vector////////////////////////// + std::vector gammavector; + for( int i=0; i +Author: Peter Boyle + +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 + +using namespace Grid; +using namespace Hadrons; +using namespace MNPR; + +template class Grid::Hadrons::MNPR::TFourQuark; + diff --git a/Hadrons/Modules/MNPR/FourQuark.hpp b/Hadrons/Modules/MNPR/FourQuark.hpp new file mode 100644 index 00000000..f961a366 --- /dev/null +++ b/Hadrons/Modules/MNPR/FourQuark.hpp @@ -0,0 +1,274 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MNPR/FourQuark.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Julia Kettle J.R.Kettle-2@sms.ed.ac.uk +Author: Peter Boyle + +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_FourQuark_hpp_ +#define Hadrons_FourQuark_hpp_ + +#include +#include +#include +#include +#include +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * TFourQuark * + Performs fourquark contractions of the type tr[g5*adj(Sout)*g5*G*Sin] + Suitable for non exceptional momenta +******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MNPR) + +class FourQuarkPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(FourQuarkPar, + std::string, Sin, //need to make this a propogator type? + std::string, Sout, //same + std::string, pin, + std::string, pout, + bool, fullbasis, + std::string, output); +}; + +template +class TFourQuark: public Module +{ +public: + FERM_TYPE_ALIASES(FImpl1, 1); + FERM_TYPE_ALIASES(FImpl2, 2); + class Result: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(Result, + std::vector, fourquark); + }; +public: + // constructor + TFourQuark(const std::string name); + // destructor + virtual ~TFourQuark(void) {}; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void tensorprod(LatticeSpinColourSpinColourMatrix &lret, LatticeSpinColourMatrix a, LatticeSpinColourMatrix b); + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_TMP(FourQuark, ARG(TFourQuark), MNPR); + +/****************************************************************************** + * TFourQuark implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TFourQuark::TFourQuark(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TFourQuark::getInput(void) +{ + std::vector input = {par().Sin, par().Sout}; + + return input; +} + +template +std::vector TFourQuark::getOutput(void) +{ + std::vector output = {getName()}; + + return output; +} + + +template +void TFourQuark::tensorprod(LatticeSpinColourSpinColourMatrix &lret, LatticeSpinColourMatrix a, LatticeSpinColourMatrix b) +{ +#if 0 + parallel_for(auto site=lret.begin();site +void TFourQuark::setup(void) +{ + envCreateLat(LatticeSpinColourMatrix, getName()); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TFourQuark::execute(void) +{ + +/********************************************************************************* + +TFourQuark : Creates the four quark vertex required for the NPR of four-quark ops + +V_{Gamma_1,Gamma_2} = sum_x [ ( g5 * adj(S'(x,p2)) * g5 * G1 * S'(x,p1) )_ci,cj;si,sj x ( g5 * adj(S'(x,p2)) * g5 * G2 S'(x,p1) )_ck,cl;sk,cl ] + +Create a bilinear vertex for G1 and G2 the spin and colour indices are kept free. Where there are 16 potential Gs. +We then find the outer product of V1 and V2, keeping the spin and colour indices uncontracted +Then this is summed over the lattice coordinate +Result is a SpinColourSpinColourMatrix - with 4 colour and 4 spin indices. +We have up to 256 of these including the offdiag (G1 != G2). + + \ / + \p1 p1/ + \ / + \ / + G1 * * G2 + / \ + / \ + /p2 p2\ + / \ + +*********************************************************************************/ + + + + + LOG(Message) << "Computing fourquark contractions '" << getName() << "' using" + << " momentum '" << par().Sin << "' and '" << par().Sout << "'" + << std::endl; + + BinaryWriter writer(par().output); + + PropagatorField1 &Sin = *env().template getObject(par().Sin); + PropagatorField2 &Sout = *env().template getObject(par().Sout); + std::vector pin = strToVec(par().pin), pout = strToVec(par().pout); + bool fullbasis = par().fullbasis; + Gamma g5(Gamma::Algebra::Gamma5); + Result result; + std::vector latt_size(pin.begin(), pin.end()); + LatticeComplex pdotxin(env().getGrid()), pdotxout(env().getGrid()), coor(env().getGrid()); + LatticeSpinColourMatrix bilinear_mu(env().getGrid()), bilinear_nu(env().getGrid()); + LatticeSpinColourSpinColourMatrix lret(env().getGrid()); + Complex Ci(0.0,1.0); + + //Phase propagators + //Sin = Grid::QCD::PropUtils::PhaseProps(Sin,pin); + //Sout = Grid::QCD::PropUtils::PhaseProps(Sout,pout); + + //find p.x for in and out so phase can be accounted for in propagators + pdotxin=zero; + pdotxout=zero; + for (unsigned int mu = 0; mu < 4; ++mu) + { + Real TwoPiL = M_PI * 2.0/ latt_size[mu]; + LatticeCoordinate(coor,mu); + pdotxin = pdotxin +(TwoPiL * pin[mu]) * coor; + pdotxout= pdotxout +(TwoPiL * pout[mu]) * coor; + } + Sin = Sin*exp(-Ci*pdotxin); //phase corrections + Sout = Sout*exp(-Ci*pdotxout); + + + //Set up Gammas + std::vector gammavector; + for( int i=1; i @@ -236,6 +238,13 @@ void TA2AVectors::execute(void) } stopTimer("W high mode"); } + + // I/O if necessary + if (!par().output.empty()) + { + A2AVectorsIo::write(par().output + "_w", w, par().multiFile, vm().getTrajectory()); + A2AVectorsIo::write(par().output + "_v", v, par().multiFile, vm().getTrajectory()); + } } END_MODULE_NAMESPACE diff --git a/Hadrons/Modules/MSource/Momentum.cc b/Hadrons/Modules/MSource/Momentum.cc new file mode 100644 index 00000000..9bcf65ae --- /dev/null +++ b/Hadrons/Modules/MSource/Momentum.cc @@ -0,0 +1,36 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MSource/Momentum.cc + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Peter Boyle + +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 + +using namespace Grid; +using namespace Hadrons; +using namespace MSource; + +template class Grid::Hadrons::MSource::TMomentum; + diff --git a/Hadrons/Modules/MSource/Momentum.hpp b/Hadrons/Modules/MSource/Momentum.hpp new file mode 100644 index 00000000..8336ea5c --- /dev/null +++ b/Hadrons/Modules/MSource/Momentum.hpp @@ -0,0 +1,149 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Modules/MSource/Momentum.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli +Author: Peter Boyle + +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_Momentum_hpp_ +#define Hadrons_Momentum_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/* +Plane Wave source +----------------- +src_x = e^i2pi/L * p *position +*/ + +/****************************************************************************** + * Plane Wave source * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MSource) + +class MomentumPar: Serializable +{ +public: +//What is meant by serializable in this context +GRID_SERIALIZABLE_CLASS_MEMBERS(MomentumPar, +std::string, mom); +}; + + +template +class TMomentum: public Module +{ +public: +FERM_TYPE_ALIASES(FImpl,); +public: +// constructor +TMomentum(const std::string name); +// destructor +virtual ~TMomentum(void) {}; +// dependency relation +virtual std::vector getInput(void); +virtual std::vector getOutput(void); +// setup +virtual void setup(void); +// execution +virtual void execute(void); +}; + +MODULE_REGISTER_TMP(Momentum, TMomentum, MSource); +//MODULE_REGISTER_NS(Momentum, TMomentum, MSource); + +/****************************************************************************** +* TMomentum template implementation * +******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TMomentum::TMomentum(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TMomentum::getInput(void) +{ + std::vector in; + return in; +} + +template +std::vector TMomentum::getOutput(void) +{ + std::vector out = {getName()}; + return out; +} + + +// setup /////////////////////////////////////////////////////////////////////// +template +void TMomentum::setup(void) +{ + envCreateLat(PropagatorField, getName()); +} + + +//execution////////////////////////////////////////////////////////////////// +template +void TMomentum::execute(void) +{ + LOG(Message) << "Generating planewave momentum source with momentum " << par().mom << std::endl; + //what does this env do? + PropagatorField &src = envGet(PropagatorField, getName()); + Lattice> t(env().getGrid()); + LatticeComplex C(env().getGrid()), coor(env().getGrid()); + std::vector p; + std::vector latt_size(GridDefaultLatt().begin(), GridDefaultLatt().end()); + Complex i(0.0,1.0); + + LOG(Message) << " " << std::endl; + //get the momentum from parameters + p = strToVec(par().mom); + C = zero; + LOG(Message) << "momentum converted from string - " << std::to_string(p[0]) < + +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 using namespace Grid; diff --git a/Hadrons/TimerArray.hpp b/Hadrons/TimerArray.hpp index 477f11cd..77cc2b8c 100644 --- a/Hadrons/TimerArray.hpp +++ b/Hadrons/TimerArray.hpp @@ -1,3 +1,30 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/TimerArray.hpp + +Copyright (C) 2015-2018 + +Author: Antonin Portelli + +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_TimerArray_hpp_ #define Hadrons_TimerArray_hpp_ diff --git a/Hadrons/Utilities/EigenPackCast.cc b/Hadrons/Utilities/EigenPackCast.cc index 7247c92d..8f2755e3 100644 --- a/Hadrons/Utilities/EigenPackCast.cc +++ b/Hadrons/Utilities/EigenPackCast.cc @@ -1,3 +1,30 @@ +/************************************************************************************* + +Grid physics library, www.github.com/paboyle/Grid + +Source file: Hadrons/Utilities/EigenPackCast.cc + +Copyright (C) 2015-2018 + +Author: Antonin Portelli + +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 #include diff --git a/Hadrons/Utilities/HadronsXmlRun.cc b/Hadrons/Utilities/HadronsXmlRun.cc index c6ea7dc5..9b8fc901 100644 --- a/Hadrons/Utilities/HadronsXmlRun.cc +++ b/Hadrons/Utilities/HadronsXmlRun.cc @@ -2,7 +2,7 @@ Grid physics library, www.github.com/paboyle/Grid -Source file: Hadrons/HadronsXmlRun.cc +Source file: Hadrons/Utilities/HadronsXmlRun.cc Copyright (C) 2015-2018 diff --git a/Hadrons/modules.inc b/Hadrons/modules.inc index 74138238..c716b470 100644 --- a/Hadrons/modules.inc +++ b/Hadrons/modules.inc @@ -11,6 +11,7 @@ modules_cc =\ Modules/MContraction/Gamma3pt.cc \ Modules/MFermion/FreeProp.cc \ Modules/MFermion/GaugeProp.cc \ + Modules/MSource/Momentum.cc \ Modules/MSource/Point.cc \ Modules/MSource/Wall.cc \ Modules/MSource/SeqConserved.cc \ @@ -28,6 +29,7 @@ modules_cc =\ Modules/MGauge/StochEm.cc \ Modules/MGauge/Random.cc \ Modules/MGauge/FundtoHirep.cc \ + Modules/MGauge/GaugeFix.cc \ Modules/MNoise/TimeDilutedSpinColorDiagonal.cc \ Modules/MUtilities/RandomVectors.cc \ Modules/MUtilities/TestSeqGamma.cc \ @@ -38,6 +40,9 @@ modules_cc =\ Modules/MScalar/VPCounterTerms.cc \ Modules/MScalar/ChargedProp.cc \ Modules/MScalar/ScalarVP.cc \ + Modules/MNPR/Amputate.cc \ + Modules/MNPR/Bilinear.cc \ + Modules/MNPR/FourQuark.cc \ Modules/MAction/Wilson.cc \ Modules/MAction/MobiusDWF.cc \ Modules/MAction/ZMobiusDWF.cc \ @@ -59,7 +64,8 @@ modules_cc =\ Modules/MIO/LoadBinary.cc \ Modules/MIO/LoadNersc.cc \ Modules/MIO/LoadCoarseEigenPack.cc \ - Modules/MIO/LoadCosmHol.cc + Modules/MIO/LoadCosmHol.cc \ + Modules/MIO/LoadA2AVectors.cc modules_hpp =\ Modules/MContraction/Baryon.hpp \ @@ -80,6 +86,7 @@ modules_hpp =\ Modules/MSource/Wall.hpp \ Modules/MSource/Z2.hpp \ Modules/MSource/SeqConserved.hpp \ + Modules/MSource/Momentum.hpp \ Modules/MSink/Smear.hpp \ Modules/MSink/Point.hpp \ Modules/MSolver/MixedPrecisionRBPrecCG.hpp \ @@ -91,6 +98,7 @@ modules_hpp =\ Modules/MGauge/StoutSmearing.hpp \ Modules/MGauge/Unit.hpp \ Modules/MGauge/Random.hpp \ + Modules/MGauge/GaugeFix.hpp \ Modules/MGauge/FundtoHirep.hpp \ Modules/MGauge/StochEm.hpp \ Modules/MNoise/TimeDilutedSpinColorDiagonal.hpp \ @@ -104,6 +112,9 @@ modules_hpp =\ Modules/MScalar/ScalarVP.hpp \ Modules/MScalar/Scalar.hpp \ Modules/MScalar/ChargedProp.hpp \ + Modules/MNPR/Bilinear.hpp \ + Modules/MNPR/Amputate.hpp \ + Modules/MNPR/FourQuark.hpp \ Modules/MAction/DWF.hpp \ Modules/MAction/MobiusDWF.hpp \ Modules/MAction/Wilson.hpp \ @@ -124,6 +135,7 @@ modules_hpp =\ Modules/MScalarSUN/TrKinetic.hpp \ Modules/MIO/LoadEigenPack.hpp \ Modules/MIO/LoadNersc.hpp \ + Modules/MIO/LoadA2AVectors.hpp \ Modules/MIO/LoadCosmHol.hpp \ Modules/MIO/LoadCoarseEigenPack.hpp \ Modules/MIO/LoadBinary.hpp diff --git a/benchmarks/Benchmark_IO.cc b/benchmarks/Benchmark_IO.cc index 479ae037..58e0340d 100644 --- a/benchmarks/Benchmark_IO.cc +++ b/benchmarks/Benchmark_IO.cc @@ -1,108 +1,48 @@ -#include -#ifdef HAVE_LIME -using namespace std; -using namespace Grid; -using namespace Grid::QCD; +#include "Benchmark_IO.hpp" -#define MSG cout << GridLogMessage -#define SEP \ -"=============================================================================" #ifndef BENCH_IO_LMAX #define BENCH_IO_LMAX 40 #endif -typedef function WriterFn; -typedef function ReaderFn; +using namespace Grid; +using namespace QCD; -string filestem(const int l) +std::string filestem(const int l) { - return "iobench_l" + to_string(l); -} - -void limeWrite(const string filestem, LatticeFermion &vec) -{ - emptyUserRecord record; - ScidacWriter binWriter(vec._grid->IsBoss()); - - binWriter.open(filestem + ".bin"); - binWriter.writeScidacFieldRecord(vec, record); - binWriter.close(); -} - -void limeRead(LatticeFermion &vec, const string filestem) -{ - emptyUserRecord record; - ScidacReader binReader; - - binReader.open(filestem + ".bin"); - binReader.readScidacFieldRecord(vec, record); - binReader.close(); -} - -void writeBenchmark(const int l, const WriterFn &write) -{ - auto mpi = GridDefaultMpi(); - auto simd = GridDefaultSimd(Nd, vComplex::Nsimd()); - vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; - unique_ptr gPt(SpaceTimeGrid::makeFourDimGrid(latt, simd, mpi)); - GridCartesian *g = gPt.get(); - GridParallelRNG rng(g); - LatticeFermion vec(g); - emptyUserRecord record; - ScidacWriter binWriter(g->IsBoss()); - - cout << "-- Local volume " << l << "^4" << endl; - random(rng, vec); - write(filestem(l), vec); -} - -void readBenchmark(const int l, const ReaderFn &read) -{ - auto mpi = GridDefaultMpi(); - auto simd = GridDefaultSimd(Nd, vComplex::Nsimd()); - vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; - unique_ptr gPt(SpaceTimeGrid::makeFourDimGrid(latt, simd, mpi)); - GridCartesian *g = gPt.get(); - LatticeFermion vec(g); - emptyUserRecord record; - ScidacReader binReader; - - cout << "-- Local volume " << l << "^4" << endl; - read(vec, filestem(l)); + return "iobench_l" + std::to_string(l); } int main (int argc, char ** argv) { Grid_init(&argc,&argv); - auto simd = GridDefaultSimd(Nd,vComplex::Nsimd()); - auto mpi = GridDefaultMpi(); - int64_t threads = GridThread::GetThreads(); - MSG << "Grid is setup to use " << threads << " threads" << endl; - MSG << SEP << endl; - MSG << "Benchmark Lime write" << endl; - MSG << SEP << endl; + MSG << "Grid is setup to use " << threads << " threads" << std::endl; + MSG << SEP << std::endl; + MSG << "Benchmark Lime write" << std::endl; + MSG << SEP << std::endl; for (int l = 4; l <= BENCH_IO_LMAX; l += 2) { - writeBenchmark(l, limeWrite); + auto mpi = GridDefaultMpi(); + std::vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; + + std::cout << "-- Local volume " << l << "^4" << std::endl; + writeBenchmark(latt, filestem(l), limeWrite); } - MSG << "Benchmark Lime read" << endl; - MSG << SEP << endl; + MSG << "Benchmark Lime read" << std::endl; + MSG << SEP << std::endl; for (int l = 4; l <= BENCH_IO_LMAX; l += 2) { - readBenchmark(l, limeRead); + auto mpi = GridDefaultMpi(); + std::vector latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; + + std::cout << "-- Local volume " << l << "^4" << std::endl; + readBenchmark(latt, filestem(l), limeRead); } Grid_finalize(); return EXIT_SUCCESS; } -#else -int main (int argc, char ** argv) -{ - return EXIT_SUCCESS; -} -#endif diff --git a/benchmarks/Benchmark_IO.hpp b/benchmarks/Benchmark_IO.hpp new file mode 100644 index 00000000..9565c928 --- /dev/null +++ b/benchmarks/Benchmark_IO.hpp @@ -0,0 +1,107 @@ +#ifndef Benchmark_IO_hpp_ +#define Benchmark_IO_hpp_ + +#include + +#define MSG std::cout << GridLogMessage +#define SEP \ +"=============================================================================" + +namespace Grid { + +template +using WriterFn = std::function ; +template +using ReaderFn = std::function; + +template +void limeWrite(const std::string filestem, Field &vec) +{ + emptyUserRecord record; + QCD::ScidacWriter binWriter(vec._grid->IsBoss()); + + binWriter.open(filestem + ".bin"); + binWriter.writeScidacFieldRecord(vec, record); + binWriter.close(); +} + +template +void limeRead(Field &vec, const std::string filestem) +{ + emptyUserRecord record; + QCD::ScidacReader binReader; + + binReader.open(filestem + ".bin"); + binReader.readScidacFieldRecord(vec, record); + binReader.close(); +} + +inline void makeGrid(std::shared_ptr &gPt, + const std::shared_ptr &gBasePt, + const unsigned int Ls = 1, const bool rb = false) +{ + if (rb) + { + if (Ls > 1) + { + gPt.reset(QCD::SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, gBasePt.get())); + } + else + { + gPt.reset(QCD::SpaceTimeGrid::makeFourDimRedBlackGrid(gBasePt.get())); + } + } + else + { + if (Ls > 1) + { + gPt.reset(QCD::SpaceTimeGrid::makeFiveDimGrid(Ls, gBasePt.get())); + } + else + { + gPt = gBasePt; + } + } +} + +template +void writeBenchmark(const std::vector &latt, const std::string filename, + const WriterFn &write, + const unsigned int Ls = 1, const bool rb = false) +{ + auto mpi = GridDefaultMpi(); + auto simd = GridDefaultSimd(latt.size(), Field::vector_type::Nsimd()); + std::shared_ptr gBasePt(QCD::SpaceTimeGrid::makeFourDimGrid(latt, simd, mpi)); + std::shared_ptr gPt; + + makeGrid(gPt, gBasePt, Ls, rb); + + GridBase *g = gPt.get(); + GridParallelRNG rng(g); + Field vec(g); + + random(rng, vec); + write(filename, vec); +} + +template +void readBenchmark(const std::vector &latt, const std::string filename, + const ReaderFn &read, + const unsigned int Ls = 1, const bool rb = false) +{ + auto mpi = GridDefaultMpi(); + auto simd = GridDefaultSimd(latt.size(), Field::vector_type::Nsimd()); + std::shared_ptr gBasePt(QCD::SpaceTimeGrid::makeFourDimGrid(latt, simd, mpi)); + std::shared_ptr gPt; + + makeGrid(gPt, gBasePt, Ls, rb); + + GridBase *g = gPt.get(); + Field vec(g); + + read(vec, filename); +} + +} + +#endif // Benchmark_IO_hpp_ diff --git a/benchmarks/Benchmark_IO_vs_dir.cc b/benchmarks/Benchmark_IO_vs_dir.cc new file mode 100644 index 00000000..15f6194f --- /dev/null +++ b/benchmarks/Benchmark_IO_vs_dir.cc @@ -0,0 +1,79 @@ +#include "Benchmark_IO.hpp" + +#define MSG std::cout << GridLogMessage +#define SEP \ +"=============================================================================" + +using namespace Grid; +using namespace QCD; + +int main (int argc, char ** argv) +{ + std::vector dir; + unsigned int Ls; + bool rb; + if (argc < 4) + { + std::cerr << "usage: " << argv[0] << " [ ... ] [Grid options]"; + std::cerr << std::endl; + } + Ls = std::stoi(argv[1]); + rb = (std::string(argv[2]) == "1"); + for (unsigned int i = 3; i < argc; ++i) + { + std::string a = argv[i]; + + if (a[0] != '-') + { + dir.push_back(std::string(argv[i])); + } + else + { + break; + } + } + Grid_init(&argc,&argv); + + + int64_t threads = GridThread::GetThreads(); + MSG << "Grid is setup to use " << threads << " threads" << std::endl; + MSG << SEP << std::endl; + MSG << "Benchmark double precision Lime write" << std::endl; + MSG << SEP << std::endl; + for (auto &d: dir) + { + MSG << "-- Directory " << d << std::endl; + writeBenchmark(GridDefaultLatt(), d + "/ioBench", limeWrite, Ls, rb); + } + + MSG << SEP << std::endl; + MSG << "Benchmark double precision Lime read" << std::endl; + MSG << SEP << std::endl; + for (auto &d: dir) + { + MSG << "-- Directory " << d << std::endl; + readBenchmark(GridDefaultLatt(), d + "/ioBench", limeRead, Ls, rb); + } + + MSG << SEP << std::endl; + MSG << "Benchmark single precision Lime write" << std::endl; + MSG << SEP << std::endl; + for (auto &d: dir) + { + MSG << "-- Directory " << d << std::endl; + writeBenchmark(GridDefaultLatt(), d + "/ioBench", limeWrite, Ls, rb); + } + + MSG << SEP << std::endl; + MSG << "Benchmark single precision Lime read" << std::endl; + MSG << SEP << std::endl; + for (auto &d: dir) + { + MSG << "-- Directory " << d << std::endl; + readBenchmark(GridDefaultLatt(), d + "/ioBench", limeRead, Ls, rb); + } + + Grid_finalize(); + + return EXIT_SUCCESS; +} diff --git a/tests/debug/Test_cayley_cg.cc b/tests/debug/Test_cayley_cg.cc index 57fe7717..5150268f 100644 --- a/tests/debug/Test_cayley_cg.cc +++ b/tests/debug/Test_cayley_cg.cc @@ -1,5 +1,4 @@ /************************************************************************************* - Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/Test_cayley_cg.cc @@ -27,6 +26,7 @@ Author: paboyle *************************************************************************************/ /* END LEGAL */ #include +#include using namespace std; using namespace Grid; @@ -46,6 +46,7 @@ struct scal { template void TestCGinversions(What & Ddwf, + LatticeGaugeField &Umu, GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, RealD mass, RealD M5, @@ -75,6 +76,25 @@ void TestCGprec(What & Ddwf, GridParallelRNG *RNG4, GridParallelRNG *RNG5); +template +void TestReconstruct5D(What & Ddwf, + LatticeGaugeField &Umu, + GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, + GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, + RealD mass, RealD M5, + GridParallelRNG *RNG4, + GridParallelRNG *RNG5); + +template +void TestReconstruct5DFA(What & Ddwf, + WhatF & DdwfF, + LatticeGaugeField &Umu, + GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, + GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, + RealD mass, RealD M5, + GridParallelRNG *RNG4, + GridParallelRNG *RNG5); + int main (int argc, char ** argv) { Grid_init(&argc,&argv); @@ -83,63 +103,104 @@ int main (int argc, char ** argv) std::cout< seeds4({1,2,3,4}); std::vector seeds5({5,6,7,8}); GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5); GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); LatticeGaugeField Umu(UGrid); + LatticeGaugeFieldF UmuF(UGridF); SU3::HotConfiguration(RNG4,Umu); + precisionChange(UmuF,Umu); std::vector U(4,UGrid); RealD mass=0.1; RealD M5 =1.8; + std::cout<(Ddwf,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + DomainWallFermionF DdwfF(UmuF,*FGridF,*FrbGridF,*UGridF,*UrbGridF,mass,M5); + TestCGinversions(Ddwf,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5DFA(Ddwf,DdwfF,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); RealD b=1.5;// Scale factor b+c=2, b-c=1 RealD c=0.5; std::vector gamma(Ls,ComplexD(1.0,0.0)); + std::cout<(Dmob,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + MobiusFermionF DmobF(UmuF,*FGridF,*FrbGridF,*UGridF,*UrbGridF,mass,M5,b,c); + TestCGinversions(Dmob,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5DFA(Dmob,DmobF,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + std::cout<(ZDmob,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestCGinversions(ZDmob,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5D(ZDmob,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + std::cout<(Dzolo,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestCGinversions(Dzolo,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5D(Dzolo,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + std::cout<(Dsham,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + ScaledShamirFermionF DshamF(UmuF,*FGridF,*FrbGridF,*UGridF,*UrbGridF,mass,M5,2.0); + TestCGinversions(Dsham,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5DFA(Dsham,DshamF,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + std::cout<(Dshamz,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestCGinversions(Dshamz,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5D(Dshamz,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + std::cout<(Dov,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + std::cout<(Dov,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5DFA(Dov,DovF,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + std::cout<(Dovz,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestCGinversions(Dovz,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); + TestReconstruct5D(Dovz,Umu,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,&RNG4,&RNG5); Grid_finalize(); } template void TestCGinversions(What & Ddwf, + LatticeGaugeField &Umu, GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, RealD mass, RealD M5, @@ -154,6 +215,7 @@ void TestCGinversions(What & Ddwf, TestCGschur(Ddwf,FGrid,FrbGrid,UGrid,UrbGrid,mass,M5,RNG4,RNG5); } + template void TestCGunprec(What & Ddwf, GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, @@ -189,6 +251,147 @@ void TestCGprec(What & Ddwf, CG(HermOpEO,src_o,result_o); } +template +void TestReconstruct5D(What & Ddwf, + LatticeGaugeField & Umu, + GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, + GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, + RealD mass, RealD M5, + GridParallelRNG *RNG4, + GridParallelRNG *RNG5) +{ + LatticeFermion src4 (UGrid); random(*RNG4,src4); + LatticeFermion res4 (UGrid); res4 = zero; + + LatticeFermion src (FGrid); + LatticeFermion src_NE(FGrid); + LatticeFermion result(FGrid); + LatticeFermion result_rec(FGrid); + LatticeFermion result_madwf(FGrid); + + MdagMLinearOperator HermOp(Ddwf); + double Resid = 1.0e-12; + double Residi = 1.0e-6; + ConjugateGradient CG(Resid,10000); + ConjugateGradient CGi(Residi,10000); + + Ddwf.ImportPhysicalFermionSource(src4,src); + Ddwf.Mdag(src,src_NE); + CG(HermOp,src_NE,result); + + Ddwf.ExportPhysicalFermionSolution(result, res4); + + Ddwf.M(result,src_NE); + src_NE = src_NE - src; + std::cout < SchurSolverType; + typedef SchurRedBlackDiagTwoSolve SchurSolverTypei; + typedef PauliVillarsSolverRBprec PVinverter; + SchurSolverType SchurSolver(CG); + PVinverter PVinverse(SchurSolver); + + Reconstruct5DfromPhysical reconstructor(PVinverse); + + reconstructor(Ddwf,res4,src4,result_rec); + + std::cout < Guess; + MADWF > + madwf(Ddwf,Ddwf,PVinverse,SchurSolveri,Guess,Resid,10); + + madwf(src4,result_madwf); + result_madwf = result_madwf - result; + std::cout < +void TestReconstruct5DFA(What & Ddwf, + WhatF & DdwfF, + LatticeGaugeField & Umu, + GridCartesian * FGrid, GridRedBlackCartesian * FrbGrid, + GridCartesian * UGrid, GridRedBlackCartesian * UrbGrid, + RealD mass, RealD M5, + GridParallelRNG *RNG4, + GridParallelRNG *RNG5) +{ + LatticeFermion src4 (UGrid); random(*RNG4,src4); + LatticeFermion res4 (UGrid); res4 = zero; + + LatticeFermion src (FGrid); + LatticeFermion src_NE(FGrid); + LatticeFermion result(FGrid); + LatticeFermion result_rec(FGrid); + LatticeFermion result_madwf(FGrid); + + MdagMLinearOperator HermOp(Ddwf); + double Resid = 1.0e-12; + double Residi = 1.0e-5; + ConjugateGradient CG(Resid,10000); + ConjugateGradient CGi(Residi,10000); + + Ddwf.ImportPhysicalFermionSource(src4,src); + Ddwf.Mdag(src,src_NE); + CG(HermOp,src_NE,result); + + Ddwf.ExportPhysicalFermionSolution(result, res4); + + Ddwf.M(result,src_NE); + src_NE = src_NE - src; + std::cout < SchurSolverTypei; + typedef PauliVillarsSolverFourierAccel PVinverter; + PVinverter PVinverse(Umu,CG); + + Reconstruct5DfromPhysical reconstructor(PVinverse); + + reconstructor(Ddwf,res4,src4,result_rec); + + std::cout < Guess; + MADWF > + madwf(Ddwf,DdwfF,PVinverse,SchurSolver,Guess,Resid,10); + + madwf(src4,result_madwf); + result_madwf = result_madwf - result; + std::cout < void TestCGschur(What & Ddwf,