OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
StretchBend.hpp
1/*
2 * Copyright (c) 2019 The University of Notre Dame. All Rights Reserved.
3 *
4 * The University of Notre Dame grants you ("Licensee") a
5 * non-exclusive, royalty free, license to use, modify and
6 * redistribute this software in source and binary code form, provided
7 * that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * This software is provided "AS IS," without a warranty of any
18 * kind. All express or implied conditions, representations and
19 * warranties, including any implied warranty of merchantability,
20 * fitness for a particular purpose or non-infringement, are hereby
21 * excluded. The University of Notre Dame and its licensors shall not
22 * be liable for any damages suffered by licensee as a result of
23 * using, modifying or distributing the software or its
24 * derivatives. In no event will the University of Notre Dame or its
25 * licensors be liable for any lost revenue, profit or data, or for
26 * direct, indirect, special, consequential, incidental or punitive
27 * damages, however caused and regardless of the theory of liability,
28 * arising out of the use of or inability to use software, even if the
29 * University of Notre Dame has been advised of the possibility of
30 * such damages.
31 *
32 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33 * research, please cite the appropriate papers when you publish your
34 * work. Good starting points are:
35 *
36 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 */
42
43
44#ifndef PRIMITIVES_STRETCHBEND_HPP
45#define PRIMITIVES_STRETCHBEND_HPP
46
47#include "primitives/ShortRangeInteraction.hpp"
48#include "primitives/Atom.hpp"
49#include "types/BendType.hpp"
50
51namespace OpenMD {
52 struct BendData {
53 RealType angle;
54 RealType potential;
55 };
56
57 struct BendDataSet {
58 RealType deltaV;
59 BendData prev;
60 BendData curr;
61 };
62
63 class Bend : public ShortRangeInteraction {
64 public:
67 Bend(Atom* atom1, Atom* atom2, Atom* atom3, BendType* bt)
69 atoms_.resize(3);
70 atoms_[0] = atom1;
71 atoms_[1] = atom2;
72 atoms_[2] = atom3;
73 }
74
75 virtual ~Bend() {}
76 virtual void calcForce(RealType& angle, bool doParticlePot);
77
78 RealType getValue(int snapshotNo) {
79 Vector3d pos1 = atoms_[0]->getPos(snapshotNo);
80 Vector3d pos2 = atoms_[1]->getPos(snapshotNo);
81 Vector3d pos3 = atoms_[2]->getPos(snapshotNo);
82
83 Vector3d r21 = pos1 - pos2;
84 snapshotMan_->getSnapshot(snapshotNo)->wrapVector(r21);
85 RealType d21 = r21.length();
86
87 Vector3d r23 = pos3 - pos2;
88 snapshotMan_->getSnapshot(snapshotNo)->wrapVector(r23);
89 RealType d23 = r23.length();
90
91 RealType cosTheta = dot(r21, r23) / (d21 * d23);
92
93 //check roundoff
94 if (cosTheta > 1.0) {
95 cosTheta = 1.0;
96 } else if (cosTheta < -1.0) {
97 cosTheta = -1.0;
98 }
99
100 return acos(cosTheta);
101 }
102
103
104 RealType getPotential() {
105 return potential_;
106 }
107
108 Atom* getAtomA() {
109 return atoms_[0];
110 }
111
112 Atom* getAtomB() {
113 return atoms_[1];
114 }
115
116 Atom* getAtomC() {
117 return atoms_[2];
118 }
119
120 BendType * getBendType() {
121 return bendType_;
122 }
123
124 virtual std::string getName() { return name_;}
125 /** Sets the name of this bend for selections */
126 virtual void setName(const std::string& name) { name_ = name;}
127
129 v->visit(this);
130 }
131
132 protected:
133
134 RealType potential_;
135 BendType* bendType_; /**< bend type */
136 std::string name_;
137
138 };
139} //end namespace OpenMD
140#endif //PRIMITIVES_BEND_HPP
141
virtual std::string getName()
Returns the name of this ShortRangeInteraction.
virtual void calcForce(RealType &angle, bool doParticlePot)
Definition Bend.cpp:56
BendType * bendType_
bend type
Definition Bend.hpp:129
RealType getValue(int snapshotNo)
Returns the value of this ShortRangeInteraction in specified snapshot.
void accept(BaseVisitor *v)
virtual void setName(const std::string &name)
Sets the name of this bend for selections.
A ShortRangeInteraction holds some bookeeping data for bonded interactions (e.g.
virtual RealType getValue()
Returns the current value of this ShortRangeInteraction.
virtual RealType getPrevValue()
Returns the previous value of this ShortRangeInteraction.
void wrapVector(Vector3d &v)
Wrapping the vector according to periodic boundary condition.
Definition Snapshot.cpp:337
Real length()
Returns the length of this vector.
Definition Vector.hpp:393
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Real dot(const DynamicVector< Real > &v1, const DynamicVector< Real > &v2)
Returns the dot product of two DynamicVectors.