Skip to content

Commit

Permalink
Add PSC test case
Browse files Browse the repository at this point in the history
This add a unittest for two PSC in contact and with
patches facing each other. Also adds a note to the manual
regarding the interpretation of epsilon.
  • Loading branch information
mlund committed May 18, 2022
1 parent e32392e commit 964948e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/_docs/topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ or a capped variant where the patch stops before the caps (○◼○).
The `coswca-psc` potential can handle mixtures of PSCs and spherical particles.
When a spherical particle interacts with the PSC, the closest distances to the patch and excluded volume
are used to evaluate the attractive and repulsive energy.
For the patch-patch interaction, the `eps` value is is regarded as `kJ/mol/Å` whereby longer patch contacts
will automatically interact stronger.

`psc` | Description
---------------------- | -------------------------------------------------
Expand Down
35 changes: 35 additions & 0 deletions src/spherocylinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,41 @@ CigarWithCigar<PatchPotential, CylinderPotential>::CigarWithCigar()

template class CigarWithCigar<CosAttractMixed, WeeksChandlerAndersen>; // explicit initialization

TEST_CASE("[Faunus] CigarWithCigar") {
using CigarCigar = CigarWithCigar<CosAttractMixed, WeeksChandlerAndersen>;

// Check that we use same temperature as R. Vacha. Note also that the epsilon value
// in his code is in kT per nanometer.
CHECK(1.4_kT / 1.0_kJmol == doctest::Approx(3.47056));

// the Faunus epsilon value is in kJ/mol/Å
Faunus::atoms = R"([
{ "A": { "sigma": 10.0, "eps": 0.347056, "rc": 11.2246205, "wc": 10.0, "psc": {"length": 60, "type": "capped", "patch_angle": 80, "patch_angle_switch": 5.0} } },
{ "B": { "sigma": 10.0, "eps": 0.347056 } }
])"_json.get<decltype(atoms)>();

Particle a;
Particle b;
a.createExtension();
b.createExtension();
a = Faunus::atoms.at(0);
b = Faunus::atoms.at(0);

SUBCASE("maximum contact attraction") {
// place two parallel CPSC in contact and with patches facing each other
auto pairpot = CigarCigar(R"( {"cos2": {"mixing": "LB"}, "wca": {"mixing": "LB"}} )"_json);
const auto& atom_data = Faunus::atoms.at(0); // atom type "A"
Point psc_dir = {0.0, 1.0, 0.0}; //
Point patch_dir = {1.0, 0.0, 0.0}; //
a.getExt().setDirections(atom_data.sphero_cylinder, psc_dir, patch_dir);
b.getExt().setDirections(atom_data.sphero_cylinder, psc_dir, -patch_dir);
a.pos = {0.0, 0.0, 0.0};
b.pos = {atom_data.sigma, 0.0, 0.0}; // place a and b at contact
Point separation = a.pos - b.pos;
CHECK(pairpot(a, b, separation.squaredNorm(), separation) == doctest::Approx(-8.26)); // kT
}
}

// -----------------------------

template <RequirePairPotential PatchPotential, RequirePairPotential CylinderPotential,
Expand Down

0 comments on commit 964948e

Please sign in to comment.