1 |
tim |
1768 |
/* |
2 |
|
|
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
3 |
|
|
* |
4 |
|
|
* Contact: oopse@oopse.org |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or |
7 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
8 |
|
|
* as published by the Free Software Foundation; either version 2.1 |
9 |
|
|
* of the License, or (at your option) any later version. |
10 |
|
|
* All we ask is that proper credit is given for our work, which includes |
11 |
|
|
* - but is not limited to - adding the above copyright notice to the beginning |
12 |
|
|
* of your source code files, and to any copyright notice that you may distribute |
13 |
|
|
* with programs based on this work. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU Lesser General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
21 |
|
|
* along with this program; if not, write to the Free Software |
22 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 |
|
|
* |
24 |
|
|
*/ |
25 |
|
|
|
26 |
|
|
#include "io/BendTypesSectionParser.hpp" |
27 |
tim |
1784 |
#include "types/HarmonicBendType.hpp" |
28 |
|
|
#include "types/UreyBradleyBendType.hpp" |
29 |
|
|
#include "types/CubicBendType.hpp" |
30 |
tim |
1789 |
#include "types/QuarticBendType.hpp" |
31 |
tim |
1784 |
#include "types/PolynomialBendType.hpp" |
32 |
tim |
1800 |
#include "UseTheForce/ForceField.hpp" |
33 |
tim |
1768 |
namespace oopse { |
34 |
|
|
|
35 |
|
|
BendTypesSectionParser::BendTypesSectionParser() { |
36 |
|
|
setSectionName("BendTypes"); |
37 |
tim |
1800 |
|
38 |
|
|
stringToEnumMap_["Harmonic"] = btHarmonic; |
39 |
|
|
stringToEnumMap_["GhostBend"] = btGhostBend; |
40 |
|
|
stringToEnumMap_["UreyBradley"] = btUreyBradley; |
41 |
|
|
stringToEnumMap_["Cubic"] = btCubic; |
42 |
|
|
stringToEnumMap_["Quartic"] = btQuartic; |
43 |
|
|
stringToEnumMap_["Polynomial"] = btPolynomial; |
44 |
tim |
1768 |
} |
45 |
|
|
|
46 |
|
|
void BendTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){ |
47 |
|
|
StringTokenizer tokenizer(line); |
48 |
|
|
std::string at1; |
49 |
|
|
std::string at2; |
50 |
|
|
std::string at3; |
51 |
|
|
std::string bt; |
52 |
|
|
double theta0; |
53 |
|
|
BendType* bendType = NULL; |
54 |
|
|
|
55 |
|
|
int nTokens = tokenizer.countTokens(); |
56 |
|
|
|
57 |
|
|
if (nTokens < 5) { |
58 |
|
|
|
59 |
|
|
return; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
at1 = tokenizer.nextToken(); |
63 |
|
|
at2 = tokenizer.nextToken(); |
64 |
|
|
at3 = tokenizer.nextToken(); |
65 |
|
|
bt = tokenizer.nextToken(); |
66 |
|
|
theta0 = tokenizer.nextTokenAsDouble(); |
67 |
|
|
nTokens -= 5; |
68 |
|
|
|
69 |
|
|
//switch is a maintain nightmare |
70 |
|
|
switch(bt) { |
71 |
|
|
|
72 |
tim |
1800 |
case btHarmonic : |
73 |
tim |
1768 |
|
74 |
|
|
if (nTokens < 1) { |
75 |
|
|
|
76 |
|
|
} else { |
77 |
|
|
|
78 |
|
|
double ktheta = tokenizer.nextTokenAsDouble(); |
79 |
|
|
bendType = new HarmonicBendType(theta0, ktheta); |
80 |
|
|
} |
81 |
|
|
break; |
82 |
tim |
1800 |
case btGhostBend : |
83 |
tim |
1768 |
if (nTokens < 1) { |
84 |
|
|
|
85 |
|
|
} else { |
86 |
|
|
double ktheta = tokenizer.nextTokenAsDouble(); |
87 |
|
|
bendType = new HarmonicBendType(theta0, ktheta); |
88 |
|
|
} |
89 |
|
|
break; |
90 |
|
|
|
91 |
tim |
1800 |
case btUreyBradley : |
92 |
tim |
1768 |
if (nTokens < 3) { |
93 |
|
|
|
94 |
|
|
} else { |
95 |
|
|
double ktheta = tokenizer.nextTokenAsDouble(); |
96 |
|
|
double s0 = tokenizer.nextTokenAsDouble(); |
97 |
|
|
double kub = tokenizer.nextTokenAsDouble(); |
98 |
|
|
bendType = new UreyBradleyBendType(theta0, ktheta, s0, kub); |
99 |
|
|
} |
100 |
|
|
break; |
101 |
|
|
|
102 |
tim |
1800 |
case btCubic : |
103 |
tim |
1768 |
if (nTokens < 4) { |
104 |
|
|
|
105 |
|
|
} else { |
106 |
|
|
|
107 |
|
|
double k3 = tokenizer.nextTokenAsDouble(); |
108 |
|
|
double k2 = tokenizer.nextTokenAsDouble(); |
109 |
|
|
double k1 = tokenizer.nextTokenAsDouble(); |
110 |
|
|
double k0 = tokenizer.nextTokenAsDouble(); |
111 |
|
|
|
112 |
|
|
bendType = new CubicBendType(theta0, k3, k2, k1, k0); |
113 |
|
|
} |
114 |
|
|
break; |
115 |
|
|
|
116 |
tim |
1800 |
case btQuartic : |
117 |
tim |
1768 |
if (nTokens < 5) { |
118 |
|
|
|
119 |
|
|
} else { |
120 |
|
|
|
121 |
|
|
theta0 = tokenizer.nextTokenAsDouble(); |
122 |
|
|
double k4 = tokenizer.nextTokenAsDouble(); |
123 |
|
|
double k3 = tokenizer.nextTokenAsDouble(); |
124 |
|
|
double k2 = tokenizer.nextTokenAsDouble(); |
125 |
|
|
double k1 = tokenizer.nextTokenAsDouble(); |
126 |
|
|
double k0 = tokenizer.nextTokenAsDouble(); |
127 |
|
|
|
128 |
tim |
1789 |
bendType = new QuarticBendType(theta0, k4, k3, k2, k1, k0); |
129 |
tim |
1768 |
} |
130 |
|
|
break; |
131 |
|
|
|
132 |
tim |
1800 |
case btPolynomial : |
133 |
tim |
1768 |
if (nTokens < 2 || nTokens % 2 != 0) { |
134 |
|
|
|
135 |
|
|
} else { |
136 |
|
|
int nPairs = nTokens / 2; |
137 |
|
|
int power; |
138 |
|
|
double coefficient; |
139 |
|
|
PolynomialBendType* pbt = new PolynomialBendType(); |
140 |
|
|
|
141 |
|
|
for (int i = 0; i < nPairs; ++i) { |
142 |
|
|
power = tokenizer.nextTokenAsInt(); |
143 |
|
|
coefficient = tokenizer.nextTokenAsDouble(); |
144 |
|
|
pbt->setCoefficient(power, coefficient); |
145 |
|
|
} |
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
break; |
149 |
|
|
|
150 |
|
|
default: |
151 |
|
|
|
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
if (bendType != NULL) { |
155 |
|
|
ff.addBendType(at1, at2, at3, bendType); |
156 |
|
|
} |
157 |
|
|
} |
158 |
|
|
|
159 |
tim |
1800 |
BendTypeEnum BendTypesSectionParser::getTorsionTypeEnum(const std::string& str) { |
160 |
|
|
std::map<std::string, BondTypeEnum>::iterator i; |
161 |
|
|
i = stringToEnumMap_.find(str); |
162 |
|
|
|
163 |
|
|
return i == stringToEnumMap_.end() ? TorsionTypesSectionParser::ttUnknown : i->second; |
164 |
|
|
} |
165 |
|
|
|
166 |
tim |
1768 |
} //end namespace oopse |
167 |
|
|
|
168 |
|
|
|