ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/dump2Xyz/Dump2XYZ.cpp
(Generate patch)

Comparing:
trunk/src/applications/dump2Xyz/Dump2XYZ.cpp (file contents), Revision 294 by tim, Fri Feb 4 22:46:10 2005 UTC vs.
branches/development/src/applications/dump2Xyz/Dump2XYZ.cpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 1 | Line 1
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
# Line 6 | Line 6
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.
# Line 37 | Line 28
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]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include <iostream>
# Line 47 | Line 48
48   #include "brains/Register.hpp"
49   #include "brains/SimCreator.hpp"
50   #include "brains/SimInfo.hpp"
51 + #include "brains/ForceManager.hpp"
52   #include "io/DumpReader.hpp"
53   #include "utils/simError.h"
54   #include "visitors/AtomVisitor.hpp"
55 + #include "visitors/ReplacementVisitor.hpp"
56   #include "visitors/CompositeVisitor.hpp"
57   #include "visitors/RigidBodyVisitor.hpp"
58   #include "visitors/OtherVisitor.hpp"
59   #include "visitors/ZconsVisitor.hpp"
60   #include "selection/SelectionEvaluator.hpp"
61 < using namespace oopse;
61 > #include "selection/SelectionManager.hpp"
62 > #include "visitors/LipidTransVisitor.hpp"
63 > #include "visitors/AtomNameVisitor.hpp"
64  
65 + using namespace OpenMD;
66 +
67   int main(int argc, char* argv[]){
68    
69    //register force fields
# Line 64 | Line 71 | int main(int argc, char* argv[]){
71    
72    gengetopt_args_info args_info;
73    std::string dumpFileName;
67  std::string mdFileName;
74    std::string xyzFileName;
75 +  bool printVel;
76 +  bool printFrc;
77 +  bool printVec;
78 +  bool printChrg;
79    
80    //parse the command line option
81    if (cmdline_parser (argc, argv, &args_info) != 0) {
# Line 80 | Line 90 | int main(int argc, char* argv[]){
90      exit(1);
91    }
92    
83  mdFileName = dumpFileName;
84  mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md";
85
93    if (args_info.output_given){
94      xyzFileName = args_info.output_arg;
95    } else {
# Line 92 | Line 99 | int main(int argc, char* argv[]){
99    
100    //parse md file and set up the system
101    SimCreator creator;
102 <  SimInfo* info = creator.createSim(mdFileName, false);
102 >  SimInfo* info = creator.createSim(dumpFileName, false);
103 >  ForceManager* forceMan = new ForceManager(info);
104    
105 <  
98 <  
99 <  //creat visitor list
105 >  //create visitor list
106    CompositeVisitor* compositeVisitor = new CompositeVisitor();
107    
108 <  //creat ignore visitor
103 <  if(args_info.ignore_given ||args_info.water_flag){
104 <    
105 <    IgnoreVisitor* ignoreVisitor = new IgnoreVisitor(info);
106 <    
107 <    for(int i = 0; i < args_info.ignore_given; i++)
108 <      ignoreVisitor->addIgnoreType(args_info.ignore_arg[i]);
109 <    
110 <    //ignore water
111 <    if(args_info.water_flag){
112 <      ignoreVisitor->addIgnoreType("SSD");
113 <      ignoreVisitor->addIgnoreType("SSD1");
114 <      ignoreVisitor->addIgnoreType("SSD_E");
115 <      ignoreVisitor->addIgnoreType("SSD_RF");
116 <      ignoreVisitor->addIgnoreType("TIP3P_RB_0");
117 <      ignoreVisitor->addIgnoreType("TIP4P_RB_0");
118 <      ignoreVisitor->addIgnoreType("TIP5P_RB_0");
119 <      ignoreVisitor->addIgnoreType("SPCE_RB_0");      
120 <      ignoreVisitor->addIgnoreType("DPD_RB_0");
121 <    }
122 <    
123 <    compositeVisitor->addVisitor(ignoreVisitor, 1000);
124 <  }
125 <  
126 <  //creat RigidBody Visitor
108 >  //create RigidBody Visitor
109    if(args_info.rigidbody_flag){
110      RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info);
111      compositeVisitor->addVisitor(rbCOMVisitor, 900);
112    }
113    
114 <  //create selection visitor
133 <  //if (args_info.selection_given){
134 <  //  SelectionVisitor* selectionVisitor = new SelectionVisitor(info, args_info.selection_arg);
135 <  //  compositeVisitor->addVisitor(selectionVisitor, 850);
136 <  //}
137 <
138 <  SelectionEvaluator* evaluator = NULL;
139 <  if (args_info.selection_given) {
140 <    evaluator = new SelectionEvaluator(info);
141 <    assert(evaluator);
142 <    evaluator->loadScriptString( args_info.selection_arg);
143 <          
144 <  }
145 <  
146 <  //creat SSD atom visitor
114 >  //create SSD atom visitor
115    SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info);
116    compositeVisitor->addVisitor(ssdVisitor, 800);
117    
118 <  LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info);
119 <  compositeVisitor->addVisitor(linearVisitor, 750);
118 >  //create GBtail atom visitor
119 >  GBtailVisitor* gbtVisitor = new GBtailVisitor(info);
120 >  compositeVisitor->addVisitor(gbtVisitor, 790);
121    
122 <  //creat default atom visitor
122 >  //create GBhead atom visitor
123 >  GBheadVisitor* gbhVisitor = new GBheadVisitor(info);
124 >  compositeVisitor->addVisitor(gbhVisitor, 789);
125 >  
126 >  //create default atom visitor
127    DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info);
128    compositeVisitor->addVisitor(defaultAtomVisitor, 700);
129    
130 <  //creat waterType visitor
131 <  if(args_info.watertype_flag){
132 <    WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor;
133 <    compositeVisitor->addVisitor(waterTypeVisitor, 600);
130 >  // if we gave the -w option, we want to skip the waters:
131 >  if (!args_info.water_given) {
132 >    //create waterType visitor
133 >    if(args_info.watertype_flag){
134 >      WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor;
135 >      compositeVisitor->addVisitor(waterTypeVisitor, 600);
136 >    }
137 >  }
138 >  
139 >  if (args_info.basetype_flag) {
140 >    AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info);
141 >    compositeVisitor->addVisitor(atomNameVisitor, 550);    
142 >    std::cout << compositeVisitor->toString();
143    }
144    
145    //create ZconsVisitor
# Line 172 | Line 154 | int main(int argc, char* argv[]){
154      }
155    }
156    
157 <  //creat wrapping visitor
157 >  //create wrapping visitor
158    
159 <  if(args_info.periodicBox_flag){
160 <    WrappingVisitor* wrappingVisitor = new WrappingVisitor(info);
161 <    compositeVisitor->addVisitor(wrappingVisitor, 400);
159 >  //if(args_info.periodicBox_flag){
160 >  //  WrappingVisitor* wrappingVisitor = new WrappingVisitor(info);
161 >  //  compositeVisitor->addVisitor(wrappingVisitor, 400);
162 >  //}
163 >
164 >  //create replicate visitor
165 >  if(args_info.repeatX_given > 0 ||
166 >     args_info.repeatY_given > 0 ||
167 >     args_info.repeatY_given > 0) {
168 >    Vector3i replicateOpt(args_info.repeatX_arg,
169 >                          args_info.repeatY_arg,
170 >                          args_info.repeatZ_arg);
171 >    ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info,
172 >                                                              replicateOpt);
173 >    compositeVisitor->addVisitor(replicateVisitor, 300);
174    }
175 +
176 +
177 +  //create rotation visitor
178 +  if (args_info.refsele_given&& args_info.originsele_given) {
179 +    compositeVisitor->addVisitor(new LipidTransVisitor(info,
180 +                                                       args_info.originsele_arg,
181 +                                                       args_info.refsele_arg),
182 +                                 250);
183 +  } else if (args_info.refsele_given || args_info.originsele_given) {
184 +    std::cerr << "Both of --refsele and --originsele should appear by pair"
185 +              << std::endl;
186 +    exit(1);
187 +  }
188    
189 <  //creat replicate visitor
190 <  if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){
191 <    Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg);
192 <    ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt);
193 <    compositeVisitor->addVisitor(replicateVisitor, 300);
189 >  //create xyzVisitor
190 >  XYZVisitor* xyzVisitor;
191 >
192 >  if (args_info.selection_given) {
193 >    xyzVisitor = new XYZVisitor(info, args_info.selection_arg);
194 >  } else {
195 >    xyzVisitor = new XYZVisitor(info);
196    }
197 +
198 +  if(args_info.velocities_flag){
199 +    printVel = true;
200 +    xyzVisitor->doVelocities(printVel);
201 +  }
202 +  if(args_info.forces_flag){
203 +    printFrc = true;
204 +    xyzVisitor->doForces(printFrc);
205 +  }
206 +  if(args_info.vectors_flag){
207 +    printVec = true;
208 +    xyzVisitor->doVectors(printVec);
209 +  }
210 +  if(args_info.charges_flag){
211 +    printChrg = true;
212 +    xyzVisitor->doCharges(printChrg);
213 +  }
214    
215 <  //creat xyzVisitor
190 <  XYZVisitor* xyzVisitor = new XYZVisitor(info);
191 <  compositeVisitor->addVisitor(xyzVisitor, 200);
215 >  compositeVisitor->addVisitor(xyzVisitor, 200);
216    
217 <  std::cout << compositeVisitor->toString();
194 <  
195 <  //creat prepareVisitor
217 >  //create prepareVisitor
218    PrepareVisitor* prepareVisitor = new PrepareVisitor();
219    
220    //open dump file
221    DumpReader* dumpReader = new DumpReader(info, dumpFileName);
222    int nframes = dumpReader->getNFrames();
223    
224 +  std::ofstream xyzStream(xyzFileName.c_str());
225    
203  std::ofstream xyzStream;    
204  xyzStream .open(xyzFileName.c_str());
205  
206  
226    SimInfo::MoleculeIterator miter;
227    Molecule::IntegrableObjectIterator  iiter;
228    Molecule::RigidBodyIterator rbIter;
229    Molecule* mol;
230    StuntDouble* integrableObject;
231    RigidBody* rb;
232 <
233 <  if (evaluator && !evaluator->isDynamic()) {
234 <    info->getSelectionManager()->setSelectionSet(evaluator->evaluate());
235 <  }
236 <  
232 >  Vector3d molCom;
233 >  Vector3d newMolCom;
234 >  Vector3d displacement;
235 >  Mat3x3d hmat;
236 >  Snapshot* currentSnapshot;
237 >      
238    for (int i = 0; i < nframes; i += args_info.frame_arg){
239      dumpReader->readFrame(i);
240      
241 +    if (printFrc) forceMan->calcForces();
242 +    
243 +    //wrapping the molecule
244 +    if(args_info.periodicBox_flag) {
245 +      currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot();    
246 +      for (mol = info->beginMolecule(miter); mol != NULL;
247 +           mol = info->nextMolecule(miter)) {
248 +          molCom = mol->getCom();
249 +          newMolCom = molCom;
250 +          currentSnapshot->wrapVector(newMolCom);
251 +          displacement = newMolCom - molCom;
252 +        for (integrableObject = mol->beginIntegrableObject(iiter);
253 +             integrableObject != NULL;
254 +             integrableObject = mol->nextIntegrableObject(iiter)) {  
255 +          integrableObject->setPos(integrableObject->getPos() + displacement);
256 +        }
257 +      }    
258 +    }
259      //update atoms of rigidbody
260 <    for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
260 >    for (mol = info->beginMolecule(miter); mol != NULL;
261 >         mol = info->nextMolecule(miter)) {
262        
263        //change the positions of atoms which belong to the rigidbodies
264 <      for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
264 >      for (rb = mol->beginRigidBody(rbIter); rb != NULL;
265 >           rb = mol->nextRigidBody(rbIter)) {
266          rb->updateAtoms();
267 +        if (printVel) rb->updateAtomVel();
268        }
269      }
270      
271      //prepare visit
272 <    for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
273 <      for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
272 >    for (mol = info->beginMolecule(miter); mol != NULL;
273 >         mol = info->nextMolecule(miter)) {
274 >      for (integrableObject = mol->beginIntegrableObject(iiter);
275 >           integrableObject != NULL;
276             integrableObject = mol->nextIntegrableObject(iiter)) {
277          integrableObject->accept(prepareVisitor);
278        }
# Line 238 | Line 281 | int main(int argc, char* argv[]){
281      //update visitor
282      compositeVisitor->update();
283  
284 <    //if dynamic, we need to re-evaluate the selection
242 <    if (evaluator && evaluator->isDynamic()) {
243 <      info->getSelectionManager()->setSelectionSet(evaluator->evaluate());
244 <    }
245 <    
284 >
285      //visit stuntdouble
286 <    for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
287 <      for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
286 >    for (mol = info->beginMolecule(miter); mol != NULL;
287 >         mol = info->nextMolecule(miter)) {
288 >      for (integrableObject = mol->beginIntegrableObject(iiter);
289 >           integrableObject != NULL;
290             integrableObject = mol->nextIntegrableObject(iiter)) {
291          integrableObject->accept(compositeVisitor);
292        }
# Line 255 | Line 296 | int main(int argc, char* argv[]){
296      xyzVisitor->clear();
297      
298    }//end for (int i = 0; i < nframes; i += args_info.frame_arg)
299 <  
299 >
300    xyzStream.close();
301 <  
261 <  
301 >  delete prepareVisitor;
302    delete compositeVisitor;
303    delete info;
264  
304   }

Comparing:
trunk/src/applications/dump2Xyz/Dump2XYZ.cpp (property svn:keywords), Revision 294 by tim, Fri Feb 4 22:46:10 2005 UTC vs.
branches/development/src/applications/dump2Xyz/Dump2XYZ.cpp (property svn:keywords), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines