OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
UFFAtomTypesSectionParser.cpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#include "io/UFFAtomTypesSectionParser.hpp"
46
47#include "brains/ForceField.hpp"
48#include "types/UFFAdapter.hpp"
49#include "utils/simError.h"
50
51namespace OpenMD {
52
53 UFFAtomTypesSectionParser::UFFAtomTypesSectionParser(
54 ForceFieldOptions& options) :
55 options_(options) {
56 setSectionName("UFFAtomTypes");
57 }
58
59 void UFFAtomTypesSectionParser::parseLine(ForceField& ff,
60 const std::string& line,
61 int lineNo) {
62 StringTokenizer tokenizer(line);
63 int nTokens = tokenizer.countTokens();
64
65 // in UFFAtomTypesSectionParser, a line at least contains 12 tokens:
66 // Atom r1 theta0 x1 D1 zeta Z1 Vi Uj Xi Hard Radius
67
68 if (nTokens < 12) {
69 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
70 "UFFAtomTypesSectionParser Error: "
71 "Not enough tokens at line %d\n",
72 lineNo);
73 painCave.isFatal = 1;
74 simError();
75 } else {
76 std::string atomTypeName = tokenizer.nextToken();
77 AtomType* atomType = ff.getAtomType(atomTypeName);
78
79 if (atomType != NULL) {
80 UFFAdapter uffa = UFFAdapter(atomType);
81
82 RealType r1 = tokenizer.nextTokenAsDouble();
83 RealType theta0 = tokenizer.nextTokenAsDouble();
84 RealType x1 = tokenizer.nextTokenAsDouble();
85 RealType D1 = tokenizer.nextTokenAsDouble();
86 RealType zeta = tokenizer.nextTokenAsDouble();
87 RealType Z1 = tokenizer.nextTokenAsDouble();
88 RealType Vi = tokenizer.nextTokenAsDouble();
89 RealType Uj = tokenizer.nextTokenAsDouble();
90 RealType Xi = tokenizer.nextTokenAsDouble();
91 RealType Hard = tokenizer.nextTokenAsDouble();
92 RealType Radius = tokenizer.nextTokenAsDouble();
93
94 r1 *= options_.getDistanceUnitScaling();
95 theta0 *= options_.getAngleUnitScaling();
96 x1 *= options_.getDistanceUnitScaling();
97 D1 *= options_.getEnergyUnitScaling();
98 Z1 *= options_.getChargeUnitScaling();
99 Vi *= options_.getEnergyUnitScaling();
100 Uj *= options_.getEnergyUnitScaling();
101
102 uffa.makeUFF(r1, theta0, x1, D1, zeta, Z1, Vi, Uj, Xi, Hard, Radius);
103
104 } else {
105 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
106 "UFFAtomTypesSectionParser Error: Atom Type [%s]"
107 " has not been created yet\n",
108 atomTypeName.c_str());
109 painCave.isFatal = 1;
110 simError();
111 }
112 }
113 }
114
115 void UFFAtomTypesSectionParser::validateSection(ForceField&) {
116 // ForceField::AtomTypeContainer* atomTypes = ff.getAtomTypes();
117 // ForceField::AtomTypeContainer::MapTypeIterator i;
118 // AtomType* at;
119
120 // std::vector<AtomType*> uffTypes;
121
122 // for (at = atomTypes->beginType(i); at != NULL; at =
123 // atomTypes->nextType(i))
124 // {
125
126 // UFFAdapter uffa = UFFAdapter(at);
127 // if (uffa.isUFF())
128 // uffTypes.push_back(at);
129 // }
130
131 // for (std::size_t i = 0; i < uffTypes.size(); ++i) {
132 // RealType ri = uffTypes[i]->getR1();
133 // RealType chiI = uffTypes[i]->getXi();
134 // RealType Ra = uffTypes[i]->getX1();
135 // RealType ka = uffTypes[i]->getD1();
136
137 // for (std::size_t j = 0; j < uffTypes.size(); ++j) {
138 // RealType rj = uffTypes[j]->getR1();
139 // RealType chiJ = uffTypes[j]->getXi();
140 // RealType Rb = uffTypes[j]->getX1();
141 // RealType kb = uffTypes[j]->getD1();
142
143 // // Precompute the equilibrium bond distance
144 // // From equation 3
145 // rbo = -0.1332*(ri+rj)*log(bondorder);
146 // // From equation 4
147 // ren = ri*rj*(pow((sqrt(chiI) - sqrt(chiJ)),2.0)) / (chiI*ri +
148 // chiJ*rj);
149 // // From equation 2
150 // // NOTE: See http://towhee.sourceforge.net/forcefields/uff.html
151 // // There is a typo in the published paper
152 // rij = ri + rj + rbo - ren;
153
154 // kab = sqrt(ka * kb);
155
156 // // ka now represents the xij in equation 20 -- the expected vdw
157 // distance kaSquared = (Ra * Rb); ka = sqrt(kaSquared);
158 }
159} // namespace OpenMD
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.