1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
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" |
59 |
|
#include "selection/SelectionEvaluator.hpp" |
60 |
|
#include "selection/SelectionManager.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 |
|
|
70 |
|
|
71 |
|
gengetopt_args_info args_info; |
72 |
|
std::string dumpFileName; |
70 |
– |
std::string mdFileName; |
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) { |
89 |
|
exit(1); |
90 |
|
} |
91 |
|
|
86 |
– |
mdFileName = dumpFileName; |
87 |
– |
mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md"; |
88 |
– |
|
92 |
|
if (args_info.output_given){ |
93 |
|
xyzFileName = args_info.output_arg; |
94 |
|
} else { |
98 |
|
|
99 |
|
//parse md file and set up the system |
100 |
|
SimCreator creator; |
101 |
< |
SimInfo* info = creator.createSim(mdFileName, false); |
101 |
> |
SimInfo* info = creator.createSim(dumpFileName, false); |
102 |
> |
ForceManager* forceMan = new ForceManager(info); |
103 |
|
|
104 |
< |
|
101 |
< |
|
102 |
< |
//creat visitor list |
104 |
> |
//create visitor list |
105 |
|
CompositeVisitor* compositeVisitor = new CompositeVisitor(); |
106 |
< |
|
107 |
< |
//creat RigidBody Visitor |
106 |
> |
|
107 |
> |
//create RigidBody Visitor |
108 |
|
if(args_info.rigidbody_flag){ |
109 |
|
RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info); |
110 |
|
compositeVisitor->addVisitor(rbCOMVisitor, 900); |
111 |
|
} |
112 |
|
|
113 |
< |
//creat SSD atom visitor |
113 |
> |
//create SSD atom visitor |
114 |
|
SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info); |
115 |
|
compositeVisitor->addVisitor(ssdVisitor, 800); |
116 |
|
|
117 |
< |
LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info); |
116 |
< |
compositeVisitor->addVisitor(linearVisitor, 750); |
117 |
< |
|
118 |
< |
//creat default atom visitor |
117 |
> |
//create default atom visitor |
118 |
|
DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info); |
119 |
|
compositeVisitor->addVisitor(defaultAtomVisitor, 700); |
120 |
|
|
121 |
< |
//creat waterType visitor |
122 |
< |
if(args_info.watertype_flag){ |
123 |
< |
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
124 |
< |
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
121 |
> |
// if we gave the -w option, we want to skip the waters: |
122 |
> |
if (!args_info.water_given) { |
123 |
> |
//create waterType visitor |
124 |
> |
if(args_info.watertype_flag){ |
125 |
> |
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
126 |
> |
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
127 |
> |
} |
128 |
> |
} |
129 |
> |
|
130 |
> |
if (args_info.basetype_flag) { |
131 |
> |
AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); |
132 |
> |
compositeVisitor->addVisitor(atomNameVisitor, 550); |
133 |
> |
std::cout << compositeVisitor->toString(); |
134 |
|
} |
135 |
|
|
136 |
|
//create ZconsVisitor |
145 |
|
} |
146 |
|
} |
147 |
|
|
148 |
< |
//creat wrapping visitor |
148 |
> |
//create wrapping visitor |
149 |
|
|
150 |
< |
if(args_info.periodicBox_flag){ |
151 |
< |
WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); |
152 |
< |
compositeVisitor->addVisitor(wrappingVisitor, 400); |
153 |
< |
} |
150 |
> |
//if(args_info.periodicBox_flag){ |
151 |
> |
// WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); |
152 |
> |
// compositeVisitor->addVisitor(wrappingVisitor, 400); |
153 |
> |
//} |
154 |
|
|
155 |
< |
//creat replicate visitor |
156 |
< |
if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){ |
157 |
< |
Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg); |
158 |
< |
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt); |
155 |
> |
//create replicate visitor |
156 |
> |
if(args_info.repeatX_given > 0 || |
157 |
> |
args_info.repeatY_given > 0 || |
158 |
> |
args_info.repeatY_given > 0) { |
159 |
> |
Vector3i replicateOpt(args_info.repeatX_arg, |
160 |
> |
args_info.repeatY_arg, |
161 |
> |
args_info.repeatZ_arg); |
162 |
> |
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, |
163 |
> |
replicateOpt); |
164 |
|
compositeVisitor->addVisitor(replicateVisitor, 300); |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
//create rotation visitor |
169 |
|
if (args_info.refsele_given&& args_info.originsele_given) { |
170 |
< |
compositeVisitor->addVisitor(new LipidTransVisitor(info, args_info.originsele_arg, args_info.refsele_arg), 250); |
170 |
> |
compositeVisitor->addVisitor(new LipidTransVisitor(info, |
171 |
> |
args_info.originsele_arg, |
172 |
> |
args_info.refsele_arg), |
173 |
> |
250); |
174 |
|
} else if (args_info.refsele_given || args_info.originsele_given) { |
175 |
< |
std::cerr << "Both of --refsele and --originsele should appear by pair" << std::endl; |
175 |
> |
std::cerr << "Both of --refsele and --originsele should appear by pair" |
176 |
> |
<< std::endl; |
177 |
|
exit(1); |
178 |
|
} |
179 |
< |
|
180 |
< |
//creat xyzVisitor |
179 |
> |
|
180 |
> |
//create xyzVisitor |
181 |
|
XYZVisitor* xyzVisitor; |
182 |
+ |
|
183 |
|
if (args_info.selection_given) { |
184 |
|
xyzVisitor = new XYZVisitor(info, args_info.selection_arg); |
185 |
|
} else { |
186 |
|
xyzVisitor = new XYZVisitor(info); |
187 |
|
} |
188 |
< |
compositeVisitor->addVisitor(xyzVisitor, 200); |
188 |
> |
|
189 |
> |
if(args_info.velocities_flag){ |
190 |
> |
printVel = true; |
191 |
> |
xyzVisitor->doVelocities(printVel); |
192 |
> |
} |
193 |
> |
if(args_info.forces_flag){ |
194 |
> |
printFrc = true; |
195 |
> |
xyzVisitor->doForces(printFrc); |
196 |
> |
} |
197 |
> |
if(args_info.vectors_flag){ |
198 |
> |
printVec = true; |
199 |
> |
xyzVisitor->doVectors(printVec); |
200 |
> |
} |
201 |
> |
if(args_info.charges_flag){ |
202 |
> |
printChrg = true; |
203 |
> |
xyzVisitor->doCharges(printChrg); |
204 |
> |
} |
205 |
|
|
206 |
< |
std::cout << compositeVisitor->toString(); |
206 |
> |
compositeVisitor->addVisitor(xyzVisitor, 200); |
207 |
|
|
208 |
< |
//creat prepareVisitor |
208 |
> |
//create prepareVisitor |
209 |
|
PrepareVisitor* prepareVisitor = new PrepareVisitor(); |
210 |
|
|
211 |
|
//open dump file |
212 |
|
DumpReader* dumpReader = new DumpReader(info, dumpFileName); |
213 |
|
int nframes = dumpReader->getNFrames(); |
214 |
|
|
215 |
+ |
std::ofstream xyzStream(xyzFileName.c_str()); |
216 |
|
|
182 |
– |
std::ofstream xyzStream; |
183 |
– |
xyzStream .open(xyzFileName.c_str()); |
184 |
– |
|
185 |
– |
|
217 |
|
SimInfo::MoleculeIterator miter; |
218 |
|
Molecule::IntegrableObjectIterator iiter; |
219 |
|
Molecule::RigidBodyIterator rbIter; |
220 |
|
Molecule* mol; |
221 |
|
StuntDouble* integrableObject; |
222 |
|
RigidBody* rb; |
223 |
+ |
Vector3d molCom; |
224 |
+ |
Vector3d newMolCom; |
225 |
+ |
Vector3d displacement; |
226 |
+ |
Mat3x3d hmat; |
227 |
+ |
Snapshot* currentSnapshot; |
228 |
|
|
229 |
|
for (int i = 0; i < nframes; i += args_info.frame_arg){ |
230 |
|
dumpReader->readFrame(i); |
231 |
|
|
232 |
+ |
if (printFrc) forceMan->calcForces(); |
233 |
+ |
|
234 |
+ |
//wrapping the molecule |
235 |
+ |
if(args_info.periodicBox_flag) { |
236 |
+ |
currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
237 |
+ |
for (mol = info->beginMolecule(miter); mol != NULL; |
238 |
+ |
mol = info->nextMolecule(miter)) { |
239 |
+ |
molCom = mol->getCom(); |
240 |
+ |
newMolCom = molCom; |
241 |
+ |
currentSnapshot->wrapVector(newMolCom); |
242 |
+ |
displacement = newMolCom - molCom; |
243 |
+ |
for (integrableObject = mol->beginIntegrableObject(iiter); |
244 |
+ |
integrableObject != NULL; |
245 |
+ |
integrableObject = mol->nextIntegrableObject(iiter)) { |
246 |
+ |
integrableObject->setPos(integrableObject->getPos() + displacement); |
247 |
+ |
} |
248 |
+ |
} |
249 |
+ |
} |
250 |
|
//update atoms of rigidbody |
251 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
251 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
252 |
> |
mol = info->nextMolecule(miter)) { |
253 |
|
|
254 |
|
//change the positions of atoms which belong to the rigidbodies |
255 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
255 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
256 |
> |
rb = mol->nextRigidBody(rbIter)) { |
257 |
|
rb->updateAtoms(); |
258 |
+ |
if (printVel) rb->updateAtomVel(); |
259 |
|
} |
260 |
|
} |
261 |
|
|
262 |
|
//prepare visit |
263 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
264 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
263 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
264 |
> |
mol = info->nextMolecule(miter)) { |
265 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
266 |
> |
integrableObject != NULL; |
267 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
268 |
|
integrableObject->accept(prepareVisitor); |
269 |
|
} |
274 |
|
|
275 |
|
|
276 |
|
//visit stuntdouble |
277 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
278 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
277 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
278 |
> |
mol = info->nextMolecule(miter)) { |
279 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
280 |
> |
integrableObject != NULL; |
281 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
282 |
|
integrableObject->accept(compositeVisitor); |
283 |
|
} |
287 |
|
xyzVisitor->clear(); |
288 |
|
|
289 |
|
}//end for (int i = 0; i < nframes; i += args_info.frame_arg) |
290 |
< |
|
290 |
> |
|
291 |
|
xyzStream.close(); |
292 |
< |
|
232 |
< |
|
292 |
> |
delete prepareVisitor; |
293 |
|
delete compositeVisitor; |
294 |
|
delete info; |
235 |
– |
|
295 |
|
} |