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

Comparing branches/new_design/OOPSE-4/src/io/TorsionTypesSectionParser.cpp (file contents):
Revision 1798 by tim, Tue Nov 30 03:32:12 2004 UTC vs.
Revision 1799 by tim, Tue Nov 30 03:49:22 2004 UTC

# Line 22 | Line 22
22   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23   *
24   */
25 <
25 >
26   #include "io/TorsionTypesSectionParser.hpp"
27   #include "types/TorsionType.hpp"
28   #include "types/CubicTorsionType.hpp"
29   #include "types/QuarticTorsionType.hpp"
30 + #include "types/PolynomialTorsionType.hpp"
31   #include "types/CharmmTorsionType.hpp"
32   #include "UseTheForce/ForceField.hpp"
33  
# Line 34 | Line 35 | TorsionTypesSectionParser::TorsionTypesSectionParser()
35  
36   TorsionTypesSectionParser::TorsionTypesSectionParser() {
37      setSectionName("TorsionTypes");
38 +
39 +
40 +    stringToEnumMap_["Cubic"] = ttCubic;
41 +    stringToEnumMap_["Quartic"] = ttQuartic;
42 +    stringToEnumMap_["Polynomial"] = ttPolynomial;
43 +    stringToEnumMap_["Charmm"] =  ttCharmm;
44 +
45   }
46  
47   void TorsionTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){
48      StringTokenizer tokenizer(line);
41    std::string at1;
42    std::string at2;
43    std::string at3;
44    std::string at4;
45    std::string tt;
49      TorsionType* torsionType = NULL;
50  
51      int nTokens = tokenizer.countTokens();
# Line 52 | Line 55 | void TorsionTypesSectionParser::parseLine(ForceField&
55          return;
56      }
57      
58 <    at1 = tokenizer.nextToken();
59 <    at2 = tokenizer.nextToken();
60 <    at3 = tokenizer.nextToken();
61 <    at4 = tokenizer.nextToken();
62 <    tt = tokenizer.nextToken();
58 >    std::string at1 = tokenizer.nextToken();
59 >    std::string at2 = tokenizer.nextToken();
60 >    std::string at3 = tokenizer.nextToken();
61 >    std::string at4 = tokenizer.nextToken();
62 >    TorsionTypeEnum tt = getTorsionTypeEnum(tokenizer.nextToken());
63  
64      nTokens -= 5;
65  
66      switch(tt) {
67              
68 <        case "Cubic" :
68 >        case TorsionTypesSectionParser::ttCubic :
69              if (nTokens < 4) {
70  
71              } else {
# Line 76 | Line 79 | void TorsionTypesSectionParser::parseLine(ForceField&
79              }
80              break;
81              
82 <        case "Quartic" :
82 >        case TorsionTypesSectionParser::ttQuartic:
83              if (nTokens < 5) {
84  
85              } else {
# Line 87 | Line 90 | void TorsionTypesSectionParser::parseLine(ForceField&
90                  double k1 = tokenizer.nextTokenAsDouble();
91                  double k0 = tokenizer.nextTokenAsDouble();
92                  
93 <                torsionType = new QuadraticTorsionType( k4, k3, k2, k1, k0);
93 >                torsionType = new QuarticTorsionType( k4, k3, k2, k1, k0);
94              }
95              break;
96  
97 <        case "Polynomial" :
97 >        /*
98 >        case TorsionTypesSectionParser::ttPolynomial:
99              if (nTokens < 2 || nTokens % 2 != 0) {
100  
101              } else {
# Line 108 | Line 112 | void TorsionTypesSectionParser::parseLine(ForceField&
112              }
113              
114              break;
115 <        case "Charmm" :
115 >         */    
116 >        case TorsionTypesSectionParser::ttCharmm:
117              
118              if (nTokens < 3 || nTokens % 3 != 0) {
119  
# Line 125 | Line 130 | void TorsionTypesSectionParser::parseLine(ForceField&
130                      ctt->setCharmmTorsionParameter(kchi, n, delta);
131                  }
132              }
133 +
134 +            break;
135 +            
136 +        case TorsionTypesSectionParser::ttUnknown :
137          default:
138 +
139 +            break;
140              
141      }
142  
# Line 135 | Line 146 | void TorsionTypesSectionParser::parseLine(ForceField&
146  
147   }
148  
149 + TorsionTypesSectionParser::TorsionTypeEnum TorsionTypesSectionParser::getTorsionTypeEnum(const std::string& str) {
150 +    std::map<std::string, TorsionTypeEnum>::iterator i;
151 +    i = stringToEnumMap_.find(str);
152 +
153 +    return i == stringToEnumMap_.end() ? TorsionTypesSectionParser::ttUnknown : i->second;
154 + }
155 +
156   } //end namespace oopse
157  
158  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines