Simpatico  v1.10
HarmonicCvBias.cpp
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 "HarmonicCvBias.h"
9 
10 namespace McMd
11 {
12 
13  using namespace Util;
14 
15  /*
16  * Default constructor.
17  */
19  {}
20 
21  /*
22  * Default destructor.
23  */
25  {}
26 
27  /*
28  * Read parameters from file.
29  */
30  void HarmonicCvBias::readParameters(std::istream& in)
31  {
32  read<double>(in, "cv0", cv0_);
33  read<double>(in, "k", k_);
34  }
35 
36  /*
37  * Load internal state from archive.
38  */
40  {
41  loadParameter<double>(ar, "cv0", cv0_);
42  loadParameter<double>(ar, "k", k_);
43  }
44 
45  /*
46  * Sae internal state to archive.
47  */
49  {
50  ar << cv0_;
51  ar << k_;
52  }
53 
54  /*
55  * Compute and return the bias potential value.
56  */
57  double HarmonicCvBias::value(double cv)
58  {
59  double dcv = cv - cv0_;
60  return 0.5*k_*dcv*dcv;
61  }
62 
63  /*
64  * Compute and return the derivative of the bias potential.
65  */
66  double HarmonicCvBias::derivative(double cv)
67  {
68  return k_*(cv - cv0_);
69  }
70 
71 
72 }
HarmonicCvBias()
Constructor.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Saving / output archive for binary ostream.
virtual double value(double cv)
Compute and return the bias potential value.
Utility classes for scientific computation.
Definition: accumulators.mod:1
virtual double derivative(double cv)
Compute and return the derivative of the bias potential.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
virtual void readParameters(std::istream &in)
Read parameters from file.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
virtual ~HarmonicCvBias()
Destructor.