Skip to content

Commit

Permalink
Use constexpr to define tolerance parameter in a single place
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomofiorin committed Oct 16, 2024
1 parent e42bd9a commit ad80e18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/colvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2213,12 +2213,10 @@ int colvar::set_cvc_param(std::string const &param_name, void const *new_value)
bool colvar::periodic_boundaries(colvarvalue const &lb, colvarvalue const &ub) const
{
if (period > 0.0) {
if ( ((cvm::sqrt(this->dist2(lb, ub))) / this->width)
< 1.0E-10 ) {
if (((cvm::sqrt(this->dist2(lb, ub))) / this->width) < colvar_boundaries_tol) {
return true;
}
}

return false;
}

Expand Down
8 changes: 7 additions & 1 deletion src/colvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class colvar : public colvarparse, public colvardeps {

/// Init defaults for grid options
int init_grid_parameters(std::string const &conf);

/// Consistency check for the grid paramaters
int check_grid_parameters();

Expand Down Expand Up @@ -784,4 +784,10 @@ inline void colvar::reset_bias_force() {
fb_actual.reset();
}


namespace {
// Tolerance parameter to decide when two boundaries coincide
constexpr cvm::real colvar_boundaries_tol = 1.0e-10;
}

#endif

0 comments on commit ad80e18

Please sign in to comment.