faunus
potentials.h
1 #pragma once
2 #include "potentials_base.h"
3 #include "tabulate.h"
4 #include "functionparser.h"
5 #include "multipole.h"
6 #include "spherocylinder.h"
7 #include <coulombgalore.h>
8 
9 namespace Faunus::pairpotential {
10 
16 {
17  private:
18  TExtractorFunc extract_sigma;
19  TExtractorFunc extract_epsilon;
20 
21  protected:
22  TPairMatrixPtr sigma_squared; // sigma_ij * sigma_ij
23  TPairMatrixPtr epsilon_quadruple; // 4 * epsilon_ij
24  void initPairMatrices() override;
25  void extractorsFromJson(const json& j) override;
26 
27  public:
28  explicit LennardJones(
29  const std::string& name = "lennardjones", const std::string& cite = std::string(),
30  CombinationRuleType combination_rule = CombinationRuleType::LORENTZ_BERTHELOT);
31 
32  inline Point force(const Particle& particle_a, const Particle& particle_b,
33  double squared_distance, const Point& b_towards_a) const override
34  {
35  const auto s6 = powi((*sigma_squared)(particle_a.id, particle_b.id), 3);
36  const auto r6 = squared_distance * squared_distance * squared_distance;
37  const auto r14 = r6 * r6 * squared_distance;
38  return 6.0 * (*epsilon_quadruple)(particle_a.id, particle_b.id) * s6 * (2.0 * s6 - r6) /
39  r14 * b_towards_a; // force in a
40  }
41 
42  inline double operator()(const Particle& particle_a, const Particle& particle_b,
43  double squared_distance,
44  [[maybe_unused]] const Point& b_towards_a) const override
45  {
46  auto x = (*sigma_squared)(particle_a.id, particle_b.id) / squared_distance; // s2/r2
47  x = x * x * x; // s6/r6
48  return (*epsilon_quadruple)(particle_a.id, particle_b.id) * (x * x - x);
49  }
50 };
51 
78 {
79  private:
80  TExtractorFunc extract_sigma;
81  TExtractorFunc extract_epsilon;
82  TExtractorFunc extract_lambda;
83 
84  static constexpr double two_to_one_sixth_squared = 1.2599210498948732; // 2^(1/3)
85 
86  protected:
87  TPairMatrixPtr sigma_squared;
88  TPairMatrixPtr epsilon_quadruple;
89  TPairMatrixPtr epsilon;
90  TPairMatrixPtr lambda;
91  void initPairMatrices() override;
92  void extractorsFromJson(const json& j) override;
93 
94  public:
95  explicit AshbaughHatch(const std::string& name = "ashbaugh-hatch",
96  const std::string& cite = "doi:10.1063/1.2895747",
97  CombinationRuleType combination_rule = CombinationRuleType::LORENTZ_BERTHELOT);
98 
99  inline double operator()(const Particle& a, const Particle& b, double squared_distance,
100  [[maybe_unused]] const Point& b_towards_a) const override
101  {
102  const auto sigma2 = (*sigma_squared)(a.id, b.id);
103  const auto r_min_squared = sigma2 * two_to_one_sixth_squared;
104  auto x = sigma2 / squared_distance; // (σ/r)²
105  x = x * x * x; // (σ/r)^6
106  const auto v_lj = (*epsilon_quadruple)(a.id, b.id) * (x * x - x); // 4ε[(σ/r)^12 - (σ/r)^6]
107  if (squared_distance <= r_min_squared) {
108  // Repulsive region: V_LJ + ε(1 - λ)
109  return v_lj + (*epsilon)(a.id, b.id) * (1.0 - (*lambda)(a.id, b.id));
110  }
111  // Attractive region: λ * V_LJ
112  return (*lambda)(a.id, b.id) * v_lj;
113  }
114 
115  inline Point force(const Particle& a, const Particle& b, double squared_distance,
116  const Point& b_towards_a) const override
117  {
118  const auto sigma2 = (*sigma_squared)(a.id, b.id);
119  const auto r_min_squared = sigma2 * two_to_one_sixth_squared;
120  const auto s6 = sigma2 * sigma2 * sigma2; // σ^6
121  const auto r6 = squared_distance * squared_distance * squared_distance;
122  const auto r14 = r6 * r6 * squared_distance;
123  // LJ force magnitude: 6 * 4ε * σ^6 * (2σ^6 - r^6) / r^14
124  const auto f_lj = 6.0 * (*epsilon_quadruple)(a.id, b.id) * s6 * (2.0 * s6 - r6) / r14;
125  if (squared_distance <= r_min_squared) {
126  // Repulsive region: same force as LJ (constant term doesn't contribute)
127  return f_lj * b_towards_a;
128  }
129  // Attractive region: λ * F_LJ
130  return (*lambda)(a.id, b.id) * f_lj * b_towards_a;
131  }
132 };
133 
148 {
149  static constexpr double onefourth = 0.25, twototwosixth = 1.2599210498948732;
150 
151  inline double operator()(const Particle& a, const Particle& b, double squared_distance) const
152  {
153  auto x = (*sigma_squared)(a.id, b.id); // s^2
154  if (squared_distance > x * twototwosixth) {
155  return 0;
156  }
157  x = x / squared_distance; // (s/r)^2
158  x = x * x * x; // (s/r)^6
159  return (*epsilon_quadruple)(a.id, b.id) * (x * x - x + onefourth);
160  }
161 
162  public:
163  explicit WeeksChandlerAndersen(
164  const std::string& name = "wca", const std::string& cite = "doi:ct4kh9",
165  CombinationRuleType combination_rule = CombinationRuleType::LORENTZ_BERTHELOT);
166 
167  inline double operator()(const Particle& a, const Particle& b, double squared_distance,
168  [[maybe_unused]] const Point& b_towards_a) const override
169  {
170  return operator()(a, b, squared_distance);
171  }
172 
173  inline Point force(const Particle& a, const Particle& b, const double squared_distance,
174  const Point& b_towards_a) const override
175  {
176  auto x = (*sigma_squared)(a.id, b.id); // s^2
177  if (squared_distance > x * twototwosixth) {
178  return {0.0, 0.0, 0.0};
179  }
180  x = x / squared_distance; // (s/r)^2
181  x = x * x * x; // (s/r)^6
182  return (*epsilon_quadruple)(a.id, b.id) * 6.0 * (2.0 * x * x - x) / squared_distance *
183  b_towards_a;
184  }
185 }; // Weeks-Chandler-Andersen potential
186 
194 {
195  TExtractorFunc extract_sigma;
196  TPairMatrixPtr sigma_squared; // sigma_ij * sigma_ij
197  void initPairMatrices() override;
198  void extractorsFromJson(const json& j) override;
199 
200  public:
201  explicit HardSphere(const std::string& name = "hardsphere");
202 
203  inline double operator()(const Particle& particle_a, const Particle& particle_b,
204  double squared_distance, const Point&) const override
205  {
206  return squared_distance < (*sigma_squared)(particle_a.id, particle_b.id) ? pc::infty : 0.0;
207  }
208 };
209 
222 {
223  TExtractorFunc extract_sigma, extract_epsilon;
224 
225  protected:
226  TPairMatrixPtr sigma_squared; // sigma_ij * sigma_ij
227  TPairMatrixPtr epsilon; // epsilon_ij
228  void initPairMatrices() override;
229  void extractorsFromJson(const json& j) override;
230 
231  public:
232  explicit Hertz(const std::string& name = "hertz");
233 
234  inline double operator()(const Particle& a, const Particle& b, double squared_distance,
235  [[maybe_unused]] const Point& b_towards_a) const override
236  {
237  if (squared_distance <= (*sigma_squared)(a.id, b.id)) {
238  return (*epsilon)(a.id, b.id) *
239  pow((1 - (sqrt(squared_distance / (*sigma_squared)(a.id, b.id)))), 2.5);
240  }
241  return 0.0;
242  }
243 };
244 
254 {
255  TExtractorFunc extract_sigma, extract_epsilon;
256 
257  protected:
258  TPairMatrixPtr sigma_squared; // sigma_ij * sigma_ij
259  TPairMatrixPtr epsilon; // epsilon_ij
260  void extractorsFromJson(const json& j) override;
261  void initPairMatrices() override;
262 
263  public:
264  explicit SquareWell(const std::string& name = "squarewell");
265 
266  inline double operator()(const Particle& a, const Particle& b, double squared_distance,
267  const Point&) const override
268  {
269  return (squared_distance < (*sigma_squared)(a.id, b.id)) ? -(*epsilon)(a.id, b.id) : 0.0;
270  }
271 };
272 
274 {
275  private:
276  double f = 0, s = 0, e = 0;
277  void from_json(const json& j) override;
278  void to_json(json& j) const override;
279 
280  public:
281  explicit RepulsionR3(const std::string& name = "repulsionr3")
282  : PairPotential(name) {};
283 
284  inline double operator()(const Particle&, const Particle&, double squared_distance,
285  const Point&) const override
286  {
287  const auto r = sqrt(squared_distance);
288  return f / (r * squared_distance) + e * std::pow(s / r, 12);
289  }
290 };
291 
311 class CosAttract : public PairPotential
312 {
313  double eps = 0.0;
314  double wc = 0.0;
315  double rc = 0.0;
316  double rc2 = 0.0;
317  double c = 0.0;
318  double rcwc2 = 0.0; // (rc + wc)^2 ~ "rcut2" in faunus v1
319  void from_json(const json& j) override;
320 
321  public:
322  explicit CosAttract(const std::string& name = "cos2");
323  double cutOffSquared() const;
324 
339  inline double operator()(const Particle&, const Particle&, double squared_distance,
340  const Point&) const override
341  {
342  if (squared_distance < rc2) {
343  return -eps;
344  }
345  if (squared_distance > rcwc2) {
346  return 0;
347  }
348  const auto x = std::cos(c * (sqrt(squared_distance) - rc));
349  return -eps * x * x;
350  }
351 
352  inline Point force(const Particle&, const Particle&, double squared_distance,
353  const Point& b_towards_a) const override
354  {
355  if (squared_distance > rcwc2 || squared_distance < rc2) {
356  return {0.0, 0.0, 0.0};
357  }
358  const auto r = sqrt(squared_distance);
359  const auto x1 = std::cos(c * (r - rc));
360  const auto x2 = std::sin(c * (r - rc));
361  return -2.0 * c * eps * x1 * x2 / r * b_towards_a;
362  }
363 
364  void to_json(json& j) const override;
365 };
366 
375 {
376  private:
377  TExtractorFunc extract_rc;
378  TExtractorFunc extract_wc;
379  TExtractorFunc extract_eps;
380 
381  TPairMatrixPtr switching_distance;
382  TPairMatrixPtr switching_width;
383  TPairMatrixPtr epsilon;
384 
385  void initPairMatrices() override;
386  void extractorsFromJson(const json& j) override;
387 
388  public:
389  explicit CosAttractMixed(
390  const std::string& name = "cos2", const std::string& cite = "doi:10/chqzjk"s,
391  CombinationRuleType combination_rule = CombinationRuleType::LORENTZ_BERTHELOT);
392 
393  double cutOffSquared(AtomData::index_type id1, AtomData::index_type id2) const;
394 
395  inline Point force(const Particle& a, const Particle& b, double squared_distance,
396  const Point& b_towards_a) const override
397  {
398  const auto rc = (*switching_distance)(a.id, b.id);
399  const auto wc = (*switching_width)(a.id, b.id);
400  const auto cutoff_squared = (rc + wc) * (rc + wc);
401  if (squared_distance > cutoff_squared || squared_distance < (rc * rc)) {
402  return {0.0, 0.0, 0.0};
403  }
404  const auto c = pc::pi / (2.0 * wc);
405  const auto r = sqrt(squared_distance);
406  const auto x1 = std::cos(c * (r - rc));
407  const auto x2 = std::sin(c * (r - rc));
408  return -2.0 * c * (*epsilon)(a.id, b.id) * x1 * x2 / r * b_towards_a;
409  }
410 
411  inline double operator()(const Particle& a, const Particle& b, const double squared_distance,
412  [[maybe_unused]] const Point& b_towards_a) const override
413  {
414  const auto rc = (*switching_distance)(a.id, b.id);
415  if (squared_distance < (rc * rc)) {
416  return -(*epsilon)(a.id, b.id);
417  }
418  const auto wc = (*switching_width)(a.id, b.id);
419  const auto cutoff_squared = (rc + wc) * (rc + wc);
420  if (squared_distance > cutoff_squared) {
421  return 0.0;
422  }
423  const auto c = pc::pi / (2.0 * wc);
424  const auto x = std::cos(c * (sqrt(squared_distance) - rc));
425  return -(*epsilon)(a.id, b.id) * x * x;
426  }
427 };
428 
433 {
434  private:
435  bool shift = true; // shift potential to zero at large separations?
436  double proberadius = 0, conc = 0;
437  void from_json(const json& j) override;
438 
439  double area(double R, double r, double center_center_distance_squared)
440  const;
441 
443  public:
444  inline double operator()(const Particle& a, const Particle& b, const double squared_distance,
445  [[maybe_unused]] const Point& b_towards_a) const override
446  {
447  const auto tfe = 0.5 * (atoms[a.id].tfe + atoms[b.id].tfe);
448  const auto tension = 0.5 * (atoms[a.id].tension + atoms[b.id].tension);
449  if (fabs(tfe) > 1e-6 or fabs(tension) > 1e-6)
450  return (tension + conc * tfe) *
451  area(0.5 * atoms[a.id].sigma, 0.5 * atoms[b.id].sigma, squared_distance);
452  return 0.0;
453  }
454 
455  explicit SASApotential(const std::string& name = "sasa",
456  const std::string& cite = std::string());
457  void to_json(json& j) const override;
458 };
459 
463 class Coulomb : public PairPotential
464 {
465  private:
466  void from_json(const json& j) override;
467 
468  public:
469  explicit Coulomb(const std::string& name = "coulomb");
470  double bjerrum_length = 0.0;
471 
472  inline double operator()(const Particle& a, const Particle& b, const double squared_distance,
473  const Point&) const override
474  {
475  return bjerrum_length * a.charge * b.charge / std::sqrt(squared_distance);
476  }
477 
478  void to_json(json& j) const override;
479 };
480 
482 {
483  private:
484  void from_json(const json& j) override;
485 
486  public:
487  explicit DipoleDipole(const std::string& name = "dipoledipole",
488  const std::string& cite = std::string());
489  double bjerrum_length{};
490 
491  inline double operator()(const Particle& a, const Particle& b, double,
492  const Point& b_towards_a) const override
493  {
494  return bjerrum_length * mu2mu(a.getExt().mu, b.getExt().mu,
495  a.getExt().mulen * b.getExt().mulen, b_towards_a, 1.0, 0.0);
496  }
497 
498  void to_json(json& j) const override;
499 };
500 
505 class Polarizability : public Coulomb
506 {
507  private:
508  double epsr;
509  std::shared_ptr<PairMatrix<double>> m_neutral, m_charged;
510  void from_json(const json& j) override;
511 
512  public:
513  explicit Polarizability(const std::string& name = "polar");
514  void to_json(json& j) const override;
515 
516  inline double operator()(const Particle& a, const Particle& b, double squared_distance,
517  [[maybe_unused]] const Point& b_towards_a) const override
518  {
519  double r4inv = 1 / (squared_distance * squared_distance);
520  if (fabs(a.charge) > 1e-9 or fabs(b.charge) > 1e-9) {
521  return (*m_charged)(a.id, b.id) * r4inv;
522  }
523  return (*m_neutral)(a.id, b.id) / squared_distance * r4inv;
524  }
525 
526  inline Point force(const Particle& a, const Particle& b, double squared_distance,
527  const Point& b_towards_a) const override
528  {
529  double r6inv = 1 / (squared_distance * squared_distance * squared_distance);
530  if (fabs(a.charge) > 1e-9 or fabs(b.charge) > 1e-9) {
531  return 4 * m_charged->operator()(a.id, b.id) * r6inv * b_towards_a;
532  }
533  return 6 * m_neutral->operator()(a.id, b.id) / squared_distance * r6inv * b_towards_a;
534  }
535 };
536 
551 class FENE : public PairPotential
552 {
553  double k = 0;
554  double r02 = 0;
555  double r02inv = 0;
556  void from_json(const json& j) override;
557 
558  public:
559  explicit FENE(const std::string& name = "fene");
560  void to_json(json& j) const override;
561 
562  inline double operator()([[maybe_unused]] const Particle& particle1,
563  [[maybe_unused]] const Particle& particle2, double r2,
564  [[maybe_unused]] const Point& b_towards_a) const override
565  {
566  return (r2 > r02) ? pc::infty : -0.5 * k * r02 * std::log(1 - r2 * r02inv);
567  }
568 
569  inline Point force([[maybe_unused]] const Particle& particle_a,
570  [[maybe_unused]] const Particle& particle_b, double squared_distance,
571  const Point& b_towards_a) const override
572  {
573  return (squared_distance > r02) ? -pc::infty * b_towards_a
574  : -k * r02 / (r02 - squared_distance) * b_towards_a;
575  }
576 };
577 
582 {
583  protected:
584  ::CoulombGalore::Splined pot;
585  virtual void setSelfEnergy();
586  void from_json(const json& j) override;
587 
588  public:
589  explicit NewCoulombGalore(const std::string& = "coulomb");
590 
591  inline double operator()(const Particle& particle_a, const Particle& particle_b,
592  const double squared_distance,
593  [[maybe_unused]] const Point& b_towards_a) const override
594  {
595  return bjerrum_length *
596  pot.ion_ion_energy(particle_a.charge, particle_b.charge,
597  sqrt(squared_distance) + std::numeric_limits<double>::epsilon());
598  }
599 
600  inline Point force(const Particle& particle_a, const Particle& particle_b,
601  [[maybe_unused]] double squared_distance,
602  const Point& b_towards_a) const override
603  {
604  return bjerrum_length *
605  pot.ion_ion_force(particle_a.charge, particle_b.charge, b_towards_a); // force on "a"
606  }
607 
608  void to_json(json& j) const override;
609  [[maybe_unused]] double dielectric_constant(double M2V);
610  double bjerrum_length;
611  const CoulombGalore::Splined& getCoulombGalore() const;
612 };
613 
619 {
620  private:
621  void setSelfEnergy() override;
622 
623  public:
624  explicit Multipole(const std::string& = "multipole");
625 
626  inline double operator()(const Particle& particle_a, const Particle& particle_b,
627  [[maybe_unused]] double squared_distance,
628  const Point& b_towards_a) const override
629  {
630  // Only dipole-dipole for now!
631  Point mua = particle_a.getExt().mu * particle_a.getExt().mulen;
632  Point mub = particle_b.getExt().mu * particle_b.getExt().mulen;
633  return bjerrum_length * pot.dipole_dipole_energy(mua, mub, b_towards_a);
634  }
635 
636  inline Point force(const Faunus::Particle& particle1, const Faunus::Particle& particle2,
637  [[maybe_unused]] double squared_distance,
638  const Faunus::Point& b_towards_a) const override
639  {
640  Point mua = particle1.getExt().mu * particle1.getExt().mulen;
641  Point mub = particle2.getExt().mu * particle2.getExt().mulen;
642  Point ionion = pot.ion_ion_force(particle1.charge, particle2.charge, b_towards_a);
643  Point iondip = pot.ion_dipole_force(particle1.charge, mub, b_towards_a) +
644  pot.ion_dipole_force(particle2.charge, mua, b_towards_a);
645  Point dipdip = pot.dipole_dipole_force(mua, mub, b_towards_a);
646  return bjerrum_length * (ionion + iondip + dipdip);
647  }
648 };
649 
656 {
657  private:
658  // Only ExprFunction<double> is explicitly instantiated in functionparser.cpp. Other types as
659  // well as the implicit template instantiation is disabled to save reasources during the
660  // compilation/build.
661  ExprFunction<double> expression;
662 
663  struct Symbols
664  {
665  double distance = 0.0; // available as "r"
666  double charge1 = 0.0; // available as "charge1"
667  double charge2 = 0.0; // available as "charge2"
668  double sigma1 = 0.0; // available as "s1"
669  double sigma2 = 0.0; // available as "s2"
670  };
671 
672  std::shared_ptr<Symbols> symbols;
673  double squared_cutoff_distance;
674  json original_input;
675  void from_json(const json& j) override;
676 
677  inline void setSymbols(const Particle& particle1, const Particle& particle2,
678  double squared_distance) const
679  {
680  symbols->distance = std::sqrt(squared_distance);
681  symbols->charge1 = particle1.charge;
682  symbols->charge2 = particle2.charge;
683  symbols->sigma1 = Faunus::atoms[particle1.id].sigma;
684  symbols->sigma2 = Faunus::atoms[particle2.id].sigma;
685  }
686 
687  public:
688  inline double operator()(const Particle& particle1, const Particle& particle2,
689  double squared_distance,
690  [[maybe_unused]] const Point& b_towards_a) const override
691  {
692  if (squared_distance < squared_cutoff_distance) {
693  setSymbols(particle1, particle2, squared_distance);
694  return expression();
695  }
696  return 0.0;
697  }
698 
699  inline Point force(const Particle& particle_a, const Particle& particle_b,
700  double squared_distance, const Point& b_towards_b) const override
701  {
702  if (squared_distance < squared_cutoff_distance) {
703  setSymbols(particle_a, particle_b, squared_distance);
704  return -expression.derivative(symbols->distance) / symbols->distance * b_towards_b;
705  }
706  return Point::Zero();
707  }
708 
709  explicit CustomPairPotential(const std::string& name = "custom");
710  void to_json(json& j) const override;
711 };
712 
713 using PrimitiveModel =
717 
729 {
730  using EnergyFunctor =
731  std::function<double(const Particle&, const Particle&, double, const Point&)>;
732  json backed_up_json_input; // storage for input json
733  bool have_monopole_self_energy = false;
734  bool have_dipole_self_energy = false;
735  void registerSelfEnergy(PairPotential*);
736  EnergyFunctor combinePairPotentials(
737  json& potential_array); // parse json array of potentials to a single pair-energy functor
738 
739  protected:
741  umatrix; // matrix with potential for each atom pair; cannot be Eigen matrix
742  void from_json(const json& j) override;
743 
744  public:
745  explicit FunctorPotential(const std::string& name = "functor potential");
746  void to_json(json& j) const override;
747 
748  inline double operator()(const Particle& particle_a, const Particle& particle_b,
749  const double squared_distance,
750  const Point& b_towards_a = {0, 0, 0}) const override
751  {
752  return umatrix(particle_a.id, particle_b.id)(particle_a, particle_b, squared_distance,
753  b_towards_a);
754  }
755 };
756 
771 {
773  class KnotData : public Tabulate::TabulatorBase<double>::data
774  {
775  public:
777  bool hardsphere_repulsion = false;
778  KnotData() = default;
779  KnotData(const base&);
780  };
781 
782  PairMatrix<KnotData> matrix_of_knots;
783  Tabulate::Andrea<double> spline;
784  bool hardsphere_repulsion = false;
785  const int max_iterations = 1e6;
786  void streamPairPotential(std::ostream& stream, const size_t id1,
787  const size_t id2);
788  void savePotentials();
789  double findLowerDistance(int, int, double, double);
790  double findUpperDistance(int, int, double, double);
791  double dr = 1e-2;
792  void createKnots(int, int, double,
793  double);
794  void from_json(const json& j) override;
795 
796  public:
797  explicit SplinedPotential(const std::string& name = "splined");
798 
807  inline double operator()(const Particle& particle_a, const Particle& particle_b,
808  double squared_distance,
809  [[maybe_unused]] const Point& b_towards_a) const override
810  {
811  const auto& knots = matrix_of_knots(particle_a.id, particle_b.id);
812  if (squared_distance >= knots.rmax2) {
813  return 0.0;
814  }
815  if (squared_distance > knots.rmin2) {
816  return spline.eval(knots, squared_distance); // spline energy
817  }
818  if (knots.hardsphere_repulsion) {
819  return pc::infty;
820  }
821  return FunctorPotential::operator()(particle_a, particle_b, squared_distance,
822  {0, 0, 0}); // exact energy
823  }
824 };
825 
826 } // namespace Faunus::pairpotential
TPairMatrixPtr lambda
λ_ij (hydrophobicity parameter)
Definition: potentials.h:90
nlohmann::json json
JSON object.
Definition: json_support.h:10
Eigen::Vector3d Point
3D vector used for positions, velocities, forces etc.
Definition: coordinates.h:7
CombinationRuleType
Known named combination rules for parameters of pair potential interaction.
Definition: potentials_base.h:45
Statically combines two pair potentials at compile-time.
Definition: potentials_base.h:227
double operator()(const Particle &a, const Particle &b, double squared_distance, const Point &) const override
Pair energy between two particles.
Definition: potentials.h:266
constexpr T powi(T x, unsigned int n)
n&#39;th integer power of float
Definition: pow_function.h:14
Multipole interactions.
Definition: potentials.h:618
double operator()(const Particle &a, const Particle &b, double, const Point &b_towards_a) const override
Pair energy between two particles.
Definition: potentials.h:491
Square-well potential.
Definition: potentials.h:253
double operator()(const Particle &, const Particle &, double squared_distance, const Point &) const override
Pair energy between two particles.
Definition: potentials.h:284
ParticleExtension & getExt()
get/create extension
Definition: particle.h:240
Hardsphere potential.
Definition: potentials.h:193
double mu2mu(const Tvec &muA, const Tvec &muB, double muAxmuB, const Tvec &r, double a=1.0, double b=0.0)
Returns dipole-dipole interaction.
Definition: multipole.h:37
Cosine attraction using combination rules (Eq.
Definition: potentials.h:374
Hertz potential.
Definition: potentials.h:221
Arbitrary potentials for specific atom types.
Definition: potentials.h:728
Definition: tabulate.h:28
Set pair potential between cigar-cigar, sphere-sphere, cigar-sphere.
Definition: spherocylinder.h:280
Definition: potentials.h:481
Cosine attraction.
Definition: potentials.h:311
Definition: potentials.h:273
std::function< double(const InteractionData &)> TExtractorFunc
type of a function extracting a potential coefficient from the InteractionData, e.g., sigma or eps
Definition: potentials_base.h:16
std::vector< Faunus::AtomData > atoms
Global instance of atom list.
Definition: atomdata.cpp:242
Custom pair-potential taking math.
Definition: potentials.h:655
Point force(const Particle &a, const Particle &b, const double squared_distance, const Point &b_towards_a) const override
Force on particle a due to particle b.
Definition: potentials.h:173
double operator()(const Particle &a, const Particle &b, const double squared_distance, const Point &) const override
Pair energy between two particles.
Definition: potentials.h:472
void extractorsFromJson(const json &j) override
potential-specific assignment of coefficient extracting functions
Definition: potentials.cpp:691
double operator()(const Particle &particle_a, const Particle &particle_b, double squared_distance, const Point &) const override
Pair energy between two particles.
Definition: potentials.h:203
int id
Particle id/type.
Definition: particle.h:225
Finite Extensible Nonlinear Elastic (FENE) potential.
Definition: potentials.h:551
TPairMatrixPtr epsilon_quadruple
4 * ε_ij
Definition: potentials.h:88
A common ancestor for potentials that use parameter matrices computed from atomic properties and/or c...
Definition: potentials_base.h:198
std::string name
unique name per polymorphic call; used in FunctorPotential::combinePairPotentials ...
Definition: potentials_base.h:138
Particle class for storing positions, id, and other properties.
Definition: particle.h:220
Point force(const Particle &a, const Particle &b, double squared_distance, const Point &b_towards_a) const override
Force on particle a due to particle b.
Definition: potentials.h:395
Point force(const Particle &, const Particle &, double squared_distance, const Point &b_towards_a) const override
Force on particle a due to particle b.
Definition: potentials.h:352
auto distance(T1 first, T2 last)
Distance between two arbitrary contiguous iterators.
Definition: iteratorsupport.h:7
void initPairMatrices() override
potential-specific initialization of parameter matrices
Definition: potentials.cpp:672
Namespace for particle pair-potentials.
Definition: analysis.h:18
double operator()(const Particle &particle_a, const Particle &particle_b, double squared_distance, [[maybe_unused]] const Point &b_towards_a) const override
Policies:
Definition: potentials.h:807
TPairMatrixPtr epsilon
ε_ij.
Definition: potentials.h:89
double charge
Particle charge.
Definition: particle.h:226
double operator()(const Particle &, const Particle &, double squared_distance, const Point &) const override
Definition: potentials.h:339
Lennard-Jones potential with an arbitrary combination rule.
Definition: potentials.h:15
Ashbaugh-Hatch pair potential.
Definition: potentials.h:77
Charge-nonpolar pair interaction.
Definition: potentials.h:505
Base for all pair-potentials.
Definition: potentials_base.h:131
std::string cite
Typically a short-doi litterature reference.
Definition: potentials_base.h:139
Definition: tabulate.h:63
Wrapper for external CoulombGalore library.
Definition: potentials.h:581
Point force(const Particle &a, const Particle &b, double squared_distance, const Point &b_towards_a) const override
Force on particle a due to particle b.
Definition: potentials.h:115
Splined pair potentials.
Definition: potentials.h:770
TPairMatrixPtr sigma_squared
σ_ij²
Definition: potentials.h:87
Point force(const Particle &particle_a, const Particle &particle_b, double squared_distance, const Point &b_towards_b) const override
Force on particle a due to particle b.
Definition: potentials.h:699
T eval(const typename base::data &d, T r2) const
Get tabulated value at f(x)
Definition: tabulate.h:184
Plain Coulomb potential.
Definition: potentials.h:463
Point force(const Particle &a, const Particle &b, double squared_distance, const Point &b_towards_a) const override
Force on particle a due to particle b.
Definition: potentials.h:526
Weeks-Chandler-Andersen pair potential.
Definition: potentials.h:147
double operator()(const Particle &particle_a, const Particle &particle_b, const double squared_distance, const Point &b_towards_a={0, 0, 0}) const override
Pair energy between two particles.
Definition: potentials.h:748
Point force(const Particle &particle_a, const Particle &particle_b, double squared_distance, const Point &b_towards_a) const override
Force on particle a due to particle b.
Definition: potentials.h:32
Pairwise SASA potential calculating the surface area of inter-secting spheres.
Definition: potentials.h:432