27 #include "tools/Matrix.h"
33 FlexibleBin::FlexibleBin(
int type,
ActionWithArguments *paction,
double const &d , vector<double> &smin, vector<double> &smax):type(type),paction(paction),sigma(d),sigmamin(smin),sigmamax(smax){
37 vector<double>
average(ncv*(ncv+1)/2);
38 vector<double>
variance(ncv*(ncv+1)/2);
40 paction->
log<<
" Limits for sigmas using adaptive hills: \n";
49 paction->
log<<
" Min No ";
57 paction->
log<<
" Max No ";
68 unsigned dimension=ncv*(ncv+1)/2;
77 double decay=1./
sigma;
90 for(i=0;i<ncv;i++)
average[i]=cv[i];
126 for(
unsigned i=0;i<ncv;i++){
127 for(
unsigned j=i;j<ncv;j++){
136 cerr<<
"This flexible bin is not recognized "<<endl;
160 matrix(j,i)=matrix(i,j)=
variance[k];
170 vector<double> eigenvals(ncv);
173 if(
diagMat( matrix , eigenvals , eigenvecs )!=0){plumed_merror(
"diagonalization in FlexibleBin failed! This matrix is weird\n");};
189 if(pow(eigenvals[j]*eigenvecs[j][i],2)>pow(
sigmamax[i],2) ){
190 eigenvals[j]=sqrt(pow(
sigmamax[i]/(eigenvecs[j][i]),2))*copysign(1.,eigenvals[j]);
201 double fact=pow(eigenvals[j]*eigenvecs[j][i],2);
207 eigenvals[imax]=sqrt(pow(
sigmamin[i]/(eigenvecs[imax][i]),2))*copysign(1.,eigenvals[imax]);
218 newinvmatrix[j][i]=eigenvecs[j][i]/eigenvals[j];
222 vector<double> uppervec(ncv*(ncv+1)/2);
227 for(
unsigned l=0;l<ncv;++l){
228 scal+=eigenvecs[l][i]*newinvmatrix[l][j];
230 uppervec[k]=scal; k++;
237 vector<double> uppervec(ncv*(ncv+1)/2);
242 uppervec[k]=invmatrix(i,j);
ActionWithArguments * paction
const std::string & getName() const
Get the name of the quantity.
Log & log
Reference to the log stream.
std::vector< double > variance
std::vector< double > getMatrix() const
std::vector< double > sigmamin
int Invert(const Matrix< T > &A, Matrix< double > &inverse)
double difference(int, double, double) const
Takes the difference taking into account pbc for arg i.
std::vector< double > average
Value * getPntrToArgument(const unsigned n)
Return a pointer to specific argument.
This is used to create PLMD::Action objects that take the output from some other Action as input...
std::vector< bool > limitmax
double bringBackInPbc(int i, double d1) const
Takes one value and brings it back into the pbc of argument i.
VectorGeneric< n > delta(const VectorGeneric< n > &v1, const VectorGeneric< n > &v2)
double getProjection(unsigned i, unsigned j) const
Get the scalar product between the gradients of two variables.
std::vector< bool > limitmin
std::vector< double > sigmamax
int diagMat(const Matrix< T > &A, std::vector< double > &eigenvals, Matrix< double > &eigenvecs)
double getArgument(const unsigned n) const
Returns the value of an argument.
std::vector< double > getInverseMatrix() const
Calculate the matrix of (dcv_i/dx)*(dcv_j/dx)^-1 that is needed for the metrics in metadynamics...
void update(bool nowAddAHill)
update the average (always for diffusion) or calculate the geom covariance ( only when do_when_zero i...
unsigned getNumberOfArguments() const
Returns the number of arguments.