1 #ifndef SIMP_COMPENSATED_PAIR_H 2 #define SIMP_COMPENSATED_PAIR_H 11 #include <util/param/ParamComposite.h> 12 #include <util/param/Begin.h> 13 #include <util/param/End.h> 31 template <
class BarePair,
class LinkPotential>
77 void set(std::string name,
int i,
int j,
double value);
89 double energy(
double rsq,
int i,
int j)
const;
103 double forceOverR(
double rsq,
int i,
int j)
const;
108 double cutoffSq(
int i,
int j)
const;
124 double epsilon(
int i,
int j)
const;
133 double get(std::string name,
int i,
int j)
const;
138 double maxLinkLength_;
141 double maxLinkLengthSq_;
148 double maxPairCutoff_;
153 double maxPairCutoffSq_;
178 template <
class BarePair,
class LinkPotential>
180 : maxPairCutoff_(0.0),
181 maxPairCutoffSq_(0.0),
187 std::string name(
"CompensatedPair");
189 name += pair_.className();
191 name += link_.className();
199 template <
class BarePair,
class LinkPotential>
201 : maxPairCutoff_(0.0),
212 template <
class BarePair,
class LinkPotential>
223 beginPtr = &
addBegin(pair_.className().c_str());
225 beginPtr->readParameters(in);
229 endPtr->readParameters(in);
234 beginPtr = &
addBegin(link_.className().c_str());
236 beginPtr->readParameters(in);
240 endPtr->readParameters(in);
246 read<double>(in,
"maxLinkLength", maxLinkLength_);
247 read<double>(in,
"temperature", temp_);
248 read<double>(in,
"mu", mu_);
251 activity_ = exp(mu_*beta_);
253 maxLinkLengthSq_ = maxLinkLength_*maxLinkLength_;
254 maxPairCutoff_ = maxLinkLength_;
255 if (pair_.maxPairCutoff() > maxLinkLength_) {
256 maxPairCutoff_ = pair_.maxPairCutoff();
258 maxPairCutoffSq_ = maxPairCutoff_*maxPairCutoff_;
264 template <
class BarePair,
class LinkPotential>
267 pair_.setNAtomType(nAtomType);
268 link_.setNBondType(1);
274 template <
class BarePair,
class LinkPotential>
276 { pair_.setEpsilon(i, j, epsilon); }
282 template <
class BarePair,
class LinkPotential>
284 {
return maxPairCutoff_; }
290 template <
class BarePair,
class LinkPotential>
293 double total = pair_.energy(rsq, i, j);
294 if (rsq < maxLinkLengthSq_) {
295 total += activity_ * temp_ * exp(-beta_ * link_.energy(rsq, 0));
304 template <
class BarePair,
class LinkPotential>
309 if (rsq < pair_.cutoffSq(i, j)) {
310 total += pair_.forceOverR(rsq, i, j);
312 if (rsq < maxLinkLengthSq_) {
313 total -= activity_ * exp(-beta_ * link_.energy(rsq, 0)) * link_.forceOverR(rsq, 0);
321 template <
class BarePair,
class LinkPotential>
324 {
return maxPairCutoffSq_; }
329 template <
class BarePair,
class LinkPotential>
331 ::set(std::string name,
int i,
int j,
double value)
333 if (name ==
"epsilon") {
334 pair_.setEpsilon(i, j, value);
343 template <
class BarePair,
class LinkPotential>
345 ::get(std::string name,
int i,
int j)
const 348 if (name ==
"epsilon") {
349 value = pair_.epsilon(i, j);
End bracket of a ParamComposite parameter block.
CompensatedPair()
Constructor.
double energy(double rsq, int i, int j) const
Returns interaction energy for a single pair of particles.
void setEpsilon(int i, int j, double epsilon)
Set LJ interaction energy for a specific pair of Atom types.
double cutoffSq(int i, int j) const
Get cutoff for pair potential, for a particular type pair.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
void setNAtomType(int nAtomType)
Set nAtomType value.
End & addEnd()
Add a closing bracket.
Compensated pair potential for transient gel.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.
Begin & addBegin(const char *label)
Add a Begin object representing a class name and bracket.
void readParameters(std::istream &in)
Read epsilon and sigma, initialize other variables.
void setIndent(const ParamComponent &parent, bool next=true)
Set indent level.
void setClassName(const char *className)
Set class name string.
void readParamComposite(std::istream &in, ParamComposite &child, bool next=true)
Add and read a required child ParamComposite.
double epsilon(int i, int j) const
Get LJ interaction energy for a specific pair of Atom types.
An object that can read multiple parameters from file.
double maxPairCutoff() const
Get maximum of pair cutoff distance, for all atom type pairs.
Beginning line of a composite parameter block.
double forceOverR(double rsq, int i, int j) const
Returns ratio of scalar pair interaction force to pair separation.