mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-10 19:36:56 +01:00
Integrator works now
This commit is contained in:
@ -77,7 +77,8 @@ template <class Impl>
|
||||
class LaplacianAdjointField: public Metric<typename Impl::Field> {
|
||||
OperatorFunction<typename Impl::Field> &Solver;
|
||||
LaplacianParams param;
|
||||
MultiShiftFunction PowerNegHalf;
|
||||
MultiShiftFunction PowerHalf;
|
||||
MultiShiftFunction PowerInvHalf;
|
||||
|
||||
public:
|
||||
INHERIT_GIMPL_TYPES(Impl);
|
||||
@ -87,10 +88,15 @@ class LaplacianAdjointField: public Metric<typename Impl::Field> {
|
||||
AlgRemez remez(param.lo,param.hi,param.precision);
|
||||
std::cout<<GridLogMessage << "Generating degree "<<param.degree<<" for x^(1/2)"<<std::endl;
|
||||
remez.generateApprox(param.degree,1,2);
|
||||
PowerNegHalf.Init(remez,param.tolerance,true);
|
||||
PowerHalf.Init(remez,param.tolerance,false);
|
||||
PowerInvHalf.Init(remez,param.tolerance,true);
|
||||
|
||||
|
||||
};
|
||||
|
||||
void Mdir(const GaugeField&, GaugeField&, int, int){ assert(0);}
|
||||
void Mdiag(const GaugeField&, GaugeField&){ assert(0);}
|
||||
|
||||
void ImportGauge(const GaugeField& _U) {
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
U[mu] = PeekIndex<LorentzIndex>(_U, mu);
|
||||
@ -98,6 +104,11 @@ class LaplacianAdjointField: public Metric<typename Impl::Field> {
|
||||
}
|
||||
|
||||
void M(const GaugeField& in, GaugeField& out) {
|
||||
// in is an antihermitian matrix
|
||||
// test
|
||||
//GaugeField herm = in + adj(in);
|
||||
//std::cout << "AHermiticity: " << norm2(herm) << std::endl;
|
||||
|
||||
GaugeLinkField tmp(in._grid);
|
||||
GaugeLinkField tmp2(in._grid);
|
||||
GaugeLinkField sum(in._grid);
|
||||
@ -116,17 +127,21 @@ class LaplacianAdjointField: public Metric<typename Impl::Field> {
|
||||
}
|
||||
}
|
||||
|
||||
void MDeriv(const GaugeField& in, GaugeField& der, bool dag) {
|
||||
void MDeriv(const GaugeField& in, GaugeField& der) {
|
||||
// in is anti-hermitian
|
||||
RealD factor = -kappa / (double(4 * Nd));
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
GaugeLinkField in_mu = PeekIndex<LorentzIndex>(in, mu);
|
||||
|
||||
for (int mu = 0; mu < Nd; mu++){
|
||||
GaugeLinkField der_mu(der._grid);
|
||||
if (!dag)
|
||||
der_mu =
|
||||
factor * Cshift(in_mu, mu, +1) * adj(U[mu]) + adj(U[mu]) * in_mu;
|
||||
else
|
||||
der_mu = factor * U[mu] * Cshift(in_mu, mu, +1) + in_mu * U[mu];
|
||||
}
|
||||
der_mu = zero;
|
||||
for (int nu = 0; nu < Nd; nu++){
|
||||
GaugeLinkField in_nu = PeekIndex<LorentzIndex>(in, nu);
|
||||
der_mu += U[mu] * Cshift(in_nu, mu, 1) * adj(U[mu]) * in_nu;
|
||||
}
|
||||
// the minus sign comes by using the in_nu instead of the
|
||||
// adjoint in the last multiplication
|
||||
PokeIndex<LorentzIndex>(der, -2.0 * factor * der_mu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
void Minv(const GaugeField& in, GaugeField& inverted){
|
||||
@ -134,14 +149,12 @@ class LaplacianAdjointField: public Metric<typename Impl::Field> {
|
||||
Solver(HermOp, in, inverted);
|
||||
}
|
||||
|
||||
void MInvSquareRoot(GaugeField& P){
|
||||
// Takes a gaussian gauge field and multiplies by the metric
|
||||
// need the rational approximation for the square root
|
||||
void MSquareRoot(GaugeField& P){
|
||||
GaugeField Gp(P._grid);
|
||||
HermitianLinearOperator<LaplacianAdjointField<Impl>,GaugeField> HermOp(*this);
|
||||
ConjugateGradientMultiShift<GaugeField> msCG(param.MaxIter,PowerNegHalf);
|
||||
ConjugateGradientMultiShift<GaugeField> msCG(param.MaxIter,PowerHalf);
|
||||
msCG(HermOp,P,Gp);
|
||||
P = Gp; // now P has the correct distribution
|
||||
P = Gp;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,8 @@ public:
|
||||
virtual void ImportGauge(const Field&) = 0;
|
||||
virtual void M(const Field&, Field&) = 0;
|
||||
virtual void Minv(const Field&, Field&) = 0;
|
||||
virtual void MInvSquareRoot(Field&) = 0;
|
||||
virtual void MSquareRoot(Field&) = 0;
|
||||
virtual void MDeriv(const Field&, Field&) = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -54,9 +55,12 @@ public:
|
||||
virtual void Minv(const Field& in, Field& out){
|
||||
out = in;
|
||||
}
|
||||
virtual void MInvSquareRoot(Field& P){
|
||||
virtual void MSquareRoot(Field& P){
|
||||
// do nothing
|
||||
}
|
||||
virtual void MDeriv(const Field& in, Field& out){
|
||||
out = zero;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -64,17 +68,17 @@ public:
|
||||
// Generalised momenta
|
||||
///////////////////////////////
|
||||
|
||||
template <typename Implementation, typename Metric>
|
||||
template <typename Implementation>
|
||||
class GeneralisedMomenta{
|
||||
public:
|
||||
typedef typename Implementation::Field MomentaField; //for readability
|
||||
|
||||
Metric M;
|
||||
typedef typename Implementation::GaugeLinkField MomentaLinkField; //for readability
|
||||
Metric<MomentaField>& M;
|
||||
MomentaField Mom;
|
||||
|
||||
GeneralisedMomenta(GridBase* grid): Mom(grid){}
|
||||
|
||||
GeneralisedMomenta(GridBase* grid, Metric<MomentaField>& M): M(M), Mom(grid){}
|
||||
|
||||
// Correct
|
||||
void MomentaDistribution(GridParallelRNG& pRNG){
|
||||
// Generate a distribution for
|
||||
// 1/2 P^dag G P
|
||||
@ -83,26 +87,45 @@ public:
|
||||
// Generate gaussian momenta
|
||||
Implementation::generate_momenta(Mom, pRNG);
|
||||
// Modify the distribution with the metric
|
||||
M.MInvSquareRoot(Mom);
|
||||
M.MSquareRoot(Mom);
|
||||
}
|
||||
|
||||
void Derivative(MomentaField& in, MomentaField& der){
|
||||
// Correct
|
||||
RealD MomentaAction(){
|
||||
MomentaField inv(Mom._grid);
|
||||
inv = zero;
|
||||
M.Minv(Mom, inv);
|
||||
LatticeComplex Hloc(Mom._grid);
|
||||
Hloc = zero;
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
// This is not very general
|
||||
// hide in the operators
|
||||
auto Mom_mu = PeekIndex<LorentzIndex>(Mom, mu);
|
||||
auto inv_mu = PeekIndex<LorentzIndex>(inv, mu);
|
||||
Hloc += trace(Mom_mu * inv_mu);
|
||||
}
|
||||
Complex Hsum = sum(Hloc);
|
||||
return Hsum.real();
|
||||
}
|
||||
|
||||
// Correct
|
||||
void DerivativeU(MomentaField& in, MomentaField& der){
|
||||
// Compute the derivative of the kinetic term
|
||||
// with respect to the gauge field
|
||||
MomentaField MomDer(in._grid);
|
||||
MomentaField MDer(in._grid);
|
||||
MomentaField X(in._grid);
|
||||
|
||||
M.Minv(in, X); // X = G in
|
||||
M.MDeriv(X, MomDer, DaggerNo); // MomDer = dM/dU X
|
||||
// MomDer is just the derivative
|
||||
MomDer = adj(X)* MomDer;
|
||||
// Traceless Antihermitian
|
||||
// assuming we are in the algebra
|
||||
der = Implementation::projectForce(MomDer);
|
||||
X = zero;
|
||||
M.Minv(in, X); // X = G in
|
||||
M.MDeriv(X, MDer); // MDer = U * dS/dU
|
||||
der = Implementation::projectForce(MDer); // Ta if gauge fields
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
void DerivativeP(MomentaField& der){
|
||||
der = zero;
|
||||
M.Minv(Mom, der);
|
||||
der = Implementation::projectForce(der);
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user