1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
42 |
|
#include "io/AtomTypesSectionParser.hpp" |
43 |
|
#include "types/AtomType.hpp" |
44 |
|
#include "UseTheForce/ForceField.hpp" |
45 |
+ |
#include "utils/simError.h" |
46 |
|
namespace oopse { |
47 |
|
|
48 |
< |
AtomTypesSectionParser::AtomTypesSectionParser() { |
48 |
> |
AtomTypesSectionParser::AtomTypesSectionParser() { |
49 |
|
setSectionName("AtomTypes"); |
50 |
< |
} |
50 |
> |
} |
51 |
|
|
52 |
< |
void AtomTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){ |
52 |
> |
void AtomTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){ |
53 |
|
StringTokenizer tokenizer(line); |
54 |
|
int nTokens = tokenizer.countTokens(); |
55 |
|
|
56 |
|
//in AtomTypeSection, a line at least contains 2 tokens |
57 |
|
//atomTypeName and mass |
58 |
|
if (nTokens < 2) { |
59 |
< |
|
59 |
> |
sprintf(painCave.errMsg, "AtomTypesSectionParser Error: Not enough tokens at line %d\n", |
60 |
> |
lineNo); |
61 |
> |
painCave.isFatal = 1; |
62 |
> |
simError(); |
63 |
> |
|
64 |
|
} else { |
65 |
|
|
66 |
< |
std::string atomTypeName = tokenizer.nextToken(); |
67 |
< |
AtomType* atomType = ff.getAtomType(atomTypeName); |
66 |
> |
std::string atomTypeName = tokenizer.nextToken(); |
67 |
> |
AtomType* atomType = ff.getAtomType(atomTypeName); |
68 |
|
|
69 |
< |
if (atomType == NULL) { |
70 |
< |
atomType = new AtomType(); |
71 |
< |
int ident = ff.getNAtomType() + 1; |
72 |
< |
atomType->setIdent(ident); |
73 |
< |
atomType->setName(atomTypeName); |
74 |
< |
ff.addAtomType(atomTypeName, atomType); |
75 |
< |
} |
69 |
> |
if (atomType == NULL) { |
70 |
> |
atomType = new AtomType(); |
71 |
> |
int ident = ff.getNAtomType() + 1; |
72 |
> |
atomType->setIdent(ident); |
73 |
> |
atomType->setName(atomTypeName); |
74 |
> |
ff.addAtomType(atomTypeName, atomType); |
75 |
> |
} |
76 |
|
|
77 |
< |
double mass = tokenizer.nextTokenAsDouble(); |
78 |
< |
atomType->setMass(mass); |
79 |
< |
|
77 |
> |
double mass = tokenizer.nextTokenAsDouble(); |
78 |
> |
atomType->setMass(mass); |
79 |
> |
if (tokenizer.hasMoreTokens()) { |
80 |
> |
double nelectron = tokenizer.nextTokenAsDouble(); |
81 |
> |
atomType->addProperty(new DoubleGenericData("nelectron", nelectron)); |
82 |
> |
} |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
< |
} |
86 |
> |
} |
87 |
|
|
88 |
|
} //end namespace oopse |