6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
35 |
+ |
* |
36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
+ |
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
|
*/ |
41 |
|
|
42 |
|
#include <iostream> |
47 |
|
#include "brains/Register.hpp" |
48 |
|
#include "brains/SimCreator.hpp" |
49 |
|
#include "brains/SimInfo.hpp" |
50 |
+ |
#include "brains/ForceManager.hpp" |
51 |
|
#include "io/DumpReader.hpp" |
52 |
|
#include "utils/simError.h" |
53 |
|
#include "visitors/AtomVisitor.hpp" |
54 |
+ |
#include "visitors/ReplacementVisitor.hpp" |
55 |
|
#include "visitors/CompositeVisitor.hpp" |
56 |
|
#include "visitors/RigidBodyVisitor.hpp" |
57 |
|
#include "visitors/OtherVisitor.hpp" |
61 |
|
#include "visitors/LipidTransVisitor.hpp" |
62 |
|
#include "visitors/AtomNameVisitor.hpp" |
63 |
|
|
64 |
< |
using namespace oopse; |
64 |
> |
using namespace OpenMD; |
65 |
|
|
66 |
|
int main(int argc, char* argv[]){ |
67 |
|
|
71 |
|
gengetopt_args_info args_info; |
72 |
|
std::string dumpFileName; |
73 |
|
std::string xyzFileName; |
74 |
+ |
bool printVel; |
75 |
+ |
bool printFrc; |
76 |
+ |
bool printVec; |
77 |
+ |
bool printChrg; |
78 |
|
|
79 |
|
//parse the command line option |
80 |
|
if (cmdline_parser (argc, argv, &args_info) != 0) { |
99 |
|
//parse md file and set up the system |
100 |
|
SimCreator creator; |
101 |
|
SimInfo* info = creator.createSim(dumpFileName, false); |
102 |
+ |
ForceManager* forceMan = new ForceManager(info); |
103 |
|
|
97 |
– |
|
104 |
|
//create visitor list |
105 |
|
CompositeVisitor* compositeVisitor = new CompositeVisitor(); |
106 |
< |
|
106 |
> |
|
107 |
|
//create RigidBody Visitor |
108 |
|
if(args_info.rigidbody_flag){ |
109 |
|
RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info); |
113 |
|
//create SSD atom visitor |
114 |
|
SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info); |
115 |
|
compositeVisitor->addVisitor(ssdVisitor, 800); |
110 |
– |
|
111 |
– |
LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info); |
112 |
– |
compositeVisitor->addVisitor(linearVisitor, 750); |
113 |
– |
if (args_info.gb_given) { |
114 |
– |
linearVisitor->addGayBerneAtomType(args_info.gb_arg); |
115 |
– |
} |
116 |
– |
|
117 |
– |
GBLipidAtomVisitor* gbLipidVisitor = new GBLipidAtomVisitor(info); |
118 |
– |
compositeVisitor->addVisitor(gbLipidVisitor, 740); |
116 |
|
|
117 |
< |
Ring5gbAtomVisitor* ring5Visitor = new Ring5gbAtomVisitor(info); |
118 |
< |
compositeVisitor->addVisitor(ring5Visitor, 730); |
117 |
> |
//create GBtail atom visitor |
118 |
> |
GBtailVisitor* gbtVisitor = new GBtailVisitor(info); |
119 |
> |
compositeVisitor->addVisitor(gbtVisitor, 790); |
120 |
|
|
121 |
< |
HeadAtomVisitor* headVisitor = new HeadAtomVisitor(info); |
122 |
< |
compositeVisitor->addVisitor(headVisitor, 720); |
123 |
< |
|
121 |
> |
//create GBhead atom visitor |
122 |
> |
GBheadVisitor* gbhVisitor = new GBheadVisitor(info); |
123 |
> |
compositeVisitor->addVisitor(gbhVisitor, 789); |
124 |
> |
|
125 |
|
//create default atom visitor |
126 |
|
DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info); |
127 |
|
compositeVisitor->addVisitor(defaultAtomVisitor, 700); |
128 |
|
|
129 |
|
// if we gave the -w option, we want to skip the waters: |
131 |
– |
std::cerr << "-w flag was set to:" << args_info.water_given << "\n"; |
130 |
|
if (!args_info.water_given) { |
131 |
|
//create waterType visitor |
132 |
|
if(args_info.watertype_flag){ |
133 |
|
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
134 |
|
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
135 |
|
} |
136 |
< |
} |
137 |
< |
|
136 |
> |
} |
137 |
> |
|
138 |
|
if (args_info.basetype_flag) { |
139 |
< |
AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); |
140 |
< |
compositeVisitor->addVisitor(atomNameVisitor, 550); |
141 |
< |
|
139 |
> |
AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); |
140 |
> |
compositeVisitor->addVisitor(atomNameVisitor, 550); |
141 |
> |
std::cout << compositeVisitor->toString(); |
142 |
|
} |
143 |
|
|
144 |
|
//create ZconsVisitor |
161 |
|
//} |
162 |
|
|
163 |
|
//create replicate visitor |
164 |
< |
if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){ |
165 |
< |
Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg); |
166 |
< |
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt); |
164 |
> |
if(args_info.repeatX_given > 0 || |
165 |
> |
args_info.repeatY_given > 0 || |
166 |
> |
args_info.repeatY_given > 0) { |
167 |
> |
Vector3i replicateOpt(args_info.repeatX_arg, |
168 |
> |
args_info.repeatY_arg, |
169 |
> |
args_info.repeatZ_arg); |
170 |
> |
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, |
171 |
> |
replicateOpt); |
172 |
|
compositeVisitor->addVisitor(replicateVisitor, 300); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
//create rotation visitor |
177 |
|
if (args_info.refsele_given&& args_info.originsele_given) { |
178 |
< |
compositeVisitor->addVisitor(new LipidTransVisitor(info, args_info.originsele_arg, args_info.refsele_arg), 250); |
178 |
> |
compositeVisitor->addVisitor(new LipidTransVisitor(info, |
179 |
> |
args_info.originsele_arg, |
180 |
> |
args_info.refsele_arg), |
181 |
> |
250); |
182 |
|
} else if (args_info.refsele_given || args_info.originsele_given) { |
183 |
< |
std::cerr << "Both of --refsele and --originsele should appear by pair" << std::endl; |
183 |
> |
std::cerr << "Both of --refsele and --originsele should appear by pair" |
184 |
> |
<< std::endl; |
185 |
|
exit(1); |
186 |
|
} |
187 |
< |
|
187 |
> |
|
188 |
|
//create xyzVisitor |
189 |
|
XYZVisitor* xyzVisitor; |
190 |
|
|
194 |
|
xyzVisitor = new XYZVisitor(info); |
195 |
|
} |
196 |
|
|
197 |
< |
if(args_info.printPosOnly_flag){ |
198 |
< |
bool posOnly = true; |
199 |
< |
xyzVisitor->setPosOnly(posOnly); |
197 |
> |
if(args_info.velocities_flag){ |
198 |
> |
printVel = true; |
199 |
> |
xyzVisitor->doVelocities(printVel); |
200 |
|
} |
201 |
< |
|
202 |
< |
compositeVisitor->addVisitor(xyzVisitor, 200); |
201 |
> |
if(args_info.forces_flag){ |
202 |
> |
printFrc = true; |
203 |
> |
xyzVisitor->doForces(printFrc); |
204 |
> |
} |
205 |
> |
if(args_info.vectors_flag){ |
206 |
> |
printVec = true; |
207 |
> |
xyzVisitor->doVectors(printVec); |
208 |
> |
} |
209 |
> |
if(args_info.charges_flag){ |
210 |
> |
printChrg = true; |
211 |
> |
xyzVisitor->doCharges(printChrg); |
212 |
> |
} |
213 |
|
|
214 |
< |
std::cout << compositeVisitor->toString(); |
214 |
> |
compositeVisitor->addVisitor(xyzVisitor, 200); |
215 |
|
|
216 |
|
//create prepareVisitor |
217 |
|
PrepareVisitor* prepareVisitor = new PrepareVisitor(); |
220 |
|
DumpReader* dumpReader = new DumpReader(info, dumpFileName); |
221 |
|
int nframes = dumpReader->getNFrames(); |
222 |
|
|
206 |
– |
|
223 |
|
std::ofstream xyzStream(xyzFileName.c_str()); |
224 |
|
|
225 |
|
SimInfo::MoleculeIterator miter; |
236 |
|
|
237 |
|
for (int i = 0; i < nframes; i += args_info.frame_arg){ |
238 |
|
dumpReader->readFrame(i); |
239 |
< |
|
239 |
> |
|
240 |
> |
if (printFrc) forceMan->calcForces(); |
241 |
> |
|
242 |
|
//wrapping the molecule |
243 |
|
if(args_info.periodicBox_flag) { |
244 |
|
currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
245 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
245 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
246 |
> |
mol = info->nextMolecule(miter)) { |
247 |
|
molCom = mol->getCom(); |
248 |
|
newMolCom = molCom; |
249 |
|
currentSnapshot->wrapVector(newMolCom); |
250 |
|
displacement = newMolCom - molCom; |
251 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
251 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
252 |
> |
integrableObject != NULL; |
253 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
254 |
|
integrableObject->setPos(integrableObject->getPos() + displacement); |
255 |
|
} |
256 |
|
} |
257 |
|
} |
258 |
|
//update atoms of rigidbody |
259 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
259 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
260 |
> |
mol = info->nextMolecule(miter)) { |
261 |
|
|
262 |
|
//change the positions of atoms which belong to the rigidbodies |
263 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
263 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
264 |
> |
rb = mol->nextRigidBody(rbIter)) { |
265 |
|
rb->updateAtoms(); |
266 |
+ |
if (printVel) rb->updateAtomVel(); |
267 |
|
} |
268 |
|
} |
269 |
|
|
270 |
|
//prepare visit |
271 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
272 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
271 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
272 |
> |
mol = info->nextMolecule(miter)) { |
273 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
274 |
> |
integrableObject != NULL; |
275 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
276 |
|
integrableObject->accept(prepareVisitor); |
277 |
|
} |
282 |
|
|
283 |
|
|
284 |
|
//visit stuntdouble |
285 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
286 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
285 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
286 |
> |
mol = info->nextMolecule(miter)) { |
287 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
288 |
> |
integrableObject != NULL; |
289 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
290 |
|
integrableObject->accept(compositeVisitor); |
291 |
|
} |