1 /* -*- c++ -*- */ 2 #ifndef SHADOWHMCINTEGRATOR_H 3 #define SHADOWHMCINTEGRATOR_H 4 5 #include "MCIntegrator.h" 6 #include <deque> 7 8 namespace ProtoMol { 9 class GenericTopology; 10 class ScalarStructure; 11 class Vector3DBlock; 12 class ForceGroup; 13 class ModifierUpdateBeta; 14 class ModifierUpdateBetaAndPush; 15 //____________________________________________________________ ShadowHMCIntegrator 16 17 class ShadowHMCIntegrator: public MCIntegrator { 18 19 friend class ModifierUpdateBeta; 20 friend class ModifierUpdateBetaAndPush; 21 22 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 // Constructors, destructors, assignment 24 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 public: 26 ShadowHMCIntegrator(); 27 ShadowHMCIntegrator(int cycles, 28 bool randomCycLen, 29 Real initialTemperature, 30 unsigned int shadowOrder, 31 Real c, 32 ForceGroup *overloadedForces, 33 StandardIntegrator *nextIntegrator); 34 virtual ~ShadowHMCIntegrator(); 35 36 37 38 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 39 // New methods of class ShadowHMCIntegrator 40 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41 private: 42 void updateBeta(); 43 void pushShadowHistory(); 44 void calculateShadow(); 45 Real calcShadow4(); 46 Real calcShadow8(); 47 void runPreSteps(int numTimesteps); 48 void runPostSteps(int numTimesteps); 49 void resetHistory(); 50 void disableBetaUpdate(); 51 void enableBetaUpdate(); 52 53 54 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 // From class Makeable 56 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 public: getIdNoAlias()58 virtual std::string getIdNoAlias() const{return keyword;} getParameterSize()59 virtual unsigned int getParameterSize() const{return 5;} 60 virtual void getParameters(std::vector<Parameter>& parameters) const; 61 62 63 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64 // From class Integrator 65 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 public: 67 virtual void initialize(GenericTopology *topo, 68 Vector3DBlock *positions, 69 Vector3DBlock *velocities, 70 ScalarStructure *energies); 71 72 virtual void run(int numTimesteps); 73 74 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 75 // From class MTSIntegrator 76 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 77 private: 78 virtual MTSIntegrator* doMake(std::string& errMsg, 79 const std::vector<Value>& values, ForceGroup* fg, 80 StandardIntegrator *nextIntegrator) const; 81 82 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 83 // From classs MCIntegrator 84 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 85 protected: 86 virtual void perturbSystem(); 87 virtual void saveValues(); 88 virtual void restoreValues(); 89 90 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 91 // My data members 92 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 public: 94 static const std::string keyword; 95 96 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 97 // My data members 98 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 99 private: 100 unsigned int myOrder, 101 myShadowK, 102 myShadowKover2; 103 104 Real myC; 105 Real myBeta; 106 107 Real sumTotalEnergy; 108 109 std::deque< Vector3DBlock > *myPrevVelocities; 110 std::deque< Vector3DBlock > *myPrevPositions; 111 std::deque< Real > *myPrevBeta; 112 113 ModifierUpdateBeta* myModifier1; 114 ModifierUpdateBetaAndPush* myModifier2; 115 116 Vector3DBlock* myOldForces; 117 118 }; 119 } 120 #endif 121