Skip to content

Commit

Permalink
More fixes to resolve problems with inputs in nest
Browse files Browse the repository at this point in the history
-> Changed label for list of q6 values to <shortcut_label> rather than <shortcut_label>_anorm.  This is clearer
-> Implemented UWALLS shortcut.  It just calls UPPER_WALLS.
-> Made ARG compulsory keyword for CLUSTER_PROPERTIES.
-> Creating GROUP of atoms in Distances and LOCAL_Q? so folks can use the label of the action to refer to the atom involved a la multicolvar

Also fixed a few things that I didn't implement correctly in the last commit
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Mar 24, 2024
1 parent aa29076 commit 3baf976
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 26 deletions.
2 changes: 1 addition & 1 deletion regtest/contour/rt-dfg-wcsurf/plumed.dat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dp_mat: OUTER_PRODUCT ARG=cf,cf
mat: CUSTOM ARG=c1_mat2,dp_mat FUNC=x*y PERIODIC=NO
# Find largest cluster
dfs: DFSCLUSTERING ARG=mat
clust1: CLUSTER_PROPERTIES CLUSTERS=dfs CLUSTER=1
clust1: CLUSTER_WEIGHTS CLUSTERS=dfs CLUSTER=1
nat: CLUSTER_NATOMS CLUSTERS=dfs CLUSTER=1

# Print out the size of the cluster and the atoms
Expand Down
10 changes: 5 additions & 5 deletions regtest/gridtools/rt-q6-histogram/density.reference
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#! FIELDS c1 q6_anorm h dh_c1 dh_q6_anorm
#! FIELDS c1 q6 h dh_c1 dh_q6
#! SET min_c1 0
#! SET max_c1 10
#! SET nbins_c1 200
#! SET periodic_c1 false
#! SET min_q6_anorm 0
#! SET max_q6_anorm 2
#! SET nbins_q6_anorm 200
#! SET periodic_q6_anorm false
#! SET min_q6 0
#! SET max_q6 2
#! SET nbins_q6 200
#! SET periodic_q6 false
0.0000 0.0000 0.0000 0.0000 0.0000
0.0500 0.0000 0.0000 0.0002 0.0002
0.1000 0.0000 0.0000 0.0011 0.0011
Expand Down
2 changes: 1 addition & 1 deletion regtest/gridtools/rt-q6-histogram/plumed.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
c1: COORDINATIONNUMBER SPECIESA=1,2 SPECIESB=1-200 SWITCH={RATIONAL R_0=1.0}
q6: Q6 SPECIESA=1,2 SPECIESB=1-200 SWITCH={RATIONAL R_0=1.0}
h: HISTOGRAM ARG=c1,q6_anorm GRID_BIN=200,200 GRID_MIN=0,0 GRID_MAX=10,2 BANDWIDTH=0.1,0.1
h: HISTOGRAM ARG=c1,q6 GRID_BIN=200,200 GRID_MIN=0,0 GRID_MAX=10,2 BANDWIDTH=0.1,0.1
DUMPGRID ARG=h STRIDE=20 FILE=density FMT=%8.4f
2 changes: 1 addition & 1 deletion regtest/symfunc/rt-dumpmulti/plumed.dat
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ q6n_imn-[4]: CUSTOM ARG=q6_sp.im-p4,q6_norm FUNC=x/y PERIODIC=NO
q6n_imn-[5]: CUSTOM ARG=q6_sp.im-p5,q6_norm FUNC=x/y PERIODIC=NO
q6n_imn-[6]: CUSTOM ARG=q6_sp.im-p6,q6_norm FUNC=x/y PERIODIC=NO

DUMPATOMS ATOMS=q6 ARG=q6_anorm,q6n_rmn-[-6],q6n_rmn-[-5],q6n_rmn-[-4],q6n_rmn-[-3],q6n_rmn-[-2],q6n_rmn-[-1],q6n_rmn-[0],q6n_rmn-[1],q6n_rmn-[2],q6n_rmn-[3],q6n_rmn-[4],q6n_rmn-[5],q6n_rmn-[6],q6n_imn-[-6],q6n_imn-[-5],q6n_imn-[-4],q6n_imn-[-3],q6n_imn-[-2],q6n_imn-[-1],q6n_imn-[0],q6n_imn-[1],q6n_imn-[2],q6n_imn-[3],q6n_imn-[4],q6n_imn-[5],q6n_imn-[6] FILE=q6.xyz PRECISION=4
DUMPATOMS ATOMS=q6 ARG=q6,q6n_rmn-[-6],q6n_rmn-[-5],q6n_rmn-[-4],q6n_rmn-[-3],q6n_rmn-[-2],q6n_rmn-[-1],q6n_rmn-[0],q6n_rmn-[1],q6n_rmn-[2],q6n_rmn-[3],q6n_rmn-[4],q6n_rmn-[5],q6n_rmn-[6],q6n_imn-[-6],q6n_imn-[-5],q6n_imn-[-4],q6n_imn-[-3],q6n_imn-[-2],q6n_imn-[-1],q6n_imn-[0],q6n_imn-[1],q6n_imn-[2],q6n_imn-[3],q6n_imn-[4],q6n_imn-[5],q6n_imn-[6] FILE=q6.xyz PRECISION=4

w6: LOCAL_Q6 SPECIES=q6 SWITCH={RATIONAL D_0=3.0 R_0=1.5} MEAN
DUMPATOMS ARG=w6_av ATOMS=q6 FILE=w6.xyz PRECISION=4
12 changes: 6 additions & 6 deletions regtest/symfunc/rt24/colvar2.reference
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! FIELDS time c2_moment-2 c2_moment-3 c2_lessthan-1 c2_lessthan-2
0.000000 0.0383 -0.0032 0.0005 0.0019
0.005000 0.0427 -0.0041 0.0006 0.0023
0.010000 0.0585 -0.0020 0.0008 0.0029
0.015000 0.0778 0.0037 0.0011 0.0040
0.020000 0.0707 0.0027 0.0014 0.0052
#! FIELDS time c2_lessthan-1 c2_lessthan-2 c2_moment-2 c2_moment-3
0.000000 0.0005 0.0019 0.0383 -0.0032
0.005000 0.0006 0.0023 0.0427 -0.0041
0.010000 0.0008 0.0029 0.0585 -0.0020
0.015000 0.0011 0.0040 0.0778 0.0037
0.020000 0.0014 0.0052 0.0707 0.0027
2 changes: 1 addition & 1 deletion regtest/symfunc/rt24/plumed.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ PRINT ARG=mom.* FILE=colvar FMT=%8.4f
BIASVALUE ARG=mom.*

c2: COORDINATIONNUMBER SPECIES=1-10 SWITCH={RATIONAL R_0=1.0} MOMENTS=2-3 LESS_THAN1={RATIONAL R_0=0.2} LESS_THAN2={RATIONAL R_0=0.25}
PRINT ARG=c2.moment-2,c2.moment-3,c2.* FILE=colvar2 FMT=%8.4f
PRINT ARG=c2.* FILE=colvar2 FMT=%8.4f
2 changes: 1 addition & 1 deletion regtest/volumes/rt-q3-insphere/plumed.dat
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ q3: Q3 SPECIES=ow SWITCH={GAUSSIAN D_0=0.32 R_0=0.01 D_MAX=0.34}

# Probe volume
sphere: INSPHERE ATOMS=q3 CENTER=center RADIUS={GAUSSIAN D_0=0.5 R_0=0.01 D_MAX=0.52}
prod: CUSTOM ARG=q3_anorm,sphere FUNC=x*y PERIODIC=NO
prod: CUSTOM ARG=q3,sphere FUNC=x*y PERIODIC=NO
sphere_sum: SUM ARG=prod PERIODIC=NO

# Bias the mean value of the OP in the sphere
Expand Down
2 changes: 1 addition & 1 deletion src/clusters/ClusterProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PLUMED_REGISTER_ACTION(ClusterProperties,"CLUSTER_PROPERTIES")

void ClusterProperties::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.add("optional","ARG","calculate the sum of the arguments calculated by this action for the cluster");
keys.add("compulsory","ARG","calculate the sum of the arguments calculated by this action for the cluster");
keys.add("compulsory","CLUSTERS","the label of the action that does the clustering");
keys.add("compulsory","CLUSTER","1","which cluster would you like to look at 1 is the largest cluster, 2 is the second largest, 3 is the the third largest and so on.");
multicolvar::MultiColvarShortcuts::shortcutKeywords( keys );
Expand Down
2 changes: 1 addition & 1 deletion src/core/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void Action::setupConstantValues( const bool& have_atoms ) {
}
}
ActionWithArguments* aa = castToActionWithArguments();
if( aa && aa->getNumberOfArguments()>0 ) never_activate = aa->calculateConstantValues( have_atoms );
if( aa && aa->getNumberOfArguments()>0 && getName()!="BIASVALUE" ) never_activate = aa->calculateConstantValues( have_atoms );
}

long long int Action::getStep()const {
Expand Down
5 changes: 3 additions & 2 deletions src/core/ActionShortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ void ActionShortcut::interpretDataLabel( const std::string& mystr, Action* myuse
for(unsigned j=1;; ++j) {
std::string numstr; Tools::convert( j, numstr );
ActionWithValue* act=plumed.getActionSet().selectWithLabel<ActionWithValue*>( a + "_" + out_comps[k] + "-" + numstr );
if(!act) break;
for(unsigned n=0; n<act->getNumberOfComponents(); ++n ) arg.push_back(act->copyOutput(n));
if( act ) {
for(unsigned n=0; n<act->getNumberOfComponents(); ++n ) arg.push_back(act->copyOutput(n));
} else if( j>1 ) break; // This ensures that * syntax works with moments, which normally start from 2
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/multicolvar/Angles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Angles::Angles(const ActionOptions&ao):
if( swit.length()>0 ) {
std::string cat, grp; parse("GROUPA",cat); parse("GROUPB",grp);
if( cat.length()==0 || grp.length()==0 ) error("must use GROUPA/GROUPB when using SWITCH");
readInputLine( getShortcutLabel() + ": COORD_ANGLES SWITCH={" + swit + "} CATOMS=" + cat + " GROUP=" + grp );
readInputLine( getShortcutLabel() + ": COORD_ANGLES SWITCH={" + swit + "} CATOMS=" + cat + " GROUP=" + grp + " " + convertInputLineToString() );
return;
}
std::vector<std::string> group; parseVector("GROUP",group);
Expand Down
4 changes: 4 additions & 0 deletions src/multicolvar/Distances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,16 @@ Distances::Distances(const ActionOptions& ao):
} else if( grpa.size()>0 ) {
std::vector<std::string> grpb; MultiColvarShortcuts::parseAtomList("GROUPB",grpb,this);
if( grpb.size()==0 ) error("found GROUPA but no corresponding GROUPB");
std::string grpstr = getShortcutLabel() + "_grp: GROUP ATOMS=";
for(unsigned i=0; i<grpa.size(); ++i) {
for(unsigned j=0; j<grpb.size(); ++j) {
std::string num; Tools::convert( i*grpb.size() + j + 1, num );
dline += " ATOMS" + num + "=" + grpa[i] + "," + grpb[j];
readInputLine( getShortcutLabel() + "_vatom" + num + ": CENTER ATOMS=" + grpa[i] + "," + grpb[j] );
if( i+j==0 ) grpstr += getShortcutLabel() + "_vatom" + num; else grpstr += "," + getShortcutLabel() + "_vatom" + num;
}
}
readInputLine( grpstr );
} else {
std::string grpstr = getShortcutLabel() + "_grp: GROUP ATOMS=";
for(unsigned i=1;; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/multicolvar/MFilterLess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void MFilterLess::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.add("compulsory","DATA","the vector you wish to transform");
keys.add("compulsory","SWITCH","the switching function that transform");
keys.needsAction("GROUP"); keys.needsAction("MORE_THAN");
keys.needsAction("GROUP"); keys.needsAction("LESS_THAN");
}

MFilterLess::MFilterLess(const ActionOptions& ao):
Expand Down
3 changes: 2 additions & 1 deletion src/multicolvar/MFilterMore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void MFilterMore::registerKeywords(Keywords& keys) {
keys.addFlag("LOWMEM",false,"this flag does nothing and is present only to ensure back-compatibility");
keys.addFlag("HIGHEST",false,"this flag allows you to recover the highest of these variables.");
keys.addOutputComponent("highest","HIGHEST","the largest of the colvars");
keys.needsAction("CUSTOM"); keys.needsAction("GROUP"); keys.needsAction("MORE_THAN");
keys.needsAction("CUSTOM"); keys.needsAction("GROUP");
keys.needsAction("MORE_THAN"); keys.needsAction("HIGHEST");
}

MFilterMore::MFilterMore(const ActionOptions& ao):
Expand Down
74 changes: 74 additions & 0 deletions src/multicolvar/UWalls.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2011-2018 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed.org for more information.
This file is part of plumed, version 2.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "core/ActionShortcut.h"
#include "core/ActionRegister.h"
#include "MultiColvarShortcuts.h"

//+PLUMEDOC MCOLVAR UWALLS
/*
Add lower walls to a vector of quantities
Depracated action: use UPPER_WALLS
\par Examples
*/
//+ENDPLUMEDOC

namespace PLMD {
namespace multicolvar {

class UWalls : public ActionShortcut {
public:
static void registerKeywords(Keywords& keys);
explicit UWalls(const ActionOptions&);
};

PLUMED_REGISTER_ACTION(UWalls,"UWALLS")

void UWalls::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.add("compulsory","DATA","the values you want to restrain");
keys.add("compulsory","AT","the radius of the sphere");
keys.add("compulsory","KAPPA","the force constant for the wall. The k_i in the expression for a wall.");
keys.add("compulsory","OFFSET","0.0","the offset for the start of the wall. The o_i in the expression for a wall.");
keys.add("compulsory","EXP","2.0","the powers for the walls. The e_i in the expression for a wall.");
keys.add("compulsory","EPS","1.0","the values for s_i in the expression for a wall");
keys.add("atoms","CATOMS","all the angles between the bonds that radiate out from these central atom are computed");
keys.add("atoms","GROUP","a list of angls between pairs of bonds connecting one of the atoms specified using the CATOM command and two of the atoms specified here are computed");
keys.add("compulsory","SWITCH","the switching function specifies that only those bonds that have a length that is less than a certain threshold are considered");
keys.addOutputComponent("bias","default","the instantaneous value of the bias potential");
keys.addOutputComponent("force2","default","the instantaneous value of the squared force due to this bias potential");
keys.needsAction("UPPER_WALLS");
}

UWalls::UWalls(const ActionOptions& ao):
Action(ao),
ActionShortcut(ao)
{
std::string data; parse("DATA",data);
readInputLine( getShortcutLabel() + ": UPPER_WALLS ARG=" + data + " " + convertInputLineToString() );
}

}
}
6 changes: 5 additions & 1 deletion src/symfunc/LocalSteinhardt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void LocalSteinhardt::registerKeywords( Keywords& keys ) {
"When this keyword is present you no longer need the NN, MM, D_0 and R_0 keywords.");
keys.addFlag("LOWMEM",false,"this flag does nothing and is present only to ensure back-compatibility");
multicolvar::MultiColvarShortcuts::shortcutKeywords( keys );
keys.needsAction("CONTACT_MATRIX"); keys.needsAction("MATRIX_PRODUCT");
keys.needsAction("CONTACT_MATRIX"); keys.needsAction("MATRIX_PRODUCT"); keys.needsAction("GROUP");
keys.needsAction("ONES"); keys.needsAction("OUTER_PRODUCT"); keys.needsAction("VSTACK");
keys.needsAction("CONCATENATE"); keys.needsAction("CUSTOM"); keys.needsAction("TRANSPOSE");
keys.needsAction("MATRIX_VECTOR_PRODUCT");
Expand Down Expand Up @@ -335,6 +335,8 @@ LocalSteinhardt::LocalSteinhardt(const ActionOptions& ao):
std::string sp_str; parse("SPECIES",sp_str);
std::string spa_str; parse("SPECIESA",spa_str);
if( sp_str.length()>0 ) {
// Create a group with these atoms
readInputLine( getShortcutLabel() + "_grp: GROUP ATOMS=" + sp_str );
std::vector<std::string> sp_lab = Tools::getWords(sp_str, "\t\n ,");
// This creates the stash to hold all the vectors
if( sp_lab.size()==1 ) {
Expand Down Expand Up @@ -366,6 +368,8 @@ LocalSteinhardt::LocalSteinhardt(const ActionOptions& ao):
// And the matrix of dot products
readInputLine( getShortcutLabel() + "_dpmat: MATRIX_PRODUCT ARG=" + getShortcutLabel() + "_vecs," + getShortcutLabel() + "_vecsT" );
} else if( spa_str.length()>0 ) {
// Create a group with these atoms
readInputLine( getShortcutLabel() + "_grp: GROUP ATOMS=" + spa_str );
std::string spb_str; parse("SPECIESB",spb_str);
if( spb_str.length()==0 ) plumed_merror("need both SPECIESA and SPECIESB in input");
std::vector<std::string> sp_laba = Tools::getWords(spa_str, "\t\n ,");
Expand Down
4 changes: 2 additions & 2 deletions src/symfunc/Steinhardt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ Steinhardt::Steinhardt( const ActionOptions& ao):
// Now calculate the total length of the vector
createVectorNormInput( getShortcutLabel() + "_sp", getShortcutLabel() + "_norm", l, ".", "m" );
// And take average
readInputLine( getShortcutLabel() + "_anorm: CUSTOM ARG=" + getShortcutLabel() + "_norm," + getShortcutLabel() + "_denom FUNC=x/y PERIODIC=NO");
multicolvar::MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel() + "_anorm", "", this );
readInputLine( getShortcutLabel() + ": CUSTOM ARG=" + getShortcutLabel() + "_norm," + getShortcutLabel() + "_denom FUNC=x/y PERIODIC=NO");
multicolvar::MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", this );
}

void Steinhardt::createVectorNormInput( const std::string& ilab, const std::string& olab, const int& l, const std::string& sep, const std::string& vlab ) {
Expand Down

1 comment on commit 3baf976

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.