Skip to content

Commit

Permalink
Fixed DUMPFORCES command so that you can output forces for vectors, m…
Browse files Browse the repository at this point in the history
…atrices and grids with this command.
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Nov 9, 2024
1 parent 636898f commit c9df402
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions regtest/multicolvar/rt-manyrestraints/fff.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! FIELDS time d1.1 d1.2 d1.3 d1.4 d1.5 d1.6 d1.7 d1.8 d1.9 d1.10 d1.11 d1.12 d1.13 d1.14 d1.15 d1.16 d1.17 d1.18 d1.19 d1.20
0.000000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 -0.0832 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.050000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 -0.0888 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.100000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 -0.0878 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.150000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 -0.0850 0.0000 -0.0009 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.200000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 -0.0804 0.0000 -0.0023 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
1 change: 1 addition & 0 deletions regtest/multicolvar/rt-manyrestraints/plumed.dat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ d1: DISTANCES ATOMS1=c1,1 ATOMS2=c1,2 ATOMS3=c1,3 ATOMS4=c1,4 ATOMS5=c1,5 ATOMS6
sr: UPPER_WALLS ARG=d1 AT=2.5 KAPPA=0.2

PRINT ARG=sr.bias FILE=colvar FMT=%8.4f
DUMPFORCES ARG=d1 FILE=fff FMT=%8.4f
DUMPDERIVATIVES ARG=sr.bias FILE=deriv FMT=%8.4f
14 changes: 14 additions & 0 deletions src/core/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ void Value::print( OFile& ofile ) const {
}
}

void Value::printForce( OFile& ofile ) const {
if( shape.size()==0 || getNumberOfValues()==1 ) {
ofile.printField( name, getForce(0) );
} else {
std::vector<unsigned> indices( shape.size() );
for(unsigned i=0; i<getNumberOfValues(); ++i) {
convertIndexToindices( i, indices ); std::string num, fname = name;
for(unsigned i=0; i<shape.size(); ++i) { Tools::convert( indices[i]+1, num ); fname += "." + num; }
plumed_assert( i<inputForce.size() );
ofile.printField( fname, getForce(i) );
}
}
}

unsigned Value::getGoodNumThreads( const unsigned& j, const unsigned& k ) const {
return OpenMP::getGoodNumThreads( &data[j], (k-j) );
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ class Value {
void convertIndexToindices(const std::size_t& index, std::vector<unsigned>& indices ) const ;
/// Print out all the values in this Value
void print( OFile& ofile ) const ;
/// Print out all the forces in this Value
void printForce( OFile& ofile ) const ;
/// Are we to ignore the stored value
bool ignoreStoredValue(const std::string& n) const ;
/// Set a matrix element to be non zero
Expand Down
3 changes: 1 addition & 2 deletions src/generic/DumpForces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ void DumpForces::update() {
of.fmtField(" %f");
of.printField("time",getTime());
for(unsigned i=0; i<getNumberOfArguments(); i++) {
of.fmtField(fmt);
of.printField(getPntrToArgument(i)->getName(),getPntrToArgument(i)->getForce());
of.fmtField(fmt); getPntrToArgument(i)->printForce(of);
}
of.printField();
}
Expand Down

1 comment on commit c9df402

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.