Skip to content
Snippets Groups Projects
Commit db5e9622 authored by carlocamilloni's avatar carlocamilloni
Browse files

change the order of asserts for components

make the error more informative
parent c3bf713e
No related branches found
No related tags found
No related merge requests found
...@@ -141,9 +141,9 @@ void ActionWithValue::addComponent( const std::string& name ) { ...@@ -141,9 +141,9 @@ void ActionWithValue::addComponent( const std::string& name ) {
std::string thename; thename=getLabel() + "." + name; std::string thename; thename=getLabel() + "." + name;
for(unsigned i=0; i<values.size(); ++i) { for(unsigned i=0; i<values.size(); ++i) {
plumed_massert(values[i]->name!=getLabel(),"Cannot mix single values with components"); plumed_massert(values[i]->name!=getLabel(),"Cannot mix single values with components");
plumed_massert(values[i]->name!=thename,"there is already a value with this name: "+thename);
plumed_massert(values[i]->name!=thename&&name!="bias","Since PLUMED 2.3 the component 'bias' is automatically added to all biases by the general constructor!\n" plumed_massert(values[i]->name!=thename&&name!="bias","Since PLUMED 2.3 the component 'bias' is automatically added to all biases by the general constructor!\n"
"Remove the line addComponent(\"bias\") from your bias."); "Remove the line addComponent(\"bias\") from your bias.");
plumed_massert(values[i]->name!=thename,"there is already a value with this name");
} }
values.emplace_back(new Value(this,thename, false ) ); values.emplace_back(new Value(this,thename, false ) );
std::string msg=" added component to this action: "+thename+" \n"; std::string msg=" added component to this action: "+thename+" \n";
...@@ -158,9 +158,9 @@ void ActionWithValue::addComponentWithDerivatives( const std::string& name ) { ...@@ -158,9 +158,9 @@ void ActionWithValue::addComponentWithDerivatives( const std::string& name ) {
std::string thename; thename=getLabel() + "." + name; std::string thename; thename=getLabel() + "." + name;
for(unsigned i=0; i<values.size(); ++i) { for(unsigned i=0; i<values.size(); ++i) {
plumed_massert(values[i]->name!=getLabel(),"Cannot mix single values with components"); plumed_massert(values[i]->name!=getLabel(),"Cannot mix single values with components");
plumed_massert(values[i]->name!=thename,"there is already a value with this name: "+thename);
plumed_massert(values[i]->name!=thename&&name!="bias","Since PLUMED 2.3 the component 'bias' is automatically added to all biases by the general constructor!\n" plumed_massert(values[i]->name!=thename&&name!="bias","Since PLUMED 2.3 the component 'bias' is automatically added to all biases by the general constructor!\n"
"Remove the line addComponentWithDerivatives(\"bias\") from your bias."); "Remove the line addComponentWithDerivatives(\"bias\") from your bias.");
plumed_massert(values[i]->name!=thename,"there is already a value with this name");
} }
values.emplace_back(new Value(this,thename, true ) ); values.emplace_back(new Value(this,thename, true ) );
std::string msg=" added component to this action: "+thename+" \n"; std::string msg=" added component to this action: "+thename+" \n";
......
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