namespace smooth#
Overview#
Smooth collective variables on the primitive-ring network. More…
namespace smooth {
// typedefs
typedef molSys::PointCloud<molSys::Point<double>, double> Cloud;
// enums
enum Kind;
// structs
struct RationalSwitch;
struct Topology;
// classes
class Workspace;
// global variables
int kMaxSwitchExponent = 4096;
double kFlatEigenRatio = 1e-10;
std::int64_t kMaxRingSearchSteps = 20000000;
int kMaxCandidateRings = 2000000;
std::int64_t kMaxShortcutSearchSteps = 20000000;
int kMaxShortcutPaths = 2000000;
// global functions
RationalSwitch makeSwitch(double r0, double d0, int n, int m, double dOn, double dMax);
Topology buildTopology(const std::vector<std::vector<int>>& rows, int maxRing);
std::vector<double> ringWeights(const Topology& topo, const std::vector<double>& s);
void ringWeightsAdjoint(const Topology& topo, const std::vector<double>& s, const std::vector<double>& wbar, std::vector<double>& sbar);
double hexBasalPairs(const Topology& topo, const std::vector<double>& s, const std::vector<double>& w, std::vector<double>* sbar, std::vector<double>* wbar);
std::vector<double> ringParticipation(const Topology& topo, const std::vector<double>& w, int size);
void ringParticipationAdjoint(const Topology& topo, const std::vector<double>& w, int size, const std::vector<double>& pbar, std::vector<double>& wbar);
} // namespace smooth
Detailed Documentation#
Smooth collective variables on the primitive-ring network.
Every bond of the graph carries a weight s(r) from a rational switching function with a C2 taper to zero at d_max. Every simple cycle of at most maxRing members found by primitive::countAllRingsFromIndex on the graph at d_max + skin is a candidate ring. Its weight is the product of its bond weights times one factor (1 - W_P) for every shortcut path P, a simple path between two ring members that is shorter than their separation around the ring, where W_P is the product of the path’s bond weights. With weights 0 and 1 the rings of weight one are exactly the shortest-path rings of primitive::ringNetwork.
Every ring weight, ring participation and hexagon-pair term is a fixed polynomial in the pair weights of the complete graph. A pair outside the neighbour list has weight zero, and a term that contains a zero bond weight, or a factor (1 - 0), contributes what it would contribute if the pair were listed. Those values therefore do not depend on which pairs beyond d_max the list holds, and they are as smooth as s(r) at every geometry, including where a bond crosses the list cutoff or a ring changes primitivity. The gyration values also depend on the unwrapped positions: they are as smooth only for a compact selection of positive total weight, and the volume is not differentiable where det G = 0. A tensor whose smallest eigenvalue is at most kFlatEigenRatio times its largest is treated as that flat cluster: the volume and its gradient are 0, including when rounding makes the determinant positive.
Cycles and shortcut paths are simple and no longer than maxRing, so the work is polynomial in the neighbour count. The search throws std::length_error, and the message names the limit, when a ring search would pass kMaxRingSearchSteps visits or kMaxCandidateRings rings, or a shortcut search would pass kMaxShortcutSearchSteps visits or kMaxShortcutPaths paths. Rings and paths are not dropped.
Global Variables#
int kMaxSwitchExponent = 4096
Largest numerator or denominator exponent. m == 0 means 2n, and 2n must fit under the same limit. A larger exponent is std::invalid_argument and the message names this limit.
double kFlatEigenRatio = 1e-10
Smallest gyration eigenvalue, as a fraction of the largest, at and below which the volume and its gradient are 0.
std::int64_t kMaxRingSearchSteps = 20000000
Visits of the ring search. A complete graph whose first root would pass this throws std::length_error before the search. The message names this limit.
int kMaxCandidateRings = 2000000
Candidate rings recorded by one rebuild. Passing this throws std::length_error naming this limit.
std::int64_t kMaxShortcutSearchSteps = 20000000
Visits of the shortcut-path search. Passing this throws std::length_error naming this limit.
int kMaxShortcutPaths = 2000000
Shortcut paths recorded by one rebuild. Passing this throws std::length_error naming this limit.
Global Functions#
RationalSwitch makeSwitch(double r0, double d0, int n, int m, double dOn, double dMax)
Builds and validates a switch. m == 0 selects m = 2n, as in PLUMED, and throws std::invalid_argument when 2n does not fit in an int.
Topology buildTopology(const std::vector<std::vector<int>>& rows, int maxRing)
Topology of a graph given as rows by index, each row starting with the vertex itself (the layout of primitive::ringNetwork). The rows must be symmetric. Throws std::invalid_argument for maxRing outside 3 .. 10. Throws std::length_error, naming the limit, when the ring or shortcut search exceeds kMaxRingSearchSteps, kMaxCandidateRings, kMaxShortcutSearchSteps, or kMaxShortcutPaths.
std::vector<double> ringWeights(const Topology& topo, const std::vector<double>& s)
Ring weights for bond weights s, one per edge.
void ringWeightsAdjoint(const Topology& topo, const std::vector<double>& s, const std::vector<double>& wbar, std::vector<double>& sbar)
Adds d(sum_k wbar[k] w[k]) / ds to sbar.
double hexBasalPairs(const Topology& topo, const std::vector<double>& s, const std::vector<double>& w, std::vector<double>* sbar, std::vector<double>* wbar)
Soft count of hexagon pairs that pass the HC basal test, from bond weights s and ring weights w. With sbar and wbar non-null the adjoint of the count is added to them.
std::vector<double> ringParticipation(const Topology& topo, const std::vector<double>& w, int size)
Soft ring participation of every atom: 1 - prod (1 - w_k) over the candidate rings through the atom whose size is size (0 is every size)
void ringParticipationAdjoint(const Topology& topo, const std::vector<double>& w, int size, const std::vector<double>& pbar, std::vector<double>& wbar)
Adds d(sum_i pbar[i] p[i]) / dw to wbar.