42 |
|
#include "io/LennardJonesAtomTypesSectionParser.hpp" |
43 |
|
#include "types/AtomType.hpp" |
44 |
|
#include "UseTheForce/ForceField.hpp" |
45 |
+ |
#include "utils/simError.h" |
46 |
|
namespace oopse { |
47 |
|
|
48 |
|
LennardJonesAtomTypesSectionParser::LennardJonesAtomTypesSectionParser() { |
53 |
|
StringTokenizer tokenizer(line); |
54 |
|
int nTokens = tokenizer.countTokens(); |
55 |
|
|
56 |
< |
//in AtomTypeSection, a line at least contains 2 tokens |
57 |
< |
//atomTypeName and mass |
56 |
> |
//in LennardJonesAtomTypesSectionParser, a line at least contains 3 tokens |
57 |
> |
//atomTypeName, epsilon and sigma |
58 |
|
if (nTokens < 3) { |
59 |
< |
|
59 |
> |
sprintf(painCave.errMsg, "LennardJonesAtomTypesSectionParser Error: Not enough tokens at line %d\n", |
60 |
> |
lineNo); |
61 |
> |
painCave.isFatal = 1; |
62 |
> |
simError(); |
63 |
|
} else { |
64 |
|
|
65 |
|
std::string atomTypeName = tokenizer.nextToken(); |
69 |
|
LJParam ljParam; |
70 |
|
ljParam.epsilon = tokenizer.nextTokenAsDouble(); |
71 |
|
ljParam.sigma = tokenizer.nextTokenAsDouble(); |
72 |
+ |
ljParam.soft_pot = 0; |
73 |
+ |
|
74 |
+ |
if (tokenizer.hasMoreTokens()) { |
75 |
+ |
std::string pot_type = tokenizer.nextToken(); |
76 |
+ |
if (pot_type == "soft") { |
77 |
+ |
ljParam.soft_pot = 1; |
78 |
+ |
} |
79 |
+ |
} |
80 |
+ |
|
81 |
|
atomType->addProperty(new LJParamGenericData("LennardJones", ljParam)); |
82 |
|
atomType->setLennardJones(); |
83 |
+ |
}else { |
84 |
+ |
sprintf(painCave.errMsg, "LennardJonesAtomTypesSectionParser Error: Atom Type [%s] is not created yet\n", atomTypeName.c_str()); |
85 |
+ |
painCave.isFatal = 1; |
86 |
+ |
simError(); |
87 |
|
} |
88 |
|
|
89 |
|
} |