| 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] 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> |
| 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" |
| 62 |
|
#include "visitors/LipidTransVisitor.hpp" |
| 63 |
|
#include "visitors/AtomNameVisitor.hpp" |
| 64 |
|
|
| 65 |
< |
using namespace oopse; |
| 65 |
> |
using namespace OpenMD; |
| 66 |
|
|
| 67 |
+ |
using namespace std; |
| 68 |
|
int main(int argc, char* argv[]){ |
| 69 |
|
|
| 70 |
|
//register force fields |
| 71 |
|
registerForceFields(); |
| 72 |
|
|
| 73 |
|
gengetopt_args_info args_info; |
| 74 |
< |
std::string dumpFileName; |
| 75 |
< |
std::string mdFileName; |
| 76 |
< |
std::string xyzFileName; |
| 74 |
> |
string dumpFileName; |
| 75 |
> |
string xyzFileName; |
| 76 |
> |
|
| 77 |
> |
bool printVel(false); |
| 78 |
> |
bool printFrc(false); |
| 79 |
> |
bool printVec(false); |
| 80 |
> |
bool printChrg(false); |
| 81 |
|
|
| 82 |
|
//parse the command line option |
| 83 |
|
if (cmdline_parser (argc, argv, &args_info) != 0) { |
| 88 |
|
if (args_info.input_given){ |
| 89 |
|
dumpFileName = args_info.input_arg; |
| 90 |
|
} else { |
| 91 |
< |
std::cerr << "Does not have input file name" << std::endl; |
| 91 |
> |
cerr << "Does not have input file name" << endl; |
| 92 |
|
exit(1); |
| 93 |
|
} |
| 94 |
|
|
| 87 |
– |
mdFileName = dumpFileName; |
| 88 |
– |
mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md"; |
| 89 |
– |
|
| 95 |
|
if (args_info.output_given){ |
| 96 |
|
xyzFileName = args_info.output_arg; |
| 97 |
|
} else { |
| 101 |
|
|
| 102 |
|
//parse md file and set up the system |
| 103 |
|
SimCreator creator; |
| 104 |
< |
SimInfo* info = creator.createSim(mdFileName, false); |
| 104 |
> |
SimInfo* info = creator.createSim(dumpFileName, false); |
| 105 |
> |
ForceManager* forceMan = new ForceManager(info); |
| 106 |
|
|
| 101 |
– |
|
| 102 |
– |
|
| 107 |
|
//create visitor list |
| 108 |
|
CompositeVisitor* compositeVisitor = new CompositeVisitor(); |
| 109 |
< |
|
| 109 |
> |
|
| 110 |
|
//create RigidBody Visitor |
| 111 |
|
if(args_info.rigidbody_flag){ |
| 112 |
|
RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info); |
| 117 |
|
SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info); |
| 118 |
|
compositeVisitor->addVisitor(ssdVisitor, 800); |
| 119 |
|
|
| 120 |
< |
LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info); |
| 121 |
< |
compositeVisitor->addVisitor(linearVisitor, 750); |
| 122 |
< |
if (args_info.gb_given) { |
| 119 |
< |
linearVisitor->addGayBerneAtomType(args_info.gb_arg); |
| 120 |
< |
} |
| 120 |
> |
//create GBtail atom visitor |
| 121 |
> |
GBtailVisitor* gbtVisitor = new GBtailVisitor(info); |
| 122 |
> |
compositeVisitor->addVisitor(gbtVisitor, 790); |
| 123 |
|
|
| 124 |
< |
GBLipidAtomVisitor* gbLipidVisitor = new GBLipidAtomVisitor(info); |
| 125 |
< |
compositeVisitor->addVisitor(gbLipidVisitor, 740); |
| 126 |
< |
|
| 124 |
> |
//create GBhead atom visitor |
| 125 |
> |
GBheadVisitor* gbhVisitor = new GBheadVisitor(info); |
| 126 |
> |
compositeVisitor->addVisitor(gbhVisitor, 789); |
| 127 |
> |
|
| 128 |
|
//create default atom visitor |
| 129 |
|
DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info); |
| 130 |
|
compositeVisitor->addVisitor(defaultAtomVisitor, 700); |
| 131 |
|
|
| 132 |
< |
//create waterType visitor |
| 133 |
< |
if(args_info.watertype_flag){ |
| 134 |
< |
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
| 135 |
< |
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
| 136 |
< |
} |
| 137 |
< |
|
| 132 |
> |
// if we gave the -w option, we want to skip the waters: |
| 133 |
> |
if (!args_info.water_given) { |
| 134 |
> |
//create waterType visitor |
| 135 |
> |
if(args_info.watertype_flag){ |
| 136 |
> |
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
| 137 |
> |
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
| 138 |
> |
} |
| 139 |
> |
} |
| 140 |
> |
|
| 141 |
|
if (args_info.basetype_flag) { |
| 142 |
< |
AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); |
| 143 |
< |
compositeVisitor->addVisitor(atomNameVisitor, 550); |
| 144 |
< |
|
| 142 |
> |
AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); |
| 143 |
> |
compositeVisitor->addVisitor(atomNameVisitor, 550); |
| 144 |
> |
cout << compositeVisitor->toString(); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
//create ZconsVisitor |
| 164 |
|
//} |
| 165 |
|
|
| 166 |
|
//create replicate visitor |
| 167 |
< |
if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){ |
| 168 |
< |
Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg); |
| 169 |
< |
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt); |
| 167 |
> |
if(args_info.repeatX_given > 0 || |
| 168 |
> |
args_info.repeatY_given > 0 || |
| 169 |
> |
args_info.repeatY_given > 0) { |
| 170 |
> |
Vector3i replicateOpt(args_info.repeatX_arg, |
| 171 |
> |
args_info.repeatY_arg, |
| 172 |
> |
args_info.repeatZ_arg); |
| 173 |
> |
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, |
| 174 |
> |
replicateOpt); |
| 175 |
|
compositeVisitor->addVisitor(replicateVisitor, 300); |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
//create rotation visitor |
| 180 |
|
if (args_info.refsele_given&& args_info.originsele_given) { |
| 181 |
< |
compositeVisitor->addVisitor(new LipidTransVisitor(info, args_info.originsele_arg, args_info.refsele_arg), 250); |
| 181 |
> |
compositeVisitor->addVisitor(new LipidTransVisitor(info, |
| 182 |
> |
args_info.originsele_arg, |
| 183 |
> |
args_info.refsele_arg), |
| 184 |
> |
250); |
| 185 |
|
} else if (args_info.refsele_given || args_info.originsele_given) { |
| 186 |
< |
std::cerr << "Both of --refsele and --originsele should appear by pair" << std::endl; |
| 186 |
> |
cerr << "Both of --refsele and --originsele should appear by pair" |
| 187 |
> |
<< endl; |
| 188 |
|
exit(1); |
| 189 |
|
} |
| 190 |
< |
|
| 190 |
> |
|
| 191 |
|
//create xyzVisitor |
| 192 |
|
XYZVisitor* xyzVisitor; |
| 193 |
+ |
|
| 194 |
|
if (args_info.selection_given) { |
| 195 |
|
xyzVisitor = new XYZVisitor(info, args_info.selection_arg); |
| 196 |
|
} else { |
| 197 |
|
xyzVisitor = new XYZVisitor(info); |
| 198 |
|
} |
| 199 |
< |
compositeVisitor->addVisitor(xyzVisitor, 200); |
| 199 |
> |
|
| 200 |
> |
if(args_info.velocities_flag){ |
| 201 |
> |
printVel = true; |
| 202 |
> |
xyzVisitor->doVelocities(printVel); |
| 203 |
> |
} |
| 204 |
> |
if(args_info.forces_flag){ |
| 205 |
> |
printFrc = true; |
| 206 |
> |
xyzVisitor->doForces(printFrc); |
| 207 |
> |
} |
| 208 |
> |
if(args_info.vectors_flag){ |
| 209 |
> |
printVec = true; |
| 210 |
> |
xyzVisitor->doVectors(printVec); |
| 211 |
> |
} |
| 212 |
> |
if(args_info.charges_flag){ |
| 213 |
> |
printChrg = true; |
| 214 |
> |
xyzVisitor->doCharges(printChrg); |
| 215 |
> |
} |
| 216 |
|
|
| 217 |
< |
std::cout << compositeVisitor->toString(); |
| 217 |
> |
compositeVisitor->addVisitor(xyzVisitor, 200); |
| 218 |
|
|
| 219 |
|
//create prepareVisitor |
| 220 |
|
PrepareVisitor* prepareVisitor = new PrepareVisitor(); |
| 223 |
|
DumpReader* dumpReader = new DumpReader(info, dumpFileName); |
| 224 |
|
int nframes = dumpReader->getNFrames(); |
| 225 |
|
|
| 226 |
+ |
ofstream xyzStream(xyzFileName.c_str()); |
| 227 |
|
|
| 195 |
– |
std::ofstream xyzStream; |
| 196 |
– |
xyzStream .open(xyzFileName.c_str()); |
| 197 |
– |
|
| 198 |
– |
|
| 228 |
|
SimInfo::MoleculeIterator miter; |
| 229 |
|
Molecule::IntegrableObjectIterator iiter; |
| 230 |
|
Molecule::RigidBodyIterator rbIter; |
| 239 |
|
|
| 240 |
|
for (int i = 0; i < nframes; i += args_info.frame_arg){ |
| 241 |
|
dumpReader->readFrame(i); |
| 242 |
< |
|
| 242 |
> |
|
| 243 |
> |
if (printFrc) forceMan->calcForces(); |
| 244 |
> |
|
| 245 |
|
//wrapping the molecule |
| 246 |
|
if(args_info.periodicBox_flag) { |
| 247 |
|
currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
| 248 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
| 248 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
| 249 |
> |
mol = info->nextMolecule(miter)) { |
| 250 |
|
molCom = mol->getCom(); |
| 251 |
|
newMolCom = molCom; |
| 252 |
|
currentSnapshot->wrapVector(newMolCom); |
| 253 |
|
displacement = newMolCom - molCom; |
| 254 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
| 254 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
| 255 |
> |
integrableObject != NULL; |
| 256 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
| 257 |
|
integrableObject->setPos(integrableObject->getPos() + displacement); |
| 258 |
|
} |
| 259 |
|
} |
| 260 |
|
} |
| 261 |
|
//update atoms of rigidbody |
| 262 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
| 262 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
| 263 |
> |
mol = info->nextMolecule(miter)) { |
| 264 |
|
|
| 265 |
|
//change the positions of atoms which belong to the rigidbodies |
| 266 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
| 266 |
> |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
| 267 |
> |
rb = mol->nextRigidBody(rbIter)) { |
| 268 |
|
rb->updateAtoms(); |
| 269 |
+ |
if (printVel) rb->updateAtomVel(); |
| 270 |
|
} |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
//prepare visit |
| 274 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
| 275 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
| 274 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
| 275 |
> |
mol = info->nextMolecule(miter)) { |
| 276 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
| 277 |
> |
integrableObject != NULL; |
| 278 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
| 279 |
|
integrableObject->accept(prepareVisitor); |
| 280 |
|
} |
| 285 |
|
|
| 286 |
|
|
| 287 |
|
//visit stuntdouble |
| 288 |
< |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
| 289 |
< |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
| 288 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; |
| 289 |
> |
mol = info->nextMolecule(miter)) { |
| 290 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); |
| 291 |
> |
integrableObject != NULL; |
| 292 |
|
integrableObject = mol->nextIntegrableObject(iiter)) { |
| 293 |
|
integrableObject->accept(compositeVisitor); |
| 294 |
|
} |
| 298 |
|
xyzVisitor->clear(); |
| 299 |
|
|
| 300 |
|
}//end for (int i = 0; i < nframes; i += args_info.frame_arg) |
| 301 |
< |
|
| 301 |
> |
|
| 302 |
|
xyzStream.close(); |
| 263 |
– |
|
| 303 |
|
delete prepareVisitor; |
| 304 |
|
delete compositeVisitor; |
| 305 |
|
delete info; |
| 267 |
– |
|
| 306 |
|
} |