From: Magnus Lundborg Date: Tue, 1 Sep 2020 11:24:20 +0000 (+0200) Subject: Print lambda state to log file if using AWH for FEP. X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=7d7cbb8445895cbd113f458b11258c0d4b3cc76a;p=alexxy%2Fgromacs.git Print lambda state to log file if using AWH for FEP. Change-Id: I08c7e6d51a299eb53556d5bde63c29f7c7640f6e --- diff --git a/src/gromacs/awh/awh.h b/src/gromacs/awh/awh.h index d8bdfb71ed..efd7c80a43 100644 --- a/src/gromacs/awh/awh.h +++ b/src/gromacs/awh/awh.h @@ -264,6 +264,10 @@ public: */ bool needForeignEnergyDifferences(int64_t step) const; + /*! \brief Returns true if AWH has a bias with a free energy lambda state dimension at all. + */ + bool hasFepLambdaDimension() const; + private: /*! \brief Returns whether we need to write output at the current step. * @@ -271,10 +275,6 @@ private: */ bool isOutputStep(int64_t step) const; - /*! \brief Returns true if AWH has a bias with a free energy lambda state dimension at all. - */ - bool hasFepLambdaDimension() const; - private: std::vector biasCoupledToSystem_; /**< AWH biases and definitions of their coupling to the system. */ const int64_t seed_; /**< Random seed for MC jumping with umbrella type bias potential. */ diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index 4b907ec397..3d1c95a411 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -1532,6 +1532,11 @@ void gmx::LegacySimulator::do_md() do_log ? fplog : nullptr, step, t, fr->fcdata.get(), awh.get()); } + if (do_log && ir->bDoAwh && awh->hasFepLambdaDimension()) + { + const bool isInitialOutput = false; + printLambdaStateToLog(fplog, state->lambda, isInitialOutput); + } if (ir->bPull) { diff --git a/src/gromacs/mdtypes/state.cpp b/src/gromacs/mdtypes/state.cpp index 61c280f997..5e80a74208 100644 --- a/src/gromacs/mdtypes/state.cpp +++ b/src/gromacs/mdtypes/state.cpp @@ -280,6 +280,19 @@ void preserve_box_shape(const t_inputrec* ir, matrix box_rel, matrix box) } } +void printLambdaStateToLog(FILE* fplog, const gmx::ArrayRef lambda, const bool isInitialOutput) +{ + if (fplog != nullptr) + { + fprintf(fplog, "%s vector of lambda components:[ ", isInitialOutput ? "Initial" : "Current"); + for (const auto& l : lambda) + { + fprintf(fplog, "%10.4f ", l); + } + fprintf(fplog, "]\n%s", isInitialOutput ? "" : "\n"); + } +} + void initialize_lambdas(FILE* fplog, const t_inputrec& ir, bool isMaster, @@ -338,13 +351,6 @@ void initialize_lambdas(FILE* fplog, } /* Send to the log the information on the current lambdas */ - if (fplog != nullptr) - { - fprintf(fplog, "Initial vector of lambda components:[ "); - for (const auto& l : lambda) - { - fprintf(fplog, "%10.4f ", l); - } - fprintf(fplog, "]\n"); - } + const bool isInitialOutput = true; + printLambdaStateToLog(fplog, lambda, isInitialOutput); } diff --git a/src/gromacs/mdtypes/state.h b/src/gromacs/mdtypes/state.h index 016711df7e..7be1407fbf 100644 --- a/src/gromacs/mdtypes/state.h +++ b/src/gromacs/mdtypes/state.h @@ -341,6 +341,15 @@ static inline gmx::ArrayRef positionsFromStatePointer(const t_s } }; +/*! \brief Prints the current lambda state to the log file. + * + * \param[in] fplog The log file. If fplog == nullptr there will be no output. + * \param[in] lambda The array of lambda values. + * \param[in] isInitialOutput Whether this output is the initial lambda state or not. + */ +void printLambdaStateToLog(FILE* fplog, gmx::ArrayRef lambda, bool isInitialOutput); + + /*! \brief Fills fep_state, lambda, and lam0 if needed * * If FEP or simulated tempering is in use: