Skip to content
Snippets Groups Projects
Commit 6603749d authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Addresses issue #441. The problem with convert to fes and periodic variables

parent 294d4405
No related branches found
No related tags found
No related merge requests found
...@@ -95,10 +95,12 @@ void GridVessel::setBounds( const std::vector<std::string>& smin, const std::vec ...@@ -95,10 +95,12 @@ void GridVessel::setBounds( const std::vector<std::string>& smin, const std::vec
Tools::convert( str_min[i], min[i] ); Tools::convert( str_min[i], min[i] );
Tools::convert( str_max[i], max[i] ); Tools::convert( str_max[i], max[i] );
if( spacing.size()==dimension && binsin.size()==dimension ) { if( spacing.size()==dimension && binsin.size()==dimension ) {
double range = max[i] - min[i]; unsigned spc = std::floor( range / spacing[i]); if( spacing[i]==0 ) nbin[i] = binsin[i];
// This check ensures that nbins is set correctly if spacing is set the same as the number of bins else {
if( fabs( binsin[i]*spacing[i]-range )>epsilon ) spc += 1; double range = max[i] - min[i]; nbin[i] = std::ceil( range / spacing[i]);
if( spc>binsin[i] ) nbin[i]=spc; else nbin[i]=binsin[i]; // This check ensures that nbins is set correctly if spacing is set the same as the number of bins
if( nbin[i]!=binsin[i] ) plumed_merror("mismatch between input spacing and input number of bins");
}
} else if( binsin.size()==dimension ) nbin[i]=binsin[i]; } else if( binsin.size()==dimension ) nbin[i]=binsin[i];
else if( spacing.size()==dimension ) nbin[i] = std::floor(( max[i] - min[i] ) / spacing[i]) + 1; else if( spacing.size()==dimension ) nbin[i] = std::floor(( max[i] - min[i] ) / spacing[i]) + 1;
else plumed_error(); else plumed_error();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment