76 |
|
std::string line; |
77 |
|
char buffer[bufferSize]; |
78 |
|
int lineNo = 0; |
79 |
+ |
int atomIdent = getNAtomType() + 1; //atom's indent begins from 1 (since only fortran's array begins from 1) |
80 |
|
ParseState currentSection = DUFF::UnknownSection; |
81 |
|
|
82 |
|
while(ffStream.getline(buffer, bufferSize)){ |
90 |
|
|
91 |
|
switch(currentSection) { |
92 |
|
case DUFF::AtomTypeSection : |
93 |
< |
parseAtomType(line, lineNo); |
93 |
> |
parseAtomType(line, lineNo, atomIdent); |
94 |
|
break; |
95 |
|
|
96 |
+ |
case DUFF::DirectionalAtomTypeSection : |
97 |
+ |
parseDirectionalAtomType(line, lineNo); |
98 |
+ |
break; |
99 |
+ |
|
100 |
|
case DUFF::BondTypeSection : |
101 |
|
parseBondType(line, lineNo); |
102 |
|
break; |
146 |
|
delete ffStream; |
147 |
|
} |
148 |
|
|
144 |
– |
|
149 |
|
void DUFF::parseAtomType(const std::string& line, int lineNo, int& ident){ |
150 |
|
StringTokenizer tokenizer(line); |
151 |
|
int nTokens = tokenizer.countTokens(); |
153 |
|
//in AtomTypeSection, a line at least contains 5 tokens |
154 |
|
//atomTypeName, is Directional, isLJ, isCharge and mass |
155 |
|
if (nTokens < 5) { |
156 |
< |
sprintf( painCave.errMsg, |
153 |
< |
"Not enough tokens when parsing DUFF Force Field : %s\n" |
154 |
< |
"in line %d : %s\n", |
155 |
< |
filename.c_str(), lineNo, line); |
156 |
< |
painCave.severity = OOPSE_ERROR; |
157 |
< |
painCave.isFatal = 1; |
158 |
< |
simError(); |
159 |
< |
|
160 |
< |
|
156 |
> |
|
157 |
|
} else { |
158 |
|
|
159 |
|
std::string atomTypeName = tokenizer.nextToken(); |
197 |
|
atomType->setName(atomTypeName); |
198 |
|
atomType->setMass(mass); |
199 |
|
|
200 |
< |
//by default, all of the properties in AtomTypeProperties is set to 0 |
201 |
< |
//In Lennard-Jones Force Field, we only need to set Lennard-Jones to true |
202 |
< |
atomType->setLennardJones(); |
200 |
> |
if (isLJ) { |
201 |
> |
atomType->setLennardJones(); |
202 |
> |
} |
203 |
|
|
204 |
+ |
if (isCharge) { |
205 |
+ |
atomType->setCharge(); |
206 |
+ |
} |
207 |
+ |
|
208 |
|
atomType->setIdent(ident); |
209 |
|
|
210 |
|
atomType->complete(); |
264 |
|
|
265 |
|
} |
266 |
|
|
267 |
< |
dAtomType->setDipole(isDipole); |
268 |
< |
dAtomType->setSticky(isSticky); |
267 |
> |
if (isDipole) { |
268 |
> |
dAtomType->setDipole(); |
269 |
> |
} |
270 |
|
|
271 |
+ |
if (isSticky) { |
272 |
+ |
dAtomType->setSticky(); |
273 |
+ |
} |
274 |
+ |
|
275 |
|
Mat3x3d inertialMat; |
276 |
|
inertialMat(0, 0) = Ixx; |
277 |
|
inertialMat(1, 1) = Ixx; |