8 #include "DdMdConfigIo.h" 9 #include <mcMd/simulation/System.h> 10 #include <mcMd/simulation/Simulation.h> 11 #include <mcMd/chemistry/Molecule.h> 12 #include <mcMd/chemistry/Atom.h> 13 #include <simp/species/Species.h> 14 #include <util/space/Vector.h> 15 #include <util/space/IntVector.h> 16 #include <util/param/Label.h> 17 #include <util/format/Format.h> 18 #include <util/format/Int.h> 19 #include <util/format/Dbl.h> 20 #include <util/misc/ioUtil.h> 35 hasMolecules_(hasMolecules)
53 int speciesCapacity = 0;
56 for (iSpec = 0; iSpec < nSpecies; ++iSpec) {
58 speciesCapacity = speciesPtr->
capacity();
59 atomCapacity += speciesCapacity*speciesPtr->
nAtom();
61 bondCapacity += speciesCapacity*speciesPtr->
nBond();
66 in >>
Label(
"BOUNDARY");
74 in >> Label(
"nAtom") >> nAtom;
75 if (nAtom != atomCapacity) {
80 int iMol, iAtom, nMolecule, atomId, atomTypeId;
82 for (iSpec=0; iSpec < nSpecies; ++iSpec) {
85 for (iMol = 0; iMol < nMolecule; ++iMol) {
91 for (molPtr->
begin(atomIter); atomIter.
notEnd(); ++atomIter) {
93 in >> atomId >> atomTypeId;
94 if (atomId != atomIter->id()) {
98 in >> sId >> mId >> aId;
110 in >> atomIter->position();
111 in >> atomIter->velocity();
124 int iSpec, nMolecule;
138 nAtom += nMolecule*(speciesPtr->
nAtom());
140 nBond += nMolecule*(speciesPtr->
nBond());
143 nAngle += nMolecule*(speciesPtr->
nAngle());
146 nDihedral += nMolecule*(speciesPtr->
nDihedral());
151 out <<
"BOUNDARY" << std::endl;
156 out <<
"ATOMS" << std::endl;
157 out <<
"nAtom " << nAtom << std::endl;
165 for ( ; molIter.
notEnd(); ++molIter) {
167 molIter->begin(atomIter);
168 for ( ; atomIter.
notEnd(); ++atomIter) {
169 out <<
Int(atomIter->id(), 10);
170 out <<
Int(atomIter->typeId(), 5);
172 out <<
Int(iSpec, 6);
173 out << Int(iMol, 10);
174 out << Int(iAtom, 6);
176 out <<
"\n" << atomIter->position();
177 out <<
"\n" << atomIter->velocity();
189 out <<
"BONDS" << std::endl;
190 out <<
"nBond " << nBond << std::endl;
196 for ( ; molIter.
notEnd(); ++molIter) {
197 molIter->begin(bondIter);
198 for ( ; bondIter.
notEnd(); ++bondIter) {
199 out <<
Int(i, 8) <<
Int(bondIter->typeId(), 5);
200 out <<
Int(bondIter->atom(0).id(), 10);
201 out <<
Int(bondIter->atom(1).id(), 10);
213 out <<
"ANGLES" << std::endl;
214 out <<
"nAngle " << nAngle << std::endl;
220 for ( ; molIter.
notEnd(); ++molIter) {
221 molIter->begin(angleIter);
222 for ( ; angleIter.
notEnd(); ++angleIter) {
223 out <<
Int(i, 8) <<
Int(angleIter->typeId(), 5);
224 out <<
Int(angleIter->atom(0).id(), 10);
225 out <<
Int(angleIter->atom(1).id(), 10);
226 out <<
Int(angleIter->atom(2).id(), 10);
238 out <<
"DIHEDRALS" << std::endl;
239 out <<
"nDihedral " << nDihedral << std::endl;
245 for ( ; molIter.
notEnd(); ++molIter) {
246 molIter->begin(dihedralIter);
247 for ( ; dihedralIter.
notEnd(); ++dihedralIter) {
248 out <<
Int(i, 8) <<
Int(dihedralIter->typeId(), 5);
249 out <<
Int(dihedralIter->atom(0).id(), 10);
250 out <<
Int(dihedralIter->atom(1).id(), 10);
251 out <<
Int(dihedralIter->atom(2).id(), 10);
252 out <<
Int(dihedralIter->atom(3).id(), 10);
void begin(int speciesId, MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this System.
int nAtom() const
Get number of atoms per molecule for this Species.
bool notEnd() const
Is the current pointer not at the end of the array?
virtual ~DdMdConfigIo()
Destructor.
void begin(AtomIterator &iterator)
Set an Molecule::AtomIterator to first Atom in this Molecule.
A set of interacting Molecules enclosed by a Boundary.
Classes used by all simpatico molecular simulations.
Molecule & getMolecule(int speciesId)
Get a new molecule from a reservoir of unused Molecule objects.
int nDihedral() const
Get number of dihedrals per molecule for this Species.
int nMolecule(int speciesId) const
Get the number of molecules of one Species in this System.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Simulation & simulation() const
Get the parent Simulation by reference.
void addMolecule(Molecule &molecule)
Add a Molecule to this System.
bool notEnd() const
Is the current pointer not at the end of the PArray?
Utility classes for scientific computation.
System & system() const
Get a reference to the parent System.
Wrapper for an int, for formatted ostream output.
void read(std::istream &in)
Read configuration (particle positions) from file.
Forward iterator for an Array or a C array.
Forward iterator for a PArray.
void write(std::ostream &out)
Write configuration (particle positions) to file.
A label string in a file format.
Simulation & simulation() const
Get a reference to the parent Simulation.
Boundary & boundary() const
Get the Boundary by reference.
DdMdConfigIo(System &system, bool hasMolecules=false)
Constructor.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
int capacity() const
Maximum allowed number of molecules for this Species.
A physical molecule (a set of covalently bonded Atoms).
A Species represents a set of chemically similar molecules.
int nBond() const
Get number of bonds per molecule for this Species.
int nAngle() const
Get number of angles per molecule for this Species.
Species & species(int i)
Get a specific Species by reference.
System configuration file reader and writer.