Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2011-2023 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 "core/ActionShortcut.h" 23 : #include "core/ActionRegister.h" 24 : 25 : //+PLUMEDOC MCOLVAR VORONOI 26 : /* 27 : Do a voronoi analysis 28 : 29 : This shortcut allows you to perform a [Voronoi analysis](https://en.wikipedia.org/wiki/Voronoi_diagram). 30 : The input to this action is a rectangular matrix that describes the distances between two sets of points. 31 : The points for which this action is receiving distances between could be atom positions or they could represent the 32 : dissimilarities between various trajectory frames that have been stored using [COLLECT_FRAMES](COLLECT_FRAMES.md). 33 : In the example below the matrix of input distances are distances between the positions of atoms: 34 : 35 : ```plumed 36 : d: DISTANCE_MATRIX GROUPA=1-10 GROUPB=11-100 37 : v: VORONOI ARG=d 38 : ones: ONES SIZE=90 39 : c: MATRIX_VECTOR_PRODUCT ARG=v,ones 40 : PRINT ARG=c FILE=colvar 41 : ``` 42 : 43 : The VORONOI action outputs a rectangular matrix, $V$, with the same shape as the input matrix, $D$. $V_{ij}$ 44 : is 1 if $D_{ij}$ is the shortest distance in row $i$. 45 : 46 : 47 : */ 48 : //+ENDPLUMEDOC 49 : 50 : namespace PLMD { 51 : namespace matrixtools { 52 : 53 : class Voronoi : public ActionShortcut { 54 : public: 55 : static void registerKeywords( Keywords& keys ); 56 : explicit Voronoi(const ActionOptions&); 57 : }; 58 : 59 : PLUMED_REGISTER_ACTION(Voronoi,"VORONOI") 60 : 61 11 : void Voronoi::registerKeywords( Keywords& keys ) { 62 11 : ActionShortcut::registerKeywords(keys); 63 22 : keys.addInputKeyword("compulsory","ARG","matrix","the distance/adjacency matrix that should be used to perform the voronoi analysis"); 64 22 : keys.setValueDescription("matrix","a matrix in which element ij is equal to one if the ij component of the input matrix is lower than all the ik elements of the matrix where k is not j and zero otherwise"); 65 11 : keys.needsAction("NEIGHBORS"); 66 11 : } 67 : 68 6 : Voronoi::Voronoi(const ActionOptions& ao): 69 : Action(ao), 70 6 : ActionShortcut(ao) { 71 12 : readInputLine( getShortcutLabel() + ": NEIGHBORS NLOWEST=1 " + convertInputLineToString() ); 72 6 : } 73 : 74 : } 75 : }