mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-01 04:24:32 +00:00 
			
		
		
		
	Working on the 5d
This commit is contained in:
		| @@ -1,10 +1,10 @@ | |||||||
|     /************************************************************************************* | /************************************************************************************* | ||||||
|  |  | ||||||
|     Grid physics library, www.github.com/paboyle/Grid  | Grid physics library, www.github.com/paboyle/Grid | ||||||
|  |  | ||||||
|     Source file: ./lib/qcd/QCD.h | Source file: ./lib/qcd/QCD.h | ||||||
|  |  | ||||||
|     Copyright (C) 2015 | Copyright (C) 2015 | ||||||
|  |  | ||||||
| Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk> | Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk> | ||||||
| Author: Peter Boyle <paboyle@ph.ed.ac.uk> | Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||||
| @@ -12,28 +12,30 @@ Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local> | |||||||
| Author: neo <cossu@post.kek.jp> | Author: neo <cossu@post.kek.jp> | ||||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | Author: paboyle <paboyle@ph.ed.ac.uk> | ||||||
|  |  | ||||||
|     This program is free software; you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by | ||||||
|     the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | ||||||
|     (at your option) any later version. | (at your option) any later version. | ||||||
|  |  | ||||||
|     This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|     GNU General Public License for more details. | GNU General Public License for more details. | ||||||
|  |  | ||||||
|     You should have received a copy of the GNU General Public License along | 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., | with this program; if not, write to the Free Software Foundation, Inc., | ||||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
|  |  | ||||||
|     See the full license in the file "LICENSE" in the top level distribution directory | See the full license in the file "LICENSE" in the top level distribution | ||||||
|     *************************************************************************************/ | directory | ||||||
|     /*  END LEGAL */ | *************************************************************************************/ | ||||||
|  | /*  END LEGAL */ | ||||||
| #ifndef GRID_LT_H | #ifndef GRID_LT_H | ||||||
| #define GRID_LT_H | #define GRID_LT_H | ||||||
| namespace Grid{ | namespace Grid{ | ||||||
|  |  | ||||||
| // First steps in the complete generalization of the Physics part | // First steps in the complete generalization of the Physics part | ||||||
|  | // Design not final | ||||||
| namespace LatticeTheories { | namespace LatticeTheories { | ||||||
|  |  | ||||||
| template <int Dimensions> | template <int Dimensions> | ||||||
| @@ -50,7 +52,7 @@ struct LatticeGaugeTheory : public LatticeTheory<Dimensions> { | |||||||
|   static const int Nd = Dimensions; |   static const int Nd = Dimensions; | ||||||
|   static const int Nc = Colours; |   static const int Nc = Colours; | ||||||
|  |  | ||||||
|   template <typename vtype> |   template <typename vtype>  | ||||||
|   using iColourMatrix = iScalar<iScalar<iMatrix<vtype, Nc> > >; |   using iColourMatrix = iScalar<iScalar<iMatrix<vtype, Nc> > >; | ||||||
|   template <typename vtype> |   template <typename vtype> | ||||||
|   using iLorentzColourMatrix = iVector<iScalar<iMatrix<vtype, Nc> >, Nd>; |   using iLorentzColourMatrix = iVector<iScalar<iMatrix<vtype, Nc> >, Nd>; | ||||||
| @@ -82,6 +84,13 @@ struct FermionicLatticeGaugeTheory | |||||||
|   using iHalfSpinVector = iScalar<iVector<iScalar<vtype>, Nhs> >; |   using iHalfSpinVector = iScalar<iVector<iScalar<vtype>, Nhs> >; | ||||||
|   template <typename vtype> |   template <typename vtype> | ||||||
|   using iHalfSpinColourVector = iScalar<iVector<iVector<vtype, Nc>, Nhs> >; |   using iHalfSpinColourVector = iScalar<iVector<iVector<vtype, Nc>, Nhs> >; | ||||||
|  |  | ||||||
|  |   //tests | ||||||
|  |   typedef iColourMatrix<Complex> ColourMatrix; | ||||||
|  |   typedef iColourMatrix<ComplexF> ColourMatrixF; | ||||||
|  |   typedef iColourMatrix<ComplexD> ColourMatrixD; | ||||||
|  |  | ||||||
|  |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // Examples, not complete now. | // Examples, not complete now. | ||||||
| @@ -97,10 +106,6 @@ struct QCD : public FermionicLatticeGaugeTheory<4, 3, 4> { | |||||||
|  |  | ||||||
|     typedef FermionicLatticeGaugeTheory FLGT; |     typedef FermionicLatticeGaugeTheory FLGT; | ||||||
|  |  | ||||||
|     typedef FLGT::iColourMatrix<Complex  >        ColourMatrix; |  | ||||||
|     typedef FLGT::iColourMatrix<ComplexF >        ColourMatrixF; |  | ||||||
|     typedef FLGT::iColourMatrix<ComplexD >        ColourMatrixD; |  | ||||||
|  |  | ||||||
|     typedef FLGT::iSpinMatrix<Complex  >          SpinMatrix; |     typedef FLGT::iSpinMatrix<Complex  >          SpinMatrix; | ||||||
|     typedef FLGT::iSpinMatrix<ComplexF >          SpinMatrixF; |     typedef FLGT::iSpinMatrix<ComplexF >          SpinMatrixF; | ||||||
|     typedef FLGT::iSpinMatrix<ComplexD >          SpinMatrixD; |     typedef FLGT::iSpinMatrix<ComplexD >          SpinMatrixD; | ||||||
|   | |||||||
| @@ -46,7 +46,7 @@ namespace QCD { | |||||||
|  |  | ||||||
|     static const int Nc=3; |     static const int Nc=3; | ||||||
|     static const int Ns=4; |     static const int Ns=4; | ||||||
|     static const int Nd=4; |     static const int Nd=5; | ||||||
|     static const int Nhs=2; // half spinor |     static const int Nhs=2; // half spinor | ||||||
|     static const int Nds=8; // double stored gauge field |     static const int Nds=8; // double stored gauge field | ||||||
|     static const int Ngp=2; // gparity index range |     static const int Ngp=2; // gparity index range | ||||||
|   | |||||||
| @@ -76,7 +76,7 @@ class WilsonGaugeAction : public Action<typename Gimpl::GaugeField> { | |||||||
|       // Staple in direction mu |       // Staple in direction mu | ||||||
|       WilsonLoops<Gimpl>::Staple(dSdU_mu, U, mu); |       WilsonLoops<Gimpl>::Staple(dSdU_mu, U, mu); | ||||||
|       dSdU_mu = Ta(Umu * dSdU_mu) * factor; |       dSdU_mu = Ta(Umu * dSdU_mu) * factor; | ||||||
|        |  | ||||||
|       PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu); |       PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu); | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| @@ -88,57 +88,70 @@ class VariableWilsonGaugeAction : public Action<typename Gimpl::GaugeField> { | |||||||
|   INHERIT_GIMPL_TYPES(Gimpl); |   INHERIT_GIMPL_TYPES(Gimpl); | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   std::vector<RealD> b_bulk;// bulk couplings |   std::vector<RealD> b_bulk;  // bulk couplings | ||||||
|   std::vector<RealD> b_xdim;//extra dimension couplings |   std::vector<RealD> b_xdim;  // extra dimension couplings | ||||||
|   GridBase *grid; |   GridBase *grid; | ||||||
|   LatticeComplex beta_xdim; |   LatticeComplex beta_xdim; | ||||||
|   LatticeComplex beta_xdim_shifted; |   LatticeComplex beta_xdim_shifted; | ||||||
|   LatticeComplex beta_bulk; |   LatticeComplex beta_bulk; | ||||||
|  |  | ||||||
|  |   int bulk_volume; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   VariableWilsonGaugeAction(std::vector<RealD> bulk, std::vector<RealD> xdim, |   VariableWilsonGaugeAction(std::vector<RealD> bulk, std::vector<RealD> xdim, | ||||||
|                             GridBase *_grid) |                             GridBase *_grid, bool openBC = false) | ||||||
|       : b_bulk(bulk), |       : b_bulk(bulk), | ||||||
|         b_xdim(xdim), |         b_xdim(xdim), | ||||||
|         grid(_grid), |         grid(_grid), | ||||||
|         beta_xdim(grid), |         beta_xdim(grid), | ||||||
|         beta_xdim_shifted(grid), |         beta_xdim_shifted(grid), | ||||||
|         beta_bulk(grid) |         beta_bulk(grid) { | ||||||
|         { |     // check that the grid is ok | ||||||
|           //check that the grid is ok |     // todo | ||||||
|           //todo |     int Ndim = Nd;  // change later | ||||||
|           int Ndim = Nd;//change later |  | ||||||
|  |  | ||||||
|           LatticeComplex temp(grid); |     std::vector<int> FullDim = grid->GlobalDimensions(); | ||||||
|  |     bulk_volume = 1; | ||||||
|  |     for (int s = 0; s < Ndim - 1; s++) bulk_volume *= FullDim[s]; | ||||||
|  |  | ||||||
|           Lattice<iScalar<vInteger> > coor(grid); |     LatticeComplex temp(grid); | ||||||
|  |  | ||||||
|           LatticeCoordinate(coor, Ndim - 1); |     Lattice<iScalar<vInteger> > coor(grid); | ||||||
|  |  | ||||||
|           int Nex = grid->_fdimensions[Ndim - 1]; |     LatticeCoordinate(coor, Ndim - 1); | ||||||
|           assert(b_bulk.size() == Nex); |  | ||||||
|           assert(b_xdim.size() == Nex); |  | ||||||
|  |  | ||||||
|           beta_xdim = zero; |     int Nex = FullDim[Ndim - 1]; | ||||||
|           for (int tau = 0; tau < Nex; tau++) { |     assert(b_bulk.size() == Nex); | ||||||
|             temp = b_xdim[tau]; |     assert(b_xdim.size() == Nex); | ||||||
|             beta_xdim = where(coor == tau, temp, beta_xdim); |  | ||||||
|           } |  | ||||||
|  |  | ||||||
|           beta_xdim_shifted = Cshift(beta_xdim, Ndim - 1, -1); |     beta_xdim = zero; | ||||||
|  |     for (int tau = 0; tau < Nex - 1; tau++) { | ||||||
|  |       temp = b_xdim[tau]; | ||||||
|  |       beta_xdim = where(coor == tau, temp, beta_xdim); | ||||||
|  |     } | ||||||
|  |  | ||||||
|           beta_bulk = zero; |     if (!openBC) { | ||||||
|           for (int tau = 0; tau < Nex; tau++) { |       temp = b_xdim[Nex - 1]; | ||||||
|             temp = b_bulk[tau]; |       beta_xdim = where(coor == Nex - 1, temp, beta_xdim); | ||||||
|             beta_bulk = where(coor == tau, temp, beta_bulk); |     } | ||||||
|           } |  | ||||||
|         }; |     beta_xdim_shifted = Cshift(beta_xdim, Ndim - 1, -1); | ||||||
|  |  | ||||||
|  |     beta_bulk = zero; | ||||||
|  |     for (int tau = 0; tau < Nex; tau++) { | ||||||
|  |       temp = b_bulk[tau]; | ||||||
|  |       beta_bulk = where(coor == tau, temp, beta_bulk); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     std::cout << beta_xdim << std::endl; | ||||||
|  |     std::cout << beta_xdim_shifted << std::endl; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|   virtual void refresh(const GaugeField &U, |   virtual void refresh(const GaugeField &U, | ||||||
|                        GridParallelRNG &pRNG){};  // noop as no pseudoferms |                        GridParallelRNG &pRNG){};  // noop as no pseudoferms | ||||||
|  |  | ||||||
|   virtual RealD S(const GaugeField &Umu) { |   virtual RealD S(const GaugeField &Umu) { | ||||||
|     int Ndim = Nd; // change later for generality |     int Ndim = Nd;  // change later for generality | ||||||
|     conformable(grid, Umu._grid); |     conformable(grid, Umu._grid); | ||||||
|  |  | ||||||
|     std::vector<GaugeLinkField> U(Ndim, grid); |     std::vector<GaugeLinkField> U(Ndim, grid); | ||||||
| @@ -150,19 +163,34 @@ class VariableWilsonGaugeAction : public Action<typename Gimpl::GaugeField> { | |||||||
|     LatticeComplex dirPlaq(grid); |     LatticeComplex dirPlaq(grid); | ||||||
|     LatticeComplex Plaq(grid); |     LatticeComplex Plaq(grid); | ||||||
|  |  | ||||||
|  |     LatticeComplex SumdirPlaq(grid); | ||||||
|  |  | ||||||
|     RealD OneOnNc = 1.0 / Real(Nc); |     RealD OneOnNc = 1.0 / Real(Nc); | ||||||
|  |  | ||||||
|     ///////////// |     ///////////// | ||||||
|     // Lower dim plaquettes |     // Lower dim plaquettes | ||||||
|     ///////////// |     ///////////// | ||||||
|     Plaq = zero; |     Plaq = zero; | ||||||
|  |     SumdirPlaq = zero; | ||||||
|     for (int mu = 1; mu < Ndim - 1; mu++) { |     for (int mu = 1; mu < Ndim - 1; mu++) { | ||||||
|       for (int nu = 0; nu < mu; nu++) { |       for (int nu = 0; nu < mu; nu++) { | ||||||
|         WilsonLoops<Gimpl>::traceDirPlaquette(dirPlaq, U, mu, nu); |         WilsonLoops<Gimpl>::traceDirPlaquette(dirPlaq, U, mu, nu); | ||||||
|  |         SumdirPlaq += dirPlaq; | ||||||
|         Plaq = Plaq + (1.0 - dirPlaq * OneOnNc) * beta_bulk; |         Plaq = Plaq + (1.0 - dirPlaq * OneOnNc) * beta_bulk; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     double faces = (1.0 * (Nd - 1) * (Nd - 2)) / 2.0; | ||||||
|  |     SumdirPlaq *= OneOnNc / (RealD(bulk_volume) * faces); | ||||||
|  |  | ||||||
|  |     // print slices in the extra dimension | ||||||
|  |     int Nex = grid->_fdimensions[Ndim - 1]; | ||||||
|  |     std::vector<TComplex> plaq_ex(Nex); | ||||||
|  |     sliceSum(SumdirPlaq, plaq_ex, Ndim - 1); | ||||||
|  |     for (int ex = 0; ex < Nex; ex++) | ||||||
|  |       std::cout << GridLogMessage << "Bulk plaq[" << ex | ||||||
|  |                 << "] = " << TensorRemove(plaq_ex[ex]).real() << std::endl; | ||||||
|  |  | ||||||
|     ///////////// |     ///////////// | ||||||
|     // Extra dimension |     // Extra dimension | ||||||
|     ///////////// |     ///////////// | ||||||
| @@ -186,74 +214,66 @@ class VariableWilsonGaugeAction : public Action<typename Gimpl::GaugeField> { | |||||||
|  |  | ||||||
|     // for the higher dimension plaquettes take the upper plaq of the |     // for the higher dimension plaquettes take the upper plaq of the | ||||||
|     // 4d slice and multiply by beta[s] and the lower and multiply by beta[s-1] |     // 4d slice and multiply by beta[s] and the lower and multiply by beta[s-1] | ||||||
|     // todo |  | ||||||
|     // derivative of links mu = 0, ... Nd-1 inside plaq (mu,5) |     // derivative of links mu = 0, ... Nd-1 inside plaq (mu,5) | ||||||
|     // for these I need upper and lower staples separated |     // for these I need upper and lower staples separated | ||||||
|     // each multiplied with their own beta |     // each multiplied with their own beta | ||||||
|     // derivative of links mu = 5 |     // derivative of links mu = 5 | ||||||
|     // living on the same slice, share the same beta |     // living on the same slice, share the same beta | ||||||
|  |  | ||||||
|  |     conformable(grid, U._grid); | ||||||
|  |     int Ndim = Nd;  // change later | ||||||
|  |     RealD factor = 0.5 / RealD(Nc); | ||||||
|  |  | ||||||
| conformable(grid,U._grid); |     GaugeLinkField Umu(grid); | ||||||
| int Ndim = Nd;  // change later |     GaugeLinkField dSdU_mu(grid); | ||||||
| RealD factor = 0.5 / RealD(Nc); |     GaugeLinkField staple(grid); | ||||||
|  |  | ||||||
| GaugeLinkField Umu(grid); |     for (int mu = 0; mu < Ndim; mu++) { | ||||||
| GaugeLinkField dSdU_mu(grid); |       Umu = PeekIndex<LorentzIndex>(U, mu); | ||||||
| GaugeLinkField staple(grid); |       dSdU_mu = zero; | ||||||
|  |  | ||||||
| for (int mu = 0; mu < Ndim; mu++) { |       for (int nu = 0; nu < Ndim; nu++) { | ||||||
|   Umu = PeekIndex<LorentzIndex>(U, mu); |         if (nu != mu) { | ||||||
|   dSdU_mu = zero; |           if ((mu < (Ndim - 1)) && (nu < (Ndim - 1))) { | ||||||
|  |             // Spacelike case apply beta space | ||||||
|  |             WilsonLoops<Gimpl>::Staple(staple, U, mu, nu); | ||||||
|  |             staple = staple * beta_bulk; | ||||||
|  |             dSdU_mu += staple; | ||||||
|  |  | ||||||
|   for (int nu = 0; nu < Ndim; nu++) { |           } else if (mu == (Ndim - 1)) { | ||||||
|     if (nu != mu) { |             // nu space; mu time link | ||||||
|       if ((mu < (Ndim - 1)) && (nu < (Ndim - 1))) { |             assert(nu < (Ndim - 1)); | ||||||
|         // Spacelike case apply beta space |             assert(mu == (Ndim - 1)); | ||||||
|         WilsonLoops<Gimpl>::Staple(staple, U, mu, nu); |  | ||||||
|         staple = staple * beta_bulk; |  | ||||||
|         dSdU_mu += staple; |  | ||||||
|  |  | ||||||
|       } else if (mu == (Ndim - 1)) { |             // mu==tau dir link deriv, nu spatial | ||||||
|         // nu space; mu time link |             WilsonLoops<Gimpl>::Staple(staple, U, mu, nu); | ||||||
|         assert(nu < (Ndim - 1)); |             staple = staple * beta_xdim; | ||||||
|         assert(mu == (Ndim - 1)); |             dSdU_mu += staple; | ||||||
|  |  | ||||||
|         // mu==tau dir link deriv, nu spatial |           } else { | ||||||
|         WilsonLoops<Gimpl>::Staple(staple, U, mu, nu); |             assert(mu < (Ndim - 1)); | ||||||
|         staple = staple * beta_xdim; |             assert(nu == (Ndim - 1)); | ||||||
|         dSdU_mu += staple; |  | ||||||
|  |  | ||||||
|       } else { |             // nu time; mu space link | ||||||
|         assert(mu < (Ndim - 1)); |  | ||||||
|         assert(nu == (Ndim - 1)); |  | ||||||
|  |  | ||||||
|         // nu time; mu space link |             // staple forwards in tau | ||||||
|  |             WilsonLoops<Gimpl>::StapleUpper(staple, U, mu, nu); | ||||||
|  |             staple = staple * beta_xdim; | ||||||
|  |             dSdU_mu += staple; | ||||||
|  |  | ||||||
|         // staple forwards in tau |             // staple backwards in tau | ||||||
|         WilsonLoops<Gimpl>::StapleUpper(staple, U, mu, nu); |             WilsonLoops<Gimpl>::StapleLower(staple, U, mu, nu); | ||||||
|         staple = staple * beta_xdim; |             staple = staple * beta_xdim_shifted; | ||||||
|         dSdU_mu += staple; |             dSdU_mu += staple; | ||||||
|  |           } | ||||||
|         // staple backwards in tau |         } | ||||||
|         WilsonLoops<Gimpl>::StapleLower(staple, U, mu, nu); |  | ||||||
|         staple = staple * beta_xdim_shifted; |  | ||||||
|         dSdU_mu += staple; |  | ||||||
|       } |       } | ||||||
|  |  | ||||||
|  |       dSdU_mu = Ta(Umu * dSdU_mu) * factor; | ||||||
|  |       PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu); | ||||||
|     } |     } | ||||||
|   } |  | ||||||
|  |  | ||||||
|   dSdU_mu = Ta(Umu * dSdU_mu) * factor; |  | ||||||
|   PokeIndex<LorentzIndex>(dSdU, dSdU_mu, mu); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,9 +23,9 @@ 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., | with this program; if not, write to the Free Software Foundation, Inc., | ||||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||||
|  |  | ||||||
| See the full license in the file "LICENSE" in the top level distribution |   See the full license in the file "LICENSE" in the top level distribution | ||||||
| directory |   directory | ||||||
| *************************************************************************************/ |   *************************************************************************************/ | ||||||
| /*  END LEGAL */ | /*  END LEGAL */ | ||||||
| #ifndef GENERIC_HMC_RUNNER | #ifndef GENERIC_HMC_RUNNER | ||||||
| #define GENERIC_HMC_RUNNER | #define GENERIC_HMC_RUNNER | ||||||
| @@ -33,165 +33,169 @@ directory | |||||||
| namespace Grid { | namespace Grid { | ||||||
| namespace QCD { | namespace QCD { | ||||||
|  |  | ||||||
| // Virtual Class for HMC specific for gauge theories |   // Virtual Class for HMC specific for gauge theories | ||||||
| // implement a specific theory by defining the BuildTheAction |   // implement a specific theory by defining the BuildTheAction | ||||||
| template <class Implementation, |   template <class Implementation, class RepresentationsPolicy = NoHirep> | ||||||
|           class RepresentationsPolicy = NoHirep> |   class BinaryHmcRunnerTemplate { | ||||||
| class BinaryHmcRunnerTemplate { |   public: | ||||||
|  public: |     INHERIT_FIELD_TYPES(Implementation); | ||||||
|   INHERIT_FIELD_TYPES(Implementation); |     typedef Implementation ImplPolicy; | ||||||
|   typedef Implementation ImplPolicy; |  | ||||||
|  |  | ||||||
|   enum StartType_t { ColdStart, HotStart, TepidStart, CheckpointStart }; |     enum StartType_t { ColdStart, | ||||||
|  |                        HotStart, | ||||||
|  |                        TepidStart, | ||||||
|  |                        CheckpointStart }; | ||||||
|  |  | ||||||
|   ActionSet<Field, RepresentationsPolicy> TheAction; |     ActionSet<Field, RepresentationsPolicy> TheAction; | ||||||
|    |  | ||||||
|   // A vector of HmcObservable  |  | ||||||
|   // that can be injected from outside   |  | ||||||
|   std::vector< HmcObservable<typename Implementation::Field>* > ObservablesList; |  | ||||||
|  |  | ||||||
|   IntegratorParameters MDparameters; |     // A vector of HmcObservable | ||||||
|  |     // that can be injected from outside | ||||||
|  |     std::vector<HmcObservable<typename Implementation::Field> *> | ||||||
|  |         ObservablesList; | ||||||
|  |  | ||||||
|   GridCartesian *UGrid; |     IntegratorParameters MDparameters; | ||||||
|   GridCartesian *FGrid; |  | ||||||
|   GridRedBlackCartesian *UrbGrid; |  | ||||||
|   GridRedBlackCartesian *FrbGrid; |  | ||||||
|  |  | ||||||
|   std::vector<int> SerialSeed; |     GridCartesian *        UGrid; | ||||||
|   std::vector<int> ParallelSeed; |     GridCartesian *        FGrid; | ||||||
|  |     GridRedBlackCartesian *UrbGrid; | ||||||
|  |     GridRedBlackCartesian *FrbGrid; | ||||||
|  |  | ||||||
|   void RNGSeeds(std::vector<int> S, std::vector<int> P){ |     std::vector<int> SerialSeed; | ||||||
|     SerialSeed = S; |     std::vector<int> ParallelSeed; | ||||||
|     ParallelSeed = P; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   virtual void BuildTheAction(int argc, char **argv) = 0;  // necessary? |     void RNGSeeds(std::vector<int> S, std::vector<int> P) { | ||||||
|  |       SerialSeed   = S; | ||||||
|  |       ParallelSeed = P; | ||||||
|  |     } | ||||||
|  |  | ||||||
|   // A couple of wrapper classes |     virtual void BuildTheAction(int argc, char **argv) = 0; // necessary? | ||||||
|   template <class IOCheckpointer> |  | ||||||
|   void Run(int argc, char **argv, IOCheckpointer &Checkpoint) { |  | ||||||
|     NoSmearing<Implementation> S; |  | ||||||
|     Runner(argc, argv, Checkpoint, S); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <class IOCheckpointer, class SmearingPolicy> |     // A couple of wrapper classes | ||||||
|   void Run(int argc, char **argv, IOCheckpointer &CP, SmearingPolicy &S) { |     template <class IOCheckpointer> | ||||||
|     Runner(argc, argv, CP, S); |     void Run(int argc, char **argv, IOCheckpointer &Checkpoint) { | ||||||
|   } |       NoSmearing<Implementation> S; | ||||||
|   ////////////////////////////// |       Runner(argc, argv, Checkpoint, S); | ||||||
|  |     } | ||||||
|  |  | ||||||
|   template <class SmearingPolicy, class IOCheckpointer > |     template <class IOCheckpointer, class SmearingPolicy> | ||||||
|   void Runner(int argc, char **argv, IOCheckpointer &Checkpoint, |     void Run(int argc, char **argv, IOCheckpointer &CP, SmearingPolicy &S) { | ||||||
|            SmearingPolicy &Smearing) { |       Runner(argc, argv, CP, S); | ||||||
|     StartType_t StartType = HotStart; |     } | ||||||
|  |     ////////////////////////////// | ||||||
|  |  | ||||||
|     std::string arg; |     template <class SmearingPolicy, class IOCheckpointer> | ||||||
|  |     void Runner(int             argc, | ||||||
|  |                 char **         argv, | ||||||
|  |                 IOCheckpointer &Checkpoint, | ||||||
|  |                 SmearingPolicy &Smearing) { | ||||||
|  |       StartType_t StartType = HotStart; | ||||||
|  |  | ||||||
|     if (GridCmdOptionExists(argv, argv + argc, "--StartType")) { |       std::string arg; | ||||||
|       arg = GridCmdOptionPayload(argv, argv + argc, "--StartType"); |  | ||||||
|       if (arg == "HotStart") { |       if (GridCmdOptionExists(argv, argv + argc, "--StartType")) { | ||||||
|         StartType = HotStart; |         arg = GridCmdOptionPayload(argv, argv + argc, "--StartType"); | ||||||
|       } else if (arg == "ColdStart") { |         if (arg == "HotStart") { | ||||||
|         StartType = ColdStart; |           StartType = HotStart; | ||||||
|       } else if (arg == "TepidStart") { |         } else if (arg == "ColdStart") { | ||||||
|         StartType = TepidStart; |           StartType = ColdStart; | ||||||
|       } else if (arg == "CheckpointStart") { |         } else if (arg == "TepidStart") { | ||||||
|         StartType = CheckpointStart; |           StartType = TepidStart; | ||||||
|       } else { |         } else if (arg == "CheckpointStart") { | ||||||
|         std::cout << GridLogError << "Unrecognized option in --StartType\n"; |           StartType = CheckpointStart; | ||||||
|         std::cout |         } else { | ||||||
|             << GridLogError |           std::cout << GridLogError << "Unrecognized option in --StartType\n"; | ||||||
|             << "Valid [HotStart, ColdStart, TepidStart, CheckpointStart]\n"; |           std::cout | ||||||
|         assert(0); |               << GridLogError | ||||||
|  |               << "Valid [HotStart, ColdStart, TepidStart, CheckpointStart]\n"; | ||||||
|  |           assert(0); | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
|  |       int StartTraj = 0; | ||||||
|  |       if (GridCmdOptionExists(argv, argv + argc, "--StartTrajectory")) { | ||||||
|  |         arg = GridCmdOptionPayload(argv, argv + argc, "--StartTrajectory"); | ||||||
|  |         std::vector<int> ivec(0); | ||||||
|  |         GridCmdOptionIntVector(arg, ivec); | ||||||
|  |         StartTraj = ivec[0]; | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       int NumTraj = 1; | ||||||
|  |       if (GridCmdOptionExists(argv, argv + argc, "--Trajectories")) { | ||||||
|  |         arg = GridCmdOptionPayload(argv, argv + argc, "--Trajectories"); | ||||||
|  |         std::vector<int> ivec(0); | ||||||
|  |         GridCmdOptionIntVector(arg, ivec); | ||||||
|  |         NumTraj = ivec[0]; | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       int NumThermalizations = 10; | ||||||
|  |       if (GridCmdOptionExists(argv, argv + argc, "--Thermalizations")) { | ||||||
|  |         arg = GridCmdOptionPayload(argv, argv + argc, "--Thermalizations"); | ||||||
|  |         std::vector<int> ivec(0); | ||||||
|  |         GridCmdOptionIntVector(arg, ivec); | ||||||
|  |         NumThermalizations = ivec[0]; | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       GridSerialRNG   sRNG; | ||||||
|  |       GridParallelRNG pRNG(UGrid); | ||||||
|  |       Field           U(UGrid); | ||||||
|  |  | ||||||
|  |       typedef MinimumNorm2<Implementation, | ||||||
|  |                            SmearingPolicy, | ||||||
|  |                            RepresentationsPolicy> | ||||||
|  |           IntegratorType; // change here to change the algorithm | ||||||
|  |       IntegratorType MDynamics(UGrid, MDparameters, TheAction, Smearing); | ||||||
|  |  | ||||||
|  |       HMCparameters HMCpar; | ||||||
|  |       HMCpar.StartTrajectory   = StartTraj; | ||||||
|  |       HMCpar.Trajectories      = NumTraj; | ||||||
|  |       HMCpar.NoMetropolisUntil = NumThermalizations; | ||||||
|  |  | ||||||
|  |       if (StartType == HotStart) { | ||||||
|  |         // Hot start | ||||||
|  |         HMCpar.MetropolisTest = true; | ||||||
|  |         sRNG.SeedFixedIntegers(SerialSeed); | ||||||
|  |         pRNG.SeedFixedIntegers(ParallelSeed); | ||||||
|  |         Implementation::HotConfiguration(pRNG, U); | ||||||
|  |       } else if (StartType == ColdStart) { | ||||||
|  |         // Cold start | ||||||
|  |         HMCpar.MetropolisTest = true; | ||||||
|  |         sRNG.SeedFixedIntegers(SerialSeed); | ||||||
|  |         pRNG.SeedFixedIntegers(ParallelSeed); | ||||||
|  |         Implementation::ColdConfiguration(pRNG, U); | ||||||
|  |       } else if (StartType == TepidStart) { | ||||||
|  |         // Tepid start | ||||||
|  |         HMCpar.MetropolisTest = true; | ||||||
|  |         sRNG.SeedFixedIntegers(SerialSeed); | ||||||
|  |         pRNG.SeedFixedIntegers(ParallelSeed); | ||||||
|  |         Implementation::TepidConfiguration(pRNG, U); | ||||||
|  |       } else if (StartType == CheckpointStart) { | ||||||
|  |         HMCpar.MetropolisTest = true; | ||||||
|  |         // CheckpointRestart | ||||||
|  |         Checkpoint.CheckpointRestore(StartTraj, U, sRNG, pRNG); | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       Smearing.set_Field(U); | ||||||
|  |  | ||||||
|  |       HybridMonteCarlo<IntegratorType> HMC(HMCpar, MDynamics, sRNG, pRNG, U); | ||||||
|  |  | ||||||
|  |       for (int obs = 0; obs < ObservablesList.size(); obs++) | ||||||
|  |         HMC.AddObservable(ObservablesList[obs]); | ||||||
|  |  | ||||||
|  |       // Run it | ||||||
|  |       HMC.evolve(); | ||||||
|     } |     } | ||||||
|  |   }; | ||||||
|  |  | ||||||
|     int StartTraj = 0; |   // These are for gauge fields | ||||||
|     if (GridCmdOptionExists(argv, argv + argc, "--StartTrajectory")) { |   typedef BinaryHmcRunnerTemplate<PeriodicGimplR> BinaryHmcRunner; | ||||||
|       arg = GridCmdOptionPayload(argv, argv + argc, "--StartTrajectory"); |   typedef BinaryHmcRunnerTemplate<PeriodicGimplF> BinaryHmcRunnerF; | ||||||
|       std::vector<int> ivec(0); |   typedef BinaryHmcRunnerTemplate<PeriodicGimplD> BinaryHmcRunnerD; | ||||||
|       GridCmdOptionIntVector(arg, ivec); |  | ||||||
|       StartTraj = ivec[0]; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     int NumTraj = 1; |   template <class RepresentationsPolicy> | ||||||
|     if (GridCmdOptionExists(argv, argv + argc, "--Trajectories")) { |   using BinaryHmcRunnerTemplateHirep = BinaryHmcRunnerTemplate<PeriodicGimplR, RepresentationsPolicy>; | ||||||
|       arg = GridCmdOptionPayload(argv, argv + argc, "--Trajectories"); |  | ||||||
|       std::vector<int> ivec(0); |  | ||||||
|       GridCmdOptionIntVector(arg, ivec); |  | ||||||
|       NumTraj = ivec[0]; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     int NumThermalizations = 10; |   typedef BinaryHmcRunnerTemplate<ScalarImplR, ScalarFields> | ||||||
|     if (GridCmdOptionExists(argv, argv + argc, "--Thermalizations")) { |       ScalarBinaryHmcRunner; | ||||||
|       arg = GridCmdOptionPayload(argv, argv + argc, "--Thermalizations"); |  | ||||||
|       std::vector<int> ivec(0); |  | ||||||
|       GridCmdOptionIntVector(arg, ivec); |  | ||||||
|       NumThermalizations = ivec[0]; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     GridSerialRNG sRNG; |  | ||||||
|     GridParallelRNG pRNG(UGrid); |  | ||||||
|     Field U(UGrid); |  | ||||||
|  |  | ||||||
|     typedef MinimumNorm2<Implementation, SmearingPolicy, |  | ||||||
|                          RepresentationsPolicy> |  | ||||||
|         IntegratorType;  // change here to change the algorithm |  | ||||||
|     IntegratorType MDynamics(UGrid, MDparameters, TheAction, Smearing); |  | ||||||
|  |  | ||||||
|     HMCparameters HMCpar; |  | ||||||
|     HMCpar.StartTrajectory = StartTraj; |  | ||||||
|     HMCpar.Trajectories = NumTraj; |  | ||||||
|     HMCpar.NoMetropolisUntil = NumThermalizations; |  | ||||||
|  |  | ||||||
|     if (StartType == HotStart) { |  | ||||||
|       // Hot start |  | ||||||
|       HMCpar.MetropolisTest = true; |  | ||||||
|       sRNG.SeedFixedIntegers(SerialSeed); |  | ||||||
|       pRNG.SeedFixedIntegers(ParallelSeed); |  | ||||||
|       Implementation::HotConfiguration(pRNG, U); |  | ||||||
|     } else if (StartType == ColdStart) { |  | ||||||
|       // Cold start |  | ||||||
|       HMCpar.MetropolisTest = true; |  | ||||||
|       sRNG.SeedFixedIntegers(SerialSeed); |  | ||||||
|       pRNG.SeedFixedIntegers(ParallelSeed); |  | ||||||
|       Implementation::ColdConfiguration(pRNG, U); |  | ||||||
|     } else if (StartType == TepidStart) { |  | ||||||
|       // Tepid start |  | ||||||
|       HMCpar.MetropolisTest = true; |  | ||||||
|       sRNG.SeedFixedIntegers(SerialSeed); |  | ||||||
|       pRNG.SeedFixedIntegers(ParallelSeed); |  | ||||||
|       Implementation::TepidConfiguration(pRNG, U); |  | ||||||
|     } else if (StartType == CheckpointStart) { |  | ||||||
|       HMCpar.MetropolisTest = true; |  | ||||||
|       // CheckpointRestart |  | ||||||
|       Checkpoint.CheckpointRestore(StartTraj, U, sRNG, pRNG); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     Smearing.set_Field(U); |  | ||||||
|  |  | ||||||
|     HybridMonteCarlo<IntegratorType> HMC(HMCpar, MDynamics, sRNG, pRNG, U); |  | ||||||
|  |  | ||||||
|     for (int obs = 0; obs < ObservablesList.size(); obs++) |  | ||||||
|       HMC.AddObservable(ObservablesList[obs]);  |  | ||||||
|  |  | ||||||
|     // Run it |  | ||||||
|     HMC.evolve(); |  | ||||||
|   } |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| // These are for gauge fields |  | ||||||
| typedef BinaryHmcRunnerTemplate<PeriodicGimplR> BinaryHmcRunner; |  | ||||||
| typedef BinaryHmcRunnerTemplate<PeriodicGimplF> BinaryHmcRunnerF; |  | ||||||
| typedef BinaryHmcRunnerTemplate<PeriodicGimplD> BinaryHmcRunnerD; |  | ||||||
|  |  | ||||||
| template <class RepresentationsPolicy> |  | ||||||
| using BinaryHmcRunnerTemplateHirep = |  | ||||||
|     BinaryHmcRunnerTemplate<PeriodicGimplR, RepresentationsPolicy>; |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     typedef BinaryHmcRunnerTemplate<ScalarImplR, ScalarFields> ScalarBinaryHmcRunner; |  | ||||||
| } | } | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -34,7 +34,6 @@ directory | |||||||
|  * @brief Classes for Hybrid Monte Carlo update |  * @brief Classes for Hybrid Monte Carlo update | ||||||
|  * |  * | ||||||
|  * @author Guido Cossu |  * @author Guido Cossu | ||||||
|  * Time-stamp: <2015-07-30 16:58:26 neo> |  | ||||||
|  */ |  */ | ||||||
| //-------------------------------------------------------------------- | //-------------------------------------------------------------------- | ||||||
| #ifndef HMC_INCLUDED | #ifndef HMC_INCLUDED | ||||||
|   | |||||||
| @@ -29,14 +29,6 @@ directory | |||||||
| *************************************************************************************/ | *************************************************************************************/ | ||||||
| /*  END LEGAL */ | /*  END LEGAL */ | ||||||
| //-------------------------------------------------------------------- | //-------------------------------------------------------------------- | ||||||
| /*! @file Integrator.h |  | ||||||
|  * @brief Classes for the Molecular Dynamics integrator |  | ||||||
|  * |  | ||||||
|  * @author Guido Cossu |  | ||||||
|  * Time-stamp: <2015-07-30 16:21:29 neo> |  | ||||||
|  */ |  | ||||||
| //-------------------------------------------------------------------- |  | ||||||
|  |  | ||||||
| #ifndef INTEGRATOR_INCLUDED | #ifndef INTEGRATOR_INCLUDED | ||||||
| #define INTEGRATOR_INCLUDED | #define INTEGRATOR_INCLUDED | ||||||
|  |  | ||||||
|   | |||||||
| @@ -235,7 +235,7 @@ public: | |||||||
|  |  | ||||||
|       std::vector<GaugeMat> U(Nd, grid); |       std::vector<GaugeMat> U(Nd, grid); | ||||||
|       for (int d = 0; d < Nd; d++) { |       for (int d = 0; d < Nd; d++) { | ||||||
|         U[d] = PeekIndex<LorentzIndex>(Umu, d); |         U[d] = PeekIndex<LorentzIndex>(Umu, d);// some redundant copies | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       // mu |       // mu | ||||||
| @@ -268,7 +268,7 @@ public: | |||||||
|  |  | ||||||
|       std::vector<GaugeMat> U(Nd, grid); |       std::vector<GaugeMat> U(Nd, grid); | ||||||
|       for (int d = 0; d < Nd; d++) { |       for (int d = 0; d < Nd; d++) { | ||||||
|         U[d] = PeekIndex<LorentzIndex>(Umu, d); |         U[d] = PeekIndex<LorentzIndex>(Umu, d);// some redundant copies | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       // mu |       // mu | ||||||
|   | |||||||
| @@ -79,12 +79,16 @@ class HmcRunner : public BinaryHmcRunner { | |||||||
|  |  | ||||||
|     // Gauge action |     // Gauge action | ||||||
|     int Ls = UGrid->_gdimensions[Nd - 1]; |     int Ls = UGrid->_gdimensions[Nd - 1]; | ||||||
|     std::vector<RealD> betat(Ls,5); |     std::vector<RealD> betat(Ls); | ||||||
|     std::vector<RealD> betas(Ls); |     std::vector<RealD> betas(Ls); | ||||||
|     betas={5,6,6,5}; |     //betat={5,6,6,6,6,6,6,5}; | ||||||
|     //std:cout << "Betas:" << betas << std::endl; |     betat={1,1,1,0,1,1,1,1}; | ||||||
|     //VariableWilsonGaugeActionR Waction(betas, betat, UGrid); |     //betas={5.2,5.5,5.8,6,6,5.8,5.5,5.2}; | ||||||
|     WilsonGaugeActionR Waction(5.6); |     betas={0,0,0,0,0,0,0,0}; | ||||||
|  |     bool openBC = false; | ||||||
|  |     std:cout << GridLogMessage << "Betas: " << betas << std::endl; | ||||||
|  |     VariableWilsonGaugeActionR Waction(betas, betat, UGrid, openBC); | ||||||
|  |     //WilsonGaugeActionR Waction(5.6); | ||||||
|  |  | ||||||
|     // Collect actions |     // Collect actions | ||||||
|     ActionLevel<Field> Level1(1); |     ActionLevel<Field> Level1(1); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user