OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
Ellipsoid.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/Ellipsoid.hpp"
46
47#include "math/LU.hpp"
48#include "utils/Constants.hpp"
49
50namespace OpenMD {
51
52 Ellipsoid::Ellipsoid(Vector3d origin, RealType rAxial, RealType rEquatorial,
53 Mat3x3d rotMat) :
54 origin_(origin),
55 rAxial_(rAxial), rEquatorial_(rEquatorial), rotMat_(rotMat) {
56 if (rAxial_ > rEquatorial_) {
57 rMajor_ = rAxial_;
58 rMinor_ = rEquatorial_;
59 } else {
60 rMajor_ = rEquatorial_;
61 rMinor_ = rAxial_;
62 }
63 }
64
65 bool Ellipsoid::isInterior(Vector3d pos) {
66 Vector3d r = pos - origin_;
67 Vector3d rbody = rotMat_ * r;
68
69 RealType xoverb = rbody[0] / rEquatorial_;
70 RealType yoverb = rbody[1] / rEquatorial_;
71 RealType zovera = rbody[2] / rAxial_;
72
73 bool result;
74 if (xoverb * xoverb + yoverb * yoverb + zovera * zovera < 1)
75 result = true;
76 else
77 result = false;
78
79 return result;
80 }
81
82 std::pair<Vector3d, Vector3d> Ellipsoid::getBoundingBox() {
83 std::pair<Vector3d, Vector3d> boundary;
84 // make a cubic box
85 RealType rad = rAxial_ > rEquatorial_ ? rAxial_ : rEquatorial_;
86 Vector3d r(rad, rad, rad);
87 boundary.first = origin_ - r;
88 boundary.second = origin_ + r;
89 return boundary;
90 }
91
92 HydroProp* Ellipsoid::getHydroProp(RealType viscosity) {
93 RealType a = rAxial_;
94 RealType b = rEquatorial_;
95 RealType a2 = a * a;
96 RealType b2 = b * b;
97
98 RealType p = a / b;
99 RealType S;
100 if (p > 1.0) {
101 // Ellipsoid is prolate:
102 S = 2.0 / sqrt(a2 - b2) * log((a + sqrt(a2 - b2)) / b);
103 } else {
104 // Ellipsoid is oblate:
105 S = 2.0 / sqrt(b2 - a2) * atan(sqrt(b2 - a2) / a);
106 }
107
108 RealType pi = Constants::PI;
109 RealType XittA =
110 16.0 * pi * viscosity * (a2 - b2) / ((2.0 * a2 - b2) * S - 2.0 * a);
111 RealType XittB = 32.0 * pi * viscosity * (a2 - b2) /
112 ((2.0 * a2 - 3.0 * b2) * S + 2.0 * a);
113 RealType XirrA =
114 32.0 / 3.0 * pi * viscosity * (a2 - b2) * b2 / (2.0 * a - b2 * S);
115 RealType XirrB = 32.0 / 3.0 * pi * viscosity * (a2 * a2 - b2 * b2) /
116 ((2.0 * a2 - b2) * S - 2.0 * a);
117
118 Mat6x6d Xi;
119
120 Xi(0, 0) = XittB;
121 Xi(1, 1) = XittB;
122 Xi(2, 2) = XittA;
123 Xi(3, 3) = XirrB;
124 Xi(4, 4) = XirrB;
125 Xi(5, 5) = XirrA;
126
127 Xi *= Constants::viscoConvert;
128
129 HydroProp* hprop = new HydroProp(V3Zero, Xi);
130 hprop->setName(getName());
131
132 return hprop;
133 }
134} // namespace OpenMD
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.