2016-01-02 14:51:32 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: ./lib/qcd/action/pseudofermion/TwoFlavourRatio.h
|
|
|
|
|
|
|
|
Copyright (C) 2015
|
|
|
|
|
|
|
|
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|
|
|
Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
|
|
|
|
Author: paboyle <paboyle@ph.ed.ac.uk>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2015-08-18 09:21:29 +01:00
|
|
|
#ifndef QCD_PSEUDOFERMION_TWO_FLAVOUR_RATIO_H
|
|
|
|
#define QCD_PSEUDOFERMION_TWO_FLAVOUR_RATIO_H
|
2015-08-18 09:19:42 +01:00
|
|
|
|
|
|
|
namespace Grid{
|
|
|
|
namespace QCD{
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
// Two flavour ratio
|
|
|
|
///////////////////////////////////////
|
|
|
|
template<class Impl>
|
|
|
|
class TwoFlavourRatioPseudoFermionAction : public Action<typename Impl::GaugeField> {
|
|
|
|
public:
|
|
|
|
INHERIT_IMPL_TYPES(Impl);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FermionOperator<Impl> & NumOp;// the basic operator
|
|
|
|
FermionOperator<Impl> & DenOp;// the basic operator
|
|
|
|
|
|
|
|
OperatorFunction<FermionField> &DerivativeSolver;
|
|
|
|
OperatorFunction<FermionField> &ActionSolver;
|
|
|
|
|
|
|
|
FermionField Phi; // the pseudo fermion field for this trajectory
|
|
|
|
|
|
|
|
public:
|
|
|
|
TwoFlavourRatioPseudoFermionAction(FermionOperator<Impl> &_NumOp,
|
|
|
|
FermionOperator<Impl> &_DenOp,
|
|
|
|
OperatorFunction<FermionField> & DS,
|
|
|
|
OperatorFunction<FermionField> & AS
|
2015-08-18 09:21:29 +01:00
|
|
|
) : NumOp(_NumOp), DenOp(_DenOp), DerivativeSolver(DS), ActionSolver(AS), Phi(_NumOp.FermionGrid()) {};
|
2015-08-18 09:19:42 +01:00
|
|
|
|
2015-08-30 13:39:19 +01:00
|
|
|
virtual void refresh(const GaugeField &U, GridParallelRNG& pRNG) {
|
2015-08-18 09:19:42 +01:00
|
|
|
|
|
|
|
// P(phi) = e^{- phi^dag V (MdagM)^-1 Vdag phi}
|
|
|
|
//
|
2015-08-18 09:21:29 +01:00
|
|
|
// NumOp == V
|
|
|
|
// DenOp == M
|
|
|
|
//
|
|
|
|
// Take phi = Vdag^{-1} Mdag eta ; eta = Mdag^{-1} Vdag Phi
|
2015-08-18 09:19:42 +01:00
|
|
|
//
|
|
|
|
// P(eta) = e^{- eta^dag eta}
|
|
|
|
//
|
|
|
|
// e^{x^2/2 sig^2} => sig^2 = 0.5.
|
|
|
|
//
|
2015-08-18 09:21:29 +01:00
|
|
|
// So eta should be of width sig = 1/sqrt(2) and must multiply by 0.707....
|
2015-08-18 09:19:42 +01:00
|
|
|
//
|
|
|
|
RealD scale = std::sqrt(0.5);
|
|
|
|
|
|
|
|
FermionField eta(NumOp.FermionGrid());
|
2015-08-18 09:21:29 +01:00
|
|
|
FermionField tmp(NumOp.FermionGrid());
|
2015-08-18 09:19:42 +01:00
|
|
|
|
|
|
|
gaussian(pRNG,eta);
|
|
|
|
|
|
|
|
NumOp.ImportGauge(U);
|
|
|
|
DenOp.ImportGauge(U);
|
|
|
|
|
2015-08-18 09:21:29 +01:00
|
|
|
// Note: this hard codes normal equations type solvers; alternate implementation needed for
|
|
|
|
// non-herm style solvers.
|
2015-08-18 09:19:42 +01:00
|
|
|
MdagMLinearOperator<FermionOperator<Impl> ,FermionField> MdagMOp(NumOp);
|
|
|
|
|
|
|
|
DenOp.Mdag(eta,Phi); // Mdag eta
|
2015-12-21 15:34:35 +00:00
|
|
|
tmp = zero;
|
2015-08-18 09:19:42 +01:00
|
|
|
ActionSolver(MdagMOp,Phi,tmp); // (VdagV)^-1 Mdag eta = V^-1 Vdag^-1 Mdag eta
|
|
|
|
NumOp.M(tmp,Phi); // Vdag^-1 Mdag eta
|
|
|
|
|
|
|
|
Phi=Phi*scale;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// S = phi^dag V (Mdag M)^-1 Vdag phi
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
virtual RealD S(const GaugeField &U) {
|
|
|
|
|
|
|
|
NumOp.ImportGauge(U);
|
|
|
|
DenOp.ImportGauge(U);
|
|
|
|
|
|
|
|
FermionField X(NumOp.FermionGrid());
|
|
|
|
FermionField Y(NumOp.FermionGrid());
|
|
|
|
|
|
|
|
MdagMLinearOperator<FermionOperator<Impl> ,FermionField> MdagMOp(DenOp);
|
|
|
|
|
2015-08-18 09:21:29 +01:00
|
|
|
NumOp.Mdag(Phi,Y); // Y= Vdag phi
|
2015-12-21 15:34:35 +00:00
|
|
|
X=zero;
|
2015-08-18 09:21:29 +01:00
|
|
|
ActionSolver(MdagMOp,Y,X); // X= (MdagM)^-1 Vdag phi
|
|
|
|
DenOp.M(X,Y); // Y= Mdag^-1 Vdag phi
|
2015-08-18 09:19:42 +01:00
|
|
|
|
|
|
|
RealD action = norm2(Y);
|
|
|
|
|
|
|
|
return action;
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// dS/du = phi^dag dV (Mdag M)^-1 V^dag phi
|
|
|
|
// - phi^dag V (Mdag M)^-1 [ Mdag dM + dMdag M ] (Mdag M)^-1 V^dag phi
|
|
|
|
// + phi^dag V (Mdag M)^-1 dV^dag phi
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
virtual void deriv(const GaugeField &U,GaugeField & dSdU) {
|
|
|
|
|
|
|
|
NumOp.ImportGauge(U);
|
|
|
|
DenOp.ImportGauge(U);
|
|
|
|
|
|
|
|
MdagMLinearOperator<FermionOperator<Impl> ,FermionField> MdagMOp(DenOp);
|
|
|
|
|
|
|
|
FermionField X(NumOp.FermionGrid());
|
|
|
|
FermionField Y(NumOp.FermionGrid());
|
|
|
|
|
2015-08-18 09:21:29 +01:00
|
|
|
GaugeField force(NumOp.GaugeGrid());
|
2015-08-18 09:19:42 +01:00
|
|
|
|
|
|
|
|
2015-08-18 09:21:29 +01:00
|
|
|
//Y=Vdag phi
|
2015-08-18 09:19:42 +01:00
|
|
|
//X = (Mdag M)^-1 V^dag phi
|
|
|
|
//Y = (Mdag)^-1 V^dag phi
|
2015-08-18 09:21:29 +01:00
|
|
|
NumOp.Mdag(Phi,Y); // Y= Vdag phi
|
2015-12-21 15:34:35 +00:00
|
|
|
X=zero;
|
2015-08-18 09:21:29 +01:00
|
|
|
DerivativeSolver(MdagMOp,Y,X); // X= (MdagM)^-1 Vdag phi
|
|
|
|
DenOp.M(X,Y); // Y= Mdag^-1 Vdag phi
|
2015-08-18 09:19:42 +01:00
|
|
|
|
|
|
|
// phi^dag V (Mdag M)^-1 dV^dag phi
|
|
|
|
NumOp.MDeriv(force , X, Phi, DaggerYes ); dSdU=force;
|
|
|
|
|
|
|
|
// phi^dag dV (Mdag M)^-1 V^dag phi
|
|
|
|
NumOp.MDeriv(force , Phi, X ,DaggerNo ); dSdU=dSdU+force;
|
|
|
|
|
|
|
|
// - phi^dag V (Mdag M)^-1 Mdag dM (Mdag M)^-1 V^dag phi
|
|
|
|
// - phi^dag V (Mdag M)^-1 dMdag M (Mdag M)^-1 V^dag phi
|
|
|
|
DenOp.MDeriv(force,Y,X,DaggerNo); dSdU=dSdU-force;
|
|
|
|
DenOp.MDeriv(force,X,Y,DaggerYes); dSdU=dSdU-force;
|
2015-08-18 10:37:08 +01:00
|
|
|
|
2016-07-04 16:17:28 +01:00
|
|
|
dSdU *= -1.0;
|
|
|
|
//dSdU = - Ta(dSdU);
|
2015-08-18 09:19:42 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|