seams-core v2.15.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
smooth Namespace Reference

Smooth collective variables on the primitive-ring network. More...

Classes

struct  RationalSwitch
 PLUMED RATIONAL switching function times a C2 taper. More...
struct  Topology
 Candidate rings, shortcut paths and hexagon pairs of one graph. More...
class  Workspace
 Switch, candidate topology, rebuild reference and state clauses. More...

Typedefs

using Cloud = molSys::PointCloud<molSys::Point<double>, double>

Enumerations

enum class  Kind {
  RingCount = 0 , RingAtoms = 1 , HexBasalPairs = 2 , GyrationRg2 = 3 ,
  GyrationVolume = 4 , State = 5
}
 The collective variables of one frame, with their gradients. More...

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)
 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)
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)
 Adds d(sum_i pbar[i] p[i]) / dw to wbar.

Variables

constexpr int kMaxSwitchExponent = 4096
constexpr double kFlatEigenRatio = 1e-10
constexpr std::int64_t kMaxRingSearchSteps = 20000000
constexpr int kMaxCandidateRings = 2000000
constexpr std::int64_t kMaxShortcutSearchSteps = 20000000
constexpr int kMaxShortcutPaths = 2000000

Detailed Description

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.

Typedef Documentation

◆ Cloud

Definition at line 69 of file smooth_cv.hpp.

Enumeration Type Documentation

◆ Kind

enum class smooth::Kind
strong

The collective variables of one frame, with their gradients.

The first three are as smooth as the switch; see the namespace notes for the gyration kinds. A state is as smooth as its clauses.

Enumerator
RingCount 
RingAtoms 
HexBasalPairs 
GyrationRg2 
GyrationVolume 
State 

Definition at line 210 of file smooth_cv.hpp.

210 {
211 RingCount = 0,
212 RingAtoms = 1,
213 HexBasalPairs = 2,
214 GyrationRg2 = 3,
215 GyrationVolume = 4,
216 State = 5
217};

Function Documentation

◆ buildTopology()

Topology smooth::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.

◆ hexBasalPairs()

double smooth::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.

◆ makeSwitch()

RationalSwitch smooth::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.

◆ ringParticipation()

std::vector< double > smooth::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)

◆ ringParticipationAdjoint()

void smooth::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.

◆ ringWeights()

std::vector< double > smooth::ringWeights ( const Topology & topo,
const std::vector< double > & s )

Ring weights for bond weights s, one per edge.

◆ ringWeightsAdjoint()

void smooth::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.

Variable Documentation

◆ kFlatEigenRatio

double smooth::kFlatEigenRatio = 1e-10
inlineconstexpr

Smallest gyration eigenvalue, as a fraction of the largest, at and below which the volume and its gradient are 0.

Definition at line 78 of file smooth_cv.hpp.

◆ kMaxCandidateRings

int smooth::kMaxCandidateRings = 2000000
inlineconstexpr

Candidate rings recorded by one rebuild. Passing this throws std::length_error naming this limit.

Definition at line 87 of file smooth_cv.hpp.

◆ kMaxRingSearchSteps

std::int64_t smooth::kMaxRingSearchSteps = 20000000
inlineconstexpr

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.

Definition at line 83 of file smooth_cv.hpp.

◆ kMaxShortcutPaths

int smooth::kMaxShortcutPaths = 2000000
inlineconstexpr

Shortcut paths recorded by one rebuild. Passing this throws std::length_error naming this limit.

Definition at line 95 of file smooth_cv.hpp.

◆ kMaxShortcutSearchSteps

std::int64_t smooth::kMaxShortcutSearchSteps = 20000000
inlineconstexpr

Visits of the shortcut-path search. Passing this throws std::length_error naming this limit.

Definition at line 91 of file smooth_cv.hpp.

◆ kMaxSwitchExponent

int smooth::kMaxSwitchExponent = 4096
inlineconstexpr

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.

Definition at line 74 of file smooth_cv.hpp.