3 #ifndef MCMD_MC_EXTERNAL_PERTURBATION_H 4 #define MCMD_MC_EXTERNAL_PERTURBATION_H 14 #include <mcMd/perturb/LinearPerturbation.h> 15 #include <mcMd/potentials/external/ExternalPotentialImpl.h> 16 #include <mcMd/mcSimulation/McSystem.h> 17 #include <mcMd/simulation/Simulation.h> 18 #include <mcMd/chemistry/Atom.h> 19 #include <simp/ensembles/EnergyEnsemble.h> 37 template <
class Interaction >
62 virtual void readParameters(std::istream& in);
67 virtual void setParameter();
75 virtual double parameter(
int i)
const;
83 virtual double derivative(
int i)
const;
88 Interaction& interaction()
const;
93 mutable Interaction* interactionPtr_;
103 template <
class Interaction >
108 { setClassName(
"McExternalPerturbation"); }
113 template <
class Interaction >
120 template <
class Interaction >
130 template <
class Interaction >
133 if (interactionPtr_ == 0) {
138 UTIL_THROW(
"Failed dynamic cast of ExternalPotential");
142 return *interactionPtr_;
148 template <
class Interaction >
151 interaction().setExternalParameter(parameter_[0]);
157 template <
class Interaction >
160 if (i > nParameters_) {
161 UTIL_THROW(
"perturbation parameter index is out of bounds");
163 return interaction().externalParameter();
169 template <
class Interaction >
173 if (i > nParameters_) {
174 UTIL_THROW(
"perturbation parameter index is out of bounds");
177 if (fabs(parameter_[i] - parameter(i)) > 1.0E-8) {
178 UTIL_THROW(
"Perturbation parameter is not set correctly");
187 for (
int iSpec=0; iSpec < system().simulation().nSpecies(); ++iSpec){
188 for (system().begin(iSpec, molIter); molIter.
notEnd(); ++molIter){
189 for (molIter->begin(atomIter); atomIter.
notEnd(); ++atomIter) {
190 energy += interaction().energy(atomIter->position(), atomIter->typeId());
197 if (system().energyEnsemble().isIsothermal()) {
198 energy *= system().energyEnsemble().beta();
203 return energy/parameter_[i];
208 #endif // #ifdef SIMP_EXTERNAL 209 #endif // #ifdef MCMD_PERTURB A System for use in a Markov chain Monte Carlo simulation.
Interaction & interaction() const
Return the external potential interaction.
virtual double derivative(int i) const
Return external potential energy / ( kT *external parameter )
bool notEnd() const
Is the current pointer not at the end of the array?
A Perturbation in the external potential external parameter.
A Perturbation that is a linear function of a parameter.
Classes used by all simpatico molecular simulations.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
virtual void readParameters(std::istream &in)
Read external parameter from file.
Abstract External Potential class.
Interaction & interaction()
Return external interaction by reference.
bool notEnd() const
Is the current pointer not at the end of the PArray?
Utility classes for scientific computation.
int getNParameters() const
Gets the number of parameters per system.
Forward iterator for an Array or a C array.
Forward iterator for a PArray.
Template implementation of ExternalPotential.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
virtual double parameter(int i) const
Return the external parameter for this System.
McExternalPerturbation(McSystem &system, int size, int rank)
Constructor.
virtual void setParameter()
Set external parameter for this System.
void readParameters(std::istream &in)
Read perturbation parameter(s) from file.