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 |
+ |
//the order of adding section parsers are important |
55 |
+ |
//DirectionalAtomTypesSectionParser should be added before AtomTypesSectionParser Since |
56 |
+ |
//These two section parsers will actually create "real" AtomTypes (AtomTypesSectionParser will create |
57 |
+ |
//AtomType and DirectionalAtomTypesSectionParser will creat DirectionalAtomType which is a subclass |
58 |
+ |
//of AtomType, therefore it should come first). Other AtomTypes Section Parser will not create the |
59 |
+ |
//"real" AtomType, they only add and set some attribute of the AtomType. Thus their order are not |
60 |
+ |
//important. AtomTypesSectionParser should be added before other atom type section parsers. |
61 |
+ |
//Make sure they are added after DirectionalAtomTypesSectionParser and AtomTypesSectionParser. |
62 |
+ |
//The order of BondTypesSectionParser, BendTypesSectionParser and TorsionTypesSectionParser are |
63 |
+ |
//not important. |
64 |
+ |
spMan_.push_back(new DirectionalAtomTypesSectionParser()); |
65 |
+ |
spMan_.push_back(new AtomTypesSectionParser()); |
66 |
+ |
spMan_.push_back(new LennardJonesAtomTypesSectionParser()); |
67 |
+ |
spMan_.push_back(new ElectrostaticAtomTypesSectionParser()); |
68 |
+ |
spMan_.push_back(new EAMAtomTypesSectionParser()); |
69 |
+ |
spMan_.push_back(new StickyAtomTypesSectionParser()); |
70 |
+ |
spMan_.push_back(new BondTypesSectionParser()); |
71 |
+ |
spMan_.push_back(new BendTypesSectionParser()); |
72 |
+ |
spMan_.push_back(new TorsionTypesSectionParser()); |
73 |
+ |
|
74 |
+ |
} |
75 |
+ |
|
76 |
+ |
void DUFF::parse(const std::string& filename) { |
77 |
+ |
ifstrstream* ffStream; |
78 |
+ |
ffStream = openForceFieldFile(filename); |
79 |
+ |
|
80 |
+ |
spMan_.parse(*ffStream, *this); |
81 |
+ |
|
82 |
+ |
ForceField::AtomTypeContainer::MapTypeIterator i; |
83 |
+ |
AtomType* at; |
84 |
+ |
|
85 |
+ |
for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) { |
86 |
+ |
at->makeFortranAtomType(); |
87 |
+ |
} |
88 |
+ |
|
89 |
+ |
for (at = atomTypeCont_.beginType(i); at != NULL; at = atomTypeCont_.nextType(i)) { |
90 |
+ |
at->complete(); |
91 |
+ |
} |
92 |
+ |
|
93 |
+ |
} |
94 |
+ |
|
95 |
+ |
/* |
96 |
|
ParseState DUFF::getSection(const std::string& section) { |
97 |
|
ParseState result; |
98 |
|
|
124 |
|
|
125 |
|
void DUFF::parse(const std::string& filename) { |
126 |
|
ifstrstream* ffStream; |
127 |
< |
ffStream = openForceFiledFile(filename); |
127 |
> |
ffStream = openForceFieldFile(filename); |
128 |
|
const int bufferSize = 65535; |
129 |
|
std::string line; |
130 |
|
char buffer[bufferSize]; |
291 |
|
StringTokenizer tokenizer(line); |
292 |
|
int nTokens = tokenizer.countTokens(); |
293 |
|
|
294 |
< |
//in irectionalAtomTypeSection, a line at least contains 6 tokens |
294 |
> |
//in DirectionalAtomTypeSection, a line at least contains 6 tokens |
295 |
|
//AtomTypeName, isDipole, isSticky, I_xx, I_yy and I_zz |
296 |
|
if (nTokens < 6) { |
297 |
< |
|
297 |
> |
std::cerr << "Not enought tokens" << std::endl; |
298 |
|
} else { |
299 |
|
|
300 |
|
|
327 |
|
|
328 |
|
Mat3x3d inertialMat; |
329 |
|
inertialMat(0, 0) = Ixx; |
330 |
< |
inertialMat(1, 1) = Ixx; |
331 |
< |
inertialMat(2, 2) = Ixx; |
330 |
> |
inertialMat(1, 1) = Iyy; |
331 |
> |
inertialMat(2, 2) = Izz; |
332 |
|
dAtomType->setI(inertialMat); |
333 |
|
|
334 |
|
//read dipole moment |
411 |
|
|
412 |
|
//switch is a maintain nightmare |
413 |
|
switch(bt) { |
414 |
< |
case "FixedBondType" : |
414 |
> |
case "Fixed" : |
415 |
|
bondType = new FixedBondType(); |
416 |
|
break; |
417 |
|
|
418 |
< |
case "HarmonicBondType" : |
418 |
> |
case "Harmonic" : |
419 |
|
if (nTokens < 1) { |
420 |
|
|
421 |
|
} else { |
426 |
|
|
427 |
|
break; |
428 |
|
|
429 |
< |
case "CubicBondType" : |
429 |
> |
case "Cubic" : |
430 |
|
if (nTokens < 4) { |
431 |
|
|
432 |
|
} else { |
440 |
|
} |
441 |
|
break; |
442 |
|
|
443 |
< |
case "QuadraticBondType" : |
443 |
> |
case "Quartic" : |
444 |
|
if (nTokens < 5) { |
445 |
|
|
446 |
|
} else { |
456 |
|
} |
457 |
|
break; |
458 |
|
|
459 |
< |
case "PolynomialBondType " : |
459 |
> |
case "Polynomial" : |
460 |
|
if (nTokens < 2 || nTokens % 2 != 0) { |
461 |
|
|
462 |
|
} else { |
509 |
|
//switch is a maintain nightmare |
510 |
|
switch(bt) { |
511 |
|
|
512 |
< |
case "HarmonicBendType" : |
512 |
> |
case "Harmonic" : |
513 |
|
|
514 |
|
if (nTokens < 1) { |
515 |
|
|
519 |
|
bendType = new HarmonicBendType(theta0, ktheta); |
520 |
|
} |
521 |
|
break; |
522 |
< |
case "GhostBendType" : |
522 |
> |
case "GhostBend" : |
523 |
|
if (nTokens < 1) { |
524 |
|
|
525 |
|
} else { |
528 |
|
} |
529 |
|
break; |
530 |
|
|
531 |
< |
case "UreyBradleyBendType" : |
531 |
> |
case "UreyBradley" : |
532 |
|
if (nTokens < 3) { |
533 |
|
|
534 |
|
} else { |
539 |
|
} |
540 |
|
break; |
541 |
|
|
542 |
< |
case "CubicBendType" : |
542 |
> |
case "Cubic" : |
543 |
|
if (nTokens < 4) { |
544 |
|
|
545 |
|
} else { |
553 |
|
} |
554 |
|
break; |
555 |
|
|
556 |
< |
case "QuadraticBendType" : |
556 |
> |
case "Quartic" : |
557 |
|
if (nTokens < 5) { |
558 |
|
|
559 |
|
} else { |
569 |
|
} |
570 |
|
break; |
571 |
|
|
572 |
< |
case "PolynomialBendType " : |
572 |
> |
case "Polynomial" : |
573 |
|
if (nTokens < 2 || nTokens % 2 != 0) { |
574 |
|
|
575 |
|
} else { |
604 |
|
std::string at3; |
605 |
|
std::string at4; |
606 |
|
std::string tt; |
607 |
< |
TorsionType* bendType = NULL; |
607 |
> |
TorsionType* torsionType = NULL; |
608 |
|
|
609 |
|
int nTokens = tokenizer.countTokens(); |
610 |
|
|
623 |
|
|
624 |
|
switch(tt) { |
625 |
|
|
626 |
< |
case "CubicTorsionType" : |
626 |
> |
case "Cubic" : |
627 |
|
if (nTokens < 4) { |
628 |
|
|
629 |
|
} else { |
637 |
|
} |
638 |
|
break; |
639 |
|
|
640 |
< |
case "QuadraticTorsionType" : |
640 |
> |
case "Quartic" : |
641 |
|
if (nTokens < 5) { |
642 |
|
|
643 |
|
} else { |
653 |
|
} |
654 |
|
break; |
655 |
|
|
656 |
< |
case "PolynomialTorsionType " : |
656 |
> |
case "Polynomial" : |
657 |
|
if (nTokens < 2 || nTokens % 2 != 0) { |
658 |
|
|
659 |
|
} else { |
670 |
|
} |
671 |
|
|
672 |
|
break; |
673 |
< |
case "CharmmTorsionType" : |
673 |
> |
case "Charmm" : |
674 |
|
|
675 |
|
if (nTokens < 3 || nTokens % 3 != 0) { |
676 |
|
|
691 |
|
|
692 |
|
} |
693 |
|
|
694 |
< |
if (bendType != NULL) { |
695 |
< |
addTorsionType(at1, at2, at3, bendType); |
694 |
> |
if (torsionType != NULL) { |
695 |
> |
addTorsionType(at1, at2, at3, at4, torsionType); |
696 |
|
} |
697 |
|
} |
698 |
< |
|
698 |
> |
*/ |
699 |
|
} //end namespace oopse |