mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 20:57:06 +01:00
Integrator works now
This commit is contained in:
178
tests/forces/Test_laplacian_force.cc
Normal file
178
tests/forces/Test_laplacian_force.cc
Normal file
@ -0,0 +1,178 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_rect_force.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Azusa Yamaguchi <ayamaguc@staffmail.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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
#define parallel_for PARALLEL_FOR_LOOP for
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
Grid_init(&argc,&argv);
|
||||
|
||||
std::vector<int> latt_size = GridDefaultLatt();
|
||||
std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd());
|
||||
std::vector<int> mpi_layout = GridDefaultMpi();
|
||||
|
||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||
GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout);
|
||||
|
||||
int threads = GridThread::GetThreads();
|
||||
std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl;
|
||||
|
||||
std::vector<int> seeds({1,2,3,4});
|
||||
|
||||
GridParallelRNG pRNG(&Grid);
|
||||
pRNG.SeedRandomDevice();
|
||||
|
||||
LatticeGaugeField U(&Grid);
|
||||
LatticeGaugeField P(&Grid);
|
||||
LatticeColourMatrix P_mu(&Grid);
|
||||
// Matrix in the algebra
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
SU<Nc>::GaussianFundamentalLieAlgebraMatrix(pRNG, P_mu);
|
||||
PokeIndex<LorentzIndex>(P, P_mu, mu);
|
||||
}
|
||||
|
||||
SU3::HotConfiguration(pRNG,U);
|
||||
|
||||
|
||||
ConjugateGradient<LatticeGaugeField> CG(1.0e-8, 10000);
|
||||
LaplacianParams LapPar(0.001, 1.0, 1000, 1e-8, 10, 64);
|
||||
RealD Kappa = 0.99;
|
||||
LaplacianAdjointField<PeriodicGimplR> Laplacian(&Grid, CG, LapPar, Kappa);
|
||||
GeneralisedMomenta<PeriodicGimplR> LaplacianMomenta(&Grid, Laplacian);
|
||||
LaplacianMomenta.M.ImportGauge(U);
|
||||
LaplacianMomenta.MomentaDistribution(pRNG);// fills the Momenta with the correct distr
|
||||
|
||||
|
||||
std::cout << std::setprecision(15);
|
||||
std::cout << GridLogMessage << "MomentaAction" << std::endl;
|
||||
ComplexD S = LaplacianMomenta.MomentaAction();
|
||||
|
||||
// get the deriv with respect to "U"
|
||||
LatticeGaugeField UdSdU(&Grid);
|
||||
std::cout << GridLogMessage<< "DerivativeU" << std::endl;
|
||||
LaplacianMomenta.DerivativeU(LaplacianMomenta.Mom, UdSdU);
|
||||
|
||||
|
||||
////////////////////////////////////
|
||||
// Modify the gauge field a little
|
||||
////////////////////////////////////
|
||||
RealD dt = 0.001;
|
||||
|
||||
LatticeColourMatrix mommu(&Grid);
|
||||
LatticeColourMatrix forcemu(&Grid);
|
||||
LatticeGaugeField mom(&Grid);
|
||||
LatticeGaugeField Uprime(&Grid);
|
||||
|
||||
std::cout << GridLogMessage << "Update the U " << std::endl;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
// Traceless antihermitian momentum; gaussian in lie algebra
|
||||
SU3::GaussianFundamentalLieAlgebraMatrix(pRNG, mommu);
|
||||
auto Umu = PeekIndex<LorentzIndex>(U, mu);
|
||||
PokeIndex<LorentzIndex>(mom,mommu,mu);
|
||||
Umu = expMat(mommu, dt, 12) * Umu;
|
||||
PokeIndex<LorentzIndex>(Uprime, ProjectOnGroup(Umu), mu);
|
||||
|
||||
}
|
||||
|
||||
std::cout << GridLogMessage << "New action " << std::endl;
|
||||
LaplacianMomenta.M.ImportGauge(Uprime);
|
||||
ComplexD Sprime = LaplacianMomenta.MomentaAction();
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Use derivative to estimate dS
|
||||
//////////////////////////////////////////////
|
||||
|
||||
LatticeComplex dS(&Grid); dS = zero;
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
auto UdSdUmu = PeekIndex<LorentzIndex>(UdSdU,mu);
|
||||
mommu = PeekIndex<LorentzIndex>(mom,mu);
|
||||
|
||||
// Update gauge action density
|
||||
// U = exp(p dt) U
|
||||
// dU/dt = p U
|
||||
// so dSdt = trace( dUdt dSdU) = trace( p UdSdUmu )
|
||||
|
||||
dS = dS + trace(mommu*UdSdUmu)*dt*2.0;
|
||||
}
|
||||
|
||||
Complex dSpred = sum(dS);
|
||||
|
||||
std::cout << GridLogMessage << " S "<<S<<std::endl;
|
||||
std::cout << GridLogMessage << " Sprime "<<Sprime<<std::endl;
|
||||
std::cout << GridLogMessage << "dS "<<Sprime-S<<std::endl;
|
||||
std::cout << GridLogMessage << "pred dS "<< dSpred <<std::endl;
|
||||
|
||||
|
||||
// P derivative
|
||||
// Increment p
|
||||
dt = 0.0001;
|
||||
LaplacianMomenta.M.ImportGauge(U);
|
||||
LatticeGaugeField UdSdP(&Grid);
|
||||
LaplacianMomenta.DerivativeP(UdSdP);
|
||||
|
||||
|
||||
LaplacianMomenta.Mom += dt*P;
|
||||
|
||||
Sprime = LaplacianMomenta.MomentaAction();
|
||||
|
||||
// Prediciton
|
||||
|
||||
dS = zero;
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
auto dSdPmu = PeekIndex<LorentzIndex>(UdSdP,mu);
|
||||
auto Pmu = PeekIndex<LorentzIndex>(P,mu);
|
||||
// Update gauge action density
|
||||
//
|
||||
// dMom/dt = P
|
||||
// so dSdt = trace( dPdt dSdP) = trace( P dSdP )
|
||||
|
||||
dS = dS + trace(Pmu*dSdPmu)*dt*2.0;
|
||||
}
|
||||
dSpred = sum(dS);
|
||||
|
||||
std::cout << GridLogMessage << " S "<<S<<std::endl;
|
||||
std::cout << GridLogMessage << " Sprime "<<Sprime<<std::endl;
|
||||
std::cout << GridLogMessage << "dS "<<Sprime-S<<std::endl;
|
||||
std::cout << GridLogMessage << "pred dS "<< dSpred <<std::endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::cout<< GridLogMessage << "Done" <<std::endl;
|
||||
Grid_finalize();
|
||||
}
|
97
tests/hmc/Test_hmc_WilsonGauge_Implicit.cc
Normal file
97
tests/hmc/Test_hmc_WilsonGauge_Implicit.cc
Normal file
@ -0,0 +1,97 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: ./tests/Test_hmc_WilsonFermionGauge.cc
|
||||
|
||||
Copyright (C) 2015
|
||||
|
||||
Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
|
||||
Author: neo <cossu@post.kek.jp>
|
||||
Author: Guido Cossu <guido.cossu@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 */
|
||||
#include <Grid/Grid.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
using namespace Grid;
|
||||
using namespace Grid::QCD;
|
||||
|
||||
Grid_init(&argc, &argv);
|
||||
int threads = GridThread::GetThreads();
|
||||
// here make a routine to print all the relevant information on the run
|
||||
std::cout << GridLogMessage << "Grid is setup to use " << threads << " threads" << std::endl;
|
||||
|
||||
// Typedefs to simplify notation
|
||||
typedef GenericHMCRunner<ImplicitLeapFrog> HMCWrapper; // Uses the default minimum norm
|
||||
HMCWrapper TheHMC;
|
||||
|
||||
// Grid from the command line
|
||||
TheHMC.Resources.AddFourDimGrid("gauge");
|
||||
// Possibile to create the module by hand
|
||||
// hardcoding parameters or using a Reader
|
||||
|
||||
|
||||
// Checkpointer definition
|
||||
CheckpointerParameters CPparams;
|
||||
CPparams.config_prefix = "ckpoint_lat";
|
||||
CPparams.rng_prefix = "ckpoint_rng";
|
||||
CPparams.saveInterval = 20;
|
||||
CPparams.format = "IEEE64BIG";
|
||||
|
||||
TheHMC.Resources.LoadBinaryCheckpointer(CPparams);
|
||||
|
||||
RNGModuleParameters RNGpar;
|
||||
RNGpar.serial_seeds = "1 2 3 4 5";
|
||||
RNGpar.parallel_seeds = "6 7 8 9 10 12";
|
||||
TheHMC.Resources.SetRNGSeeds(RNGpar);
|
||||
|
||||
// Construct observables
|
||||
// here there is too much indirection
|
||||
PlaquetteObsParameters PlPar;
|
||||
PlPar.output_prefix = "Plaquette";
|
||||
PlaquetteMod<HMCWrapper::ImplPolicy> PlaqModule(PlPar);
|
||||
TheHMC.Resources.AddObservable(&PlaqModule);
|
||||
//////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Collect actions, here use more encapsulation
|
||||
// need wrappers of the fermionic classes
|
||||
// that have a complex construction
|
||||
// standard
|
||||
RealD beta = 5.6;
|
||||
WilsonGaugeActionR Waction(beta);
|
||||
|
||||
ActionLevel<HMCWrapper::Field> Level1(1);
|
||||
Level1.push_back(&Waction);
|
||||
//Level1.push_back(WGMod.getPtr());
|
||||
TheHMC.TheAction.push_back(Level1);
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
// HMC parameters are serialisable
|
||||
TheHMC.Parameters.MD.MDsteps = 60;
|
||||
TheHMC.Parameters.MD.trajL = 1.0;
|
||||
|
||||
TheHMC.ReadCommandLine(argc, argv); // these can be parameters from file
|
||||
TheHMC.Run(); // no smearing
|
||||
|
||||
Grid_finalize();
|
||||
|
||||
} // main
|
@ -70,13 +70,13 @@ int main (int argc, char ** argv)
|
||||
LatticeColourMatrix src_mu(&Grid);
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
SU<Nc>::GaussianFundamentalLieAlgebraMatrix(pRNG, src_mu);
|
||||
PokeIndex<LorentzIndex>(src_f, src_mu, mu);
|
||||
PokeIndex<LorentzIndex>(src_f, timesI(src_mu), mu);
|
||||
}
|
||||
LatticeGaugeField result_f(&Grid);
|
||||
|
||||
// Definition of the Laplacian operator
|
||||
ConjugateGradient<LatticeGaugeField> CG(1.0e-8,10000);
|
||||
LaplacianParams LapPar(0.001, 1.0, 1000, 1e-8, 10, 64);
|
||||
LaplacianParams LapPar(0.00001, 1.0, 1000, 1e-8, 10, 64);
|
||||
LaplacianAdjointField<PeriodicGimplR> Laplacian(&Grid, CG, LapPar, Kappa);
|
||||
Laplacian.ImportGauge(Umu);
|
||||
std::cout << GridLogMessage << "Testing the Laplacian using the full matrix" <<std::endl;
|
||||
@ -84,7 +84,7 @@ int main (int argc, char ** argv)
|
||||
|
||||
|
||||
|
||||
Laplacian.MomentaDistribution(src_f);
|
||||
Laplacian.MSquareRoot(src_f);
|
||||
|
||||
|
||||
// Tests also the version using the algebra decomposition
|
||||
|
Reference in New Issue
Block a user