8 #include "HoomdConfigWriter.h" 10 #include <tools/chemistry/Atom.h> 11 #include <tools/chemistry/Group.h> 12 #include <tools/chemistry/Species.h> 14 #include <tools/storage/GroupStorage.h> 15 #include <tools/storage/Configuration.h> 17 #include <util/space/Vector.h> 18 #include <util/format/Int.h> 19 #include <util/format/Dbl.h> 20 #include <util/misc/ioUtil.h> 41 std::stringstream line;
47 atomTypeMap_.
read(file);
54 bondTypeMap_.
read(file);
61 angleTypeMap_.
read(file);
71 HoomdConfigWriter::writeGroups(std::ofstream& file,
72 const std::string& label,
76 int nGroup = storage.
size();
78 <<
" num=\"" << nGroup <<
"\">\n";
83 typeName = map.
name(iter->typeId);
84 file << typeName <<
" ";
85 for (j = 0; j < N; ++j) {
86 file << iter->atomIds[j] <<
" ";
90 file <<
"</" << label <<
">\n";
99 if (!file.is_open()) {
103 UTIL_THROW(
"Error: Must read type map auxiliary file before config");
105 int nAtom = configuration().
atoms().
size();
107 file <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
108 file <<
"<hoomd_xml version=\"1.5\">\n";
109 file <<
"<configuration time_step=\"0\" dimensions=\"3\" natoms=\"" 110 << nAtom <<
"\" >\n";
114 file.unsetf(std::ios_base::floatfield);
120 <<
" lx=\"" << lengths[0] <<
"\"" 121 <<
" ly=\"" << lengths[1] <<
"\"" 122 <<
" lz=\"" << lengths[2] <<
"\"" 129 file <<
"<position num=\"" << nAtom <<
"\">\n";
134 for (; iter.
notEnd(); ++iter) {
135 boundary.
shift(iter->position);
145 file << rc[j] <<
" ";
149 file <<
"</position>\n";
153 file <<
"<velocity num=\"" << nAtom <<
"\">\n";
155 for (; iter.
notEnd(); ++iter) {
156 file << iter->velocity <<
"\n";
158 file <<
"</velocity>\n";
162 file <<
"<type num=\"" << nAtom <<
"\">\n";
164 for (; iter.
notEnd(); ++iter) {
165 file << atomTypeMap_.
name(iter->typeId) <<
"\n";
171 if (configuration().bonds().size()) {
172 writeGroups(file,
"bond", configuration().bonds(),
177 if (configuration().angles().size()) {
178 writeGroups(file,
"angle", configuration().angles(),
183 if (configuration().dihedrals().size()) {
184 writeGroups(file,
"dihedral", configuration().dihedrals(),
189 file <<
"</configuration>\n";
190 file <<
"</hoomd_xml>\n";
int size() const
Return logical size of this array (i.e., number of elements).
const int Dimension
Dimensionality of space.
A Vector is a Cartesian vector.
bool notEnd() const
Is the current pointer not at the end of the array?
const Vector & lengths() const
Get Vector of unit cell lengths by const reference.
An orthorhombic periodic unit cell.
Forward const iterator for an Array or a C array.
bool getNextLine(std::istream &in, std::string &line)
Read the next non-empty line into a string, strip trailing whitespace.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.
void shift(Vector &r) const
Shift Cartesian Vector r to its primary image.
void checkString(std::istream &in, const std::string &expected)
Extract string from stream, and compare to expected value.
Forward iterator for an Array or a C array.
void transformGenToCart(const Vector &Rg, Vector &Rc) const
Transform Vector of generalized coordinates to Cartesian Vector.
void begin(ArrayIterator< Group< N > > &iterator)
Set an ArrayIterator to the beginning of this Array.
void setClassName(const char *className)
Set class name string.
bool notEnd() const
Is this not the end of the array?
void transformCartToGen(const Vector &Rc, Vector &Rg) const
Transform Cartesian Vector to scaled / generalized coordinates.