8 #include "McMdConfigIo.h" 9 #include <mcMd/simulation/Simulation.h> 10 #include <mcMd/simulation/System.h> 11 #include <mcMd/species/SpeciesMutator.h> 12 #include <mcMd/chemistry/Molecule.h> 13 #include <mcMd/chemistry/Atom.h> 15 #include <mcMd/tethers/TetherMaster.h> 18 #include <mcMd/links/LinkMaster.h> 20 #include <simp/species/Species.h> 21 #include <util/param/Label.h> 22 #include <util/param/OptionalLabel.h> 23 #include <util/format/Int.h> 53 in >>
Label(
"BOUNDARY");
57 Label speciesLabel(
"species");
58 Label nMoleculeLabel(
"nMolecule");
59 Label moleculeLabel(
"molecule");
63 int iSpecies, iSpeciesIn, nMolecule, iMol, iMolIn;
65 in >> Label(
"MOLECULES");
68 in >> Label(
"species") >> iSpeciesIn;
69 if (iSpeciesIn != iSpecies) {
72 in >> Label(
"nMolecule") >> nMolecule;
73 for (iMol = 0; iMol < nMolecule; ++iMol) {
74 in >> moleculeLabel >> iMolIn;
81 if (molPtr != &
system().molecule(iSpecies, iMol)) {
91 for (molPtr->
begin(atomIter); atomIter.
notEnd(); ++atomIter) {
104 int iTether, nTether, iAtom;
107 in >> Label(
"nTether") >> nTether;
108 for (iTether = 0; iTether < nTether; ++iTether) {
109 in >> iSpecies >> iMol >> iAtom >> anchor;
111 UTIL_THROW(
"Invalid species index for tether");
113 if (iMol >=
system().nMolecule(iSpecies)) {
114 UTIL_THROW(
"Invalid molecule index for tether");
117 if (iAtom >= molPtr->
nAtom()) {
121 atomPtr = &molPtr->
atom(iAtom);
122 system().tetherMaster().addTether(*atomPtr, anchor);
134 int iLink, nLink, iAtom, linkType;
136 in >> Label(
"nLink") >> nLink;
137 for (iLink = 0; iLink < nLink; ++iLink) {
140 in >> iSpecies >> iMol >> iAtom;
141 if (iSpecies < 0 || iSpecies >=
simulation().nSpecies()) {
142 Log::file() <<
"iLink = " << iLink << std::endl;
143 UTIL_THROW(
"Invalid iSpecies0 index in link");
145 if (iMol < 0 || iMol >=
system().nMolecule(iSpecies)) {
146 Log::file() <<
"iLink = " << iLink << std::endl;
150 if (iAtom < 0 || iAtom >= molPtr->
nAtom()) {
151 Log::file() <<
"iLink = " << iLink << std::endl;
154 atom0Ptr = &molPtr->
atom(iAtom);
157 in >> iSpecies >> iMol >> iAtom;
158 if (iSpecies < 0 || iSpecies >=
simulation().nSpecies()) {
159 Log::file() <<
"iLink = " << iLink << std::endl;
160 UTIL_THROW(
"Invalid iSpecies1 index in link");
162 if (iMol < 0 || iMol >=
system().nMolecule(iSpecies)) {
163 Log::file() <<
"iLink = " << iLink << std::endl;
167 if (iAtom < 0 || iAtom >= molPtr->
nAtom()) {
168 Log::file() <<
"iLink = " << iLink << std::endl;
171 atom1Ptr = &molPtr->
atom(iAtom);
191 out <<
"BOUNDARY" << endl << endl;
198 int iSpecies, iMolecule;
199 out << endl <<
"MOLECULES" << endl;
202 out <<
"species " << iSpecies << endl;
207 for ( ; molIter.
notEnd(); ++molIter) {
209 out <<
"molecule " << iMolecule << endl;
213 for (molIter->begin(atomIter); atomIter.
notEnd(); ++atomIter) {
228 int iTether, nTether, iAtom;
230 out <<
"TETHERS" << endl << endl;
231 nTether =
system().tetherMaster().nTether();
232 out <<
Label(
"nTether") << nTether << std::endl;
233 for (iTether = 0; iTether < nTether; ++iTether) {
234 tetherPtr = &(
system().tetherMaster().tether(iTether));
235 atomPtr = &tetherPtr->atom();
240 out <<
Int(iSpecies,5) <<
Int(iMolecule,9) <<
Int(iAtom,6)
241 << tetherPtr->anchor() << std::endl;
254 int iLink, nLink, iAtom;
256 out <<
"LINKS" << endl << endl;
258 out <<
Label(
"nLink") << nLink << std::endl;
259 for (iLink = 0; iLink < nLink; ++iLink) {
263 atomPtr = &(linkPtr->
atom0());
268 out <<
Int(iSpecies,8) <<
Int(iMolecule,8) <<
Int(iAtom,8);
272 atomPtr = &(linkPtr->
atom1());
277 out << Int(iSpecies,8) << Int(iMolecule,8) << Int(iAtom,8);
280 out << Int(linkPtr->
typeId(),8) << std::endl;
int nLink() const
Get the total number of active Links.
Boundary & boundary() const
Get the Boundary.
An optional Label string in a file format.
McMdConfigIo(System &system)
Constructor.
Molecule & molecule() const
Get the parent Molecule by reference.
A Vector is a Cartesian vector.
void begin(int speciesId, MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this System.
bool notEnd() const
Is the current pointer not at the end of the array?
Species & species() const
Get the molecular Species by reference.
void begin(AtomIterator &iterator)
Set an Molecule::AtomIterator to first Atom in this Molecule.
A set of interacting Molecules enclosed by a Boundary.
A Link represents a crosslink between two Atoms.
Forward iterator for a PArray.
virtual void read(std::istream &in)
Read configuration (particle positions) from file.
virtual void write(std::ostream &out)
Write configuration (particle positions) to file.
Classes used by all simpatico molecular simulations.
virtual void readAtom(std::istream &out, Atom &atom)=0
Read data for one atom.
Molecule & getMolecule(int speciesId)
Get a new molecule from a reservoir of unused Molecule objects.
Forward const iterator for an Array or a C array.
virtual ~McMdConfigIo()
Destructor.
Molecule & molecule(int speciesId, int moleculeId)
Get a specific Molecule in this System, by integer index.
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.
void addMolecule(Molecule &molecule)
Add a Molecule to this System.
A point particle within a Molecule.
Utility classes for scientific computation.
System & system() const
Get a reference to the parent System.
virtual void readMoleculeState(std::istream &in, Molecule &molecule)
Read the state id for one molecule from a configuration file stream.
Wrapper for an int, for formatted ostream output.
Forward iterator for an Array or a C array.
virtual void writeMoleculeState(std::ostream &out, const Molecule &molecule) const
Write the state id for one molecule to a configuration file stream.
A label string in a file format.
Simulation & simulation() const
Get a reference to the parent Simulation.
static std::ostream & file()
Get log ostream by reference.
bool notEnd() const
Is the current pointer not at the end of the array?
int typeId() const
Get the typeId for this Link.
int id() const
Get integer id of this Species.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
bool isMutable() const
Is this a mutable Species?
virtual void writeAtom(std::ostream &out, const Atom &atom)=0
Write data for one atom.
const Atom & atom1() const
Get Atom1 connected to a Link.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
int indexInMolecule() const
Get local index for this Atom within the parent molecule;.
Link & link(int id) const
Return an active link by an internal set index.
A physical molecule (a set of covalently bonded Atoms).
bool notEnd() const
Is this not the end of the array?
McMd::SpeciesMutator & mutator()
Return the species mutator object by reference.
A Species represents a set of chemically similar molecules.
void addLink(Atom &atom0, Atom &atom1, int typeId)
Add a link betwen two specific Atoms.
Species & species(int i)
Get a specific Species by reference.
const Atom & atom0() const
Get Atom0 connected to a Link.
int nAtom() const
Get the number of Atoms in this Molecule.
int moleculeId(const Molecule &molecule) const
Get the index of a Molecule within its Species in this System.
System configuration file reader and writer.
LinkMaster & linkMaster() const
Get the LinkMaster by reference.