Rename VRescaleThermostat to VelocityScalingTemperatureCoupling
authorPascal Merz <pascal.merz@me.com>
Thu, 3 Sep 2020 03:56:11 +0000 (21:56 -0600)
committerMagnus Lundborg <magnus.lundborg@scilifelab.se>
Thu, 17 Sep 2020 13:39:07 +0000 (13:39 +0000)
Also moves vrescalethermostat.h/cpp to
velocityscalingtemperaturecoupling.h/cpp.

This reflects upcoming changes making the thermostat more general.
As these changes touch a lot of lines in the implementation file,
renaming the file at the same time throws git diff off. Doing the
renaming in a separate commit should therefore make for easier reviewing.

Refs #3423

src/gromacs/modularsimulator/energydata.cpp
src/gromacs/modularsimulator/energydata.h
src/gromacs/modularsimulator/modularsimulator.cpp
src/gromacs/modularsimulator/simulatoralgorithm.cpp
src/gromacs/modularsimulator/velocityscalingtemperaturecoupling.cpp [moved from src/gromacs/modularsimulator/vrescalethermostat.cpp with 77% similarity]
src/gromacs/modularsimulator/velocityscalingtemperaturecoupling.h [moved from src/gromacs/modularsimulator/vrescalethermostat.h with 83% similarity]

index 1619484851c76390e7460571bdb0a27b3077ade0..f3df288719164874457bd46647d1108573d12ac0 100644 (file)
@@ -69,7 +69,7 @@
 #include "parrinellorahmanbarostat.h"
 #include "simulatoralgorithm.h"
 #include "statepropagatordata.h"
-#include "vrescalethermostat.h"
+#include "velocityscalingtemperaturecoupling.h"
 
 struct pull_t;
 class t_state;
@@ -103,7 +103,7 @@ EnergyData::EnergyData(StatePropagatorData*        statePropagatorData,
     startingBehavior_(startingBehavior),
     statePropagatorData_(statePropagatorData),
     freeEnergyPerturbationData_(freeEnergyPerturbationData),
-    vRescaleThermostat_(nullptr),
+    velocityScalingTemperatureCoupling_(nullptr),
     parrinelloRahmanBarostat_(nullptr),
     inputrec_(inputrec),
     top_global_(globalTopology),
@@ -242,7 +242,9 @@ void EnergyData::doStep(Time time, bool isEnergyCalculationStep, bool isFreeEner
     {
         enerd_->term[F_ECONSERVED] =
                 enerd_->term[F_ETOT]
-                + (vRescaleThermostat_ ? vRescaleThermostat_->conservedEnergyContribution() : 0)
+                + (velocityScalingTemperatureCoupling_
+                           ? velocityScalingTemperatureCoupling_->conservedEnergyContribution()
+                           : 0)
                 + (parrinelloRahmanBarostat_ ? parrinelloRahmanBarostat_->conservedEnergyContribution() : 0);
     }
     matrix nullMatrix = {};
@@ -481,9 +483,9 @@ void EnergyData::initializeEnergyHistory(StartingBehavior    startingBehavior,
     energyOutput->fillEnergyHistory(observablesHistory->energyHistory.get());
 }
 
-void EnergyData::setVRescaleThermostat(const gmx::VRescaleThermostat* vRescaleThermostat)
+void EnergyData::setVelocityScalingTemperatureCoupling(const VelocityScalingTemperatureCoupling* velocityScalingTemperatureCoupling)
 {
-    vRescaleThermostat_ = vRescaleThermostat;
+    velocityScalingTemperatureCoupling_ = velocityScalingTemperatureCoupling;
 }
 
 void EnergyData::setParrinelloRahamnBarostat(const gmx::ParrinelloRahmanBarostat* parrinelloRahmanBarostat)
index 660f9f07757cc1cfbd67d9377d0ee5bb78917f82..025702fec53f8caa5739b72ff813887de227d764 100644 (file)
@@ -69,7 +69,7 @@ class MDAtoms;
 class ModularSimulatorAlgorithmBuilderHelper;
 class ParrinelloRahmanBarostat;
 class StatePropagatorData;
-class VRescaleThermostat;
+class VelocityScalingTemperatureCoupling;
 struct MdModulesNotifier;
 
 /*! \internal
@@ -187,13 +187,13 @@ public:
      */
     [[nodiscard]] bool hasReadEkinFromCheckpoint() const;
 
-    /*! \brief set vrescale thermostat
+    /*! \brief Set velocity scaling temperature coupling
      *
-     * This allows to set a pointer to the vrescale thermostat used to
-     * print the thermostat integral.
+     * This allows to set a pointer to a velocity scaling temperature coupling
+     * element used to obtain contributions to the conserved energy.
      * TODO: This should be made obsolete my a more modular energy element
      */
-    void setVRescaleThermostat(const VRescaleThermostat* vRescaleThermostat);
+    void setVelocityScalingTemperatureCoupling(const VelocityScalingTemperatureCoupling* velocityScalingTemperatureCoupling);
 
     /*! \brief set Parrinello-Rahman barostat
      *
@@ -290,7 +290,7 @@ private:
     //! Pointer to the free energy perturbation data
     FreeEnergyPerturbationData* freeEnergyPerturbationData_;
     //! Pointer to the vrescale thermostat
-    const VRescaleThermostat* vRescaleThermostat_;
+    const VelocityScalingTemperatureCoupling* velocityScalingTemperatureCoupling_;
     //! Pointer to the Parrinello-Rahman barostat
     const ParrinelloRahmanBarostat* parrinelloRahmanBarostat_;
     //! Contains user input mdp options.
index f10d038808c45d63c24277e8cd2ad5c7aa6952bd..5e4aa552cd3f1401d3822368906bc756af64a7f9 100644 (file)
@@ -79,7 +79,7 @@
 #include "parrinellorahmanbarostat.h"
 #include "simulatoralgorithm.h"
 #include "statepropagatordata.h"
-#include "vrescalethermostat.h"
+#include "velocityscalingtemperaturecoupling.h"
 
 namespace gmx
 {
@@ -110,7 +110,8 @@ void ModularSimulator::addIntegrationElements(ModularSimulatorAlgorithmBuilder*
         builder->add<StatePropagatorData::Element>();
         if (legacySimulatorData_->inputrec->etc == etcVRESCALE)
         {
-            builder->add<VRescaleThermostat>(-1, UseFullStepKE::No, ReportPreviousStepConservedEnergy::No);
+            builder->add<VelocityScalingTemperatureCoupling>(-1, UseFullStepKE::No,
+                                                             ReportPreviousStepConservedEnergy::No);
         }
         builder->add<Propagator<IntegrationStep::LeapFrog>>(legacySimulatorData_->inputrec->delta_t,
                                                             RegisterWithThermostat::True,
@@ -141,7 +142,8 @@ void ModularSimulator::addIntegrationElements(ModularSimulatorAlgorithmBuilder*
         builder->add<StatePropagatorData::Element>();
         if (legacySimulatorData_->inputrec->etc == etcVRESCALE)
         {
-            builder->add<VRescaleThermostat>(0, UseFullStepKE::Yes, ReportPreviousStepConservedEnergy::Yes);
+            builder->add<VelocityScalingTemperatureCoupling>(
+                    0, UseFullStepKE::Yes, ReportPreviousStepConservedEnergy::Yes);
         }
         builder->add<Propagator<IntegrationStep::VelocityVerletPositionsAndVelocities>>(
                 legacySimulatorData_->inputrec->delta_t, RegisterWithThermostat::True,
index 26c8f02d7971d7e321c3cddcdfd42408127cc875..96836d59b7f5ba3851cb359583ecc466f2167b2c 100644 (file)
@@ -83,7 +83,7 @@
 #include "pmeloadbalancehelper.h"
 #include "propagator.h"
 #include "statepropagatordata.h"
-#include "vrescalethermostat.h"
+#include "velocityscalingtemperaturecoupling.h"
 
 namespace gmx
 {
similarity index 77%
rename from src/gromacs/modularsimulator/vrescalethermostat.cpp
rename to src/gromacs/modularsimulator/velocityscalingtemperaturecoupling.cpp
index 40f87857e954c1c2ce9c918687ebf8ce1630bfc2..54b3a104b78db3ef5605401e43e314e234bed2fc 100644 (file)
@@ -33,7 +33,8 @@
  * the research papers on the package. Check out http://www.gromacs.org.
  */
 /*! \internal \file
- * \brief Defines the v-rescale thermostat for the modular simulator
+ * \brief Defines a velocity-scaling temperature coupling element for
+ * the modular simulator
  *
  * \author Pascal Merz <pascal.merz@me.com>
  * \ingroup module_modularsimulator
@@ -41,7 +42,7 @@
 
 #include "gmxpre.h"
 
-#include "vrescalethermostat.h"
+#include "velocityscalingtemperaturecoupling.h"
 
 #include <numeric>
 
 namespace gmx
 {
 
-VRescaleThermostat::VRescaleThermostat(int                               nstcouple,
-                                       int                               offset,
-                                       UseFullStepKE                     useFullStepKE,
-                                       ReportPreviousStepConservedEnergy reportPreviousConservedEnergy,
-                                       int64_t                           seed,
-                                       int                               numTemperatureGroups,
-                                       double                            couplingTimeStep,
-                                       const real*                       referenceTemperature,
-                                       const real*                       couplingTime,
-                                       const real*                       numDegreesOfFreedom,
-                                       EnergyData*                       energyData) :
+VelocityScalingTemperatureCoupling::VelocityScalingTemperatureCoupling(
+        int                               nstcouple,
+        int                               offset,
+        UseFullStepKE                     useFullStepKE,
+        ReportPreviousStepConservedEnergy reportPreviousConservedEnergy,
+        int64_t                           seed,
+        int                               numTemperatureGroups,
+        double                            couplingTimeStep,
+        const real*                       referenceTemperature,
+        const real*                       couplingTime,
+        const real*                       numDegreesOfFreedom,
+        EnergyData*                       energyData) :
     nstcouple_(nstcouple),
     offset_(offset),
     useFullStepKE_(useFullStepKE),
@@ -90,29 +92,31 @@ VRescaleThermostat::VRescaleThermostat(int                               nstcoup
     {
         thermostatIntegralPreviousStep_ = thermostatIntegral_;
     }
-    energyData->setVRescaleThermostat(this);
+    energyData->setVelocityScalingTemperatureCoupling(this);
 }
 
-void VRescaleThermostat::connectWithPropagator(const PropagatorThermostatConnection& connectionData)
+void VelocityScalingTemperatureCoupling::connectWithPropagator(const PropagatorThermostatConnection& connectionData)
 {
     connectionData.setNumVelocityScalingVariables(numTemperatureGroups_);
     lambda_             = connectionData.getViewOnVelocityScaling();
     propagatorCallback_ = connectionData.getVelocityScalingCallback();
 }
 
-void VRescaleThermostat::elementSetup()
+void VelocityScalingTemperatureCoupling::elementSetup()
 {
     if (!propagatorCallback_ || lambda_.empty())
     {
         throw MissingElementConnectionError(
-                "V-rescale thermostat was not connected to a propagator.\n"
+                "Velocity scaling temperature coupling was not connected to a propagator.\n"
                 "Connection to a propagator element is needed to scale the velocities.\n"
                 "Use connectWithPropagator(...) before building the ModularSimulatorAlgorithm "
                 "object.");
     }
 }
 
-void VRescaleThermostat::scheduleTask(Step step, Time gmx_unused time, const RegisterRunFunction& registerRunFunction)
+void VelocityScalingTemperatureCoupling::scheduleTask(Step step,
+                                                      Time gmx_unused            time,
+                                                      const RegisterRunFunction& registerRunFunction)
 {
     /* The thermostat will need a valid kinetic energy when it is running.
      * Currently, computeGlobalCommunicationPeriod() is making sure this
@@ -132,7 +136,7 @@ void VRescaleThermostat::scheduleTask(Step step, Time gmx_unused time, const Reg
     }
 }
 
-void VRescaleThermostat::setLambda(Step step)
+void VelocityScalingTemperatureCoupling::setLambda(Step step)
 {
     // if we report the previous energy, calculate before the step
     if (reportPreviousConservedEnergy_ == ReportPreviousStepConservedEnergy::Yes)
@@ -191,7 +195,7 @@ void VRescaleThermostat::setLambda(Step step)
 namespace
 {
 /*!
- * \brief Enum describing the contents VRescaleThermostat writes to modular checkpoint
+ * \brief Enum describing the contents VelocityScalingTemperatureCoupling writes to modular checkpoint
  *
  * When changing the checkpoint content, add a new element just above Count, and adjust the
  * checkpoint functionality.
@@ -205,7 +209,8 @@ constexpr auto c_currentVersion = CheckpointVersion(int(CheckpointVersion::Count
 } // namespace
 
 template<CheckpointDataOperation operation>
-void VRescaleThermostat::doCheckpointData(CheckpointData<operation>* checkpointData, const t_commrec* cr)
+void VelocityScalingTemperatureCoupling::doCheckpointData(CheckpointData<operation>* checkpointData,
+                                                          const t_commrec*           cr)
 {
     if (MASTER(cr))
     {
@@ -220,22 +225,24 @@ void VRescaleThermostat::doCheckpointData(CheckpointData<operation>* checkpointD
     }
 }
 
-void VRescaleThermostat::writeCheckpoint(WriteCheckpointData checkpointData, const t_commrec* cr)
+void VelocityScalingTemperatureCoupling::writeCheckpoint(WriteCheckpointData checkpointData,
+                                                         const t_commrec*    cr)
 {
     doCheckpointData<CheckpointDataOperation::Write>(&checkpointData, cr);
 }
 
-void VRescaleThermostat::readCheckpoint(ReadCheckpointData checkpointData, const t_commrec* cr)
+void VelocityScalingTemperatureCoupling::readCheckpoint(ReadCheckpointData checkpointData,
+                                                        const t_commrec*   cr)
 {
     doCheckpointData<CheckpointDataOperation::Read>(&checkpointData, cr);
 }
 
-const std::string& VRescaleThermostat::clientID()
+const std::string& VelocityScalingTemperatureCoupling::clientID()
 {
     return identifier_;
 }
 
-real VRescaleThermostat::conservedEnergyContribution() const
+real VelocityScalingTemperatureCoupling::conservedEnergyContribution() const
 {
     return (reportPreviousConservedEnergy_ == ReportPreviousStepConservedEnergy::Yes)
                    ? std::accumulate(thermostatIntegralPreviousStep_.begin(),
@@ -243,7 +250,7 @@ real VRescaleThermostat::conservedEnergyContribution() const
                    : std::accumulate(thermostatIntegral_.begin(), thermostatIntegral_.end(), 0.0);
 }
 
-ISimulatorElement* VRescaleThermostat::getElementPointerImpl(
+ISimulatorElement* VelocityScalingTemperatureCoupling::getElementPointerImpl(
         LegacySimulatorData*                    legacySimulatorData,
         ModularSimulatorAlgorithmBuilderHelper* builderHelper,
         StatePropagatorData gmx_unused* statePropagatorData,
@@ -254,13 +261,13 @@ ISimulatorElement* VRescaleThermostat::getElementPointerImpl(
         UseFullStepKE                         useFullStepKE,
         ReportPreviousStepConservedEnergy     reportPreviousStepConservedEnergy)
 {
-    auto* element    = builderHelper->storeElement(std::make_unique<VRescaleThermostat>(
+    auto* element = builderHelper->storeElement(std::make_unique<VelocityScalingTemperatureCoupling>(
             legacySimulatorData->inputrec->nsttcouple, offset, useFullStepKE, reportPreviousStepConservedEnergy,
             legacySimulatorData->inputrec->ld_seed, legacySimulatorData->inputrec->opts.ngtc,
             legacySimulatorData->inputrec->delta_t * legacySimulatorData->inputrec->nsttcouple,
             legacySimulatorData->inputrec->opts.ref_t, legacySimulatorData->inputrec->opts.tau_t,
             legacySimulatorData->inputrec->opts.nrdf, energyData));
-    auto* thermostat = static_cast<VRescaleThermostat*>(element);
+    auto* thermostat = static_cast<VelocityScalingTemperatureCoupling*>(element);
     builderHelper->registerThermostat([thermostat](const PropagatorThermostatConnection& connection) {
         thermostat->connectWithPropagator(connection);
     });
similarity index 83%
rename from src/gromacs/modularsimulator/vrescalethermostat.h
rename to src/gromacs/modularsimulator/velocityscalingtemperaturecoupling.h
index 7730b8e38e42912b0040c0dc34f76e6f9bfcc512..388bd4c4a913369686fcf7533879cf24024ce26c 100644 (file)
@@ -33,7 +33,8 @@
  * the research papers on the package. Check out http://www.gromacs.org.
  */
 /*! \internal \file
- * \brief Declares the v-rescale thermostat for the modular simulator
+ * \brief Declares a velocity-scaling temperature coupling element for
+ * the modular simulator
  *
  * \author Pascal Merz <pascal.merz@me.com>
  * \ingroup module_modularsimulator
@@ -41,8 +42,8 @@
  * This header is only used within the modular simulator module
  */
 
-#ifndef GMX_MODULARSIMULATOR_VRESCALETHERMOSTAT_H
-#define GMX_MODULARSIMULATOR_VRESCALETHERMOSTAT_H
+#ifndef GMX_MODULARSIMULATOR_VELOCITYSCALINGTEMPERATURECOUPLING_H
+#define GMX_MODULARSIMULATOR_VELOCITYSCALINGTEMPERATURECOUPLING_H
 
 #include "gromacs/utility/arrayref.h"
 
@@ -79,21 +80,21 @@ enum class ReportPreviousStepConservedEnergy
  * This element takes a callback to the propagator and updates the velocity
  * scaling factor according to the v-rescale thermostat.
  */
-class VRescaleThermostat final : public ISimulatorElement, public ICheckpointHelperClient
+class VelocityScalingTemperatureCoupling final : public ISimulatorElement, public ICheckpointHelperClient
 {
 public:
     //! Constructor
-    VRescaleThermostat(int                               nstcouple,
-                       int                               offset,
-                       UseFullStepKE                     useFullStepKE,
-                       ReportPreviousStepConservedEnergy reportPreviousConservedEnergy,
-                       int64_t                           seed,
-                       int                               numTemperatureGroups,
-                       double                            couplingTimeStep,
-                       const real*                       referenceTemperature,
-                       const real*                       couplingTime,
-                       const real*                       numDegreesOfFreedom,
-                       EnergyData*                       energyData);
+    VelocityScalingTemperatureCoupling(int                               nstcouple,
+                                       int                               offset,
+                                       UseFullStepKE                     useFullStepKE,
+                                       ReportPreviousStepConservedEnergy reportPreviousConservedEnergy,
+                                       int64_t                           seed,
+                                       int                               numTemperatureGroups,
+                                       double                            couplingTimeStep,
+                                       const real*                       referenceTemperature,
+                                       const real*                       couplingTime,
+                                       const real*                       numDegreesOfFreedom,
+                                       EnergyData*                       energyData);
 
     /*! \brief Register run function for step / time
      *
@@ -186,7 +187,7 @@ private:
     void setLambda(Step step);
 
     //! CheckpointHelper identifier
-    const std::string identifier_ = "VRescaleThermostat";
+    const std::string identifier_ = "VelocityScalingTemperatureCoupling";
     //! Helper function to read from / write to CheckpointData
     template<CheckpointDataOperation operation>
     void doCheckpointData(CheckpointData<operation>* checkpointData, const t_commrec* cr);
@@ -194,4 +195,4 @@ private:
 
 } // namespace gmx
 
-#endif // GMX_MODULARSIMULATOR_VRESCALETHERMOSTAT_H
+#endif // GMX_MODULARSIMULATOR_VELOCITYSCALINGTEMPERATURECOUPLING_H