48#include "restraints/ThermoIntegrationForceModifier.hpp"
59 ThermoIntegrationForceModifier::ThermoIntegrationForceModifier(
62 currSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
63 simParam_ = info_->getSimParams();
65 RealType tIntLambda, tIntK;
67 if (simParam_->haveThermodynamicIntegrationLambda()) {
68 tIntLambda = simParam_->getThermodynamicIntegrationLambda();
71 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
72 "ThermoIntegration error: the transformation parameter\n"
73 "\t(lambda) was not specified. OpenMD will use a default\n"
74 "\tvalue of %f. To set lambda, use the \n"
75 "\tthermodynamicIntegrationLambda variable.\n",
81 if (simParam_->haveThermodynamicIntegrationK()) {
82 tIntK = simParam_->getThermodynamicIntegrationK();
85 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
86 "ThermoIntegration Warning: the tranformation parameter\n"
87 "\texponent (k) was not specified. OpenMD will use a default\n"
88 "\tvalue of %f. To set k, use the thermodynamicIntegrationK\n"
96 factor_ = pow(tIntLambda, tIntK);
99 void ThermoIntegrationForceModifier::modifyForces() {
100 Snapshot* curSnapshot;
101 SimInfo::MoleculeIterator mi;
103 Molecule::IntegrableObjectIterator ii;
110 for (mol = info_->beginMolecule(mi); mol != NULL;
111 mol = info_->nextMolecule(mi)) {
112 for (sd = mol->beginIntegrableObject(ii); sd != NULL;
113 sd = mol->nextIntegrableObject(ii)) {
118 if (sd->isDirectional()) {
126 curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
129 RealType rawPot = curSnapshot->getPotentialEnergy();
130 curSnapshot->setRawPotential(rawPot);
132 RealType rp = curSnapshot->getRestraintPotential();
136 curSnapshot->setPotentialEnergy(rawPot);
139 tempTau = curSnapshot->getVirialTensor();
141 curSnapshot->setVirialTensor(tempTau);
144 RealType scaledRestPot(0.0);
145 RealType restPot(0.0);
147 if (simParam_->getUseRestraints()) {
149 scaledRestPot = doRestraints(1.0 - factor_);
150 restPot = getUnscaledPotential();
154 MPI_Allreduce(MPI_IN_PLACE, &scaledRestPot, 1, MPI_REALTYPE, MPI_SUM,
156 MPI_Allreduce(MPI_IN_PLACE, &restPot, 1, MPI_REALTYPE, MPI_SUM,
161 curSnapshot->setPotentialEnergy(rawPot + scaledRestPot);
162 curSnapshot->setRestraintPotential(rp + restPot);
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.