1 |
/* |
2 |
* Copyright (c) 2005 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. Acknowledgement of the program authors must be made in any |
10 |
* publication of scientific results based in part on use of the |
11 |
* program. An acceptable form of acknowledgement is citation of |
12 |
* the article in which the program was described (Matthew |
13 |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
* |
18 |
* 2. Redistributions of source code must retain the above copyright |
19 |
* notice, this list of conditions and the following disclaimer. |
20 |
* |
21 |
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
* notice, this list of conditions and the following disclaimer in the |
23 |
* documentation and/or other materials provided with the |
24 |
* distribution. |
25 |
* |
26 |
* This software is provided "AS IS," without a warranty of any |
27 |
* kind. All express or implied conditions, representations and |
28 |
* warranties, including any implied warranty of merchantability, |
29 |
* fitness for a particular purpose or non-infringement, are hereby |
30 |
* excluded. The University of Notre Dame and its licensors shall not |
31 |
* be liable for any damages suffered by licensee as a result of |
32 |
* using, modifying or distributing the software or its |
33 |
* derivatives. In no event will the University of Notre Dame or its |
34 |
* licensors be liable for any lost revenue, profit or data, or for |
35 |
* direct, indirect, special, consequential, incidental or punitive |
36 |
* damages, however caused and regardless of the theory of liability, |
37 |
* arising out of the use of or inability to use software, even if the |
38 |
* University of Notre Dame has been advised of the possibility of |
39 |
* such damages. |
40 |
*/ |
41 |
|
42 |
#include "applications/hydrodynamics/HydrodynamicsModel.hpp" |
43 |
#include "math/LU.hpp" |
44 |
#include "math/DynamicRectMatrix.hpp" |
45 |
#include "math/SquareMatrix3.hpp" |
46 |
namespace oopse { |
47 |
/** |
48 |
* Reference: |
49 |
* Beatriz Carrasco and Jose Gracia de la Torre, Hydrodynamic Properties of Rigid Particles: |
50 |
* Comparison of Different Modeling and Computational Procedures. |
51 |
* Biophysical Journal, 75(6), 3044, 1999 |
52 |
*/ |
53 |
bool HydrodynamicsModel::calcHydrodyanmicsProps(double eta) { |
54 |
if (!createBeads(beads_)) { |
55 |
std::cout << "can not create beads" << std::endl; |
56 |
return false; |
57 |
} |
58 |
|
59 |
int nbeads = beads_.size(); |
60 |
DynamicRectMatrix<double> B(3*nbeads, 3*nbeads); |
61 |
DynamicRectMatrix<double> C(3*nbeads, 3*nbeads); |
62 |
Mat3x3d I; |
63 |
for (std::size_t i = 0; i < nbeads; ++i) { |
64 |
for (std::size_t j = 0; j < nbeads; ++j) { |
65 |
Mat3x3d Tij; |
66 |
if (i != j ) { |
67 |
Vector3d Rij = beads_[i].pos - beads_[j].pos; |
68 |
double rij = Rij.length(); |
69 |
double rij2 = rij * rij; |
70 |
double sumSigma2OverRij2 = ((beads_[i].radius*beads_[i].radius) + (beads_[i].radius*beads_[i].radius)) / rij2; |
71 |
Mat3x3d tmpMat; |
72 |
tmpMat = outProduct(beads_[i].pos, beads_[j].pos) / rij2; |
73 |
double constant = 8.0 * NumericConstant::PI * eta * rij; |
74 |
Tij = ((1.0 + sumSigma2OverRij2/3.0) * I + (1.0 - sumSigma2OverRij2) * tmpMat ) / constant; |
75 |
}else { |
76 |
double constant = 1.0 / (6.0 * NumericConstant::PI * eta * beads_[i].radius); |
77 |
Tij(0, 0) = constant; |
78 |
Tij(1, 1) = constant; |
79 |
Tij(2, 2) = constant; |
80 |
} |
81 |
B.setSubMatrix(i*3, j*3, Tij); |
82 |
} |
83 |
} |
84 |
|
85 |
//invert B Matrix |
86 |
invertMatrix(B, C); |
87 |
|
88 |
//prepare U Matrix relative to arbitrary origin O(0.0, 0.0, 0.0) |
89 |
std::vector<Mat3x3d> U; |
90 |
for (int i = 0; i < nbeads; ++i) { |
91 |
Mat3x3d currU; |
92 |
currU.setupSkewMat(beads_[i].pos); |
93 |
U.push_back(currU); |
94 |
} |
95 |
|
96 |
//calculate Xi matrix at arbitrary origin O |
97 |
Mat3x3d Xitt; |
98 |
Mat3x3d Xirr; |
99 |
Mat3x3d Xitr; |
100 |
|
101 |
for (std::size_t i = 0; i < nbeads; ++i) { |
102 |
for (std::size_t j = 0; j < nbeads; ++j) { |
103 |
Mat3x3d Cij; |
104 |
C.getSubMatrix(i*3, j*3, Cij); |
105 |
|
106 |
Xitt += Cij; |
107 |
Xirr += U[i] * Cij; |
108 |
Xitr += U[i] * Cij * U[j]; |
109 |
} |
110 |
} |
111 |
|
112 |
//invert Xi to get Diffusion Tensor at arbitrary origin O |
113 |
RectMatrix<double, 6, 6> Xi; |
114 |
RectMatrix<double, 6, 6> Do; |
115 |
Xi.setSubMatrix(0, 0, Xitt); |
116 |
Xi.setSubMatrix(0, 3, Xitr.transpose()); |
117 |
Xi.setSubMatrix(3, 0, Xitr); |
118 |
Xi.setSubMatrix(3, 3, Xitt); |
119 |
invertMatrix(Xi, Do); |
120 |
|
121 |
Mat3x3d Dott; //translational diffusion tensor at arbitrary origin O |
122 |
Mat3x3d Dorr; //rotational diffusion tensor at arbitrary origin O |
123 |
Mat3x3d Dotr; //translation-rotation couplingl diffusion tensor at arbitrary origin O |
124 |
Do.getSubMatrix(0, 0 , Dott); |
125 |
Do.getSubMatrix(3, 0, Dotr); |
126 |
Do.getSubMatrix(3, 3, Dorr); |
127 |
|
128 |
//calculate center of diffusion |
129 |
Mat3x3d tmpMat; |
130 |
tmpMat(0, 0) = Dorr(1, 1) + Dorr(2, 2); |
131 |
tmpMat(0, 1) = - Dorr(0, 1); |
132 |
tmpMat(0, 2) = -Dorr(0, 2); |
133 |
tmpMat(1, 0) = -Dorr(0, 1); |
134 |
tmpMat(1, 1) = Dorr(0, 0) + Dorr(2, 2); |
135 |
tmpMat(1, 2) = -Dorr(1, 2); |
136 |
tmpMat(2, 0) = -Dorr(0, 2); |
137 |
tmpMat(2, 1) = -Dorr(1, 2); |
138 |
tmpMat(2, 2) = Dorr(1, 1) + Dorr(0, 0); |
139 |
|
140 |
Vector3d tmpVec; |
141 |
tmpVec[0] = Dotr(1, 2) - Dotr(2, 1); |
142 |
tmpVec[1] = Dotr(2, 0) - Dotr(0, 2); |
143 |
tmpVec[2] = Dotr(0, 1) - Dotr(1, 0); |
144 |
|
145 |
Vector3d rod = tmpMat.inverse() * tmpVec; |
146 |
|
147 |
//calculate Diffusion Tensor at center of diffusion |
148 |
Mat3x3d Uod; |
149 |
Uod.setupSkewMat(rod); |
150 |
|
151 |
Mat3x3d Ddtt; //translational diffusion tensor at diffusion center |
152 |
Mat3x3d Ddtr; //rotational diffusion tensor at diffusion center |
153 |
Mat3x3d Ddrr; //translation-rotation couplingl diffusion tensor at diffusion tensor |
154 |
|
155 |
Ddtt = Dott - Uod * Dorr * Uod + Dotr.transpose() * Uod - Uod * Dotr; |
156 |
Ddrr = Dorr; |
157 |
Ddtr = Dotr + Dorr * Uod; |
158 |
|
159 |
props_.diffCenter = rod; |
160 |
props_.transDiff = Ddtt; |
161 |
props_.transRotDiff = Ddtr; |
162 |
props_.rotDiff = Ddrr; |
163 |
|
164 |
return true; |
165 |
} |
166 |
|
167 |
void HydrodynamicsModel::writeBeads(std::ostream& os) { |
168 |
|
169 |
} |
170 |
|
171 |
void HydrodynamicsModel::writeDiffCenterAndDiffTensor(std::ostream& os) { |
172 |
|
173 |
} |
174 |
|
175 |
} |