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