Simpatico  v1.10
ColVarPotentialTmpl.tpp
1 /*
2 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "ColVarPotentialTmpl.h"
9 #include <mcMd/simulation/System.h>
10 
11 namespace McMd
12 {
13 
14  using namespace Util;
15 
19  template <class ColVarType, class BiasType>
21  : SpecialPotential(false),
22  systemPtr_(&system),
23  colVar_(),
24  bias_(),
25  { setClassName("ColVarPotential"); }
26 
27  /*
28  * Destructor.
29  */
30  template <class ColVarType, class BiasType>
32  {}
33 
34  /*
35  * Read parameters from file.
36  */
37  template <class ColVarType, class BiasType>
38  void
40  {
41  colVar_.readParam(in);
42  bias_.readParam(in);
43  }
44 
45  /*
46  * Compute total energy.
47  */
48  template <class ColVarType, class BiasType>
50  {
51  double cv = colVar_.value();
52  return bias_.value(cv);
53  }
54 
55  /*
56  * Unset energy and value of collective variable.
57  */
58  template <class ColVarType, class BiasType> void
60  {
62  colVar_.unset();
63  }
64 
65  /*
66  * Add forces from this potential to all atomic forces.
67  */
68  template <class ColVarType, class BiasType>
70  {
71  double cv = colVar_.value();
72  double dwdc = bias_.derivative(cv);
73  colVar.addForces(dwdc);
74  }
75 
76 }
A set of interacting Molecules enclosed by a Boundary.
Definition: System.h:115
ColVarPotentialTmpl(System &system)
Constructor.
void readParameters(std::istream &in)
Read parameters.
Specialized potential for an MD simulation.
virtual ~ColVarPotentialTmpl()
Destructor.
virtual void unsetEnergy()
Mark the energy as unknown.
Utility classes for scientific computation.
Definition: accumulators.mod:1
void computeEnergy()
Compute total energy.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void unsetEnergy()
Unset the total energy (mark as unknown or obsolete).
void setClassName(const char *className)
Set class name string.
void addForces()
Add forces from this potential to all atomic forces.