From 3baf976268aef6a36a20c5502cced6c9938236c2 Mon Sep 17 00:00:00 2001 From: Gareth Aneurin Tribello Date: Sun, 24 Mar 2024 13:03:55 +0000 Subject: [PATCH] More fixes to resolve problems with inputs in nest -> Changed label for list of q6 values to rather than _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 --- regtest/contour/rt-dfg-wcsurf/plumed.dat | 2 +- .../rt-q6-histogram/density.reference | 10 +-- regtest/gridtools/rt-q6-histogram/plumed.dat | 2 +- regtest/symfunc/rt-dumpmulti/plumed.dat | 2 +- regtest/symfunc/rt24/colvar2.reference | 12 +-- regtest/symfunc/rt24/plumed.dat | 2 +- regtest/volumes/rt-q3-insphere/plumed.dat | 2 +- src/clusters/ClusterProperties.cpp | 2 +- src/core/Action.cpp | 2 +- src/core/ActionShortcut.cpp | 5 +- src/multicolvar/Angles.cpp | 2 +- src/multicolvar/Distances.cpp | 4 + src/multicolvar/MFilterLess.cpp | 2 +- src/multicolvar/MFilterMore.cpp | 3 +- src/multicolvar/UWalls.cpp | 74 +++++++++++++++++++ src/symfunc/LocalSteinhardt.cpp | 6 +- src/symfunc/Steinhardt.cpp | 4 +- 17 files changed, 110 insertions(+), 26 deletions(-) create mode 100644 src/multicolvar/UWalls.cpp diff --git a/regtest/contour/rt-dfg-wcsurf/plumed.dat b/regtest/contour/rt-dfg-wcsurf/plumed.dat index 813217bd4a..c9bd138726 100644 --- a/regtest/contour/rt-dfg-wcsurf/plumed.dat +++ b/regtest/contour/rt-dfg-wcsurf/plumed.dat @@ -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 diff --git a/regtest/gridtools/rt-q6-histogram/density.reference b/regtest/gridtools/rt-q6-histogram/density.reference index 9c331d6bc2..b96254c0e6 100644 --- a/regtest/gridtools/rt-q6-histogram/density.reference +++ b/regtest/gridtools/rt-q6-histogram/density.reference @@ -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 diff --git a/regtest/gridtools/rt-q6-histogram/plumed.dat b/regtest/gridtools/rt-q6-histogram/plumed.dat index d6e08d0e5d..731750ef5d 100644 --- a/regtest/gridtools/rt-q6-histogram/plumed.dat +++ b/regtest/gridtools/rt-q6-histogram/plumed.dat @@ -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 diff --git a/regtest/symfunc/rt-dumpmulti/plumed.dat b/regtest/symfunc/rt-dumpmulti/plumed.dat index 1cb0dd299a..162c775dfb 100644 --- a/regtest/symfunc/rt-dumpmulti/plumed.dat +++ b/regtest/symfunc/rt-dumpmulti/plumed.dat @@ -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 diff --git a/regtest/symfunc/rt24/colvar2.reference b/regtest/symfunc/rt24/colvar2.reference index 07202ed498..1a254ba62a 100644 --- a/regtest/symfunc/rt24/colvar2.reference +++ b/regtest/symfunc/rt24/colvar2.reference @@ -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 diff --git a/regtest/symfunc/rt24/plumed.dat b/regtest/symfunc/rt24/plumed.dat index 270c105e1c..af67ca16c4 100644 --- a/regtest/symfunc/rt24/plumed.dat +++ b/regtest/symfunc/rt24/plumed.dat @@ -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 diff --git a/regtest/volumes/rt-q3-insphere/plumed.dat b/regtest/volumes/rt-q3-insphere/plumed.dat index 343cea1d83..b81c86a858 100644 --- a/regtest/volumes/rt-q3-insphere/plumed.dat +++ b/regtest/volumes/rt-q3-insphere/plumed.dat @@ -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 diff --git a/src/clusters/ClusterProperties.cpp b/src/clusters/ClusterProperties.cpp index e5091c0f19..3799a1bbb3 100644 --- a/src/clusters/ClusterProperties.cpp +++ b/src/clusters/ClusterProperties.cpp @@ -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 ); diff --git a/src/core/Action.cpp b/src/core/Action.cpp index 9636ca0695..001a413a8c 100644 --- a/src/core/Action.cpp +++ b/src/core/Action.cpp @@ -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 { diff --git a/src/core/ActionShortcut.cpp b/src/core/ActionShortcut.cpp index 5c22e062e4..fe9f19b3d7 100644 --- a/src/core/ActionShortcut.cpp +++ b/src/core/ActionShortcut.cpp @@ -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( a + "_" + out_comps[k] + "-" + numstr ); - if(!act) break; - for(unsigned n=0; ngetNumberOfComponents(); ++n ) arg.push_back(act->copyOutput(n)); + if( act ) { + for(unsigned n=0; ngetNumberOfComponents(); ++n ) arg.push_back(act->copyOutput(n)); + } else if( j>1 ) break; // This ensures that * syntax works with moments, which normally start from 2 } } } diff --git a/src/multicolvar/Angles.cpp b/src/multicolvar/Angles.cpp index cde1115bf6..d035dc28df 100644 --- a/src/multicolvar/Angles.cpp +++ b/src/multicolvar/Angles.cpp @@ -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 group; parseVector("GROUP",group); diff --git a/src/multicolvar/Distances.cpp b/src/multicolvar/Distances.cpp index 0053b4b78c..1586b0cbc1 100644 --- a/src/multicolvar/Distances.cpp +++ b/src/multicolvar/Distances.cpp @@ -246,12 +246,16 @@ Distances::Distances(const ActionOptions& ao): } else if( grpa.size()>0 ) { std::vector 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. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#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() ); +} + +} +} diff --git a/src/symfunc/LocalSteinhardt.cpp b/src/symfunc/LocalSteinhardt.cpp index 9dfcb399ab..426ea7d494 100644 --- a/src/symfunc/LocalSteinhardt.cpp +++ b/src/symfunc/LocalSteinhardt.cpp @@ -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"); @@ -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 sp_lab = Tools::getWords(sp_str, "\t\n ,"); // This creates the stash to hold all the vectors if( sp_lab.size()==1 ) { @@ -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 sp_laba = Tools::getWords(spa_str, "\t\n ,"); diff --git a/src/symfunc/Steinhardt.cpp b/src/symfunc/Steinhardt.cpp index 8255c98eab..3366a0f634 100644 --- a/src/symfunc/Steinhardt.cpp +++ b/src/symfunc/Steinhardt.cpp @@ -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 ) {