22 #include "core/ActionAtomistic.h"
23 #include "core/ActionPilot.h"
24 #include "core/ActionRegister.h"
25 #include "tools/Pbc.h"
26 #include "tools/File.h"
27 #include "core/PlumedMain.h"
28 #include "core/Atoms.h"
29 #include "tools/Units.h"
31 #include "core/SetupMolInfo.h"
32 #include "core/ActionSet.h"
100 static void registerKeywords(
Keywords& keys );
106 PLUMED_REGISTER_ACTION(DumpAtoms,
"DUMPATOMS")
109 Action::registerKeywords( keys );
110 ActionPilot::registerKeywords( keys );
111 ActionAtomistic::registerKeywords( keys );
112 keys.add(
"compulsory",
"STRIDE",
"1",
"the frequency with which the atoms should be output");
113 keys.add(
"atoms",
"ATOMS",
"the atom indices whose positions you would like to print out");
114 keys.add(
"compulsory",
"FILE",
"file on which to output coordinates. .gro extension is automatically detected");
115 keys.add(
"compulsory",
"UNITS",
"PLUMED",
"the units in which to print out the coordinates. PLUMED means internal PLUMED units");
116 keys.add(
"optional",
"TYPE",
"file type, either xyz or gro, can override an automatically detected file extension");
124 vector<AtomNumber>
atoms;
127 if(file.length()==0)
error(
"name out output file was not specified");
129 log<<
" file name "<<file<<
"\n";
131 log<<
" file extension indicates a "<<
type<<
" file\n";
133 log<<
" file extension not detected, assuming xyz\n";
138 if(ntype.length()>0){
139 if(ntype!=
"xyz" && ntype!=
"gro")
error(
"TYPE should be either xyz or gro");
140 log<<
" file type enforced to be "<<ntype<<
"\n";
146 std::string unitname;
parse(
"UNITS",unitname);
147 if(unitname!=
"PLUMED"){
157 log.
printf(
" printing the following atoms in %s :", unitname.c_str() );
158 for(
unsigned i=0;i<atoms.size();++i)
log.
printf(
" %d",atoms[i].serial() );
162 if( moldat.size()==1 ){
163 log<<
" MOLINFO DATA found, using proper atom names\n";
164 names.resize(atoms.size());
165 for(
unsigned i=0;i<atoms.size();i++)
names[i]=moldat[0]->getAtomName(atoms[i]);
177 if(
getPbc().isOrthorombic()){
180 of.
printf(
" %f %f %f %f %f %f %f %f %f\n",
187 const char* defname=
"X";
188 const char*
name=defname;
192 }
else if(
type==
"gro"){
197 const char* defname=
"X";
198 const char*
name=defname;
199 unsigned residueNumber=0;
202 std::string resname=
"";
207 of.
printf(
"%12.7f %12.7f %12.7f %12.7f %12.7f %12.7f %12.7f %12.7f %12.7f\n",
211 }
else plumed_merror(
"unknown file type "+
type);
const Vector & getPosition(int) const
Get position of i-th atom.
std::vector< std::string > residueNames
Log & log
Reference to the log stream.
This is used to create PLMD::Action objects that are run with some set frequency. ...
Class implementing fixed size matrices of doubles.
unsigned serial() const
Returns the serial number.
AtomNumber getAbsoluteIndex(int i) const
Get the absolute index of an atom.
void setLength(const std::string &)
Set lengh units from string.
void error(const std::string &msg) const
Crash calculation and print documentation.
void checkRead()
Check if Action was properly read.
void parseAtomList(const std::string &key, std::vector< AtomNumber > &t)
Parse a list of atoms without a numbered keyword.
const Pbc & getPbc() const
Get reference to Pbc.
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
This class holds the keywords and their documentation.
const std::string name
Name of the directive in the plumed.dat file.
Small utility class that contains information about units.
This class is used to bring the relevant information to the Action constructor.
Action used to create objects that access the positions of the atoms from the MD code.
OFile & link(OFile &)
Allows linking this OFile to another one.
double getTime() const
Return the present time.
int printf(const char *fmt,...)
Formatted output with explicit format - a la printf.
void calculate()
Calculate an Action.
Base class for all the input Actions.
std::vector< std::string > names
Provides the keyword DUMPATOMS
std::vector< unsigned > residueNumbers
const double & getLength() const
Get length units as double.
void apply()
Apply an Action.
void requestAtoms(const std::vector< AtomNumber > &a)
Request an array of atoms.
const Tensor & getBox() const
Get position of i-th atom.
unsigned getNumberOfAtoms() const
Get number of available atoms.
OFile & open(const std::string &name)
Opens the file using automatic append/backup.