mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-13 20:57:06 +01:00
Committing incomplete work for parameter file I/O.
MacroMagic.h is central. Guido and I plan to move over to generating virtual (XML, JSON, YAML, text, binary) encoding from macro based system.
This commit is contained in:
@ -7,14 +7,30 @@ template<class GaugeField>
|
||||
class Action {
|
||||
|
||||
public:
|
||||
virtual void init(const GaugeField &U, GridParallelRNG& pRNG) = 0;
|
||||
virtual RealD S(const GaugeField &U) = 0; // evaluate the action
|
||||
virtual void deriv(const GaugeField &U,GaugeField & dSdU ) = 0; // evaluate the action derivative
|
||||
//virtual void refresh(const GaugeField & ) {} ;
|
||||
virtual void init (const GaugeField &U, GridParallelRNG& pRNG) = 0; //
|
||||
virtual RealD S (const GaugeField &U) = 0; // evaluate the action
|
||||
virtual void deriv(const GaugeField &U,GaugeField & dSdU ) = 0; // evaluate the action derivative
|
||||
virtual void refresh(const GaugeField & ) {}; // Default to no-op for actions with no internal fields
|
||||
// Boundary conditions?
|
||||
// Heatbath?
|
||||
virtual ~Action() {};
|
||||
};
|
||||
|
||||
// Could derive PseudoFermion action with a PF field, FermionField, and a Grid; implement refresh
|
||||
template<class GaugeField, class FermionField>
|
||||
class PseudoFermionAction : public Action<GaugeField> {
|
||||
public:
|
||||
FermionField Phi;
|
||||
GridParallelRNG &pRNG;
|
||||
GridBase &Grid;
|
||||
|
||||
PseudoFermionAction(GridBase &_Grid,GridParallelRNG &_pRNG) : Grid(_Grid), Phi(&_Grid), pRNG(_pRNG) {
|
||||
};
|
||||
|
||||
virtual void refresh(const GaugeField &gauge) {
|
||||
gaussian(Phi,pRNG);
|
||||
};
|
||||
|
||||
};
|
||||
}}
|
||||
#endif
|
||||
|
@ -149,6 +149,7 @@ PARALLEL_FOR_LOOP
|
||||
////////////////////////////
|
||||
// spin trace outer product
|
||||
////////////////////////////
|
||||
// FIXME : need to sum over fifth direction.
|
||||
tmp = TraceIndex<SpinIndex>(outerProduct(Btilde,A)); // ordering here
|
||||
PokeIndex<LorentzIndex>(mat,tmp,mu);
|
||||
|
||||
|
@ -17,8 +17,5 @@ namespace Grid{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,22 @@ namespace Grid{
|
||||
|
||||
template <class Algorithm>
|
||||
class HybridMonteCarlo{
|
||||
|
||||
const HMCparameters Params;
|
||||
GridSerialRNG sRNG;
|
||||
|
||||
GridSerialRNG sRNG; // Fixme: need a RNG management strategy.
|
||||
|
||||
Integrator<Algorithm>& MD;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Metropolis step
|
||||
/////////////////////////////////////////////////////////
|
||||
bool metropolis_test(const RealD DeltaH){
|
||||
|
||||
RealD rn_test;
|
||||
|
||||
RealD prob = std::exp(-DeltaH);
|
||||
|
||||
random(sRNG,rn_test);
|
||||
|
||||
std::cout<<GridLogMessage<< "--------------------------------------------\n";
|
||||
@ -47,14 +56,19 @@ namespace Grid{
|
||||
std::cout<<GridLogMessage <<"-- REJECTED\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Evolution
|
||||
/////////////////////////////////////////////////////////
|
||||
RealD evolve_step(LatticeLorentzColourMatrix& U){
|
||||
|
||||
MD.init(U); // set U and initialize P and phi's
|
||||
|
||||
RealD H0 = MD.S(U); // initial state action
|
||||
std::cout<<GridLogMessage<<"Total H before = "<< H0 << "\n";
|
||||
|
||||
|
||||
MD.integrate(U);
|
||||
|
||||
RealD H1 = MD.S(U); // updated state action
|
||||
@ -64,13 +78,17 @@ namespace Grid{
|
||||
}
|
||||
|
||||
public:
|
||||
HybridMonteCarlo(HMCparameters Pms,
|
||||
Integrator<Algorithm>& MolDyn):
|
||||
Params(Pms),MD(MolDyn){
|
||||
//FIXME
|
||||
// initialize RNGs also with seed
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Constructor
|
||||
/////////////////////////////////////////
|
||||
HybridMonteCarlo(HMCparameters Pms, Integrator<Algorithm>& MolDyn): Params(Pms),MD(MolDyn) {
|
||||
|
||||
//FIXME... initialize RNGs also with seed ; RNG management strategy
|
||||
sRNG.SeedRandomDevice();
|
||||
|
||||
}
|
||||
|
||||
~HybridMonteCarlo(){};
|
||||
|
||||
|
||||
@ -95,7 +113,8 @@ namespace Grid{
|
||||
DeltaH = evolve_step(Ucopy);
|
||||
|
||||
if(metropolis_test(DeltaH)) Uin = Ucopy;
|
||||
//need sync?
|
||||
//need sync? // Query Guido on this comment
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user