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/TorsionTypesSectionParser.hpp" |
27 |
tim |
1784 |
#include "types/TorsionType.hpp" |
28 |
|
|
#include "types/CubicTorsionType.hpp" |
29 |
tim |
1798 |
#include "types/QuarticTorsionType.hpp" |
30 |
tim |
1784 |
#include "types/CharmmTorsionType.hpp" |
31 |
|
|
#include "UseTheForce/ForceField.hpp" |
32 |
tim |
1768 |
|
33 |
|
|
namespace oopse { |
34 |
|
|
|
35 |
|
|
TorsionTypesSectionParser::TorsionTypesSectionParser() { |
36 |
|
|
setSectionName("TorsionTypes"); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
void TorsionTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){ |
40 |
|
|
StringTokenizer tokenizer(line); |
41 |
|
|
std::string at1; |
42 |
|
|
std::string at2; |
43 |
|
|
std::string at3; |
44 |
|
|
std::string at4; |
45 |
|
|
std::string tt; |
46 |
|
|
TorsionType* torsionType = NULL; |
47 |
|
|
|
48 |
|
|
int nTokens = tokenizer.countTokens(); |
49 |
|
|
|
50 |
|
|
if (nTokens < 5) { |
51 |
|
|
|
52 |
|
|
return; |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
at1 = tokenizer.nextToken(); |
56 |
|
|
at2 = tokenizer.nextToken(); |
57 |
|
|
at3 = tokenizer.nextToken(); |
58 |
|
|
at4 = tokenizer.nextToken(); |
59 |
|
|
tt = tokenizer.nextToken(); |
60 |
|
|
|
61 |
|
|
nTokens -= 5; |
62 |
|
|
|
63 |
|
|
switch(tt) { |
64 |
|
|
|
65 |
|
|
case "Cubic" : |
66 |
|
|
if (nTokens < 4) { |
67 |
|
|
|
68 |
|
|
} else { |
69 |
|
|
|
70 |
|
|
double k3 = tokenizer.nextTokenAsDouble(); |
71 |
|
|
double k2 = tokenizer.nextTokenAsDouble(); |
72 |
|
|
double k1 = tokenizer.nextTokenAsDouble(); |
73 |
|
|
double k0 = tokenizer.nextTokenAsDouble(); |
74 |
|
|
|
75 |
|
|
torsionType = new CubicTorsionType(k3, k2, k1, k0); |
76 |
|
|
} |
77 |
|
|
break; |
78 |
|
|
|
79 |
|
|
case "Quartic" : |
80 |
|
|
if (nTokens < 5) { |
81 |
|
|
|
82 |
|
|
} else { |
83 |
|
|
|
84 |
|
|
double k4 = tokenizer.nextTokenAsDouble(); |
85 |
|
|
double k3 = tokenizer.nextTokenAsDouble(); |
86 |
|
|
double k2 = tokenizer.nextTokenAsDouble(); |
87 |
|
|
double k1 = tokenizer.nextTokenAsDouble(); |
88 |
|
|
double k0 = tokenizer.nextTokenAsDouble(); |
89 |
|
|
|
90 |
|
|
torsionType = new QuadraticTorsionType( k4, k3, k2, k1, k0); |
91 |
|
|
} |
92 |
|
|
break; |
93 |
|
|
|
94 |
|
|
case "Polynomial" : |
95 |
|
|
if (nTokens < 2 || nTokens % 2 != 0) { |
96 |
|
|
|
97 |
|
|
} else { |
98 |
|
|
int nPairs = nTokens / 2; |
99 |
|
|
int power; |
100 |
|
|
double coefficient; |
101 |
|
|
PolynomialTorsionType* ptt = new PolynomialTorsionType(); |
102 |
|
|
|
103 |
|
|
for (int i = 0; i < nPairs; ++i) { |
104 |
|
|
power = tokenizer.nextTokenAsInt(); |
105 |
|
|
coefficient = tokenizer.nextTokenAsDouble(); |
106 |
|
|
ptt->setCoefficient(power, coefficient); |
107 |
|
|
} |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
break; |
111 |
|
|
case "Charmm" : |
112 |
|
|
|
113 |
|
|
if (nTokens < 3 || nTokens % 3 != 0) { |
114 |
|
|
|
115 |
|
|
} else { |
116 |
|
|
int nSets = nTokens / 3; |
117 |
|
|
|
118 |
|
|
CharmmTorsionType* ctt = new CharmmTorsionType(); |
119 |
|
|
|
120 |
|
|
for (int i = 0; i < nSets; ++i) { |
121 |
|
|
double kchi = tokenizer.nextTokenAsDouble(); |
122 |
|
|
int n = tokenizer.nextTokenAsInt(); |
123 |
|
|
double delta = tokenizer.nextTokenAsDouble(); |
124 |
|
|
|
125 |
|
|
ctt->setCharmmTorsionParameter(kchi, n, delta); |
126 |
|
|
} |
127 |
|
|
} |
128 |
|
|
default: |
129 |
|
|
|
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
if (torsionType != NULL) { |
133 |
|
|
ff.addTorsionType(at1, at2, at3, at4, torsionType); |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
} //end namespace oopse |
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|