Skip to content

Commit

Permalink
Merge branch 'v2.8' into v2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanniBussi committed Jan 22, 2024
2 parents 419a19c + 5f8926e commit 1b62bac
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES/v2.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ Changes from version 2.7 which are relevant for users:
## Version 2.8.4
- Added the possibility to disable `RTLD_DEEPBIND` (see \issue{952}).
- Fixed a bug in `switchingfunction` mode `Q` thanks to @nm3787, (see #951)
- Improved error reporting in CUSTOM switching function: an error is thrown if one uses `x` and `x2` arguments simultaneously (reported by Olivier Languin-Cattoen).
6 changes: 6 additions & 0 deletions regtest/basic/rt-make-exceptions/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ int main(){
// check error in regular expression
test_line(ofs,plumed,"RESTRAINT ARG=([a) KAPPA=5 AT=0");

// cannot use simultaneously x2 and x
test_line(ofs,plumed,"COORDINATION GROUPA=1 GROUPB=2 SWITCH={CUSTOM FUNC=x2+x R_0=1.0}");

// cannot use variables other than x2 or x
test_line(ofs,plumed,"COORDINATION GROUPA=1 GROUPB=2 SWITCH={CUSTOM FUNC=c R_0=1.0}");

test_line(ofs,plumed,"EXTERNAL ARG=d FILE=potential LABEL=ext");
test_line(ofs,plumed,"METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1 RESTART=WHAT");
test_line(ofs,plumed,"METAD ARG=d PACE=1 SIGMA=1 TAU=5");
Expand Down
4 changes: 4 additions & 0 deletions regtest/basic/rt-make-exceptions/output.reference
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ readInputLine RESTRAINT ARG=(d)x KAPPA=5 AT=0
+++ catched
readInputLine RESTRAINT ARG=([a) KAPPA=5 AT=0
+++ catched
readInputLine COORDINATION GROUPA=1 GROUPB=2 SWITCH={CUSTOM FUNC=x2+x R_0=1.0}
+++ catched
readInputLine COORDINATION GROUPA=1 GROUPB=2 SWITCH={CUSTOM FUNC=c R_0=1.0}
+++ catched
readInputLine EXTERNAL ARG=d FILE=potential LABEL=ext
+++ catched
readInputLine METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1 RESTART=WHAT
Expand Down
26 changes: 16 additions & 10 deletions src/tools/SwitchingFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "OpenMP.h"
#include <vector>
#include <limits>
#include <algorithm>

#define PI 3.14159265358979323846

Expand Down Expand Up @@ -269,17 +270,22 @@ void SwitchingFunction::set(const std::string & definition,std::string& errormsg
for(auto & e : expression) e=pe.createCompiledExpression();
lepton_ref.resize(expression.size());
for(unsigned t=0; t<lepton_ref.size(); t++) {
try {
lepton_ref[t]=&const_cast<lepton::CompiledExpression*>(&expression[t])->getVariableReference("x");
} catch(const PLMD::lepton::Exception& exc) {
try {
lepton_ref[t]=&const_cast<lepton::CompiledExpression*>(&expression[t])->getVariableReference("x2");
leptonx2=true;
} catch(const PLMD::lepton::Exception& exc) {
// this is necessary since in some cases lepton things a variable is not present even though it is present
auto vars=expression[t].getVariables();
bool found_x=std::find(vars.begin(),vars.end(),"x")!=vars.end();
bool found_x2=std::find(vars.begin(),vars.end(),"x2")!=vars.end();
if (vars.size()==0) {
// this is necessary since in some cases lepton thinks a variable is not present even though it is present
// e.g. func=0*x
lepton_ref[t]=nullptr;
}
lepton_ref[t]=nullptr;
} else if(vars.size()==1 && found_x) {
lepton_ref[t]=&const_cast<lepton::CompiledExpression*>(&expression[t])->getVariableReference("x");
} else if(vars.size()==1 && found_x2) {
lepton_ref[t]=&const_cast<lepton::CompiledExpression*>(&expression[t])->getVariableReference("x2");
leptonx2=true;
} else if(vars.size()==2 && found_x && found_x2) {
plumed_error() << "Cannot use simultaneously x and x2 argument in switching function: "<<func;
} else {
plumed_error() << "Something wrong in the arguments for switching function: "<<func;
}
}
std::string arg="x";
Expand Down

1 comment on commit 1b62bac

@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/a-masterclass-22-09.txt
Found broken examples in automatic/a-masterclass-22-11.txt
Found broken examples in automatic/a-masterclass-22-12.txt
Found broken examples in automatic/performance-optimization.txt
Found broken examples in automatic/a-trieste-6.txt
Found broken examples in automatic/munster.txt
Found broken examples in automatic/ANN.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/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/INCLUDE.tmp
Found broken examples in automatic/MAZE_MEMETIC_SAMPLING.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_RANDOM_WALK.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in MiscelaneousPP.md

Please sign in to comment.