28 |
|
#include "UseTheForce/DarkSide/charge_interface.h" |
29 |
|
#include "UseTheForce/DarkSide/dipole_interface.h" |
30 |
|
#include "UseTheForce/DarkSide/sticky_interface.h" |
31 |
+ |
#include "UseTheForce/ForceFieldFactory.hpp" |
32 |
+ |
#include "io/DirectionalAtomTypesSectionParser.hpp" |
33 |
+ |
#include "io/AtomTypesSectionParser.hpp" |
34 |
+ |
#include "io/LennardJonesAtomTypesSectionParser.hpp" |
35 |
+ |
#include "io/ElectrostaticAtomTypesSectionParser.hpp" |
36 |
+ |
#include "io/EAMAtomTypesSectionParser.hpp" |
37 |
+ |
#include "io/StickyAtomTypesSectionParser.hpp" |
38 |
+ |
#include "io/BondTypesSectionParser.hpp" |
39 |
+ |
#include "io/BendTypesSectionParser.hpp" |
40 |
+ |
#include "io/TorsionTypesSectionParser.hpp" |
41 |
|
|
42 |
|
namespace oopse { |
43 |
|
|
47 |
|
} |
48 |
|
|
49 |
|
//register createDUFF to ForceFieldFactory |
50 |
< |
ForceFieldFactory::getInstance()->registerForceField("DUFF", createDUFF); |
50 |
> |
bool registerDUFFStatus = ForceFieldFactory::getInstance()->registerForceField("DUFF", createDUFF); |
51 |
|
|
52 |
+ |
DUFF::DUFF(){ |
53 |
|
|
54 |
+ |
//set default force field filename |
55 |
+ |
setForceFieldFileName("DUFF.frc"); |
56 |
+ |
|
57 |
+ |
//the order of adding section parsers are important |
58 |
+ |
//DirectionalAtomTypesSectionParser should be added before AtomTypesSectionParser Since |
59 |
+ |
//These two section parsers will actually create "real" AtomTypes (AtomTypesSectionParser will create |
60 |
+ |
//AtomType and DirectionalAtomTypesSectionParser will creat DirectionalAtomType which is a subclass |
61 |
+ |
//of AtomType, therefore it should come first). Other AtomTypes Section Parser will not create the |
62 |
+ |
//"real" AtomType, they only add and set some attribute of the AtomType. Thus their order are not |
63 |
+ |
//important. AtomTypesSectionParser should be added before other atom type section parsers. |
64 |
+ |
//Make sure they are added after DirectionalAtomTypesSectionParser and AtomTypesSectionParser. |
65 |
+ |
//The order of BondTypesSectionParser, BendTypesSectionParser and TorsionTypesSectionParser are |
66 |
+ |
//not important. |
67 |
+ |
spMan_.push_back(new DirectionalAtomTypesSectionParser()); |
68 |
+ |
spMan_.push_back(new AtomTypesSectionParser()); |
69 |
+ |
spMan_.push_back(new LennardJonesAtomTypesSectionParser()); |
70 |
+ |
spMan_.push_back(new ElectrostaticAtomTypesSectionParser()); |
71 |
+ |
spMan_.push_back(new EAMAtomTypesSectionParser()); |
72 |
+ |
spMan_.push_back(new StickyAtomTypesSectionParser()); |
73 |
+ |
spMan_.push_back(new BondTypesSectionParser()); |
74 |
+ |
spMan_.push_back(new BendTypesSectionParser()); |
75 |
+ |
spMan_.push_back(new TorsionTypesSectionParser()); |
76 |
+ |
|
77 |
+ |
} |
78 |
+ |
|
79 |
+ |
void DUFF::parse(const std::string& filename) { |
80 |
+ |
ifstrstream* ffStream; |
81 |
+ |
ffStream = openForceFieldFile(filename); |
82 |
+ |
|
83 |
+ |
spMan_.parse(*ffStream, *this); |
84 |
+ |
|
85 |
+ |
ForceField::AtomTypeContainer::MapTypeIterator i; |
86 |
+ |
AtomType* at; |
87 |
+ |
|
88 |
+ |
for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) { |
89 |
+ |
at->makeFortranAtomType(); |
90 |
+ |
} |
91 |
+ |
|
92 |
+ |
for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) { |
93 |
+ |
at->complete(); |
94 |
+ |
} |
95 |
+ |
|
96 |
+ |
} |
97 |
+ |
|
98 |
+ |
/* |
99 |
|
ParseState DUFF::getSection(const std::string& section) { |
100 |
|
ParseState result; |
101 |
|
|
127 |
|
|
128 |
|
void DUFF::parse(const std::string& filename) { |
129 |
|
ifstrstream* ffStream; |
130 |
< |
ffStream = openForceFiledFile(filename); |
130 |
> |
ffStream = openForceFieldFile(filename); |
131 |
|
const int bufferSize = 65535; |
132 |
|
std::string line; |
133 |
|
char buffer[bufferSize]; |
134 |
|
int lineNo = 0; |
135 |
< |
int atomIdent = 1; //atom's indent begins from 1 (since only fortran's array begins from 1) |
135 |
> |
int atomIdent = getNAtomType() + 1; //atom's indent begins from 1 (since only fortran's array begins from 1) |
136 |
|
ParseState currentSection = DUFF::UnknownSection; |
137 |
|
|
138 |
|
while(ffStream.getline(buffer, bufferSize)){ |
202 |
|
delete ffStream; |
203 |
|
} |
204 |
|
|
149 |
– |
|
205 |
|
void DUFF::parseAtomType(const std::string& line, int lineNo, int& ident){ |
206 |
|
StringTokenizer tokenizer(line); |
207 |
|
int nTokens = tokenizer.countTokens(); |
253 |
|
atomType->setName(atomTypeName); |
254 |
|
atomType->setMass(mass); |
255 |
|
|
256 |
< |
//by default, all of the properties in AtomTypeProperties is set to 0 |
257 |
< |
//In Lennard-Jones Force Field, we only need to set Lennard-Jones to true |
258 |
< |
atomType->setLennardJones(); |
256 |
> |
if (isLJ) { |
257 |
> |
atomType->setLennardJones(); |
258 |
> |
} |
259 |
|
|
260 |
+ |
if (isCharge) { |
261 |
+ |
atomType->setCharge(); |
262 |
+ |
} |
263 |
+ |
|
264 |
|
atomType->setIdent(ident); |
265 |
|
|
266 |
|
atomType->complete(); |
294 |
|
StringTokenizer tokenizer(line); |
295 |
|
int nTokens = tokenizer.countTokens(); |
296 |
|
|
297 |
< |
//in irectionalAtomTypeSection, a line at least contains 6 tokens |
297 |
> |
//in DirectionalAtomTypeSection, a line at least contains 6 tokens |
298 |
|
//AtomTypeName, isDipole, isSticky, I_xx, I_yy and I_zz |
299 |
|
if (nTokens < 6) { |
300 |
< |
|
300 |
> |
std::cerr << "Not enought tokens" << std::endl; |
301 |
|
} else { |
302 |
|
|
303 |
|
|
320 |
|
|
321 |
|
} |
322 |
|
|
323 |
< |
dAtomType->setDipole(isDipole); |
324 |
< |
dAtomType->setSticky(isSticky); |
323 |
> |
if (isDipole) { |
324 |
> |
dAtomType->setDipole(); |
325 |
> |
} |
326 |
|
|
327 |
+ |
if (isSticky) { |
328 |
+ |
dAtomType->setSticky(); |
329 |
+ |
} |
330 |
+ |
|
331 |
|
Mat3x3d inertialMat; |
332 |
|
inertialMat(0, 0) = Ixx; |
333 |
< |
inertialMat(1, 1) = Ixx; |
334 |
< |
inertialMat(2, 2) = Ixx; |
333 |
> |
inertialMat(1, 1) = Iyy; |
334 |
> |
inertialMat(2, 2) = Izz; |
335 |
|
dAtomType->setI(inertialMat); |
336 |
|
|
337 |
|
//read dipole moment |
414 |
|
|
415 |
|
//switch is a maintain nightmare |
416 |
|
switch(bt) { |
417 |
< |
case "FixedBondType" : |
417 |
> |
case "Fixed" : |
418 |
|
bondType = new FixedBondType(); |
419 |
|
break; |
420 |
|
|
421 |
< |
case "HarmonicBondType" : |
421 |
> |
case "Harmonic" : |
422 |
|
if (nTokens < 1) { |
423 |
|
|
424 |
|
} else { |
429 |
|
|
430 |
|
break; |
431 |
|
|
432 |
< |
case "CubicBondType" : |
432 |
> |
case "Cubic" : |
433 |
|
if (nTokens < 4) { |
434 |
|
|
435 |
|
} else { |
443 |
|
} |
444 |
|
break; |
445 |
|
|
446 |
< |
case "QuadraticBondType" : |
446 |
> |
case "Quartic" : |
447 |
|
if (nTokens < 5) { |
448 |
|
|
449 |
|
} else { |
459 |
|
} |
460 |
|
break; |
461 |
|
|
462 |
< |
case "PolynomialBondType " : |
462 |
> |
case "Polynomial" : |
463 |
|
if (nTokens < 2 || nTokens % 2 != 0) { |
464 |
|
|
465 |
|
} else { |
512 |
|
//switch is a maintain nightmare |
513 |
|
switch(bt) { |
514 |
|
|
515 |
< |
case "HarmonicBendType" : |
515 |
> |
case "Harmonic" : |
516 |
|
|
517 |
|
if (nTokens < 1) { |
518 |
|
|
522 |
|
bendType = new HarmonicBendType(theta0, ktheta); |
523 |
|
} |
524 |
|
break; |
525 |
< |
case "GhostBendType" : |
525 |
> |
case "GhostBend" : |
526 |
|
if (nTokens < 1) { |
527 |
|
|
528 |
|
} else { |
531 |
|
} |
532 |
|
break; |
533 |
|
|
534 |
< |
case "UreyBradleyBendType" : |
534 |
> |
case "UreyBradley" : |
535 |
|
if (nTokens < 3) { |
536 |
|
|
537 |
|
} else { |
542 |
|
} |
543 |
|
break; |
544 |
|
|
545 |
< |
case "CubicBendType" : |
545 |
> |
case "Cubic" : |
546 |
|
if (nTokens < 4) { |
547 |
|
|
548 |
|
} else { |
556 |
|
} |
557 |
|
break; |
558 |
|
|
559 |
< |
case "QuadraticBendType" : |
559 |
> |
case "Quartic" : |
560 |
|
if (nTokens < 5) { |
561 |
|
|
562 |
|
} else { |
572 |
|
} |
573 |
|
break; |
574 |
|
|
575 |
< |
case "PolynomialBendType " : |
575 |
> |
case "Polynomial" : |
576 |
|
if (nTokens < 2 || nTokens % 2 != 0) { |
577 |
|
|
578 |
|
} else { |
607 |
|
std::string at3; |
608 |
|
std::string at4; |
609 |
|
std::string tt; |
610 |
< |
TorsionType* bendType = NULL; |
610 |
> |
TorsionType* torsionType = NULL; |
611 |
|
|
612 |
|
int nTokens = tokenizer.countTokens(); |
613 |
|
|
626 |
|
|
627 |
|
switch(tt) { |
628 |
|
|
629 |
< |
case "CubicTorsionType" : |
629 |
> |
case "Cubic" : |
630 |
|
if (nTokens < 4) { |
631 |
|
|
632 |
|
} else { |
640 |
|
} |
641 |
|
break; |
642 |
|
|
643 |
< |
case "QuadraticTorsionType" : |
643 |
> |
case "Quartic" : |
644 |
|
if (nTokens < 5) { |
645 |
|
|
646 |
|
} else { |
656 |
|
} |
657 |
|
break; |
658 |
|
|
659 |
< |
case "PolynomialTorsionType " : |
659 |
> |
case "Polynomial" : |
660 |
|
if (nTokens < 2 || nTokens % 2 != 0) { |
661 |
|
|
662 |
|
} else { |
673 |
|
} |
674 |
|
|
675 |
|
break; |
676 |
< |
case "CharmmTorsionType" : |
676 |
> |
case "Charmm" : |
677 |
|
|
678 |
|
if (nTokens < 3 || nTokens % 3 != 0) { |
679 |
|
|
694 |
|
|
695 |
|
} |
696 |
|
|
697 |
< |
if (bendType != NULL) { |
698 |
< |
addTorsionType(at1, at2, at3, bendType); |
697 |
> |
if (torsionType != NULL) { |
698 |
> |
addTorsionType(at1, at2, at3, at4, torsionType); |
699 |
|
} |
700 |
|
} |
701 |
< |
|
701 |
> |
*/ |
702 |
|
} //end namespace oopse |