From 14ac70186f0f55cdb94ec6a3e2ae980ffd410ae2 Mon Sep 17 00:00:00 2001 From: Gareth Tribello <gareth.tribello@gmail.com> Date: Sat, 27 Jul 2019 17:37:39 +0200 Subject: [PATCH] Redid testing script for multiple replica inputs using comment with number of replicas rather than separate environment --- src/colvar/Dimer.cpp | 1 + src/generic/Include.cpp | 8 ++++---- src/ves/Opt_BachAveragedSGD.cpp | 5 +++-- user-doc/Doxyfile | 2 -- user-doc/Miscelaneous.md | 20 ++++++++++++-------- user-doc/go-example-check | 18 ++++++------------ user-doc/tutorials/a-trieste-5.txt | 20 ++++++++++++-------- 7 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/colvar/Dimer.cpp b/src/colvar/Dimer.cpp index cb547a2f3..bbf18c510 100644 --- a/src/colvar/Dimer.cpp +++ b/src/colvar/Dimer.cpp @@ -113,6 +113,7 @@ like in the previous examples, and each replica will read its own DSIGMA value. a unique plumed.dat is given, DSIGMA has to be a list containing a value for each replica. For 4 replicas: \plumedfile +#SETTINGS NREPLICAS=4 dim: DIMER TEMP=300 Q=0.5 ATOMS1=1,5,7 ATOMS2=23,27,29 DSIGMA=0.002,0.002,0.004,0.01 \endplumedfile diff --git a/src/generic/Include.cpp b/src/generic/Include.cpp index 84bec5cb2..950d6ef7e 100644 --- a/src/generic/Include.cpp +++ b/src/generic/Include.cpp @@ -121,12 +121,12 @@ a file for reading it looks for a file with the replica suffix first. This is true also for files opened by INCLUDE! As an example, the same result of the inputs above could have been obtained using -`plumed.dat`: -\plumedmultireplicafile{2} -# this is plumed.dat +the following `plumed.dat` file: +\plumedfile +#SETTINGS NREPLICAS=2 t: TORSION ATOMS=1,2,3,4 INCLUDE FILE=other.inc -\endplumedmultireplicafile +\endplumedfile Then `other.0.inc`: \plumedincludefile # this is other.0.inc diff --git a/src/ves/Opt_BachAveragedSGD.cpp b/src/ves/Opt_BachAveragedSGD.cpp index 34151444f..5c44decbf 100644 --- a/src/ves/Opt_BachAveragedSGD.cpp +++ b/src/ves/Opt_BachAveragedSGD.cpp @@ -138,7 +138,8 @@ is updated every 500 iterations (e.g. every 1000 ps). The target distribution is also output to a file every 2000 iterations (the TARGETDIST_OUTPUT keyword). Here we also employ MULTIPLE_WALKERS flag to enable the usage of multiple walkers. -\plumedmultireplicafile{2} +\plumedfile +#SETTINGS NREPLICAS=2 phi: TORSION ATOMS=5,7,9,15 psi: TORSION ATOMS=7,9,15,17 @@ -172,7 +173,7 @@ OPT_AVERAGED_SGD ... TARGETDIST_STRIDE=500 TARGETDIST_OUTPUT=2000 ... OPT_AVERAGED_SGD -\endplumedmultireplicafile +\endplumedfile diff --git a/user-doc/Doxyfile b/user-doc/Doxyfile index 7844b91fb..571e3ad3b 100644 --- a/user-doc/Doxyfile +++ b/user-doc/Doxyfile @@ -238,8 +238,6 @@ ALIASES = \ "tarball{1}=\htmlonly<span style=\"background-color:yellow\">\endhtmlonly<a href=\"tutorial-resources/\1.tar.gz\" style=\"font-weight:bold\" style=\"color:green\" download=\"\1.tar.gz\"> TARBALL </a>\htmlonly</span>\endhtmlonly" \ "plumedfile=\verbatim BEGIN_PLUMED_FILE" \ "endplumedfile=\endverbatim" \ - "plumedmultireplicafile{1}=\verbatim BEGIN_PLUMED_FILE" \ - "endplumedmultireplicafile=\endverbatim" \ "plumedincludefile=\verbatim BEGIN_PLUMED_FILE" \ "endplumedincludefile=\endverbatim" \ "auxfile{1}=\verbatim" \ diff --git a/user-doc/Miscelaneous.md b/user-doc/Miscelaneous.md index 9978e59f1..30f8557d8 100644 --- a/user-doc/Miscelaneous.md +++ b/user-doc/Miscelaneous.md @@ -530,7 +530,8 @@ file with common definitions and specific input files with replica-dependent key However, as of PLUMED 2.4, we introduced a simpler manner to manipulate multiple replica inputs with tiny differences. Look at the following example: -\plumedmultireplicafile{3} +\plumedfile +#SETTINGS NREPLICAS=3 # Compute a distance d: DISTANCE ATOMS=1,2 @@ -542,7 +543,7 @@ RESTRAINT ARG=d AT=@replicas:1.0,1.1,1.2 KAPPA=1.0 # RESTRAINT ARG=d AT=1.1 KAPPA=1.0 # On replica 2, this means: # RESTRAINT ARG=d AT=1.2 KAPPA=1.0 -\endplumedmultireplicafile +\endplumedfile If you prepare a single `plumed.dat` file like this one and feeds it to PLUMED while using 3 replicas, the 3 replicas will see the very same input except for the `AT` keyword, that sets the position of the restraint. @@ -550,7 +551,8 @@ Replica 0 will see a restraint centered at 1.0, replica 1 centered at 1.1, and r The `@replicas:` keyword is not special for \ref RESTRAINT or for the `AT` keyword. Any keyword in PLUMED can accept that syntax. For instance, the following single input file can be used to setup a bias exchange metadynamics \cite piana simulations: -\plumedmultireplicafile{2} +\plumedfile +#SETTINGS NREPLICAS=2 # Compute distance between atoms 1 and 2 d: DISTANCE ATOMS=1,2 @@ -570,7 +572,7 @@ METAD ... # METAD ARG=d HEIGHT=1.0 PACE=100 SIGMA=0.1 GRID_MIN=0.0 GRID_MAX=2.0 # On replica 1, this means: # METAD ARG=t HEIGHT=1.0 PACE=100 SIGMA=0.3 GRID_MIN=-pi GRID_MAX=+pi -\endplumedmultireplicafile +\endplumedfile This would be a typical setup for a bias exchange simulation. Notice that even though variables `d` and `t` are both read in both replicas, @@ -580,7 +582,8 @@ This is because variables that are defined but not used are never actually calcu If the value that should be provided for each replica is a vector, you should use curly braces as delimiters. For instance, if the restraint acts on two variables, you can use the following input: -\plumedmultireplicafile{3} +\plumedfile +#SETTINGS NREPLICAS=3 # Compute distance between atoms 1 and 2 d: DISTANCE ATOMS=10,20 @@ -599,13 +602,14 @@ RESTRAINT ... # RESTRAINT ARG=d AT=3.0,4.0 KAPPA=1.0,3.0 # On replica 2 this means: # RESTRAINT ARG=d AT=5.0,6.0 KAPPA=1.0,3.0 -\endplumedmultireplicafile +\endplumedfile Notice the double curly braces. The outer ones are used by PLUMED to know there the argument of the `AT` keyword ends, whereas the inner ones are used to group the values corresponding to each replica. Also notice that the last example can be split in multiple lines exploiting the fact that within multi-line statements (enclosed by pairs of `...`) newlines are replaced with simple spaces: -\plumedmultireplicafile{3} +\plumedfile +#SETTINGS NREPLICAS=3 d: DISTANCE ATOMS=10,20 t: TORSION ATOMS=30,31,32,33 RESTRAINT ... @@ -619,7 +623,7 @@ RESTRAINT ... } KAPPA=1.0,3.0 ... -\endplumedmultireplicafile +\endplumedfile In short, whenever there are keywords that should vary across replicas, you should set them using the `@replicas:` keyword. As mentioned above, you can always use the old syntax with separate input file, and this is recommended when the diff --git a/user-doc/go-example-check b/user-doc/go-example-check index 5fd360d9b..f4d44a76f 100755 --- a/user-doc/go-example-check +++ b/user-doc/go-example-check @@ -16,16 +16,6 @@ for file in *PP.md automatic/*.txt ../CHANGES/*.md tutorials/*.txt tutorials/*.s else if( $1=="\\plumedfile" ){ inp=1; } else if( inp==1 ){ print $0; } }' > example-check/$fname.dat - # Multiple replica examples - splits=`echo $file | sed -e 's/\// /g'` - nf=`echo $splits | awk '{print NF}'` - fname=`echo $splits | awk -v n=$nf '{print $n}'` - cat $file | - awk 'BEGIN{inp=0;}{ - if( $1=="\\endplumedmultireplicafile" ){ print ">>END OF EXAMPLE>>"; inp=0; } - else if( match($1,"plumedmultireplicafile") ){ inp=1; print "# " $0 } - else if( inp==1 ){ print $0; } - }' >> example-check/$fname.dat #Â Count the number of examples found in the input neg=`grep ">>END OF EXAMPLE>>" example-check/$fname.dat | wc -l | awk '{print $1}'` if [ $neg -gt 0 ] ; then @@ -143,9 +133,13 @@ for dir in * ; do # Want to get rid of these ntarget=`grep "TARGET=" $file | wc -l | awk '{print $1}'` if [ $nsnip -eq 0 ] && [ $nload -eq 0 ] && [ $nfill -eq 0 ] ; then - hasrep=`grep plumedmultireplicafile $file | wc -l | awk '{print $1}'` + hasrep=0 + settings=`grep "#SETTINGS" $file | wc -l | awk '{print $1}'` + if [ $settings -gt 0 ] ; then + hasrep=`grep "#SETTINGS" $file | grep "NREPLICAS=" | wc -l | awk '{print $1}'` + fi if [ $hasrep -gt 0 ] ; then - nrep=`grep plumedmultireplicafile $file | awk '{print $2}' | sed -e 's/\\\plumedmultireplicafile{//' | sed -e 's/}//'` + nrep=`grep "#SETTINGS" $file | awk '{for(i=1;i<=NF;++i){if(match($i,"NREPLICAS=")){print $i}}}' | sed -e 's/NREPLICAS=//'` mpirun -np $nrep ../../../src/lib/plumed driver --natoms 100000 --parse-only --kt 2.49 --plumed $file --multi $nrep > check.log else ../../../src/lib/plumed driver --natoms 100000 --parse-only --kt 2.49 --plumed $file > check.log diff --git a/user-doc/tutorials/a-trieste-5.txt b/user-doc/tutorials/a-trieste-5.txt index 17d39dec9..6989f02dc 100644 --- a/user-doc/tutorials/a-trieste-5.txt +++ b/user-doc/tutorials/a-trieste-5.txt @@ -103,7 +103,8 @@ file with common definitions and specific input files with replica-dependent key However, as of PLUMED 2.4, we introduced a simpler manner to manipulate multiple replica inputs with tiny differences. Look at the following example: -\plumedmultireplicafile{3} +\plumedfile +#SETTINGS NREPLICAS=3 # Compute a distance d: DISTANCE ATOMS=1,2 @@ -115,7 +116,7 @@ RESTRAINT ARG=d AT=@replicas:1.0,1.1,1.2 KAPPA=1.0 # RESTRAINT ARG=d AT=1.1 KAPPA=1.0 # On replica 2, this means: # RESTRAINT ARG=d AT=1.2 KAPPA=1.0 -\endplumedmultireplicafile +\endplumedfile If you prepare a single `plumed.dat` file like this one and feeds it to PLUMED while using 3 replicas, the 3 replicas will see the very same input except for the `AT` keyword, that sets the position of the restraint. @@ -123,7 +124,8 @@ Replica 0 will see a restraint centered at 1.0, replica 1 centered at 1.1, and r The `@replicas:` keyword is not special for \ref RESTRAINT or for the `AT` keyword. Any keyword in PLUMED can accept that syntax. For instance, the following single input file can be used to setup a bias exchange metadynamics \cite piana simulations: -\plumedmultireplicafile{2} +\plumedfile +#SETTINGS NREPLICAS=2 # Compute distance between atoms 1 and 2 d: DISTANCE ATOMS=1,2 @@ -143,7 +145,7 @@ METAD ... # METAD ARG=d HEIGHT=1.0 PACE=100 SIGMA=0.1 GRID_MIN=0.0 GRID_MAX=2.0 # On replica 1, this means: # METAD ARG=t HEIGHT=1.0 PACE=100 SIGMA=0.3 GRID_MIN=-pi GRID_MAX=+pi -\endplumedmultireplicafile +\endplumedfile This would be a typical setup for a bias exchange simulation. Notice that even though variables `d` and `t` are both read in both replicas, @@ -153,7 +155,8 @@ This is because variables that are defined but not used are never actually calcu If the value that should be provided for each replica is a vector, you should use curly braces as delimiters. For instance, if the restraint acts on two variables, you can use the following input: -\plumedmultireplicafile{3} +\plumedfile +#SETTINGS NREPLICAS=3 # Compute distance between atoms 1 and 2 d: DISTANCE ATOMS=10,20 @@ -172,13 +175,14 @@ RESTRAINT ... # RESTRAINT ARG=d AT=3.0,4.0 KAPPA=1.0,3.0 # On replica 2 this means: # RESTRAINT ARG=d AT=5.0,6.0 KAPPA=1.0,3.0 -\endplumedmultireplicafile +\endplumedfile Notice the double curly braces. The outer ones are used by PLUMED to know there the argument of the `AT` keyword ends, whereas the inner ones are used to group the values corresponding to each replica. Also notice that the last example can be split in multiple lines exploiting the fact that within multi-line statements (enclosed by pairs of `...`) newlines are replaced with simple spaces: -\plumedmultireplicafile{3} +\plumedfile +#SETTINGS NREPLICAS=3 d: DISTANCE ATOMS=10,20 t: TORSION ATOMS=30,31,32,33 RESTRAINT ... @@ -192,7 +196,7 @@ RESTRAINT ... } KAPPA=1.0 ... -\endplumedmultireplicafile +\endplumedfile In short, whenever there are keywords that should vary across replicas, you should set them using the `@replicas:` keyword. As mentioned above, you can always use the old syntax with separate input file, and this is recommended when the -- GitLab