--- trunk/src/applications/hydrodynamics/HydrodynamicsModel.cpp 2006/02/22 20:35:16 891 +++ trunk/src/applications/hydrodynamics/HydrodynamicsModel.cpp 2009/11/25 20:02:06 1390 @@ -6,19 +6,10 @@ * redistribute this software in source and binary code form, provided * that the following conditions are met: * - * 1. Acknowledgement of the program authors must be made in any - * publication of scientific results based in part on use of the - * program. An acceptable form of acknowledgement is citation of - * the article in which the program was described (Matthew - * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher - * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented - * Parallel Simulation Engine for Molecular Dynamics," - * J. Comput. Chem. 26, pp. 252-271 (2005)) - * - * 2. Redistributions of source code must retain the above copyright + * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - * 3. Redistributions in binary form must reproduce the above copyright + * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. @@ -37,139 +28,147 @@ * arising out of the use of or inability to use software, even if the * University of Notre Dame has been advised of the possibility of * such damages. + * + * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your + * research, please cite the appropriate papers when you publish your + * work. Good starting points are: + * + * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). + * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [4] Vardeman & Gezelter, in progress (2009). */ +#include "applications/hydrodynamics/HydrodynamicsModel.hpp" +#include "hydrodynamics/Shape.hpp" +#include "hydrodynamics/Sphere.hpp" +#include "hydrodynamics/Ellipsoid.hpp" +#include "applications/hydrodynamics/CompositeShape.hpp" -#include "applications/hydrodynamics/HydrodynamicsModel.hpp" -#include "math/LU.hpp" -#include "math/DynamicRectMatrix.hpp" -#include "math/SquareMatrix3.hpp" -namespace oopse { -/** - * Reference: - * Beatriz Carrasco and Jose Gracia de la Torre, Hydrodynamic Properties of Rigid Particles: - * Comparison of Different Modeling and Computational Procedures. - * Biophysical Journal, 75(6), 3044, 1999 - */ -bool HydrodynamicsModel::calcHydrodyanmicsProps(double eta) { - if (!createBeads(beads_)) { - std::cout << "can not create beads" << std::endl; - return false; - } - - int nbeads = beads_.size(); - DynamicRectMatrix B(3*nbeads, 3*nbeads); - DynamicRectMatrix C(3*nbeads, 3*nbeads); - Mat3x3d I; - for (std::size_t i = 0; i < nbeads; ++i) { - for (std::size_t j = 0; j < nbeads; ++j) { - Mat3x3d Tij; - if (i != j ) { - Vector3d Rij = beads_[i].pos - beads_[j].pos; - double rij = Rij.length(); - double rij2 = rij * rij; - double sumSigma2OverRij2 = ((beads_[i].radius*beads_[i].radius) + (beads_[i].radius*beads_[i].radius)) / rij2; - Mat3x3d tmpMat; - tmpMat = outProduct(beads_[i].pos, beads_[j].pos) / rij2; - double constant = 8.0 * NumericConstant::PI * eta * rij; - Tij = ((1.0 + sumSigma2OverRij2/3.0) * I + (1.0 - sumSigma2OverRij2) * tmpMat ) / constant; - }else { - double constant = 1.0 / (6.0 * NumericConstant::PI * eta * beads_[i].radius); - Tij(0, 0) = constant; - Tij(1, 1) = constant; - Tij(2, 2) = constant; - } - B.setSubMatrix(i*3, j*3, Tij); - } - } +namespace OpenMD { + + bool HydrodynamicsModel::calcHydroProps(Shape* shape, RealType viscosity, RealType temperature) { + return false; + } + + void HydrodynamicsModel::writeHydroProps(std::ostream& os) { - //invert B Matrix - invertMatrix(B, C); + Vector3d center; + Mat6x6d Xi, D; - //prepare U Matrix relative to arbitrary origin O(0.0, 0.0, 0.0) - std::vector U; - for (int i = 0; i < nbeads; ++i) { - Mat3x3d currU; - currU.setupSkewMat(beads_[i].pos); - U.push_back(currU); - } + os << sd_->getType() << "\t"; - //calculate Xi matrix at arbitrary origin O - Mat3x3d Xitt; - Mat3x3d Xirr; - Mat3x3d Xitr; - - for (std::size_t i = 0; i < nbeads; ++i) { - for (std::size_t j = 0; j < nbeads; ++j) { - Mat3x3d Cij; - C.getSubMatrix(i*3, j*3, Cij); - - Xitt += Cij; - Xirr += U[i] * Cij; - Xitr += U[i] * Cij * U[j]; - } - } + //center of resistance - //invert Xi to get Diffusion Tensor at arbitrary origin O - RectMatrix Xi; - RectMatrix Do; - Xi.setSubMatrix(0, 0, Xitt); - Xi.setSubMatrix(0, 3, Xitr.transpose()); - Xi.setSubMatrix(3, 0, Xitr); - Xi.setSubMatrix(3, 3, Xitt); - invertMatrix(Xi, Do); + center = cr_->getCOR(); - Mat3x3d Dott; //translational diffusion tensor at arbitrary origin O - Mat3x3d Dorr; //rotational diffusion tensor at arbitrary origin O - Mat3x3d Dotr; //translation-rotation couplingl diffusion tensor at arbitrary origin O - Do.getSubMatrix(0, 0 , Dott); - Do.getSubMatrix(3, 0, Dotr); - Do.getSubMatrix(3, 3, Dorr); + os << center[0] << "\t" << center[1] << "\t" << center[2] << "\t"; + + //resistance tensor at center of resistance + //translation - //calculate center of diffusion - Mat3x3d tmpMat; - tmpMat(0, 0) = Dorr(1, 1) + Dorr(2, 2); - tmpMat(0, 1) = - Dorr(0, 1); - tmpMat(0, 2) = -Dorr(0, 2); - tmpMat(1, 0) = -Dorr(0, 1); - tmpMat(1, 1) = Dorr(0, 0) + Dorr(2, 2); - tmpMat(1, 2) = -Dorr(1, 2); - tmpMat(2, 0) = -Dorr(0, 2); - tmpMat(2, 1) = -Dorr(1, 2); - tmpMat(2, 2) = Dorr(1, 1) + Dorr(0, 0); + Xi = cr_->getXi(); - Vector3d tmpVec; - tmpVec[0] = Dotr(1, 2) - Dotr(2, 1); - tmpVec[1] = Dotr(2, 0) - Dotr(0, 2); - tmpVec[2] = Dotr(0, 1) - Dotr(1, 0); - - Vector3d rod = tmpMat.inverse() * tmpVec; + os << Xi(0, 0) << "\t" << Xi(0, 1) << "\t" << Xi(0, 2) << "\t" + << Xi(1, 0) << "\t" << Xi(1, 1) << "\t" << Xi(1, 2) << "\t" + << Xi(2, 0) << "\t" << Xi(2, 1) << "\t" << Xi(2, 2) << "\t"; + + //rotation-translation + os << Xi(0, 3) << "\t" << Xi(0, 4) << "\t" << Xi(0, 5) << "\t" + << Xi(1, 3) << "\t" << Xi(1, 4) << "\t" << Xi(1, 5) << "\t" + << Xi(2, 3) << "\t" << Xi(2, 4) << "\t" << Xi(2, 5) << "\t"; + + //translation-rotation + os << Xi(3, 0) << "\t" << Xi(3, 1) << "\t" << Xi(3, 2) << "\t" + << Xi(4, 0) << "\t" << Xi(4, 1) << "\t" << Xi(4, 2) << "\t" + << Xi(5, 0) << "\t" << Xi(5, 1) << "\t" << Xi(5, 2) << "\t"; + + //rotation + os << Xi(3, 3) << "\t" << Xi(3, 4) << "\t" << Xi(3, 5) << "\t" + << Xi(4, 3) << "\t" << Xi(4, 4) << "\t" << Xi(4, 5) << "\t" + << Xi(5, 3) << "\t" << Xi(5, 4) << "\t" << Xi(5, 5) << "\t"; + + + //diffusion tensor at center of resistance + //translation - //calculate Diffusion Tensor at center of diffusion - Mat3x3d Uod; - Uod.setupSkewMat(rod); + D = cr_->getD(); + + os << D(0, 0) << "\t" << D(0, 1) << "\t" << D(0, 2) << "\t" + << D(1, 0) << "\t" << D(1, 1) << "\t" << D(1, 2) << "\t" + << D(2, 0) << "\t" << D(2, 1) << "\t" << D(2, 2) << "\t"; - Mat3x3d Ddtt; //translational diffusion tensor at diffusion center - Mat3x3d Ddtr; //rotational diffusion tensor at diffusion center - Mat3x3d Ddrr; //translation-rotation couplingl diffusion tensor at diffusion tensor + //rotation-translation + os << D(0, 3) << "\t" << D(0, 4) << "\t" << D(0, 5) << "\t" + << D(1, 3) << "\t" << D(1, 4) << "\t" << D(1, 5) << "\t" + << D(2, 3) << "\t" << D(2, 4) << "\t" << D(2, 5) << "\t"; - Ddtt = Dott - Uod * Dorr * Uod + Dotr.transpose() * Uod - Uod * Dotr; - Ddrr = Dorr; - Ddtr = Dotr + Dorr * Uod; + //translation-rotation + os << D(3, 0) << "\t" << D(3, 1) << "\t" << D(3, 2) << "\t" + << D(4, 0) << "\t" << D(4, 1) << "\t" << D(4, 2) << "\t" + << D(5, 0) << "\t" << D(5, 1) << "\t" << D(5, 2) << "\t"; - props_.diffCenter = rod; - props_.transDiff = Ddtt; - props_.transRotDiff = Ddtr; - props_.rotDiff = Ddrr; + //rotation + os << D(3, 3) << "\t" << D(3, 4) << "\t" << D(3, 5) << "\t" + << D(4, 3) << "\t" << D(4, 4) << "\t" << D(4, 5) << "\t" + << D(5, 3) << "\t" << D(5, 4) << "\t" << D(5, 5) << "\t"; + + //--------------------------------------------------------------------- + + //center of diffusion - return true; -} + center = cd_->getCOR(); -void HydrodynamicsModel::writeBeads(std::ostream& os) { + os << center[0] << "\t" << center[1] << "\t" << center[2] << "\t"; + + //resistance tensor at center of diffusion + //translation -} + Xi = cd_->getXi(); -void HydrodynamicsModel::writeDiffCenterAndDiffTensor(std::ostream& os) { + os << Xi(0, 0) << "\t" << Xi(0, 1) << "\t" << Xi(0, 2) << "\t" + << Xi(1, 0) << "\t" << Xi(1, 1) << "\t" << Xi(1, 2) << "\t" + << Xi(2, 0) << "\t" << Xi(2, 1) << "\t" << Xi(2, 2) << "\t"; + + //rotation-translation + os << Xi(0, 3) << "\t" << Xi(0, 4) << "\t" << Xi(0, 5) << "\t" + << Xi(1, 3) << "\t" << Xi(1, 4) << "\t" << Xi(1, 5) << "\t" + << Xi(2, 3) << "\t" << Xi(2, 4) << "\t" << Xi(2, 5) << "\t"; + + //translation-rotation + os << Xi(3, 0) << "\t" << Xi(3, 1) << "\t" << Xi(3, 2) << "\t" + << Xi(4, 0) << "\t" << Xi(4, 1) << "\t" << Xi(4, 2) << "\t" + << Xi(5, 0) << "\t" << Xi(5, 1) << "\t" << Xi(5, 2) << "\t"; + + //rotation + os << Xi(3, 3) << "\t" << Xi(3, 4) << "\t" << Xi(3, 5) << "\t" + << Xi(4, 3) << "\t" << Xi(4, 4) << "\t" << Xi(4, 5) << "\t" + << Xi(5, 3) << "\t" << Xi(5, 4) << "\t" << Xi(5, 5) << "\t"; + + + //diffusion tensor at center of diffusion + //translation -} + D = cd_->getD(); + os << D(0, 0) << "\t" << D(0, 1) << "\t" << D(0, 2) << "\t" + << D(1, 0) << "\t" << D(1, 1) << "\t" << D(1, 2) << "\t" + << D(2, 0) << "\t" << D(2, 1) << "\t" << D(2, 2) << "\t"; + + //rotation-translation + os << D(0, 3) << "\t" << D(0, 4) << "\t" << D(0, 5) << "\t" + << D(1, 3) << "\t" << D(1, 4) << "\t" << D(1, 5) << "\t" + << D(2, 3) << "\t" << D(2, 4) << "\t" << D(2, 5) << "\t"; + + //translation-rotation + os << D(3, 0) << "\t" << D(3, 1) << "\t" << D(3, 2) << "\t" + << D(4, 0) << "\t" << D(4, 1) << "\t" << D(4, 2) << "\t" + << D(5, 0) << "\t" << D(5, 1) << "\t" << D(5, 2) << "\t"; + + //rotation + os << D(3, 3) << "\t" << D(3, 4) << "\t" << D(3, 5) << "\t" + << D(4, 3) << "\t" << D(4, 4) << "\t" << D(4, 5) << "\t" + << D(5, 3) << "\t" << D(5, 4) << "\t" << D(5, 5) << "\n"; + + } + }