OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
BeadModel.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 "hydrodynamics/BeadModel.hpp"
46
47#include "hydrodynamics/CompositeShape.hpp"
48#include "hydrodynamics/Ellipsoid.hpp"
49#include "hydrodynamics/Sphere.hpp"
51#include "math/LU.hpp"
53#include "utils/Constants.hpp"
54#include "utils/simError.h"
55
56namespace OpenMD {
57
58 /**
59 * References:
60 *
61 * For the General Hydro Framework:
62 * Beatriz Carrasco and Jose Gracia de la Torre; "Hydrodynamic
63 * Properties of Rigid Particles: Comparison of Different Modeling
64 * and Computational Procedures", Biophysical Journal, 75(6), 3044,
65 * 1999
66 *
67 * Xiuquan Sun, Teng Lin, and J. Daniel Gezelter; "Langevin dynamics
68 * for rigid bodies of arbitrary shape", J. Chem. Phys. 128, 234107
69 * (2008)
70 *
71 * For overlapping beads and overlapping volume:
72 *
73 * Beatriz Carrasco and Jose Garcia de la Torre and Peter Zipper;
74 * "Calculation of hydrodynamic properties of macromolecular bead
75 * models with overlapping spheres", Eur Biophys J (1999) 28:
76 * 510-515
77 *
78 * For overlapping volume between two spherical beads:
79 * http://mathworld.wolfram.com/Sphere-SphereIntersection.html
80 *
81 * For non-overlapping and overlapping translation-translation
82 * mobility tensors:
83 *
84 * Zuk, P. J., E. Wajnryb, K. A. Mizerski, and P. Szymczak;
85 * “Rotne–Prager–Yamakawa Approximation for Different-Sized
86 * Particles in Application to Macromolecular Bead Models.”, Journal
87 * of Fluid Mechanics, 741 (2014)
88 *
89 * For distinctions between centers of resistance and diffusion:
90 * Steven Harvey and Jose Garcia de la Torre; "Coordinate Systems
91 * for Modeling the Hydrodynamic Resistance and Diffusion
92 * Coefficients of Irregularly Shaped Rigid Macromolecules",
93 * Macromolecules 1980 13 (4), 960-964
94 **/
95 BeadModel::BeadModel() : ApproximateModel() { volumeOverlap_ = 0.0; }
96
97 void BeadModel::checkElement(std::size_t i) {
98 // checking if the radius is a non-negative value.
99 if (elements_[i].radius < 0) {
100 snprintf(
101 painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
102 "BeadModel::checkElement: There is a bead with a negative radius.\n"
103 "\tStarting from index 0, check bead (%lu).\n",
104 i);
105 painCave.isFatal = 1;
106 simError();
107 }
108 // if the bead's radius is below 1.0e-14, substitute by 1.0e-14;
109 // to avoid problem in the self-interaction part (i.e., to not divide by
110 // zero)
111 if (elements_[i].radius < 1.0e-14) elements_[i].radius = 1.0e-14;
112 }
113
114 RealType BeadModel::volumeCorrection() {
115 RealType volume(0.0);
116 for (std::vector<HydrodynamicsElement>::iterator iter = elements_.begin();
117 iter != elements_.end(); ++iter) {
118 volume += 4.0 / 3.0 * Constants::PI * pow((*iter).radius, 3);
119 }
120 // double loop double counts overlap volume Vij = Vji
121 volume -= 0.5 * volumeOverlap_;
122
123 return volume;
124 }
125
126 void BeadModel::writeElements(std::ostream& os) {
127 std::vector<HydrodynamicsElement>::iterator iter;
128 os << elements_.size() << std::endl;
129 os << "Generated by Hydro" << std::endl;
130 for (iter = elements_.begin(); iter != elements_.end(); ++iter) {
131 os << iter->name << "\t" << iter->pos[0] << "\t" << iter->pos[1] << "\t"
132 << iter->pos[2] << std::endl;
133 }
134 }
135
136 Mat3x3d BeadModel::interactionTensor(const std::size_t i, const std::size_t j,
137 const RealType viscosity) {
138 Mat3x3d Tij;
140 RealType c {};
141
142 if (i == j) {
143 // self interaction, there is no overlapping volume
144 c = 1.0 / (6.0 * Constants::PI * viscosity * elements_[i].radius);
145
146 Tij(0, 0) = c;
147 Tij(1, 1) = c;
148 Tij(2, 2) = c;
149
150 } else {
151 // non-self interaction: divided into overlapping and
152 // non-overlapping beads; the transitions between these cases
153 // are continuous
154
155 Vector3d Rij = elements_[i].pos - elements_[j].pos;
156 RealType rij = Rij.length();
157 RealType rij2 = rij * rij;
158
159 if (rij >= (elements_[i].radius + elements_[j].radius)) {
160 // non-overlapping beads
161 RealType a = ((elements_[i].radius * elements_[i].radius) +
162 (elements_[j].radius * elements_[j].radius)) /
163 rij2;
164 Mat3x3d op;
165 op = outProduct(Rij, Rij) / rij2;
166 c = 1.0 / (8.0 * Constants::PI * viscosity * rij);
167 RealType b1 = 1.0 + a / 3.0;
168 RealType b2 = 1.0 - a;
169 Tij = (b1 * I + b2 * op) * c;
170
171 } else if (rij > fabs(elements_[i].radius - elements_[j].radius) &&
172 rij < (elements_[i].radius + elements_[j].radius)) {
173 // overlapping beads, part I
174
175 RealType sum = (elements_[i].radius + elements_[j].radius);
176 RealType diff = (elements_[i].radius - elements_[j].radius);
177 RealType diff2 = diff * diff;
178
179 c = 1.0 / (6.0 * Constants::PI * viscosity *
180 (elements_[i].radius * elements_[j].radius));
181
182 RealType rij3 = rij2 * rij;
183 Mat3x3d op;
184 op = outProduct(Rij, Rij) / rij2;
185
186 RealType a = diff2 + 3.0 * rij2;
187 RealType ao = (16.0 * rij3 * sum - a * a) / (32.0 * rij3);
188
189 RealType b = diff2 - rij2;
190 RealType bo = (3.0 * b * b) / (32.0 * rij3);
191
192 Tij = (ao * I + bo * op) * c;
193
194 RealType v1 = (-rij + sum) * (-rij + sum);
195 RealType v2 = (rij2 + 2.0 * (rij * elements_[i].radius) -
196 3.0 * (elements_[i].radius * elements_[i].radius) +
197 2.0 * (rij * elements_[j].radius) +
198 6.0 * (elements_[i].radius * elements_[j].radius) -
199 3.0 * (elements_[j].radius * elements_[j].radius));
200
201 volumeOverlap_ += (Constants::PI / (12.0 * rij)) * v1 * v2;
202
203 } else {
204 // overlapping beads, part II: one bead inside the other
205
206 RealType rmin = std::min(elements_[i].radius, elements_[j].radius);
207 RealType rmax = std::max(elements_[i].radius, elements_[j].radius);
208
209 c = 1.0 / (6.0 * Constants::PI * viscosity * rmax);
210
211 Tij(0, 0) = c;
212 Tij(1, 1) = c;
213 Tij(2, 2) = c;
214
215 volumeOverlap_ += (4.0 / 3.0) * Constants::PI * pow(rmin, 3);
216 }
217 }
218
219 return Tij;
220 }
221
222} // namespace OpenMD
BeadModel()
References:
Definition BeadModel.cpp:95
static SquareMatrix< Real, Dim > identity()
Returns an identity matrix.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.