Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2015-2019 The plumed team
3 : (see the PEOPLE file at the root of the distribution for a list of names)
4 :
5 : See http://www.plumed.org for more information.
6 :
7 : This file is part of plumed, version 2.
8 :
9 : plumed is free software: you can redistribute it and/or modify
10 : it under the terms of the GNU Lesser General Public License as published by
11 : the Free Software Foundation, either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : plumed is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU Lesser General Public License for more details.
18 :
19 : You should have received a copy of the GNU Lesser General Public License
20 : along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 : #include "ClusterAnalysisBase.h"
23 :
24 : namespace PLMD {
25 : namespace adjmat {
26 :
27 58 : void ClusterAnalysisBase::registerKeywords( Keywords& keys ) {
28 58 : MultiColvarBase::registerKeywords( keys );
29 232 : keys.add("compulsory","CLUSTERS","the label of the action that does the clustering");
30 58 : }
31 :
32 54 : ClusterAnalysisBase::ClusterAnalysisBase(const ActionOptions& ao):
33 : Action(ao),
34 : MultiColvarBase(ao),
35 : myfvals(0,0),
36 : myfatoms( myfvals, this ),
37 54 : myclusters(NULL)
38 : {
39 : // This makes these colvars behave appropriately with dump and analysis
40 54 : matsums=usespecies=true; std::vector<AtomNumber> fake_atoms;
41 : // Find what action we are taking the clusters from
42 108 : if( !parseMultiColvarAtomList("CLUSTERS",-1,fake_atoms ) ) error("unable to interpret input CLUSTERS" );
43 54 : if( mybasemulticolvars.size()!=1 ) error("should be exactly one multicolvar input");
44 108 : atom_lab.resize(0); myclusters = dynamic_cast<ClusteringBase*>( mybasemulticolvars[0] );
45 54 : if( !myclusters ) error("input label is not that of a DFS object");
46 : // Setup the atom pack
47 54 : myfatoms.setNumberOfAtoms( myclusters->getNumberOfNodes() );
48 54 : myfvals.getIndices().resize( myclusters->getNumberOfNodes() );
49 67352 : for(unsigned i=0; i<myclusters->getNumberOfNodes(); ++i) myfatoms.setAtomIndex( i, i );
50 54 : }
51 :
52 8 : void ClusterAnalysisBase::turnOnDerivatives() {
53 : // Check for dubious vessels
54 28 : for(unsigned i=0; i<getNumberOfVessels(); ++i) {
55 20 : if( getPntrToVessel(i)->getName()=="MEAN" ) error("MEAN of cluster is not differentiable");
56 20 : if( getPntrToVessel(i)->getName()=="VMEAN" ) error("VMEAN of cluster is not differentiable");
57 : }
58 8 : MultiColvarBase::turnOnDerivatives();
59 8 : }
60 :
61 2073 : unsigned ClusterAnalysisBase::getNumberOfQuantities() const {
62 2073 : return myclusters->getNumberOfQuantities();
63 : }
64 :
65 15981876 : unsigned ClusterAnalysisBase::getNumberOfNodes() const {
66 15981876 : return myclusters->getNumberOfNodes();
67 : }
68 :
69 4 : unsigned ClusterAnalysisBase::getNumberOfClusters() const {
70 8 : return myclusters->getNumberOfClusters();
71 : }
72 :
73 11 : bool ClusterAnalysisBase::isPeriodic() {
74 11 : return mybasemulticolvars[0]->isPeriodic();
75 : }
76 :
77 66 : void ClusterAnalysisBase::retrieveAtomsInCluster( const unsigned& clust, std::vector<unsigned>& myatoms ) const {
78 66 : myclusters->retrieveAtomsInCluster( clust, myatoms );
79 66 : }
80 :
81 1 : bool ClusterAnalysisBase::nodeIsActive( const unsigned& ind ) const {
82 1 : return myclusters->isCurrentlyActive( ind );
83 : }
84 :
85 1801 : void ClusterAnalysisBase::getPropertiesOfNode( const unsigned& ind, std::vector<double>& vals ) const {
86 1801 : myclusters->getInputData( ind, false, myfatoms, vals );
87 1801 : }
88 :
89 1604 : void ClusterAnalysisBase::getNodePropertyDerivatives( const unsigned& ind, MultiValue& myvals ) const {
90 1604 : myvals=myclusters->getInputDerivatives( ind, false, myfatoms );
91 1604 : }
92 :
93 1975 : Vector ClusterAnalysisBase::getPositionOfAtomForLinkCells( const unsigned& iatom ) const {
94 1975 : return myclusters->getPositionOfAtomForLinkCells( iatom );
95 : }
96 :
97 0 : double ClusterAnalysisBase::getCutoffForConnection() const {
98 0 : return myclusters->getCutoffForConnection();
99 : }
100 :
101 0 : bool ClusterAnalysisBase::areConnected( const unsigned& ind1, const unsigned& ind2 ) const {
102 0 : return myclusters->areConnected( ind1, ind2 );
103 : }
104 :
105 : }
106 4839 : }
|