NAMD
GlobalMasterMisc.C
Go to the documentation of this file.
1 
7 /*
8  Forwards atoms to master node for force evaluation.
9 */
10 
11 #include "InfoStream.h"
12 #include "NamdTypes.h"
13 #include "GlobalMaster.h"
14 #include "GlobalMasterMisc.h"
15 
16 //#define DEBUGM
17 #define MIN_DEBUG_LEVEL 1
18 #include "Debug.h"
19 
21  // Initialize subclass
23  delete[] config;
24 }
25 
27  ;
28 }
29 
30 /* you may use the following in easy_init or easy_calc
31  int getAtomID(const char *segid, int resid, const char *aname); // zero-based
32  int getNumAtoms(const char* segid, int resid); // 0 on error
33  int getAtomID(const char *segid, int resid, int index);
34  double getMass(int atomid); // -1.0 on error
35 */
36 
37 /* you may use the following only in easy_init()
38  int requestAtom(int atomid); // 0 on success, -1 on error
39 */
40 
41 void GlobalMasterMisc::easy_init(const char *config) {
42  iout << iINFO << " MISC FORCES CONFIG\n";
43  iout << iINFO << "**********************\n";
44  iout << config;
45  iout << iINFO << "**********************\n" << endi;
46 
47  requestAtom(0);
48 
49  firstTime = true;
50 }
51 
52 /* you may use the following only in easy_calc()
53  int getPosition(int atomid, Position &position); // 0 on success, -1 on error
54  int addForce(int atomid, Force force); // 0 on success, -1 on error
55  void addEnergy(BigReal);
56 */
57 
58 /* EXAMPEL: harmonically restrain atom 0 to its original position */
59 
61  if(firstTime) {
63  NAMD_die("Couldn't get initial position.");
64  }
65  iout << iINFO << "Initial pos: " << originalPosition << "\n" << endi;
66  firstTime = false;
67  }
68 
69  Vector myp;
70  BigReal k = 100.0;
71  if(getPosition(0,myp)) {
72  NAMD_die("Couldn't get position.");
73  }
74  iout << iINFO << "Atom 0 is at " << myp << "\n" << endi;
75  addForce(0,-k * (myp-originalPosition));
76  iout<<iINFO << "Adding force " << -k*(myp-originalPosition) << "\n" << endi;
77  addEnergy(0.5 * k * (myp-originalPosition).length2());
78 }
79 
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
int getPosition(int atomid, Position &position)
Definition: Vector.h:64
int addForce(int atomid, Force force)
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define iout
Definition: InfoStream.h:51
virtual void easy_calc(void)
int requestAtom(int atomid)
void addEnergy(BigReal)
virtual void easy_init(const char *)
void NAMD_die(const char *err_msg)
Definition: common.C:85
virtual ~GlobalMasterMisc()
double BigReal
Definition: common.h:114