28 #define MIN_DEBUG_LEVEL 1 33 const Vector direction,
int output_frequency,
34 int first_timestep,
const char *filename,
36 DebugM(3,
"initialize called\n");
39 outputFreq = output_frequency;
41 k2 = transverse_spring_constant;
42 currentTime = first_timestep;
44 parseAtoms(filename,numAtoms);
46 DebugM(1,
"done with initialize\n");
49 void GlobalMasterSMD::parseAtoms(
const char *file,
int numTotalAtoms) {
50 DebugM(3,
"parseAtoms called\n");
54 NAMD_die(
"No atoms found in SMDFile\n");
56 NAMD_die(
"The number of atoms in SMDFile must be equal to the total number of atoms in the structure!");
64 cm.
x = cm.
y = cm.
z = 0;
69 #ifdef MEM_OPT_VERSION 70 PDBCoreData *atom = smdpdb.atom(i);
80 cm.
x += atom->
xcoor()*mass;
81 cm.
y += atom->
ycoor()*mass;
82 cm.
z += atom->
zcoor()*mass;
87 NAMD_die(
"SMDFile contained no SMD atoms (atoms w/ nonzero occupancy)\n");
91 DebugM(1,
"done with parseAtoms\n");
97 void GlobalMasterSMD::calculate() {
98 DebugM(3,
"calculate called\n");
102 NAMD_die(
"Internal error: uninitialized!");
106 DebugM(1,
"Current CM "<<cm<<
"\n");
108 BigReal diff = diffCOM*moveDir;
109 BigReal preFactor = moveVel*currentTime - diff;
112 Force f = k*preFactor*moveDir + k2*(diff*moveDir - diffCOM);
117 BigReal energy = 0.5*k*preFactor*preFactor;
118 energy += 0.5*k2*(diffCOM.
length2() - diff*diff);
121 if (currentTime % outputFreq == 0)
122 output(currentTime, curcm, f);
127 DebugM(1,
"done with calculate: force: "<<f<<
"\n");
131 DebugM(3,
"output called\n");
133 if (t % (100*outputFreq) == 0)
134 iout <<
"SMDTITLE: TS CURRENT_POSITION FORCE\n" <<
endi;
137 DebugM(1,
"done with output\n");
std::ostream & iINFO(std::ostream &s)
std::ostream & endi(std::ostream &s)
Molecule stores the structural information for the system.
const ResizeArray< AtomIDList > & requestedGroups()
GlobalMasterSMD(BigReal spring_constant, BigReal transverse_spring_constant, BigReal velocity, const Vector direction, int output_frequency, int first_timestep, const char *filename, int)
NAMD_HOST_DEVICE BigReal length2(void) const
ResizeArray< AtomIDList > & modifyRequestedGroups()
void NAMD_die(const char *err_msg)
ForceList & modifyGroupForces()
Real atommass(int anum) const
void addReductionEnergy(int reductionTag, BigReal energy)
PositionList::const_iterator getGroupPositionBegin()