Skip to content
Snippets Groups Projects
Commit 0299ecf4 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Small optimizations

Relevant when using a huge number of restraints
parent f6996563
No related branches found
No related tags found
No related merge requests found
...@@ -62,6 +62,8 @@ class Restraint : public Bias{ ...@@ -62,6 +62,8 @@ class Restraint : public Bias{
std::vector<double> at; std::vector<double> at;
std::vector<double> kappa; std::vector<double> kappa;
std::vector<double> slope; std::vector<double> slope;
Value* valueBias;
Value* valueForce2;
public: public:
Restraint(const ActionOptions&); Restraint(const ActionOptions&);
void calculate(); void calculate();
...@@ -101,6 +103,8 @@ slope(getNumberOfArguments(),0.0) ...@@ -101,6 +103,8 @@ slope(getNumberOfArguments(),0.0)
addComponent("bias"); componentIsNotPeriodic("bias"); addComponent("bias"); componentIsNotPeriodic("bias");
addComponent("force2"); componentIsNotPeriodic("force2"); addComponent("force2"); componentIsNotPeriodic("force2");
valueBias=getPntrToComponent("bias");
valueForce2=getPntrToComponent("force2");
} }
...@@ -116,8 +120,8 @@ void Restraint::calculate(){ ...@@ -116,8 +120,8 @@ void Restraint::calculate(){
setOutputForce(i,f); setOutputForce(i,f);
totf2+=f*f; totf2+=f*f;
}; };
getPntrToComponent("bias")->set(ene); valueBias->set(ene);
getPntrToComponent("force2")->set(totf2); valueForce2->set(totf2);
} }
} }
......
...@@ -169,10 +169,8 @@ double ActionWithValue::getOutputQuantity(const unsigned j) const { ...@@ -169,10 +169,8 @@ double ActionWithValue::getOutputQuantity(const unsigned j) const {
inline inline
double ActionWithValue::getOutputQuantity( const std::string& name ) const { double ActionWithValue::getOutputQuantity( const std::string& name ) const {
std::string thename; thename=getLabel() + "." + name; std::string thename; thename=getLabel() + "." + name;
if( exists(thename) ){ for(unsigned i=0;i<values.size();++i){
for(unsigned i=0;i<values.size();++i){ if( values[i]->name==thename ) return values[i]->value;
if( values[i]->name==thename ) return values[i]->value;
}
} }
return 0.0; return 0.0;
} }
......
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