ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/UseTheForce/DUFF.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-4/src/UseTheForce/DUFF.cpp (file contents):
Revision 1765 by tim, Mon Nov 22 20:55:52 2004 UTC vs.
Revision 1783 by tim, Wed Nov 24 21:33:00 2004 UTC

# Line 28 | Line 28
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  
# Line 37 | Line 47 | ForceFieldFactory::getInstance()->registerForceField("
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      
# Line 71 | Line 124 | void DUFF::parse(const std::string& filename) {
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];
# Line 358 | Line 411 | void DUFF::parseBondType(const std::string& line, int
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 {
# Line 373 | Line 426 | void DUFF::parseBondType(const std::string& line, int
426  
427              break;
428  
429 <        case "CubicBondType" :
429 >        case "Cubic" :
430              if (nTokens < 4) {
431  
432              } else {
# Line 387 | Line 440 | void DUFF::parseBondType(const std::string& line, int
440              }
441              break;
442              
443 <        case "QuadraticBondType" :
443 >        case "Quartic" :
444              if (nTokens < 5) {
445  
446              } else {
# Line 403 | Line 456 | void DUFF::parseBondType(const std::string& line, int
456              }
457              break;
458  
459 <        case "PolynomialBondType " :
459 >        case "Polynomial" :
460              if (nTokens < 2 || nTokens % 2 != 0) {
461  
462              } else {
# Line 456 | Line 509 | void DUFF::parseBendType(const std::string& line, int
509      //switch is a maintain nightmare
510      switch(bt) {
511              
512 <        case "HarmonicBendType" :
512 >        case "Harmonic" :
513              
514              if (nTokens < 1) {
515  
# Line 466 | Line 519 | void DUFF::parseBendType(const std::string& line, int
519                  bendType = new HarmonicBendType(theta0, ktheta);
520              }
521              break;
522 <        case "GhostBendType" :
522 >        case "GhostBend" :
523              if (nTokens < 1) {
524  
525              } else {
# Line 475 | Line 528 | void DUFF::parseBendType(const std::string& line, int
528              }
529              break;            
530  
531 <        case "UreyBradleyBendType" :
531 >        case "UreyBradley" :
532              if (nTokens < 3) {
533  
534              } else {
# Line 486 | Line 539 | void DUFF::parseBendType(const std::string& line, int
539              }
540              break;
541              
542 <        case "CubicBendType" :
542 >        case "Cubic" :
543              if (nTokens < 4) {
544  
545              } else {
# Line 500 | Line 553 | void DUFF::parseBendType(const std::string& line, int
553              }
554              break;
555              
556 <        case "QuadraticBendType" :
556 >        case "Quartic" :
557              if (nTokens < 5) {
558  
559              } else {
# Line 516 | Line 569 | void DUFF::parseBendType(const std::string& line, int
569              }
570              break;
571  
572 <        case "PolynomialBendType " :
572 >        case "Polynomial" :
573              if (nTokens < 2 || nTokens % 2 != 0) {
574  
575              } else {
# Line 551 | Line 604 | void DUFF::parseTorsionType(const std::string& line, i
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  
# Line 570 | Line 623 | void DUFF::parseTorsionType(const std::string& line, i
623  
624      switch(tt) {
625              
626 <        case "CubicTorsionType" :
626 >        case "Cubic" :
627              if (nTokens < 4) {
628  
629              } else {
# Line 584 | Line 637 | void DUFF::parseTorsionType(const std::string& line, i
637              }
638              break;
639              
640 <        case "QuadraticTorsionType" :
640 >        case "Quartic" :
641              if (nTokens < 5) {
642  
643              } else {
# Line 600 | Line 653 | void DUFF::parseTorsionType(const std::string& line, i
653              }
654              break;
655  
656 <        case "PolynomialTorsionType " :
656 >        case "Polynomial" :
657              if (nTokens < 2 || nTokens % 2 != 0) {
658  
659              } else {
# Line 617 | Line 670 | void DUFF::parseTorsionType(const std::string& line, i
670              }
671              
672              break;
673 <        case "CharmmTorsionType" :
673 >        case "Charmm" :
674              
675              if (nTokens < 3 || nTokens % 3 != 0) {
676  
# Line 638 | Line 691 | void DUFF::parseTorsionType(const std::string& line, i
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines