45#include "types/BondTypeParser.hpp"
49#include "types/CubicBondType.hpp"
51#include "types/HarmonicBondType.hpp"
52#include "types/MorseBondType.hpp"
55#include "types/ShiftedMieBondType.hpp"
56#include "utils/OpenMDException.hpp"
62 BondTypeParser::BondTypeParser() {
63 stringToEnumMap_[
"Fixed"] = btFixed;
64 stringToEnumMap_[
"Harmonic"] = btHarmonic;
65 stringToEnumMap_[
"Cubic"] = btCubic;
66 stringToEnumMap_[
"Quartic"] = btQuartic;
67 stringToEnumMap_[
"Polynomial"] = btPolynomial;
68 stringToEnumMap_[
"Morse"] = btMorse;
69 stringToEnumMap_[
"ShiftedMie"] = btShiftedMie;
72 BondType* BondTypeParser::parseTypeAndPars(
const std::string& type,
73 std::vector<RealType> pars) {
74 std::string line(type);
76 std::vector<RealType>::iterator it;
77 for (it = pars.begin(); it != pars.end(); ++it) {
79 line.append(std::to_string(*it));
82 return parseLine(line, 1.0);
85 BondType* BondTypeParser::parseLine(
const std::string& line,
89 int nTokens = tokenizer.countTokens();
95 BondTypeEnum bt = getBondTypeEnum(tokenizer.nextToken());
103 RealType b0 = tokenizer.nextTokenAsDouble();
112 RealType b0 = tokenizer.nextTokenAsDouble();
113 RealType kb = tokenizer.nextTokenAsDouble();
123 RealType b0 = tokenizer.nextTokenAsDouble();
124 RealType k3 = tokenizer.nextTokenAsDouble();
125 RealType k2 = tokenizer.nextTokenAsDouble();
126 RealType k1 = tokenizer.nextTokenAsDouble();
127 RealType k0 = tokenizer.nextTokenAsDouble();
137 RealType b0 = tokenizer.nextTokenAsDouble();
138 RealType k4 = tokenizer.nextTokenAsDouble();
139 RealType k3 = tokenizer.nextTokenAsDouble();
140 RealType k2 = tokenizer.nextTokenAsDouble();
141 RealType k1 = tokenizer.nextTokenAsDouble();
142 RealType k0 = tokenizer.nextTokenAsDouble();
150 if (nTokens < 3 || nTokens % 2 != 1) {
153 RealType b0 = tokenizer.nextTokenAsDouble();
156 int nPairs = nTokens / 2;
158 RealType coefficient;
161 for (
int i = 0; i < nPairs; ++i) {
162 power = tokenizer.nextTokenAsInt();
163 coefficient = tokenizer.nextTokenAsDouble();
164 pbt->setCoefficient(power, coefficient);
174 RealType b0 = tokenizer.nextTokenAsDouble();
175 RealType D = tokenizer.nextTokenAsDouble();
176 RealType beta = tokenizer.nextTokenAsDouble();
185 RealType sigma = tokenizer.nextTokenAsDouble();
186 RealType epsilon = tokenizer.nextTokenAsDouble();
187 int nRep = tokenizer.nextTokenAsInt();
188 int mAtt = tokenizer.nextTokenAsInt();
202 BondTypeParser::BondTypeEnum BondTypeParser::getBondTypeEnum(
203 const std::string& str) {
204 std::map<std::string, BondTypeEnum>::iterator i;
205 i = stringToEnumMap_.find(str);
207 return i == stringToEnumMap_.end() ? btUnknown : i->second;
BondType class is responsible for calculating the force and energy of the bond.
FixedBondType class is responsible for calculating the force and energy of the bond.
HarmonicBondType is the basic OpenMD bond type.
MorseBondType is a more realistic bond potential.
"types/PolynomialBondType.hpp"
ShiftedMieBondType is used to correct 1-3 bend interactions in the SDK force field.
The string tokenizer class allows an application to break a string into tokens The set of delimiters ...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.