| 44 | 
  | 
#include "math/DynamicRectMatrix.hpp" | 
| 45 | 
  | 
#include "math/SquareMatrix3.hpp" | 
| 46 | 
  | 
#include "utils/OOPSEConstant.hpp" | 
| 47 | 
< | 
#include "applications/hydrodynamics/Spheric.hpp" | 
| 48 | 
< | 
#include "applications/hydrodynamics/Ellipsoid.hpp" | 
| 47 | 
> | 
#include "hydrodynamics/Sphere.hpp" | 
| 48 | 
> | 
#include "hydrodynamics/Ellipsoid.hpp" | 
| 49 | 
  | 
#include "applications/hydrodynamics/CompositeShape.hpp" | 
| 50 | 
  | 
#include "math/LU.hpp" | 
| 51 | 
  | 
#include "utils/simError.h" | 
| 57 | 
  | 
 * Biophysical Journal, 75(6), 3044, 1999 | 
| 58 | 
  | 
 */ | 
| 59 | 
  | 
 | 
| 60 | 
< | 
ApproximationModel::ApproximationModel(StuntDouble* sd, SimInfo* info): HydrodynamicsModel(sd, info){ | 
| 61 | 
< | 
 | 
| 62 | 
< | 
} | 
| 63 | 
< | 
 | 
| 64 | 
< | 
bool ApproximationModel::calcHydroProps(Spheric* spheric, double viscosity, double temperature) { | 
| 65 | 
< | 
    return internalCalcHydroProps(static_cast<Shape*>(spheric), viscosity, temperature); | 
| 66 | 
< | 
} | 
| 67 | 
< | 
 | 
| 68 | 
< | 
bool ApproximationModel::calcHydroProps(Ellipsoid* ellipsoid, double viscosity, double temperature) { | 
| 69 | 
< | 
    return internalCalcHydroProps(static_cast<Shape*>(ellipsoid), viscosity, temperature); | 
| 70 | 
< | 
} | 
| 71 | 
< | 
bool ApproximationModel::calcHydroProps(CompositeShape* compositeShape, double viscosity, double temperature) { | 
| 72 | 
< | 
    return internalCalcHydroProps(static_cast<Shape*>(compositeShape), viscosity, temperature); | 
| 73 | 
< | 
} | 
| 74 | 
< | 
 | 
| 75 | 
< | 
void ApproximationModel::init() { | 
| 60 | 
> | 
  ApproximationModel::ApproximationModel(StuntDouble* sd, SimInfo* info): HydrodynamicsModel(sd, info){     | 
| 61 | 
> | 
  } | 
| 62 | 
> | 
   | 
| 63 | 
> | 
  void ApproximationModel::init() { | 
| 64 | 
  | 
    if (!createBeads(beads_)) { | 
| 65 | 
  | 
      sprintf(painCave.errMsg, "ApproximationModel::init() : Can not create beads\n"); | 
| 66 | 
  | 
      painCave.isFatal = 1; | 
| 67 | 
  | 
      simError();         | 
| 68 | 
  | 
    } | 
| 69 | 
< | 
 | 
| 70 | 
< | 
} | 
| 71 | 
< | 
 | 
| 72 | 
< | 
bool ApproximationModel::internalCalcHydroProps(Shape* shape, double viscosity, double temperature) { | 
| 73 | 
< | 
 | 
| 69 | 
> | 
     | 
| 70 | 
> | 
  } | 
| 71 | 
> | 
   | 
| 72 | 
> | 
  bool ApproximationModel::calcHydroProps(Shape* shape, RealType viscosity, RealType temperature) { | 
| 73 | 
> | 
     | 
| 74 | 
  | 
    bool ret = true; | 
| 75 | 
< | 
    HydroProps cr; | 
| 76 | 
< | 
    HydroProps cd; | 
| 75 | 
> | 
    HydroProp* cr = new HydroProp(); | 
| 76 | 
> | 
    HydroProp* cd = new HydroProp(); | 
| 77 | 
  | 
    calcHydroPropsAtCR(beads_, viscosity, temperature, cr); | 
| 78 | 
< | 
    //calcHydroPropsAtCD(beads_, viscosity, temperature, cd); | 
| 78 | 
> | 
    calcHydroPropsAtCD(beads_, viscosity, temperature, cd); | 
| 79 | 
  | 
    setCR(cr); | 
| 80 | 
  | 
    setCD(cd); | 
| 93 | 
– | 
     | 
| 81 | 
  | 
    return true;     | 
| 82 | 
< | 
} | 
| 83 | 
< | 
 | 
| 84 | 
< | 
bool ApproximationModel::calcHydroPropsAtCR(std::vector<BeadParam>& beads, double viscosity, double temperature, HydroProps& cr) { | 
| 85 | 
< | 
 | 
| 82 | 
> | 
  } | 
| 83 | 
> | 
   | 
| 84 | 
> | 
  bool ApproximationModel::calcHydroPropsAtCR(std::vector<BeadParam>& beads, RealType viscosity, RealType temperature, HydroProp* cr) { | 
| 85 | 
> | 
     | 
| 86 | 
  | 
    int nbeads = beads.size(); | 
| 87 | 
< | 
    DynamicRectMatrix<double> B(3*nbeads, 3*nbeads); | 
| 88 | 
< | 
    DynamicRectMatrix<double> C(3*nbeads, 3*nbeads); | 
| 87 | 
> | 
    DynamicRectMatrix<RealType> B(3*nbeads, 3*nbeads); | 
| 88 | 
> | 
    DynamicRectMatrix<RealType> C(3*nbeads, 3*nbeads); | 
| 89 | 
  | 
    Mat3x3d I; | 
| 90 | 
  | 
    I(0, 0) = 1.0; | 
| 91 | 
  | 
    I(1, 1) = 1.0; | 
| 92 | 
  | 
    I(2, 2) = 1.0; | 
| 93 | 
  | 
     | 
| 94 | 
  | 
    for (std::size_t i = 0; i < nbeads; ++i) { | 
| 95 | 
< | 
        for (std::size_t j = 0; j < nbeads; ++j) { | 
| 96 | 
< | 
            Mat3x3d Tij; | 
| 95 | 
> | 
      for (std::size_t j = 0; j < nbeads; ++j) { | 
| 96 | 
> | 
        Mat3x3d Tij; | 
| 97 | 
  | 
            if (i != j ) { | 
| 98 | 
< | 
                Vector3d Rij = beads[i].pos - beads[j].pos; | 
| 99 | 
< | 
                double rij = Rij.length(); | 
| 100 | 
< | 
                double rij2 = rij * rij; | 
| 101 | 
< | 
                double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                 | 
| 102 | 
< | 
                Mat3x3d tmpMat; | 
| 103 | 
< | 
                tmpMat = outProduct(Rij, Rij) / rij2; | 
| 104 | 
< | 
                double constant = 8.0 * NumericConstant::PI * viscosity * rij; | 
| 105 | 
< | 
                Tij = ((1.0 + sumSigma2OverRij2/3.0) * I + (1.0 - sumSigma2OverRij2) * tmpMat ) / constant; | 
| 98 | 
> | 
              Vector3d Rij = beads[i].pos - beads[j].pos; | 
| 99 | 
> | 
              RealType rij = Rij.length(); | 
| 100 | 
> | 
              RealType rij2 = rij * rij; | 
| 101 | 
> | 
              RealType sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                 | 
| 102 | 
> | 
              Mat3x3d tmpMat; | 
| 103 | 
> | 
              tmpMat = outProduct(Rij, Rij) / rij2; | 
| 104 | 
> | 
              RealType constant = 8.0 * NumericConstant::PI * viscosity * rij; | 
| 105 | 
> | 
              RealType tmp1 = 1.0 + sumSigma2OverRij2/3.0; | 
| 106 | 
> | 
              RealType tmp2 = 1.0 - sumSigma2OverRij2; | 
| 107 | 
> | 
              Tij = (tmp1 * I + tmp2 * tmpMat ) / constant; | 
| 108 | 
  | 
            }else { | 
| 109 | 
< | 
                double constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius); | 
| 110 | 
< | 
                Tij(0, 0) = constant; | 
| 111 | 
< | 
                Tij(1, 1) = constant; | 
| 112 | 
< | 
                Tij(2, 2) = constant; | 
| 109 | 
> | 
              RealType constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius); | 
| 110 | 
> | 
              Tij(0, 0) = constant; | 
| 111 | 
> | 
              Tij(1, 1) = constant; | 
| 112 | 
> | 
              Tij(2, 2) = constant; | 
| 113 | 
  | 
            } | 
| 114 | 
  | 
            B.setSubMatrix(i*3, j*3, Tij); | 
| 115 | 
< | 
        } | 
| 115 | 
> | 
      } | 
| 116 | 
  | 
    } | 
| 117 | 
< | 
 | 
| 117 | 
> | 
     | 
| 118 | 
  | 
    //invert B Matrix | 
| 119 | 
  | 
    invertMatrix(B, C); | 
| 120 | 
  | 
     | 
| 121 | 
  | 
    //prepare U Matrix relative to arbitrary origin O(0.0, 0.0, 0.0) | 
| 122 | 
  | 
    std::vector<Mat3x3d> U; | 
| 123 | 
  | 
    for (int i = 0; i < nbeads; ++i) { | 
| 124 | 
< | 
        Mat3x3d currU; | 
| 125 | 
< | 
        currU.setupSkewMat(beads[i].pos); | 
| 126 | 
< | 
        U.push_back(currU); | 
| 124 | 
> | 
      Mat3x3d currU; | 
| 125 | 
> | 
      currU.setupSkewMat(beads[i].pos); | 
| 126 | 
> | 
      U.push_back(currU); | 
| 127 | 
  | 
    } | 
| 128 | 
  | 
     | 
| 129 | 
  | 
    //calculate Xi matrix at arbitrary origin O | 
| 130 | 
  | 
    Mat3x3d Xiott; | 
| 131 | 
  | 
    Mat3x3d Xiorr; | 
| 132 | 
  | 
    Mat3x3d Xiotr; | 
| 133 | 
< | 
 | 
| 133 | 
> | 
     | 
| 134 | 
  | 
    //calculate the total volume | 
| 135 | 
< | 
 | 
| 136 | 
< | 
    double volume = 0.0; | 
| 135 | 
> | 
     | 
| 136 | 
> | 
    RealType volume = 0.0; | 
| 137 | 
  | 
    for (std::vector<BeadParam>::iterator iter = beads.begin(); iter != beads.end(); ++iter) { | 
| 138 | 
< | 
        volume += 4.0/3.0 * NumericConstant::PI * pow((*iter).radius,3); | 
| 138 | 
> | 
      volume += 4.0/3.0 * NumericConstant::PI * pow((*iter).radius,3); | 
| 139 | 
  | 
    } | 
| 140 | 
< | 
         | 
| 140 | 
> | 
     | 
| 141 | 
  | 
    for (std::size_t i = 0; i < nbeads; ++i) { | 
| 142 | 
< | 
        for (std::size_t j = 0; j < nbeads; ++j) { | 
| 143 | 
< | 
            Mat3x3d Cij; | 
| 144 | 
< | 
            C.getSubMatrix(i*3, j*3, Cij); | 
| 145 | 
< | 
             | 
| 146 | 
< | 
            Xiott += Cij; | 
| 147 | 
< | 
            Xiotr += U[i] * Cij; | 
| 148 | 
< | 
            //Xiorr += -U[i] * Cij * U[j] + (6 * viscosity * volume) * I;     | 
| 149 | 
< | 
            Xiorr += -U[i] * Cij * U[j];  | 
| 150 | 
< | 
        } | 
| 142 | 
> | 
      for (std::size_t j = 0; j < nbeads; ++j) { | 
| 143 | 
> | 
        Mat3x3d Cij; | 
| 144 | 
> | 
        C.getSubMatrix(i*3, j*3, Cij); | 
| 145 | 
> | 
         | 
| 146 | 
> | 
        Xiott += Cij; | 
| 147 | 
> | 
        Xiotr += U[i] * Cij; | 
| 148 | 
> | 
        //Xiorr += -U[i] * Cij * U[j] + (6 * viscosity * volume) * I;     | 
| 149 | 
> | 
        Xiorr += -U[i] * Cij * U[j];  | 
| 150 | 
> | 
      } | 
| 151 | 
  | 
    } | 
| 152 | 
< | 
 | 
| 153 | 
< | 
    const double convertConstant = 6.023; //convert poise.angstrom to amu/fs | 
| 152 | 
> | 
     | 
| 153 | 
> | 
    const RealType convertConstant = 6.023; //convert poise.angstrom to amu/fs | 
| 154 | 
  | 
    Xiott *= convertConstant; | 
| 155 | 
  | 
    Xiotr *= convertConstant; | 
| 156 | 
  | 
    Xiorr *= convertConstant; | 
| 157 | 
  | 
     | 
| 169 | 
– | 
 | 
| 158 | 
  | 
     | 
| 159 | 
+ | 
     | 
| 160 | 
  | 
    Mat3x3d tmp; | 
| 161 | 
  | 
    Mat3x3d tmpInv; | 
| 162 | 
  | 
    Vector3d tmpVec; | 
| 186 | 
  | 
    Xirrr = Xiorr - Uor * Xiott * Uor + Xiotr * Uor - Uor * Xiotr.transpose(); | 
| 187 | 
  | 
     | 
| 188 | 
  | 
 | 
| 189 | 
< | 
    SquareMatrix<double,6> Xir6x6; | 
| 190 | 
< | 
    SquareMatrix<double,6> Dr6x6; | 
| 189 | 
> | 
    SquareMatrix<RealType,6> Xir6x6; | 
| 190 | 
> | 
    SquareMatrix<RealType,6> Dr6x6; | 
| 191 | 
  | 
 | 
| 192 | 
  | 
    Xir6x6.setSubMatrix(0, 0, Xirtt); | 
| 193 | 
  | 
    Xir6x6.setSubMatrix(0, 3, Xirtr.transpose()); | 
| 203 | 
  | 
    Dr6x6.getSubMatrix(0, 3, Drrt); | 
| 204 | 
  | 
    Dr6x6.getSubMatrix(3, 0, Drtr); | 
| 205 | 
  | 
    Dr6x6.getSubMatrix(3, 3, Drrr); | 
| 206 | 
< | 
    double kt = OOPSEConstant::kB * temperature ; | 
| 206 | 
> | 
    RealType kt = OOPSEConstant::kB * temperature ; | 
| 207 | 
  | 
    Drtt *= kt; | 
| 208 | 
  | 
    Drrt *= kt; | 
| 209 | 
  | 
    Drtr *= kt; | 
| 212 | 
  | 
    Xirtr *= OOPSEConstant::kb * temperature; | 
| 213 | 
  | 
    Xirrr *= OOPSEConstant::kb * temperature; | 
| 214 | 
  | 
     | 
| 215 | 
+ | 
    Mat6x6d Xi, D; | 
| 216 | 
  | 
 | 
| 217 | 
< | 
    cr.center = ror; | 
| 218 | 
< | 
    cr.Xi.setSubMatrix(0, 0, Xirtt); | 
| 219 | 
< | 
    cr.Xi.setSubMatrix(0, 3, Xirtr); | 
| 220 | 
< | 
    cr.Xi.setSubMatrix(3, 0, Xirtr); | 
| 221 | 
< | 
    cr.Xi.setSubMatrix(3, 3, Xirrr); | 
| 222 | 
< | 
    cr.D.setSubMatrix(0, 0, Drtt); | 
| 223 | 
< | 
    cr.D.setSubMatrix(0, 3, Drrt); | 
| 224 | 
< | 
    cr.D.setSubMatrix(3, 0, Drtr); | 
| 225 | 
< | 
    cr.D.setSubMatrix(3, 3, Drrr);     | 
| 217 | 
> | 
    cr->setCOR(ror); | 
| 218 | 
> | 
 | 
| 219 | 
> | 
    Xi.setSubMatrix(0, 0, Xirtt); | 
| 220 | 
> | 
    Xi.setSubMatrix(0, 3, Xirtr); | 
| 221 | 
> | 
    Xi.setSubMatrix(3, 0, Xirtr); | 
| 222 | 
> | 
    Xi.setSubMatrix(3, 3, Xirrr); | 
| 223 | 
> | 
 | 
| 224 | 
> | 
    cr->setXi(Xi); | 
| 225 | 
> | 
 | 
| 226 | 
> | 
    D.setSubMatrix(0, 0, Drtt); | 
| 227 | 
> | 
    D.setSubMatrix(0, 3, Drrt); | 
| 228 | 
> | 
    D.setSubMatrix(3, 0, Drtr); | 
| 229 | 
> | 
    D.setSubMatrix(3, 3, Drrr);     | 
| 230 | 
> | 
 | 
| 231 | 
> | 
    cr->setD(D); | 
| 232 | 
  | 
     | 
| 233 | 
  | 
    std::cout << "-----------------------------------------\n"; | 
| 234 | 
  | 
    std::cout << "center of resistance :" << std::endl; | 
| 253 | 
  | 
 | 
| 254 | 
  | 
    return true; | 
| 255 | 
  | 
} | 
| 256 | 
< | 
 | 
| 257 | 
< | 
bool ApproximationModel::calcHydroPropsAtCD(std::vector<BeadParam>& beads, double viscosity, double temperature, HydroProps& cr) { | 
| 258 | 
< | 
 | 
| 256 | 
> | 
   | 
| 257 | 
> | 
  bool ApproximationModel::calcHydroPropsAtCD(std::vector<BeadParam>& beads, RealType viscosity, RealType temperature, HydroProp* cd) { | 
| 258 | 
> | 
     | 
| 259 | 
  | 
    int nbeads = beads.size(); | 
| 260 | 
< | 
    DynamicRectMatrix<double> B(3*nbeads, 3*nbeads); | 
| 261 | 
< | 
    DynamicRectMatrix<double> C(3*nbeads, 3*nbeads); | 
| 260 | 
> | 
    DynamicRectMatrix<RealType> B(3*nbeads, 3*nbeads); | 
| 261 | 
> | 
    DynamicRectMatrix<RealType> C(3*nbeads, 3*nbeads); | 
| 262 | 
  | 
    Mat3x3d I; | 
| 263 | 
  | 
    I(0, 0) = 1.0; | 
| 264 | 
  | 
    I(1, 1) = 1.0; | 
| 265 | 
  | 
    I(2, 2) = 1.0; | 
| 266 | 
  | 
     | 
| 267 | 
  | 
    for (std::size_t i = 0; i < nbeads; ++i) { | 
| 268 | 
< | 
        for (std::size_t j = 0; j < nbeads; ++j) { | 
| 269 | 
< | 
            Mat3x3d Tij; | 
| 270 | 
< | 
            if (i != j ) { | 
| 271 | 
< | 
                Vector3d Rij = beads[i].pos - beads[j].pos; | 
| 272 | 
< | 
                double rij = Rij.length(); | 
| 273 | 
< | 
                double rij2 = rij * rij; | 
| 274 | 
< | 
                double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                 | 
| 275 | 
< | 
                Mat3x3d tmpMat; | 
| 276 | 
< | 
                tmpMat = outProduct(Rij, Rij) / rij2; | 
| 277 | 
< | 
                double constant = 8.0 * NumericConstant::PI * viscosity * rij; | 
| 278 | 
< | 
                Tij = ((1.0 + sumSigma2OverRij2/3.0) * I + (1.0 - sumSigma2OverRij2) * tmpMat ) / constant; | 
| 279 | 
< | 
            }else { | 
| 280 | 
< | 
                double constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius); | 
| 281 | 
< | 
                Tij(0, 0) = constant; | 
| 282 | 
< | 
                Tij(1, 1) = constant; | 
| 283 | 
< | 
                Tij(2, 2) = constant; | 
| 284 | 
< | 
            } | 
| 285 | 
< | 
            B.setSubMatrix(i*3, j*3, Tij); | 
| 268 | 
> | 
      for (std::size_t j = 0; j < nbeads; ++j) { | 
| 269 | 
> | 
        Mat3x3d Tij; | 
| 270 | 
> | 
        if (i != j ) { | 
| 271 | 
> | 
          Vector3d Rij = beads[i].pos - beads[j].pos; | 
| 272 | 
> | 
          RealType rij = Rij.length(); | 
| 273 | 
> | 
          RealType rij2 = rij * rij; | 
| 274 | 
> | 
          RealType sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                 | 
| 275 | 
> | 
          Mat3x3d tmpMat; | 
| 276 | 
> | 
          tmpMat = outProduct(Rij, Rij) / rij2; | 
| 277 | 
> | 
          RealType constant = 8.0 * NumericConstant::PI * viscosity * rij; | 
| 278 | 
> | 
          RealType tmp1 = 1.0 + sumSigma2OverRij2/3.0; | 
| 279 | 
> | 
          RealType tmp2 = 1.0 - sumSigma2OverRij2; | 
| 280 | 
> | 
          Tij = (tmp1 * I + tmp2 * tmpMat ) / constant; | 
| 281 | 
> | 
        }else { | 
| 282 | 
> | 
          RealType constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius); | 
| 283 | 
> | 
          Tij(0, 0) = constant; | 
| 284 | 
> | 
          Tij(1, 1) = constant; | 
| 285 | 
> | 
          Tij(2, 2) = constant; | 
| 286 | 
  | 
        } | 
| 287 | 
+ | 
        B.setSubMatrix(i*3, j*3, Tij); | 
| 288 | 
+ | 
      } | 
| 289 | 
  | 
    } | 
| 290 | 
< | 
 | 
| 290 | 
> | 
     | 
| 291 | 
  | 
    //invert B Matrix | 
| 292 | 
  | 
    invertMatrix(B, C); | 
| 293 | 
< | 
 | 
| 293 | 
> | 
     | 
| 294 | 
  | 
    //prepare U Matrix relative to arbitrary origin O(0.0, 0.0, 0.0) | 
| 295 | 
  | 
    std::vector<Mat3x3d> U; | 
| 296 | 
  | 
    for (int i = 0; i < nbeads; ++i) { | 
| 297 | 
< | 
        Mat3x3d currU; | 
| 298 | 
< | 
        currU.setupSkewMat(beads[i].pos); | 
| 299 | 
< | 
        U.push_back(currU); | 
| 297 | 
> | 
      Mat3x3d currU; | 
| 298 | 
> | 
      currU.setupSkewMat(beads[i].pos); | 
| 299 | 
> | 
      U.push_back(currU); | 
| 300 | 
  | 
    } | 
| 301 | 
  | 
     | 
| 302 | 
  | 
    //calculate Xi matrix at arbitrary origin O | 
| 306 | 
  | 
 | 
| 307 | 
  | 
    //calculate the total volume | 
| 308 | 
  | 
 | 
| 309 | 
< | 
    double volume = 0.0; | 
| 309 | 
> | 
    RealType volume = 0.0; | 
| 310 | 
  | 
    for (std::vector<BeadParam>::iterator iter = beads.begin(); iter != beads.end(); ++iter) { | 
| 311 | 
< | 
        volume += 4.0/3.0 * NumericConstant::PI * pow((*iter).radius,3); | 
| 311 | 
> | 
      volume += 4.0/3.0 * NumericConstant::PI * pow((*iter).radius,3); | 
| 312 | 
  | 
    } | 
| 313 | 
< | 
         | 
| 313 | 
> | 
     | 
| 314 | 
  | 
    for (std::size_t i = 0; i < nbeads; ++i) { | 
| 315 | 
< | 
        for (std::size_t j = 0; j < nbeads; ++j) { | 
| 316 | 
< | 
            Mat3x3d Cij; | 
| 317 | 
< | 
            C.getSubMatrix(i*3, j*3, Cij); | 
| 315 | 
> | 
      for (std::size_t j = 0; j < nbeads; ++j) { | 
| 316 | 
> | 
        Mat3x3d Cij; | 
| 317 | 
> | 
        C.getSubMatrix(i*3, j*3, Cij); | 
| 318 | 
  | 
             | 
| 319 | 
< | 
            Xitt += Cij; | 
| 320 | 
< | 
            Xitr += U[i] * Cij; | 
| 319 | 
> | 
        Xitt += Cij; | 
| 320 | 
> | 
        Xitr += U[i] * Cij; | 
| 321 | 
  | 
            //Xirr += -U[i] * Cij * U[j] + (6 * viscosity * volume) * I;             | 
| 322 | 
< | 
            Xirr += -U[i] * Cij * U[j]; | 
| 323 | 
< | 
        } | 
| 322 | 
> | 
        Xirr += -U[i] * Cij * U[j]; | 
| 323 | 
> | 
      } | 
| 324 | 
  | 
    } | 
| 325 | 
< | 
 | 
| 326 | 
< | 
    const double convertConstant = 6.023; //convert poise.angstrom to amu/fs | 
| 325 | 
> | 
     | 
| 326 | 
> | 
    const RealType convertConstant = 6.023; //convert poise.angstrom to amu/fs | 
| 327 | 
  | 
    Xitt *= convertConstant; | 
| 328 | 
  | 
    Xitr *= convertConstant; | 
| 329 | 
  | 
    Xirr *= convertConstant; | 
| 330 | 
< | 
 | 
| 331 | 
< | 
    double kt = OOPSEConstant::kB * temperature; | 
| 332 | 
< | 
 | 
| 330 | 
> | 
     | 
| 331 | 
> | 
    RealType kt = OOPSEConstant::kB * temperature; | 
| 332 | 
> | 
     | 
| 333 | 
  | 
    Mat3x3d Dott; //translational diffusion tensor at arbitrary origin O | 
| 334 | 
  | 
    Mat3x3d Dorr; //rotational diffusion tensor at arbitrary origin O | 
| 335 | 
  | 
    Mat3x3d Dotr; //translation-rotation couplingl diffusion tensor at arbitrary origin O | 
| 336 | 
< | 
 | 
| 336 | 
> | 
     | 
| 337 | 
  | 
    const static Mat3x3d zeroMat(0.0); | 
| 338 | 
  | 
     | 
| 339 | 
  | 
    Mat3x3d XittInv(0.0); | 
| 387 | 
  | 
    Ddrr = Dorr; | 
| 388 | 
  | 
    Ddtr = Dotr + Dorr * Uod; | 
| 389 | 
  | 
 | 
| 390 | 
< | 
    SquareMatrix<double, 6> Dd; | 
| 390 | 
> | 
    SquareMatrix<RealType, 6> Dd; | 
| 391 | 
  | 
    Dd.setSubMatrix(0, 0, Ddtt); | 
| 392 | 
  | 
    Dd.setSubMatrix(0, 3, Ddtr.transpose()); | 
| 393 | 
  | 
    Dd.setSubMatrix(3, 0, Ddtr); | 
| 394 | 
  | 
    Dd.setSubMatrix(3, 3, Ddrr);     | 
| 395 | 
< | 
    SquareMatrix<double, 6> Xid; | 
| 395 | 
> | 
    SquareMatrix<RealType, 6> Xid; | 
| 396 | 
  | 
    Ddtt *= kt; | 
| 397 | 
  | 
    Ddtr *=kt; | 
| 398 | 
  | 
    Ddrr *= kt; | 
| 404 | 
  | 
    //Xid /= OOPSEConstant::energyConvert; | 
| 405 | 
  | 
    Xid *= OOPSEConstant::kb * temperature; | 
| 406 | 
  | 
 | 
| 407 | 
< | 
    cr.center = rod; | 
| 410 | 
< | 
    cr.D.setSubMatrix(0, 0, Ddtt); | 
| 411 | 
< | 
    cr.D.setSubMatrix(0, 3, Ddtr); | 
| 412 | 
< | 
    cr.D.setSubMatrix(3, 0, Ddtr); | 
| 413 | 
< | 
    cr.D.setSubMatrix(3, 3, Ddrr); | 
| 414 | 
< | 
    cr.Xi = Xid; | 
| 407 | 
> | 
    Mat6x6d Xi, D; | 
| 408 | 
  | 
 | 
| 409 | 
+ | 
    cd->setCOR(rod); | 
| 410 | 
+ | 
 | 
| 411 | 
+ | 
    cd->setXi(Xid); | 
| 412 | 
+ | 
 | 
| 413 | 
+ | 
    D.setSubMatrix(0, 0, Ddtt); | 
| 414 | 
+ | 
    D.setSubMatrix(0, 3, Ddtr); | 
| 415 | 
+ | 
    D.setSubMatrix(3, 0, Ddtr); | 
| 416 | 
+ | 
    D.setSubMatrix(3, 3, Ddrr); | 
| 417 | 
+ | 
 | 
| 418 | 
+ | 
    cd->setD(D); | 
| 419 | 
+ | 
 | 
| 420 | 
  | 
    std::cout << "viscosity = " << viscosity << std::endl; | 
| 421 | 
  | 
    std::cout << "temperature = " << temperature << std::endl; | 
| 422 | 
  | 
    std::cout << "center of diffusion :" << std::endl; | 
| 450 | 
  | 
    std::cout << Xidrr << std::endl; | 
| 451 | 
  | 
 | 
| 452 | 
  | 
    return true; | 
| 453 | 
< | 
       | 
| 454 | 
< | 
} | 
| 453 | 
> | 
     | 
| 454 | 
> | 
  } | 
| 455 | 
  | 
 | 
| 456 | 
< | 
 | 
| 453 | 
< | 
void ApproximationModel::writeBeads(std::ostream& os) { | 
| 456 | 
> | 
  void ApproximationModel::writeBeads(std::ostream& os) { | 
| 457 | 
  | 
    std::vector<BeadParam>::iterator iter; | 
| 458 | 
  | 
    os << beads_.size() << std::endl; | 
| 459 | 
  | 
    os << "Generated by Hydro" << std::endl; | 
| 460 | 
  | 
    for (iter = beads_.begin(); iter != beads_.end(); ++iter) { | 
| 461 | 
< | 
        os << iter->atomName << "\t" << iter->pos[0] << "\t" << iter->pos[1] << "\t" << iter->pos[2] << std::endl; | 
| 461 | 
> | 
      os << iter->atomName << "\t" << iter->pos[0] << "\t" << iter->pos[1] << "\t" << iter->pos[2] << std::endl; | 
| 462 | 
  | 
    } | 
| 463 | 
< | 
 | 
| 463 | 
> | 
     | 
| 464 | 
> | 
  }     | 
| 465 | 
  | 
} | 
| 462 | 
– | 
 | 
| 463 | 
– | 
 | 
| 464 | 
– | 
 | 
| 465 | 
– | 
} |