From f7e4cd8efef465c96a030e688f943f4ba6afe5bb Mon Sep 17 00:00:00 2001 From: Michele Invernizzi Date: Thu, 28 Sep 2023 15:42:49 +0200 Subject: [PATCH 1/5] update OPES explore bibliography --- src/opes/OPESmetad.cpp | 2 +- user-doc/bibliography.bib | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/opes/OPESmetad.cpp b/src/opes/OPESmetad.cpp index da6516b73c..cee142ee42 100644 --- a/src/opes/OPESmetad.cpp +++ b/src/opes/OPESmetad.cpp @@ -934,7 +934,7 @@ OPESmetad::OPESmetad(const ActionOptions& ao) log.printf(" Bibliography: "); log< Date: Wed, 29 Nov 2023 16:07:12 +0100 Subject: [PATCH 2/5] test robust isnan --- src/opes/ECVlinear.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/opes/ECVlinear.cpp b/src/opes/ECVlinear.cpp index 56e895e3c3..6be407afd3 100644 --- a/src/opes/ECVlinear.cpp +++ b/src/opes/ECVlinear.cpp @@ -121,6 +121,22 @@ ECVlinear::ECVlinear(const ActionOptions&ao) parseFlag("DIMENSIONLESS",dimensionless); if(dimensionless) beta0_=1; + + //workaround to understand if the user is setting a value or not + bool nan_support=true; + const double my_nan_value=-42; + if(!std::isnan(std::numeric_limits::quiet_NaN())) + { + nan_support=false; + log.printf(" +++ WARNING +++ do not set LAMBDA_MIN/MAX=%g, see https://github.com/plumed/plumed2/pull/990\n", my_nan_value); + } + auto isNaN=[nan_support,my_nan_value](const double value) + { + if(nan_support) + return std::isnan(value); + else + return value==my_nan_value; + }; //parse lambda info parse("LAMBDA",lambda0_); @@ -140,7 +156,7 @@ ECVlinear::ECVlinear(const ActionOptions&ao) if(lambdas.size()>0) { plumed_massert(lambda_steps==0,"cannot set both LAMBDA_STEPS and LAMBDA_SET_ALL"); - plumed_massert(std::isnan(lambda_min) && std::isnan(lambda_max),"cannot set both LAMBDA_SET_ALL and LAMBDA_MIN/MAX"); + plumed_massert(isNaN(lambda_min) && isNaN(lambda_max),"cannot set both LAMBDA_SET_ALL and LAMBDA_MIN/MAX"); plumed_massert(lambdas.size()>=2,"set at least 2 lambdas with LAMBDA_SET_ALL"); for(unsigned k=0; k Date: Wed, 29 Nov 2023 16:23:14 +0100 Subject: [PATCH 3/5] switch to robust isnan --- src/opes/ECVlinear.cpp | 10 +++++----- src/opes/ECVmultiThermal.cpp | 24 ++++++++++++------------ src/opes/ECVmultiThermalBaric.cpp | 24 ++++++++++++++++++++---- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/opes/ECVlinear.cpp b/src/opes/ECVlinear.cpp index 6be407afd3..f58d723455 100644 --- a/src/opes/ECVlinear.cpp +++ b/src/opes/ECVlinear.cpp @@ -122,7 +122,7 @@ ECVlinear::ECVlinear(const ActionOptions&ao) if(dimensionless) beta0_=1; - //workaround to understand if the user is setting a value or not +//workaround needed for intel compiler bool nan_support=true; const double my_nan_value=-42; if(!std::isnan(std::numeric_limits::quiet_NaN())) @@ -130,7 +130,7 @@ ECVlinear::ECVlinear(const ActionOptions&ao) nan_support=false; log.printf(" +++ WARNING +++ do not set LAMBDA_MIN/MAX=%g, see https://github.com/plumed/plumed2/pull/990\n", my_nan_value); } - auto isNaN=[nan_support,my_nan_value](const double value) + auto isNone=[nan_support,my_nan_value](const double value) { if(nan_support) return std::isnan(value); @@ -156,7 +156,7 @@ ECVlinear::ECVlinear(const ActionOptions&ao) if(lambdas.size()>0) { plumed_massert(lambda_steps==0,"cannot set both LAMBDA_STEPS and LAMBDA_SET_ALL"); - plumed_massert(isNaN(lambda_min) && isNaN(lambda_max),"cannot set both LAMBDA_SET_ALL and LAMBDA_MIN/MAX"); + plumed_massert(isNone(lambda_min) && isNone(lambda_max),"cannot set both LAMBDA_SET_ALL and LAMBDA_MIN/MAX"); plumed_massert(lambdas.size()>=2,"set at least 2 lambdas with LAMBDA_SET_ALL"); for(unsigned k=0; k&) override; }; -PLUMED_REGISTER_ACTION(ECVmultiCanonical,"ECV_MULTITHERMAL") +PLUMED_REGISTER_ACTION(ECVmultiThermal,"ECV_MULTITHERMAL") -void ECVmultiCanonical::registerKeywords(Keywords& keys) +void ECVmultiThermal::registerKeywords(Keywords& keys) { ExpansionCVs::registerKeywords(keys); keys.remove("ARG"); @@ -114,7 +114,7 @@ void ECVmultiCanonical::registerKeywords(Keywords& keys) keys.addFlag("NO_GEOM_SPACING",false,"do not use geometrical spacing in temperature, but instead linear spacing in inverse temperature"); } -ECVmultiCanonical::ECVmultiCanonical(const ActionOptions&ao) +ECVmultiThermal::ECVmultiThermal(const ActionOptions&ao) : Action(ao) , ExpansionCVs(ao) , todoAutomatic_(false) @@ -188,28 +188,28 @@ ECVmultiCanonical::ECVmultiCanonical(const ActionOptions&ao) log.printf(" -- NO_GEOM_SPACING: inverse temperatures will be linearly spaced\n"); } -void ECVmultiCanonical::calculateECVs(const double * ene) +void ECVmultiThermal::calculateECVs(const double * ene) { for(unsigned k=0; k ECVmultiCanonical::getLambdas() const +std::vector ECVmultiThermal::getLambdas() const { plumed_massert(!todoAutomatic_,"cannot access lambdas before initializing them"); const double temp0=kbt_/plumed.getAtoms().getKBoltzmann(); @@ -223,7 +223,7 @@ std::vector ECVmultiCanonical::getLambdas() const return lambdas; } -void ECVmultiCanonical::initECVs() +void ECVmultiThermal::initECVs() { plumed_massert(!isReady_,"initialization should not be called twice"); plumed_massert(!todoAutomatic_,"this should not happen"); @@ -233,7 +233,7 @@ void ECVmultiCanonical::initECVs() log.printf(" *%4lu temperatures for %s\n",derECVs_.size(),getName().c_str()); } -void ECVmultiCanonical::initECVs_observ(const std::vector& all_obs_cvs,const unsigned ncv,const unsigned index_j) +void ECVmultiThermal::initECVs_observ(const std::vector& all_obs_cvs,const unsigned ncv,const unsigned index_j) { if(todoAutomatic_) //estimate the steps in beta from observations { @@ -250,7 +250,7 @@ void ECVmultiCanonical::initECVs_observ(const std::vector& all_obs_cvs,c calculateECVs(&all_obs_cvs[index_j]); } -void ECVmultiCanonical::initECVs_restart(const std::vector& lambdas) +void ECVmultiThermal::initECVs_restart(const std::vector& lambdas) { std::size_t pos=lambdas[0].find("_"); plumed_massert(pos==std::string::npos,"this should not happen, only one CV is used in "+getName()); diff --git a/src/opes/ECVmultiThermalBaric.cpp b/src/opes/ECVmultiThermalBaric.cpp index 17b3d07e31..01e237779e 100644 --- a/src/opes/ECVmultiThermalBaric.cpp +++ b/src/opes/ECVmultiThermalBaric.cpp @@ -145,6 +145,22 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao) //set temp0 const double kB=plumed.getAtoms().getKBoltzmann(); const double temp0=kbt_/kB; + +//workaround needed for intel compiler + bool nan_support=true; + const double my_nan_value=-42; + if(!std::isnan(std::numeric_limits::quiet_NaN())) + { + nan_support=false; + log.printf(" +++ WARNING +++ do not set LAMBDA_MIN/MAX=%g, see https://github.com/plumed/plumed2/pull/990\n", my_nan_value); + } + auto isNone=[nan_support,my_nan_value](const double value) + { + if(nan_support) + return std::isnan(value); + else + return value==my_nan_value; + }; //parse temp range double temp_min=-1; @@ -181,7 +197,7 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao) plumed_massert(temp_steps==0,"cannot set both SET_ALL_TEMP_PRESSURE and TEMP_STEPS"); plumed_massert(pres_steps==0,"cannot set both SET_ALL_TEMP_PRESSURE and PRESSURE_STEPS"); plumed_massert(temp_min==-1 && temp_max==-1,"cannot set both SET_ALL_TEMP_PRESSURE and TEMP_MIN/MAX"); - plumed_massert(std::isnan(pres_min) && std::isnan(pres_max),"cannot set both SET_ALL_TEMP_PRESSURE and PRESSURE_MIN/MAX"); + plumed_massert(isNone(pres_min) && isNone(pres_max),"cannot set both SET_ALL_TEMP_PRESSURE and PRESSURE_MIN/MAX"); plumed_massert(cut_corner.size()==0,"cannot set both SET_ALL_TEMP_PRESSURE and CUT_CORNER"); //setup the target temperature-pressure grid derECVs_beta_.resize(custom_lambdas_.size()); @@ -257,7 +273,7 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao) if(pres_.size()>0) { plumed_massert(pres_steps==0,"cannot set both PRESSURE_STEPS and PRESSURE_SET_ALL"); - plumed_massert(std::isnan(pres_min) && std::isnan(pres_max),"cannot set both PRESSURE_SET_ALL and PRESSURE_MIN/MAX"); + plumed_massert(isNone(pres_min) && isNone(pres_max),"cannot set both PRESSURE_SET_ALL and PRESSURE_MIN/MAX"); plumed_massert(pres_.size()>=2,"set at least 2 pressures"); for(unsigned kk=0; kk Date: Wed, 29 Nov 2023 16:27:00 +0100 Subject: [PATCH 4/5] fix warning message --- src/opes/ECVmultiThermalBaric.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opes/ECVmultiThermalBaric.cpp b/src/opes/ECVmultiThermalBaric.cpp index 01e237779e..e85f0a567f 100644 --- a/src/opes/ECVmultiThermalBaric.cpp +++ b/src/opes/ECVmultiThermalBaric.cpp @@ -152,7 +152,7 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao) if(!std::isnan(std::numeric_limits::quiet_NaN())) { nan_support=false; - log.printf(" +++ WARNING +++ do not set LAMBDA_MIN/MAX=%g, see https://github.com/plumed/plumed2/pull/990\n", my_nan_value); + log.printf(" +++ WARNING +++ do not set PRESSURE_MIN/MAX=%g, see https://github.com/plumed/plumed2/pull/990\n", my_nan_value); } auto isNone=[nan_support,my_nan_value](const double value) { From fae2c45bef12caa0c0866544d79c8dbc49329b76 Mon Sep 17 00:00:00 2001 From: Michele Invernizzi Date: Wed, 29 Nov 2023 16:59:56 +0100 Subject: [PATCH 5/5] astyle --- src/opes/ECVlinear.cpp | 2 +- src/opes/ECVmultiThermalBaric.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opes/ECVlinear.cpp b/src/opes/ECVlinear.cpp index f58d723455..be573ed5e2 100644 --- a/src/opes/ECVlinear.cpp +++ b/src/opes/ECVlinear.cpp @@ -121,7 +121,7 @@ ECVlinear::ECVlinear(const ActionOptions&ao) parseFlag("DIMENSIONLESS",dimensionless); if(dimensionless) beta0_=1; - + //workaround needed for intel compiler bool nan_support=true; const double my_nan_value=-42; diff --git a/src/opes/ECVmultiThermalBaric.cpp b/src/opes/ECVmultiThermalBaric.cpp index e85f0a567f..5ede40c3b0 100644 --- a/src/opes/ECVmultiThermalBaric.cpp +++ b/src/opes/ECVmultiThermalBaric.cpp @@ -145,7 +145,7 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao) //set temp0 const double kB=plumed.getAtoms().getKBoltzmann(); const double temp0=kbt_/kB; - + //workaround needed for intel compiler bool nan_support=true; const double my_nan_value=-42;