Skip to content

Commit c9df402

Browse files
Gareth Aneurin TribelloGareth Aneurin Tribello
Gareth Aneurin Tribello
authored and
Gareth Aneurin Tribello
committed
Fixed DUMPFORCES command so that you can output forces for vectors, matrices and grids with this command.
1 parent 636898f commit c9df402

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! 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
2+
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
3+
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
4+
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
5+
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
6+
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

regtest/multicolvar/rt-manyrestraints/plumed.dat

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ d1: DISTANCES ATOMS1=c1,1 ATOMS2=c1,2 ATOMS3=c1,3 ATOMS4=c1,4 ATOMS5=c1,5 ATOMS6
33
sr: UPPER_WALLS ARG=d1 AT=2.5 KAPPA=0.2
44

55
PRINT ARG=sr.bias FILE=colvar FMT=%8.4f
6+
DUMPFORCES ARG=d1 FILE=fff FMT=%8.4f
67
DUMPDERIVATIVES ARG=sr.bias FILE=deriv FMT=%8.4f

src/core/Value.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,20 @@ void Value::print( OFile& ofile ) const {
359359
}
360360
}
361361

362+
void Value::printForce( OFile& ofile ) const {
363+
if( shape.size()==0 || getNumberOfValues()==1 ) {
364+
ofile.printField( name, getForce(0) );
365+
} else {
366+
std::vector<unsigned> indices( shape.size() );
367+
for(unsigned i=0; i<getNumberOfValues(); ++i) {
368+
convertIndexToindices( i, indices ); std::string num, fname = name;
369+
for(unsigned i=0; i<shape.size(); ++i) { Tools::convert( indices[i]+1, num ); fname += "." + num; }
370+
plumed_assert( i<inputForce.size() );
371+
ofile.printField( fname, getForce(i) );
372+
}
373+
}
374+
}
375+
362376
unsigned Value::getGoodNumThreads( const unsigned& j, const unsigned& k ) const {
363377
return OpenMP::getGoodNumThreads( &data[j], (k-j) );
364378
}

src/core/Value.h

+2
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ class Value {
213213
void convertIndexToindices(const std::size_t& index, std::vector<unsigned>& indices ) const ;
214214
/// Print out all the values in this Value
215215
void print( OFile& ofile ) const ;
216+
/// Print out all the forces in this Value
217+
void printForce( OFile& ofile ) const ;
216218
/// Are we to ignore the stored value
217219
bool ignoreStoredValue(const std::string& n) const ;
218220
/// Set a matrix element to be non zero

src/generic/DumpForces.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ void DumpForces::update() {
104104
of.fmtField(" %f");
105105
of.printField("time",getTime());
106106
for(unsigned i=0; i<getNumberOfArguments(); i++) {
107-
of.fmtField(fmt);
108-
of.printField(getPntrToArgument(i)->getName(),getPntrToArgument(i)->getForce());
107+
of.fmtField(fmt); getPntrToArgument(i)->printForce(of);
109108
}
110109
of.printField();
111110
}

0 commit comments

Comments
 (0)