45#include "restraints/ThermoIntegrationForceModifier.hpp"
56 ThermoIntegrationForceModifier::ThermoIntegrationForceModifier(
58 RestraintForceModifier {info} {
59 currSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot();
60 simParam_ = info_->getSimParams();
62 RealType tIntLambda, tIntK;
64 if (simParam_->haveThermodynamicIntegrationLambda()) {
65 tIntLambda = simParam_->getThermodynamicIntegrationLambda();
68 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
69 "ThermoIntegration error: the transformation parameter\n"
70 "\t(lambda) was not specified. OpenMD will use a default\n"
71 "\tvalue of %f. To set lambda, use the \n"
72 "\tthermodynamicIntegrationLambda variable.\n",
78 if (simParam_->haveThermodynamicIntegrationK()) {
79 tIntK = simParam_->getThermodynamicIntegrationK();
82 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
83 "ThermoIntegration Warning: the tranformation parameter\n"
84 "\texponent (k) was not specified. OpenMD will use a default\n"
85 "\tvalue of %f. To set k, use the thermodynamicIntegrationK\n"
93 factor_ = pow(tIntLambda, tIntK);
96 void ThermoIntegrationForceModifier::modifyForces() {
97 Snapshot* curSnapshot;
98 SimInfo::MoleculeIterator mi;
100 Molecule::IntegrableObjectIterator ii;
107 for (mol = info_->beginMolecule(mi); mol != NULL;
108 mol = info_->nextMolecule(mi)) {
109 for (sd = mol->beginIntegrableObject(ii); sd != NULL;
110 sd = mol->nextIntegrableObject(ii)) {
115 if (sd->isDirectional()) {
123 curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
126 RealType rawPot = curSnapshot->getPotentialEnergy();
127 curSnapshot->setRawPotential(rawPot);
129 RealType rp = curSnapshot->getRestraintPotential();
133 curSnapshot->setPotentialEnergy(rawPot);
136 tempTau = curSnapshot->getVirialTensor();
138 curSnapshot->setVirialTensor(tempTau);
141 RealType scaledRestPot(0.0);
142 RealType restPot(0.0);
144 if (simParam_->getUseRestraints()) {
146 scaledRestPot = doRestraints(1.0 - factor_);
147 restPot = getUnscaledPotential();
151 MPI_Allreduce(MPI_IN_PLACE, &scaledRestPot, 1, MPI_REALTYPE, MPI_SUM,
153 MPI_Allreduce(MPI_IN_PLACE, &restPot, 1, MPI_REALTYPE, MPI_SUM,
158 curSnapshot->setPotentialEnergy(rawPot + scaledRestPot);
159 curSnapshot->setRestraintPotential(rp + restPot);
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.