this->densityFittingSimulationParameters_.setPeriodicBoundaryConditionType(pbc);
};
notifier->notifier_.subscribe(setPeriodicBoundaryContionsFunction);
+
+ // adding output to energy file
+ const auto requestEnergyOutput
+ = [this](MdModulesEnergyOutputToDensityFittingRequestChecker *energyOutputRequest) {
+ this->setEnergyOutputRequest(energyOutputRequest);
+ };
+ notifier->notifier_.subscribe(requestEnergyOutput);
}
//! From IMDModule
*/
void constructLocalAtomSet(LocalAtomSetManager * localAtomSetManager)
{
- LocalAtomSet atomSet = localAtomSetManager->add(densityFittingOptions_.buildParameters().indices_);
- densityFittingSimulationParameters_.setLocalAtomSet(atomSet);
+ if (densityFittingOptions_.active())
+ {
+ LocalAtomSet atomSet
+ = localAtomSetManager->add(densityFittingOptions_.buildParameters().indices_);
+ densityFittingSimulationParameters_.setLocalAtomSet(atomSet);
+ }
+ }
+
+ /*! \brief Request energy output to energy file during simulation.
+ */
+ void setEnergyOutputRequest(MdModulesEnergyOutputToDensityFittingRequestChecker *energyOutputRequest)
+ {
+ energyOutputRequest->energyOutputToDensityFitting_ = densityFittingOptions_.active();
}
private:
// calculate corresponding potential energy
const float similarity = measure_.similarity(gaussTransform_.constView());
const real energy = -similarity * parameters_.forceConstant_;
- forceProviderOutput->enerd_.term[F_COM_PULL] += energy;
+ forceProviderOutput->enerd_.term[F_DENSITYFITTING] += energy;
}
/********************************************************************
{ 79, F_DVDL_BONDED, },
{ 79, F_DVDL_RESTRAINT },
{ 79, F_DVDL_TEMPERATURE },
+ { tpxv_GenericInternalParameters, F_DENSITYFITTING },
};
#define NFTUPD asize(ftupd)
BondedInteractions {unimplemented, -1 }, // F_VSITE4FDN
BondedInteractions {unimplemented, -1 }, // F_VSITEN
BondedInteractions {unimplemented, -1 }, // F_COM_PULL
+ BondedInteractions {unimplemented, -1 }, // F_DENSITYFITTING
BondedInteractions {unimplemented, -1 }, // F_EQM
BondedInteractions {unimplemented, -1 }, // F_EPOT
BondedInteractions {unimplemented, -1 }, // F_EKIN
#include "gromacs/trajectory/energyframe.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/mdmodulenotification.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
* \todo Remove GMX_CONSTRAINTVIR
* \todo Write free-energy output also to energy file (after adding more tests)
*/
-EnergyOutput::EnergyOutput(ener_file *fp_ene,
- const gmx_mtop_t *mtop,
- const t_inputrec *ir,
- const pull_t *pull_work,
- FILE *fp_dhdl,
- bool isRerun)
+EnergyOutput::EnergyOutput(ener_file * fp_ene,
+ const gmx_mtop_t * mtop,
+ const t_inputrec * ir,
+ const pull_t * pull_work,
+ FILE * fp_dhdl,
+ bool isRerun,
+ const MdModulesNotifier &mdModulesNotifier)
{
const char *ener_nm[F_NRE];
static const char *vir_nm[] = {
bEner_[F_ORIRESDEV] = (gmx_mtop_ftype_count(mtop, F_ORIRES) > 0);
bEner_[F_COM_PULL] = ((ir->bPull && pull_have_potential(pull_work)) || ir->bRot);
+ MdModulesEnergyOutputToDensityFittingRequestChecker mdModulesAddOutputToDensityFittingFieldRequest;
+ mdModulesNotifier.notifier_.notify(&mdModulesAddOutputToDensityFittingFieldRequest);
+
+ bEner_[F_DENSITYFITTING] = mdModulesAddOutputToDensityFittingFieldRequest.energyOutputToDensityFitting_;
+
+
// Counting the energy terms that will be printed and saving their names
f_nre_ = 0;
for (i = 0; i < F_NRE; i++)
{
class Awh;
class Constraints;
+struct MdModulesNotifier;
}
//! \brief Printed names for intergroup energies
* \param[in] pull_work Pulling simulations data
* \param[in] fp_dhdl FEP file.
* \param[in] isRerun Is this is a rerun instead of the simulations.
+ * \param[in] mdModulesNotifier Notifications to MD modules.
*/
- EnergyOutput(ener_file *fp_ene,
- const gmx_mtop_t *mtop,
- const t_inputrec *ir,
- const pull_t *pull_work,
- FILE *fp_dhdl,
- bool isRerun);
+ EnergyOutput(ener_file * fp_ene,
+ const gmx_mtop_t * mtop,
+ const t_inputrec * ir,
+ const pull_t * pull_work,
+ FILE * fp_dhdl,
+ bool isRerun,
+ const MdModulesNotifier &mdModulesNotifier);
~EnergyOutput();
#include "gromacs/mdtypes/state.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/mdmodulenotification.h"
#include "gromacs/utility/stringutil.h"
#include "gromacs/utility/textreader.h"
#include "gromacs/utility/unique_cptr.h"
state_.nhpres_xi[k] = (*testValue += 0.1);
state_.nhpres_vxi[k] = (*testValue += 0.1);
}
-
}
/*! \brief Check if the contents of the .edr file correspond to the reference data.
inputrec_.ref_p[YY][XX] = 1.0;
}
- std::unique_ptr<EnergyOutput> energyOutput = std::make_unique<EnergyOutput>(energyFile_, &mtop_, &inputrec_, nullptr, nullptr, parameters.isRerun);
+ MdModulesNotifier mdModulesNotifier;
+ std::unique_ptr<EnergyOutput> energyOutput = std::make_unique<EnergyOutput>(energyFile_, &mtop_, &inputrec_, nullptr, nullptr, parameters.isRerun, mdModulesNotifier);
// Add synthetic data for a single step
double testValue = 10.0;
}
gmx_mdoutf *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, mdModulesNotifier, ir, top_global, oenv, wcycle,
StartingBehavior::NewSimulation);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, ir, pull_work, mdoutf_get_fp_dhdl(outf), false);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, ir, pull_work, mdoutf_get_fp_dhdl(outf), false, mdModulesNotifier);
gstat = global_stat_init(ir);
gmx_mdoutf *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, mdModulesNotifier, ir, top_global, oenv, wcycle,
StartingBehavior::NewSimulation);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, ir, pull_work, mdoutf_get_fp_dhdl(outf), true);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, ir, pull_work, mdoutf_get_fp_dhdl(outf), true, mdModulesNotifier);
gstat = global_stat_init(ir);
vsite, constr, nullptr);
gmx_mdoutf *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, mdModulesNotifier, inputrec, top_global, nullptr, wcycle,
StartingBehavior::NewSimulation);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work, nullptr, false);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work, nullptr, false, mdModulesNotifier);
/* Print to log file */
print_em_start(fplog, cr, walltime_accounting, wcycle, CG);
vsite, constr, nullptr);
gmx_mdoutf *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, mdModulesNotifier, inputrec, top_global, nullptr, wcycle,
StartingBehavior::NewSimulation);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work, nullptr, false);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work, nullptr, false, mdModulesNotifier);
start = 0;
end = mdatoms->homenr;
vsite, constr, nullptr);
gmx_mdoutf *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, mdModulesNotifier, inputrec, top_global, nullptr, wcycle,
StartingBehavior::NewSimulation);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work, nullptr, false);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work, nullptr, false, mdModulesNotifier);
/* Print to log file */
print_em_start(fplog, cr, walltime_accounting, wcycle, SD);
initialize_lambdas(fplog, *ir, MASTER(cr), &state_global->fep_state, state_global->lambda, lam0);
gmx_mdoutf *outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider, mdModulesNotifier, ir, top_global, oenv, wcycle,
StartingBehavior::NewSimulation);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, ir, pull_work, mdoutf_get_fp_dhdl(outf), true);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, ir, pull_work, mdoutf_get_fp_dhdl(outf), true, mdModulesNotifier);
gstat = global_stat_init(ir);
class Awh;
EnergyElement::EnergyElement(
- StatePropagatorData *statePropagatorData,
- const gmx_mtop_t *globalTopology,
- const t_inputrec *inputrec,
- const MDAtoms *mdAtoms,
- gmx_enerdata_t *enerd,
- gmx_ekindata_t *ekind,
- const Constraints *constr,
- FILE *fplog,
- t_fcdata *fcd,
- bool isMaster) :
+ StatePropagatorData *statePropagatorData,
+ const gmx_mtop_t *globalTopology,
+ const t_inputrec *inputrec,
+ const MDAtoms *mdAtoms,
+ gmx_enerdata_t *enerd,
+ gmx_ekindata_t *ekind,
+ const Constraints *constr,
+ FILE *fplog,
+ t_fcdata *fcd,
+ const MdModulesNotifier &mdModulesNotifier,
+ bool isMaster) :
isMaster_(isMaster),
energyWritingStep_(-1),
energyCalculationStep_(-1),
constr_(constr),
fplog_(fplog),
fcd_(fcd),
+ mdModulesNotifier_(mdModulesNotifier),
groups_(&globalTopology->groups)
{
clear_mat(forceVirial_);
pull_t *pull_work = nullptr;
energyOutput_ = std::make_unique<EnergyOutput>(
mdoutf_get_fp_ene(outf), top_global_,
- inputrec_, pull_work, mdoutf_get_fp_dhdl(outf), false);
+ inputrec_, pull_work, mdoutf_get_fp_dhdl(outf), false,
+ mdModulesNotifier_);
if (!isMaster_)
{
class EnergyOutput;
class MDAtoms;
class StatePropagatorData;
+struct MdModulesNotifier;
//! \addtogroup module_modularsimulator
//! \{
const Constraints *constr,
FILE *fplog,
t_fcdata *fcd,
+ const MdModulesNotifier &mdModulesNotifier,
bool isMaster);
/*! \brief Register run function for step / time
* Pointers to Simulator data
*/
//! The microstate
- StatePropagatorData * statePropagatorData_;
+ StatePropagatorData *statePropagatorData_;
//! Contains user input mdp options.
- const t_inputrec *inputrec_;
+ const t_inputrec *inputrec_;
//! Full system topology.
- const gmx_mtop_t *top_global_;
+ const gmx_mtop_t *top_global_;
//! Atom parameters for this domain.
- const MDAtoms *mdAtoms_;
+ const MDAtoms *mdAtoms_;
//! Energy data structure
- gmx_enerdata_t *enerd_;
+ gmx_enerdata_t *enerd_;
//! Kinetic energy data
- gmx_ekindata_t *ekind_;
+ gmx_ekindata_t *ekind_;
//! Handles constraints.
- const Constraints *constr_;
+ const Constraints *constr_;
//! Handles logging.
- FILE *fplog_;
+ FILE *fplog_;
//! Helper struct for force calculations.
- t_fcdata *fcd_;
+ t_fcdata *fcd_;
+ //! Notification to MD modules
+ const MdModulesNotifier &mdModulesNotifier_;
//! Global topology groups
- const SimulationGroups *groups_;
+ const SimulationGroups *groups_;
};
//! /}
def_vsite ("VSITE4FDN", "Virtual site 4fdn", 5, 3 ),
def_vsite ("VSITEN", "Virtual site N", 2, 2 ),
def_nofc ("COM_PULL", "COM Pull En." ),
+ def_nofc ("DENSITYFIT", "Density fitting"),
def_nofc ("EQM", "Quantum En." ),
def_nofc ("EPOT", "Potential" ),
def_nofc ("EKIN", "Kinetic En." ),
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2014,2015,2016,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2016,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#define IS_TABULATED(ftype) (interaction_function[(ftype)].flags & IF_TABULATED)
/* this MUST correspond to the
- t_interaction_function[F_NRE] in gmxlib/ifunc.c */
+ t_interaction_function[F_NRE] in gmxlib/ifunc.cpp */
enum
{
F_BONDS,
F_VSITE4FDN,
F_VSITEN,
F_COM_PULL,
+ F_DENSITYFITTING,
F_EQM,
F_EPOT,
F_EKIN,
int pbcType;
};
+struct MdModulesEnergyOutputToDensityFittingRequestChecker
+{
+ bool energyOutputToDensityFitting_ = false;
+};
+
struct MdModulesNotifier
{
//! Register callback function types for MdModule
KeyValueTreeObjectBuilder,
const KeyValueTreeObject &,
LocalAtomSetManager *,
+ MdModulesEnergyOutputToDensityFittingRequestChecker *,
MdModulesCheckpointReadingDataOnMaster,
MdModulesCheckpointReadingBroadcast,
MdModulesWriteCheckpointData,