/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./lib/qcd/action/pseudofermion/DomainDecomposedTwoFlavourBoundary.h Copyright (C) 2021 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_BEGIN(Grid); /////////////////////////////////////// // Two flavour ratio /////////////////////////////////////// template class DomainDecomposedBoundaryTwoFlavourRatioPseudoFermion : public Action { public: INHERIT_IMPL_TYPES(ImplD); private: SchurFactoredFermionOperator & NumOp;// the basic operator SchurFactoredFermionOperator & DenOp;// the basic operator RealD InnerStoppingCondition; RealD ActionStoppingCondition; RealD DerivativeStoppingCondition; FermionField Phi; // the pseudo fermion field for this trajectory public: DomainDecomposedBoundaryTwoFlavourRatioPseudoFermion(SchurFactoredFermionOperator &_NumOp, SchurFactoredFermionOperator &_DenOp, RealD _DerivativeTol, RealD _ActionTol, RealD _InnerTol=1.0e-6) : NumOp(_NumOp), DenOp(_DenOp), Phi(_NumOp.PeriodicFermOpD.FermionGrid()), InnerStoppingCondition(_InnerTol), DerivativeStoppingCondition(_DerivativeTol), ActionStoppingCondition(_ActionTol) {}; virtual std::string action_name(){return "DomainDecomposedBoundaryTwoFlavourRatioPseudoFermion";} virtual std::string LogParameters(){ std::stringstream sstream; return sstream.str(); } virtual void refresh(const GaugeField &U, GridSerialRNG& sRNG, GridParallelRNG& pRNG) { NumOp.ImportGauge(U); DenOp.ImportGauge(U); FermionField eta(NumOp.PeriodicFermOpD.FermionGrid()); FermionField tmp(NumOp.PeriodicFermOpD.FermionGrid()); // P(phi) = e^{- phi^dag P^dag Rdag^-1 R^-1 P phi} // // NumOp == P // DenOp == R // // Take phi = P^{-1} R eta ; eta = R^-1 P Phi // // P(eta) = e^{- eta^dag eta} // // e^{x^2/2 sig^2} => sig^2 = 0.5. // // So eta should be of width sig = 1/sqrt(2) and must multiply by 0.707.... // RealD scale = std::sqrt(0.5); gaussian(pRNG,eta); eta=eta*scale; NumOp.ProjectBoundaryBar(eta); NumOp.tolinner=InnerStoppingCondition; DenOp.tolinner=InnerStoppingCondition; DenOp.tol = ActionStoppingCondition; NumOp.tol = ActionStoppingCondition; DenOp.R(eta,tmp); NumOp.RInv(tmp,Phi); DumpSliceNorm("Phi",Phi); }; ////////////////////////////////////////////////////// // S = phi^dag Pdag Rdag^-1 R^-1 P phi ////////////////////////////////////////////////////// virtual RealD S(const GaugeField &U) { NumOp.ImportGauge(U); DenOp.ImportGauge(U); FermionField X(NumOp.PeriodicFermOpD.FermionGrid()); FermionField Y(NumOp.PeriodicFermOpD.FermionGrid()); NumOp.tolinner=InnerStoppingCondition; DenOp.tolinner=InnerStoppingCondition; DenOp.tol = ActionStoppingCondition; NumOp.tol = ActionStoppingCondition; NumOp.R(Phi,Y); DenOp.RInv(Y,X); RealD action = norm2(X); // std::cout << " DD boundary action is " <