diff --git a/README.md b/README.md index db4e67246..85954d04f 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,9 @@ Or build from source, see [here](http://mlund.github.io/faunus/docs/install/). Documentation ============= -http://mlund.github.io/faunus +- manual for latest stable release: https://github.com/mlund/faunus/releases/latest +- manual for development branch: http://mlund.github.io/faunus +- manual for installed verion: `faunus-manual` Licence ======= diff --git a/docs/_docs/energy.md b/docs/_docs/energy.md index 47a606085..f24370725 100644 --- a/docs/_docs/energy.md +++ b/docs/_docs/energy.md @@ -102,6 +102,19 @@ Below is a description of possible pair-potentials and their configuration. `nonbonded_pm` | `coulomb`+`hardsphere` (fixed `type=plain`, `cutoff`$=\infty$) `nonbonded_pmwca` | `coulomb`+`wca` (fixed `type=plain`, `cutoff`$=\infty$) +### Mass Center Cut-offs + +For cut-off based pair-potentials working on large molecules, it can be very efficient to +use mass center cut-offs between molecular groups, thus skipping all pair-interactions. +A single cut-off can be used between all molecules (`default`), or specified for specific +combinations: + +~~~ yaml +- nonbonded: + cutoff_g2g: + default: 40 + "protein water": 60 +~~~ ### OpenMP Control diff --git a/src/energy.h b/src/energy.h index 76c21d5b3..2ebf6872e 100644 --- a/src/energy.h +++ b/src/energy.h @@ -822,6 +822,7 @@ namespace Faunus { class Nonbonded : public Energybase { private: double g2gcnt=0, g2gskip=0; + PairMatrix cutoff2; // matrix w. group-to-group cutoff protected: typedef typename Tspace::Tpvec Tpvec; @@ -835,13 +836,18 @@ namespace Faunus { void to_json(json &j) const override { j["pairpot"] = pairpot; - j["cutoff_g2g"] = std::sqrt(Rc2_g2g); if (omp_enable) { json _a = json::array(); if (omp_g2g) _a.push_back("g2g"); if (omp_i2all) _a.push_back("i2all"); j["openmp"] = _a; } + j["cutoff_g2g"] = json::object(); + auto &_j = j["cutoff_g2g"]; + for (auto &a : Faunus::molecules) + for (auto &b : Faunus::molecules) + if (a.id()>=b.id()) + _j[a.name+" "+b.name] = sqrt( cutoff2(a.id(), b.id()) ); } template @@ -849,7 +855,7 @@ namespace Faunus { g2gcnt++; if (g1.atomic || g2.atomic) return false; - if ( spc.geo.sqdist(g1.cm, g2.cm)) + for (auto &j : Faunus::molecules) + cutoff2.set(i.id(), j.id(), pc::infty); + + it = j.find("cutoff_g2g"); + if (it != j.end()) { + // old style input w. only a single cutoff + if (it->is_number()) { + Rc2_g2g = std::pow( it->get(), 2 ); + for (auto &i : Faunus::molecules) + for (auto &j : Faunus::molecules) + cutoff2.set(i.id(), j.id(), Rc2_g2g); + } + // new style input w. multiple cutoffs between molecules + else if (it->is_object()) { + // ensure that there is a default, fallback cutoff + Rc2_g2g = std::pow( it->at("default").get(), 2); + for (auto &i : Faunus::molecules) + for (auto &j : Faunus::molecules) + cutoff2.set(i.id(), j.id(), Rc2_g2g); + // loop for space separated molecule pairs in keys + for (auto& i : it->items()) { + auto v = words2vec( i.key() ); + if (v.size()==2) { + int id1 = (*findName( Faunus::molecules, v[0])).id(); + int id2 = (*findName( Faunus::molecules, v[1])).id(); + cutoff2.set( id1, id2, std::pow(i.value().get(),2) ); + } + } + } + } } void force(std::vector &forces) override {