22 #include "vesselbase/VesselRegister.h"
23 #include "vesselbase/FunctionVessel.h"
24 #include "core/PlumedMain.h"
25 #include "core/Atoms.h"
29 namespace multicolvar {
38 std::vector<double>
df;
51 FunctionVessel::registerKeywords( keys );
52 keys.add(
"compulsory",
"I",
"1.0",
"Ionic strength (M)");
53 keys.add(
"compulsory",
"TEMP",
"300.0",
"Simulation temperature (K)");
54 keys.add(
"compulsory",
"EPSILON",
"80.0",
"Dielectric constant of solvent");
58 keys.
reserve(
"numbered",
"DHENERGY",
"calculate the Debye-Huckel interaction energy. This is a alternative "
59 "implementation of \\ref DHENERGY that is particularly useful if you "
60 "want to calculate the Debye-Huckel interaction energy and some other "
61 "function of set of distances between the atoms in the two groups. "
62 "The input for this keyword should read "
63 "DHENERGY={I=\\f$I\\f$ TEMP=\\f$T\\f$ EPSILON=\\f$\\epsilon\\f$}.");
64 keys.
addOutputComponent(
"dhenergy",
"DHENERGY",
"the Debye-Huckel interaction energy. You can calculate "
65 "this quantity multiple times using different parameters");
73 plumed_massert(
mycolv,
"DHENERGY can only be used with MultiColvars and should only be used with DISTANCES");
78 if( catoms.usingNaturalUnits() )
error(
"DHENERGY cannot be used for calculations performed with natural units");
79 constant=138.935458111/catoms.getUnits().getEnergy()/catoms.getUnits().getLength();
80 k=sqrt(
I/(
epsilon*
T))*502.903741125*catoms.getUnits().getLength();
84 std::ostringstream ostr;
85 ostr<<
"the Debye-Huckel interaction energy "<<
getAction()->
plumed.
cite(
"Do, Carloni, Varani and Bussi, J. Chem. Theory Comput. 9, 1720 (2013)")<<
".";
86 ostr<<
" Parameters : temperature "<<
T<<
" K, ionic strength "<<
I<<
" M, ";
87 ostr<<
"solvent dielectric constant "<<
epsilon;
95 double invdistance = 1.0 / val;
97 double dval=-(
k+invdistance)*f;
105 df[0]=1.0;
df[1]=0.0;
static void registerKeywords(Keywords &keys)
double getFinalValue(const unsigned &j)
Get the nth value in the distribution.
void chainRuleForElementDerivatives(const unsigned &, const unsigned &, const double &, Vessel *)
Merge the derivatives.
double getCharge(unsigned) const
Get the charge of atom iatom.
std::string function_description()
The rest of the description of what we are calculating.
void setOutputValue(const double &val)
Set the final value.
Objects that inherit from FunctionVessel can be used (in tandem with PLMD::ActionWithVessel) to calcu...
static void reserveKeyword(Keywords &keys)
Class containing atom related quantities from the MD code.
void mergeFinalDerivatives(const std::vector< double > &df)
This does a combination of the product and chain rules.
void addOutputComponent(const std::string &name, const std::string &key, const std::string &descr)
Add a potential component which can be output by this particular action.
void finish()
Complete the calculation once the loop is finished.
This class holds the keywords and their documentation.
void addValueIgnoringTolerance(const unsigned &jval, const double &val)
Add some value to the accumulator and ignore the tolerance.
#define PLUMED_REGISTER_VESSEL(classname, keyword)
void reserve(const std::string &t, const std::string &k, const std::string &d, const bool isvessel=false)
Reserve a keyword.
PlumedMain & plumed
Reference to main plumed object.
void error(const std::string &errmsg)
Report an error.
This class is used to pass the input to Vessels.
bool calculate()
Calculate the part of the vessel that is done in the loop.
AtomNumber getAbsoluteIndex(unsigned) const
Get the absolute index of atom iatom.
This is the abstract base class to use for creating distributions of colvars and functions thereof...
DHEnergy(const vesselbase::VesselOptions &da)
void parse(const std::string &key, T &t)
Parse something from the input.
std::string cite(const std::string &)
Add a citation, returning a string containing the reference number, something like "[10]"...
double getElementValue(const unsigned &ival) const
Get the value of this element.
ActionWithVessel * getAction()
Return a pointer to the action we are working in.