Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions src/opes/ECVlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,11 @@ ECVlinear::ECVlinear(const ActionOptions&ao)
if(dimensionless)
beta0_=1;

//workaround needed for intel compiler
bool nan_support=true;
const double my_nan_value=-42;
if(!std::isnan(std::numeric_limits<double>::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 lambda info
parse("LAMBDA",lambda0_);
double lambda_min=std::numeric_limits<double>::quiet_NaN();
double lambda_max=std::numeric_limits<double>::quiet_NaN();
const double myNone=std::numeric_limits<double>::lowest(); //quiet_NaN is not supported by some intel compiler
double lambda_min=myNone;
double lambda_max=myNone;
parse("LAMBDA_MIN",lambda_min);
parse("LAMBDA_MAX",lambda_max);
unsigned lambda_steps=0;
Expand All @@ -156,7 +141,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(isNone(lambda_min) && isNone(lambda_max),"cannot set both LAMBDA_SET_ALL and LAMBDA_MIN/MAX");
plumed_massert(lambda_min==myNone && lambda_max==myNone,"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<lambdas.size()-1; k++)
plumed_massert(lambdas[k]<=lambdas[k+1],"LAMBDA_SET_ALL must be properly ordered");
Expand All @@ -168,12 +153,12 @@ ECVlinear::ECVlinear(const ActionOptions&ao)
}
else
{ //get LAMBDA_MIN and LAMBDA_MAX
if(isNone(lambda_min))
if(lambda_min==myNone)
{
lambda_min=0;
log.printf(" no LAMBDA_MIN provided, using LAMBDA_MIN = %g\n",lambda_min);
}
if(isNone(lambda_max))
if(lambda_max==myNone)
{
lambda_max=1;
log.printf(" no LAMBDA_MAX provided, using LAMBDA_MAX = %g\n",lambda_max);
Expand Down
29 changes: 7 additions & 22 deletions src/opes/ECVmultiThermalBaric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,6 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao)
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<double>::quiet_NaN()))
{
nan_support=false;
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)
{
if(nan_support)
return std::isnan(value);
else
return value==my_nan_value;
};

//parse temp range
double temp_min=-1;
double temp_max=-1;
Expand All @@ -175,8 +159,9 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao)
geom_spacing_=!geom_spacing_;
//parse pressures
parse("PRESSURE",pres0_);
double pres_min=std::numeric_limits<double>::quiet_NaN(); //-1 might be a meaningful pressure
double pres_max=std::numeric_limits<double>::quiet_NaN();
const double myNone=std::numeric_limits<double>::lowest(); //quiet_NaN is not supported by some intel compiler
double pres_min=myNone; //-1 might be a meaningful pressure
double pres_max=myNone;
parse("PRESSURE_MIN",pres_min);
parse("PRESSURE_MAX",pres_max);
unsigned pres_steps=0;
Expand All @@ -197,7 +182,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(isNone(pres_min) && isNone(pres_max),"cannot set both SET_ALL_TEMP_PRESSURE and PRESSURE_MIN/MAX");
plumed_massert(pres_min==myNone && pres_max==myNone,"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());
Expand Down Expand Up @@ -273,7 +258,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(isNone(pres_min) && isNone(pres_max),"cannot set both PRESSURE_SET_ALL and PRESSURE_MIN/MAX");
plumed_massert(pres_min==myNone && pres_max==myNone,"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<pres_.size()-1; kk++)
plumed_massert(pres_[kk]<=pres_[kk+1],"PRESSURE_SET_ALL must be properly ordered");
Expand All @@ -282,12 +267,12 @@ ECVmultiThermalBaric::ECVmultiThermalBaric(const ActionOptions&ao)
}
else
{ //get PRESSURE_MIN and PRESSURE_MAX
if(isNone(pres_min))
if(pres_min==myNone)
{
pres_min=pres0_;
log.printf(" no PRESSURE_MIN provided, using PRESSURE_MIN=PRESSURE\n");
}
if(isNone(pres_max))
if(pres_max==myNone)
{
pres_max=pres0_;
log.printf(" no PRESSURE_MAX provided, using PRESSURE_MAX=PRESSURE\n");
Expand Down