--- trunk/src/applications/dump2Xyz/Dump2XYZ.cpp 2005/03/09 17:30:29 413 +++ trunk/src/applications/dump2Xyz/Dump2XYZ.cpp 2010/05/10 17:28:26 1442 @@ -1,4 +1,4 @@ - /* +/* * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a @@ -6,19 +6,10 @@ * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,6 +28,15 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [4] Vardeman & Gezelter, in progress (2009). */ #include @@ -57,8 +57,9 @@ #include "selection/SelectionEvaluator.hpp" #include "selection/SelectionManager.hpp" #include "visitors/LipidTransVisitor.hpp" +#include "visitors/AtomNameVisitor.hpp" -using namespace oopse; +using namespace OpenMD; int main(int argc, char* argv[]){ @@ -67,7 +68,6 @@ int main(int argc, char* argv[]){ gengetopt_args_info args_info; std::string dumpFileName; - std::string mdFileName; std::string xyzFileName; //parse the command line option @@ -83,9 +83,6 @@ int main(int argc, char* argv[]){ exit(1); } - mdFileName = dumpFileName; - mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md"; - if (args_info.output_given){ xyzFileName = args_info.output_arg; } else { @@ -95,34 +92,55 @@ int main(int argc, char* argv[]){ //parse md file and set up the system SimCreator creator; - SimInfo* info = creator.createSim(mdFileName, false); + SimInfo* info = creator.createSim(dumpFileName, false); - - - //creat visitor list + + //create visitor list CompositeVisitor* compositeVisitor = new CompositeVisitor(); - //creat RigidBody Visitor + //create RigidBody Visitor if(args_info.rigidbody_flag){ RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info); compositeVisitor->addVisitor(rbCOMVisitor, 900); } - //creat SSD atom visitor + //create SSD atom visitor SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info); compositeVisitor->addVisitor(ssdVisitor, 800); LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info); compositeVisitor->addVisitor(linearVisitor, 750); + if (args_info.gb_given) { + linearVisitor->addGayBerneAtomType(args_info.gb_arg); + } - //creat default atom visitor + GBLipidAtomVisitor* gbLipidVisitor = new GBLipidAtomVisitor(info); + compositeVisitor->addVisitor(gbLipidVisitor, 740); + + Ring5gbAtomVisitor* ring5Visitor = new Ring5gbAtomVisitor(info); + compositeVisitor->addVisitor(ring5Visitor, 730); + + HeadAtomVisitor* headVisitor = new HeadAtomVisitor(info); + compositeVisitor->addVisitor(headVisitor, 720); + + //create default atom visitor DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info); compositeVisitor->addVisitor(defaultAtomVisitor, 700); - //creat waterType visitor - if(args_info.watertype_flag){ - WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; - compositeVisitor->addVisitor(waterTypeVisitor, 600); + // if we gave the -w option, we want to skip the waters: + std::cerr << "-w flag was set to:" << args_info.water_given << "\n"; + if (!args_info.water_given) { + //create waterType visitor + if(args_info.watertype_flag){ + WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; + compositeVisitor->addVisitor(waterTypeVisitor, 600); + } + } + + if (args_info.basetype_flag) { + AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); + compositeVisitor->addVisitor(atomNameVisitor, 550); + } //create ZconsVisitor @@ -137,14 +155,14 @@ int main(int argc, char* argv[]){ } } - //creat wrapping visitor + //create wrapping visitor - if(args_info.periodicBox_flag){ - WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); - compositeVisitor->addVisitor(wrappingVisitor, 400); - } + //if(args_info.periodicBox_flag){ + // WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); + // compositeVisitor->addVisitor(wrappingVisitor, 400); + //} - //creat replicate visitor + //create replicate visitor if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){ Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg); ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt); @@ -160,18 +178,25 @@ int main(int argc, char* argv[]){ exit(1); } - //creat xyzVisitor + //create xyzVisitor XYZVisitor* xyzVisitor; + if (args_info.selection_given) { xyzVisitor = new XYZVisitor(info, args_info.selection_arg); } else { xyzVisitor = new XYZVisitor(info); } + + if(args_info.printPosOnly_flag){ + bool posOnly = true; + xyzVisitor->setPosOnly(posOnly); + } + compositeVisitor->addVisitor(xyzVisitor, 200); std::cout << compositeVisitor->toString(); - //creat prepareVisitor + //create prepareVisitor PrepareVisitor* prepareVisitor = new PrepareVisitor(); //open dump file @@ -179,20 +204,37 @@ int main(int argc, char* argv[]){ int nframes = dumpReader->getNFrames(); - std::ofstream xyzStream; - xyzStream .open(xyzFileName.c_str()); + std::ofstream xyzStream(xyzFileName.c_str()); - SimInfo::MoleculeIterator miter; Molecule::IntegrableObjectIterator iiter; Molecule::RigidBodyIterator rbIter; Molecule* mol; StuntDouble* integrableObject; RigidBody* rb; + Vector3d molCom; + Vector3d newMolCom; + Vector3d displacement; + Mat3x3d hmat; + Snapshot* currentSnapshot; for (int i = 0; i < nframes; i += args_info.frame_arg){ dumpReader->readFrame(i); - + + //wrapping the molecule + if(args_info.periodicBox_flag) { + currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); + for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { + molCom = mol->getCom(); + newMolCom = molCom; + currentSnapshot->wrapVector(newMolCom); + displacement = newMolCom - molCom; + for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; + integrableObject = mol->nextIntegrableObject(iiter)) { + integrableObject->setPos(integrableObject->getPos() + displacement); + } + } + } //update atoms of rigidbody for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { @@ -226,11 +268,9 @@ int main(int argc, char* argv[]){ xyzVisitor->clear(); }//end for (int i = 0; i < nframes; i += args_info.frame_arg) - + xyzStream.close(); - - + delete prepareVisitor; delete compositeVisitor; delete info; - }