Simpatico  v1.10
DpdPair.h
1 #ifndef SIMP_DPD_PAIR_H
2 #define SIMP_DPD_PAIR_H
3 
4 /*
5 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/param/ParamComposite.h>
12 #include <util/global.h>
13 
14 #include <math.h>
15 
16 namespace Simp
17 {
18 
19  using namespace Util;
20 
31  class DpdPair : public ParamComposite
32  {
33 
34  public:
35 
39  DpdPair();
40 
44  DpdPair(const DpdPair& other);
45 
49  DpdPair& operator = (const DpdPair& other);
50 
52 
53 
59  void setNAtomType(int nAtomType);
60 
68  void readParameters(std::istream &in);
69 
75  virtual void loadParameters(Serializable::IArchive &ar);
76 
82  virtual void save(Serializable::OArchive &ar);
83 
91  void setEpsilon(int i, int j, double epsilon);
92 
100  void setSigma(int i, int j, double sigma);
101 
110  void set(std::string name, int i, int j, double value);
111 
113 
115 
124  double energy(double rsq, int i, int j) const;
125 
148  double forceOverR(double rsq, int i, int j) const;
149 
157  double cutoffSq(int i, int j) const;
158 
162  double maxPairCutoff() const;
163 
171  double get(std::string name, int i, int j) const;
172 
174 
176 
184  double epsilon(int i, int j) const;
185 
193  double sigma(int i, int j) const;
194 
196 
197  private:
198 
200  static const int MaxAtomType = 4;
201 
202  // Parameters for different types of particle pairs
203  double epsilon_[MaxAtomType][MaxAtomType];
204  double sigma_[MaxAtomType][MaxAtomType];
205  double sigmaSq_[MaxAtomType][MaxAtomType];
206  double ce_[MaxAtomType][MaxAtomType];
207  double cf_[MaxAtomType][MaxAtomType];
208 
214  double maxPairCutoff_;
215 
217  int nAtomType_;
218 
220  bool isInitialized_;
221 
222  };
223 
224  // inline methods
225 
226  /*
227  * Calculate interaction energy for a pair, as function of squared distance.
228  */
229  inline double DpdPair::energy(double rsq, int i, int j) const
230  {
231  double dr;
232  if (rsq < sigmaSq_[i][j]) {
233  dr = sqrt(rsq) - sigma_[i][j];
234  return ce_[i][j]*dr*dr;
235  } else {
236  return 0.0;
237  }
238  }
239 
240  /*
241  * Calculate force/distance for a pair as function of squared distance.
242  */
243  inline double DpdPair::forceOverR(double rsq, int i, int j) const
244  {
245  if (rsq < sigmaSq_[i][j]) {
246  return cf_[i][j]*(sigma_[i][j]/sqrt(rsq) - 1.0);
247  } else {
248  return 0.0;
249  }
250  }
251 
252  /*
253  * Calculate force/distance for a pair as function of squared distance.
254  */
255  inline double DpdPair::cutoffSq(int i, int j) const
256  { return sigmaSq_[i][j]; }
257 
258 }
259 #endif
double forceOverR(double rsq, int i, int j) const
Returns ratio of scalar pair interaction force to pair separation.
Definition: DpdPair.h:243
void setEpsilon(int i, int j, double epsilon)
Set LJ interaction energy for a specific pair of Atom types.
Definition: DpdPair.cpp:163
double cutoffSq(int i, int j) const
Get square of cutoff distance for specific type pair.
Definition: DpdPair.h:255
Soft pair potential used in dissipative particle dynamics (DPD) simulations of Groot, Warren et al.
Definition: DpdPair.h:31
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
Saving / output archive for binary ostream.
double sigma(int i, int j) const
Get range for a specific pair of Atom types.
Definition: DpdPair.cpp:233
DpdPair & operator=(const DpdPair &other)
Assignment.
Definition: DpdPair.cpp:51
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Definition: DpdPair.cpp:136
Utility classes for scientific computation.
Definition: accumulators.mod:1
DpdPair()
Constructor.
Definition: DpdPair.cpp:22
void readParameters(std::istream &in)
Read epsilon and sigma, initialize other variables.
Definition: DpdPair.cpp:72
double energy(double rsq, int i, int j) const
Returns interaction energy for a single pair of particles.
Definition: DpdPair.h:229
Saving archive for binary istream.
An object that can read multiple parameters from file.
void setSigma(int i, int j, double sigma)
Get LJ range for a specific pair of Atom types.
Definition: DpdPair.cpp:191
double epsilon(int i, int j) const
Get interaction energy for a specific pair of Atom types.
Definition: DpdPair.cpp:223
double maxPairCutoff() const
Get maximum of pair cutoff distance, for all atom type pairs.
Definition: DpdPair.cpp:243
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Definition: DpdPair.cpp:105
void setNAtomType(int nAtomType)
Set nAtomType value.
Definition: DpdPair.cpp:149