1 #include "ChainMaker.h" 2 #include <util/format/Int.h> 3 #include <util/format/Dbl.h> 10 ChainMaker::ChainMaker(){};
12 ChainMaker::~ChainMaker(){};
18 read<Boundary>(in,
"boundary", boundary_);
21 read<int>(in,
"nMolecule", nMolecule_);
22 read<int>(in,
"nAtomPerMolecule", nAtomPerMolecule_);
28 void ChainMaker::writeChains(std::ostream& out)
30 if (outputStyle_ ==
"McMd") {
33 if (outputStyle_ ==
"DdMd") {
36 if (outputStyle_ ==
"DdMdMolecule") {
37 writeChainsDdMdMole(out);
39 std::cout <<
"Unrecognized style " 40 << outputStyle_ << std::endl;
44 void ChainMaker::writeChainsMcMd(std::ostream& out)
52 out <<
"BOUNDARY" << std::endl;
54 out << boundary_ << std::endl;
56 out <<
"MOLECULES" << std::endl;
58 out <<
"species " << 0 << std::endl;
59 out <<
"nMolecule " << nMolecule_ << std::endl;
61 for (iMol = 0; iMol < nMolecule_; ++iMol) {
62 out <<
"molecule " << iMol << std::endl;
65 out << r << std::endl;
66 for (iAtom = 1; iAtom < nAtomPerMolecule_; ++iAtom) {
71 out << r << std::endl;
78 void ChainMaker::writeChainsDdMd(std::ostream& out)
86 int iMol, iAtom, i, j;
88 out <<
"BOUNDARY" << std::endl;
90 out << boundary_ << std::endl;
92 out <<
"ATOMS" << std::endl;
93 out <<
"nAtom " << nMolecule_*nAtomPerMolecule_ << std::endl;
97 for (iMol = 0; iMol < nMolecule_; ++iMol) {
101 for (iAtom = 0; iAtom < nAtomPerMolecule_; ++iAtom) {
103 out <<
Int(i,6) <<
Int(atomType, 10);
105 out <<
Dbl(r[j], 15, 6);
109 out <<
Dbl(0.0, 12, 4);
113 if (iAtom < nAtomPerMolecule_ - 1) {
126 out <<
"BONDS" << std::endl;
127 out <<
"nBond " << nMolecule_*(nAtomPerMolecule_ -1 ) << std::endl;
130 for (iMol = 0; iMol < nMolecule_; ++iMol) {
131 for (iAtom = 0; iAtom < nAtomPerMolecule_ - 1; ++iAtom) {
132 out <<
Int(j,5) <<
Int(bondType, 5) <<
" ";
133 out <<
Int(i, 10) <<
Int(i + 1, 10) << std::endl;
143 out <<
"ANGLES" << std::endl;
144 out <<
"nAngle " << nMolecule_*(nAtomPerMolecule_ -2) << std::endl;
147 for (iMol = 0; iMol < nMolecule_; ++iMol) {
148 for (iAtom = 0; iAtom < nAtomPerMolecule_ - 2; ++iAtom) {
149 out <<
Int(j,5) <<
Int(angleType, 5) <<
" ";
150 out <<
Int(i, 10) <<
Int(i + 1, 10) <<
Int(i + 2, 10)
159 int dihedralType = 0;
161 out <<
"DIHEDRALS" << std::endl;
162 out <<
"nDihedral " << nMolecule_*(nAtomPerMolecule_ -3) << std::endl;
165 for (iMol = 0; iMol < nMolecule_; ++iMol) {
166 for (iAtom = 0; iAtom < nAtomPerMolecule_ - 3; ++iAtom) {
167 out <<
Int(j,5) <<
Int(dihedralType, 5) <<
" ";
168 out <<
Int(i, 10) <<
Int(i + 1, 10) <<
Int(i + 2, 10)
169 <<
Int(i + 3, 10) << std::endl;
178 void ChainMaker::writeChainsDdMdMole(std::ostream& out)
187 int iMol, iAtom, i, j;
189 out <<
"BOUNDARY" << std::endl;
191 out << boundary_ << std::endl;
193 out <<
"ATOMS" << std::endl;
194 out <<
"nAtom " << nMolecule_*nAtomPerMolecule_ << std::endl;
198 for (iMol = 0; iMol < nMolecule_; ++iMol) {
202 for (iAtom = 0; iAtom < nAtomPerMolecule_; ++iAtom) {
204 out <<
Int(i,10) <<
Int(atomType, 6)
205 <<
Int(sId,6) <<
Int(iMol, 10) <<
Int(iAtom,6);
208 out <<
Dbl(r[j], 15, 6);
212 out <<
Dbl(0.0, 15, 6);
216 if (iAtom < nAtomPerMolecule_ - 1) {
230 out <<
"BONDS" << std::endl;
231 out <<
"nBond " << nMolecule_*(nAtomPerMolecule_ -1 ) << std::endl;
234 for (iMol = 0; iMol < nMolecule_; ++iMol) {
235 for (iAtom = 0; iAtom < nAtomPerMolecule_ - 1; ++iAtom) {
236 out <<
Int(j,5) <<
Int(bondType, 5) <<
" ";
237 out <<
Int(i, 10) <<
Int(i + 1, 10) << std::endl;
247 out <<
"ANGLES" << std::endl;
248 out <<
"nAngle " << nMolecule_*(nAtomPerMolecule_ -2) << std::endl;
251 for (iMol = 0; iMol < nMolecule_; ++iMol) {
252 for (iAtom = 0; iAtom < nAtomPerMolecule_ - 2; ++iAtom) {
253 out <<
Int(j,5) <<
Int(angleType, 5) <<
" ";
254 out <<
Int(i, 10) <<
Int(i + 1, 10) <<
Int(i + 2, 10)
263 int dihedralType = 0;
265 out <<
"DIHEDRALS" << std::endl;
266 out <<
"nDihedral " << nMolecule_*(nAtomPerMolecule_ -3) << std::endl;
269 for (iMol = 0; iMol < nMolecule_; ++iMol) {
270 for (iAtom = 0; iAtom < nAtomPerMolecule_ - 3; ++iAtom) {
271 out <<
Int(j,5) <<
Int(dihedralType, 5) <<
" ";
272 out <<
Int(i, 10) <<
Int(i + 1, 10) <<
Int(i + 2, 10)
273 <<
Int(i + 3, 10) << std::endl;
288 obj.writeChains(std::cout);
Vector & zero()
Set all elements of a 3D vector to zero.
const int Dimension
Dimensionality of space.
A Vector is a Cartesian vector.
void randomPosition(Random &random, Vector &r) const
Generate random position within the primary unit cell.
Wrapper for a double precision number, for formatted ostream output.
void setNBondType(int nBondType)
Set the number of bond types.
Wrapper for an int, for formatted ostream output.
void shift(Vector &r) const
Shift Cartesian Vector r to its primary image.
double randomBondLength(Random *random, double beta, int type) const
Return bond length chosen from equilibrium distribution.
void readParamComposite(std::istream &in, ParamComposite &child, bool next=true)
Add and read a required child ParamComposite.
void unitVector(Vector &v)
Generate unit vector with uniform probability over the unit sphere.