ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/hydrodynamics/ApproximationModel.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/applications/hydrodynamics/ApproximationModel.cpp (file contents):
Revision 2768 by gezelter, Wed May 24 18:31:12 2006 UTC vs.
Revision 2787 by gezelter, Mon Jun 5 18:24:45 2006 UTC

# Line 69 | Line 69 | namespace oopse {
69      
70    }
71    
72 <  bool ApproximationModel::calcHydroProps(Shape* shape, double viscosity, double temperature) {
72 >  bool ApproximationModel::calcHydroProps(Shape* shape, RealType viscosity, RealType temperature) {
73      
74      bool ret = true;
75 <    HydroProps cr;
76 <    HydroProps cd;
75 >    HydroProp* cr;
76 >    HydroProp* cd;
77      calcHydroPropsAtCR(beads_, viscosity, temperature, cr);
78      //calcHydroPropsAtCD(beads_, viscosity, temperature, cd);
79      setCR(cr);
# Line 82 | Line 82 | namespace oopse {
82      return true;    
83    }
84    
85 <  bool ApproximationModel::calcHydroPropsAtCR(std::vector<BeadParam>& beads, double viscosity, double temperature, HydroProps& cr) {
85 >  bool ApproximationModel::calcHydroPropsAtCR(std::vector<BeadParam>& beads, RealType viscosity, RealType temperature, HydroProp* cr) {
86      
87      int nbeads = beads.size();
88 <    DynamicRectMatrix<double> B(3*nbeads, 3*nbeads);
89 <    DynamicRectMatrix<double> C(3*nbeads, 3*nbeads);
88 >    DynamicRectMatrix<RealType> B(3*nbeads, 3*nbeads);
89 >    DynamicRectMatrix<RealType> C(3*nbeads, 3*nbeads);
90      Mat3x3d I;
91      I(0, 0) = 1.0;
92      I(1, 1) = 1.0;
# Line 97 | Line 97 | namespace oopse {
97          Mat3x3d Tij;
98              if (i != j ) {
99                Vector3d Rij = beads[i].pos - beads[j].pos;
100 <              double rij = Rij.length();
101 <              double rij2 = rij * rij;
102 <              double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                
100 >              RealType rij = Rij.length();
101 >              RealType rij2 = rij * rij;
102 >              RealType sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                
103                Mat3x3d tmpMat;
104                tmpMat = outProduct(Rij, Rij) / rij2;
105 <              double constant = 8.0 * NumericConstant::PI * viscosity * rij;
106 <              Tij = ((1.0 + sumSigma2OverRij2/3.0) * I + (1.0 - sumSigma2OverRij2) * tmpMat ) / constant;
105 >              RealType constant = 8.0 * NumericConstant::PI * viscosity * rij;
106 >              RealType tmp1 = 1.0 + sumSigma2OverRij2/3.0;
107 >              RealType tmp2 = 1.0 - sumSigma2OverRij2;
108 >              Tij = (tmp1 * I + tmp2 * tmpMat ) / constant;
109              }else {
110 <              double constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius);
110 >              RealType constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius);
111                Tij(0, 0) = constant;
112                Tij(1, 1) = constant;
113                Tij(2, 2) = constant;
# Line 132 | Line 134 | namespace oopse {
134      
135      //calculate the total volume
136      
137 <    double volume = 0.0;
137 >    RealType volume = 0.0;
138      for (std::vector<BeadParam>::iterator iter = beads.begin(); iter != beads.end(); ++iter) {
139        volume += 4.0/3.0 * NumericConstant::PI * pow((*iter).radius,3);
140      }
# Line 149 | Line 151 | namespace oopse {
151        }
152      }
153      
154 <    const double convertConstant = 6.023; //convert poise.angstrom to amu/fs
154 >    const RealType convertConstant = 6.023; //convert poise.angstrom to amu/fs
155      Xiott *= convertConstant;
156      Xiotr *= convertConstant;
157      Xiorr *= convertConstant;
# Line 185 | Line 187 | namespace oopse {
187      Xirrr = Xiorr - Uor * Xiott * Uor + Xiotr * Uor - Uor * Xiotr.transpose();
188      
189  
190 <    SquareMatrix<double,6> Xir6x6;
191 <    SquareMatrix<double,6> Dr6x6;
190 >    SquareMatrix<RealType,6> Xir6x6;
191 >    SquareMatrix<RealType,6> Dr6x6;
192  
193      Xir6x6.setSubMatrix(0, 0, Xirtt);
194      Xir6x6.setSubMatrix(0, 3, Xirtr.transpose());
# Line 202 | Line 204 | namespace oopse {
204      Dr6x6.getSubMatrix(0, 3, Drrt);
205      Dr6x6.getSubMatrix(3, 0, Drtr);
206      Dr6x6.getSubMatrix(3, 3, Drrr);
207 <    double kt = OOPSEConstant::kB * temperature ;
207 >    RealType kt = OOPSEConstant::kB * temperature ;
208      Drtt *= kt;
209      Drrt *= kt;
210      Drtr *= kt;
# Line 211 | Line 213 | namespace oopse {
213      Xirtr *= OOPSEConstant::kb * temperature;
214      Xirrr *= OOPSEConstant::kb * temperature;
215      
216 +    Mat6x6d Xi, D;
217  
218 <    cr.center = ror;
219 <    cr.Xi.setSubMatrix(0, 0, Xirtt);
220 <    cr.Xi.setSubMatrix(0, 3, Xirtr);
221 <    cr.Xi.setSubMatrix(3, 0, Xirtr);
222 <    cr.Xi.setSubMatrix(3, 3, Xirrr);
223 <    cr.D.setSubMatrix(0, 0, Drtt);
224 <    cr.D.setSubMatrix(0, 3, Drrt);
225 <    cr.D.setSubMatrix(3, 0, Drtr);
226 <    cr.D.setSubMatrix(3, 3, Drrr);    
218 >    cr->setCOR(ror);
219 >
220 >    Xi.setSubMatrix(0, 0, Xirtt);
221 >    Xi.setSubMatrix(0, 3, Xirtr);
222 >    Xi.setSubMatrix(3, 0, Xirtr);
223 >    Xi.setSubMatrix(3, 3, Xirrr);
224 >
225 >    cr->setXi(Xi);
226 >
227 >    D.setSubMatrix(0, 0, Drtt);
228 >    D.setSubMatrix(0, 3, Drrt);
229 >    D.setSubMatrix(3, 0, Drtr);
230 >    D.setSubMatrix(3, 3, Drrr);    
231 >
232 >    cr->setD(D);
233      
234      std::cout << "-----------------------------------------\n";
235      std::cout << "center of resistance :" << std::endl;
# Line 246 | Line 255 | namespace oopse {
255      return true;
256   }
257    
258 <  bool ApproximationModel::calcHydroPropsAtCD(std::vector<BeadParam>& beads, double viscosity, double temperature, HydroProps& cr) {
258 >  bool ApproximationModel::calcHydroPropsAtCD(std::vector<BeadParam>& beads, RealType viscosity, RealType temperature, HydroProp* cr) {
259      
260      int nbeads = beads.size();
261 <    DynamicRectMatrix<double> B(3*nbeads, 3*nbeads);
262 <    DynamicRectMatrix<double> C(3*nbeads, 3*nbeads);
261 >    DynamicRectMatrix<RealType> B(3*nbeads, 3*nbeads);
262 >    DynamicRectMatrix<RealType> C(3*nbeads, 3*nbeads);
263      Mat3x3d I;
264      I(0, 0) = 1.0;
265      I(1, 1) = 1.0;
# Line 261 | Line 270 | namespace oopse {
270          Mat3x3d Tij;
271          if (i != j ) {
272            Vector3d Rij = beads[i].pos - beads[j].pos;
273 <          double rij = Rij.length();
274 <          double rij2 = rij * rij;
275 <          double sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                
273 >          RealType rij = Rij.length();
274 >          RealType rij2 = rij * rij;
275 >          RealType sumSigma2OverRij2 = ((beads[i].radius*beads[i].radius) + (beads[j].radius*beads[j].radius)) / rij2;                
276            Mat3x3d tmpMat;
277            tmpMat = outProduct(Rij, Rij) / rij2;
278 <          double constant = 8.0 * NumericConstant::PI * viscosity * rij;
279 <          Tij = ((1.0 + sumSigma2OverRij2/3.0) * I + (1.0 - sumSigma2OverRij2) * tmpMat ) / constant;
278 >          RealType constant = 8.0 * NumericConstant::PI * viscosity * rij;
279 >          RealType tmp1 = 1.0 + sumSigma2OverRij2/3.0;
280 >          RealType tmp2 = 1.0 - sumSigma2OverRij2;
281 >          Tij = (tmp1 * I + tmp2 * tmpMat ) / constant;
282          }else {
283 <          double constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius);
283 >          RealType constant = 1.0 / (6.0 * NumericConstant::PI * viscosity * beads[i].radius);
284            Tij(0, 0) = constant;
285            Tij(1, 1) = constant;
286            Tij(2, 2) = constant;
# Line 296 | Line 307 | namespace oopse {
307  
308      //calculate the total volume
309  
310 <    double volume = 0.0;
310 >    RealType volume = 0.0;
311      for (std::vector<BeadParam>::iterator iter = beads.begin(); iter != beads.end(); ++iter) {
312        volume += 4.0/3.0 * NumericConstant::PI * pow((*iter).radius,3);
313      }
# Line 313 | Line 324 | namespace oopse {
324        }
325      }
326      
327 <    const double convertConstant = 6.023; //convert poise.angstrom to amu/fs
327 >    const RealType convertConstant = 6.023; //convert poise.angstrom to amu/fs
328      Xitt *= convertConstant;
329      Xitr *= convertConstant;
330      Xirr *= convertConstant;
331      
332 <    double kt = OOPSEConstant::kB * temperature;
332 >    RealType kt = OOPSEConstant::kB * temperature;
333      
334      Mat3x3d Dott; //translational diffusion tensor at arbitrary origin O
335      Mat3x3d Dorr; //rotational diffusion tensor at arbitrary origin O
# Line 377 | Line 388 | namespace oopse {
388      Ddrr = Dorr;
389      Ddtr = Dotr + Dorr * Uod;
390  
391 <    SquareMatrix<double, 6> Dd;
391 >    SquareMatrix<RealType, 6> Dd;
392      Dd.setSubMatrix(0, 0, Ddtt);
393      Dd.setSubMatrix(0, 3, Ddtr.transpose());
394      Dd.setSubMatrix(3, 0, Ddtr);
395      Dd.setSubMatrix(3, 3, Ddrr);    
396 <    SquareMatrix<double, 6> Xid;
396 >    SquareMatrix<RealType, 6> Xid;
397      Ddtt *= kt;
398      Ddtr *=kt;
399      Ddrr *= kt;
# Line 394 | Line 405 | namespace oopse {
405      //Xid /= OOPSEConstant::energyConvert;
406      Xid *= OOPSEConstant::kb * temperature;
407  
408 <    cr.center = rod;
398 <    cr.D.setSubMatrix(0, 0, Ddtt);
399 <    cr.D.setSubMatrix(0, 3, Ddtr);
400 <    cr.D.setSubMatrix(3, 0, Ddtr);
401 <    cr.D.setSubMatrix(3, 3, Ddrr);
402 <    cr.Xi = Xid;
408 >    Mat6x6d Xi, D;
409  
410 +    cr->setCOR(rod);
411 +
412 +    cr->setXi(Xid);
413 +
414 +    D.setSubMatrix(0, 0, Ddtt);
415 +    D.setSubMatrix(0, 3, Ddtr);
416 +    D.setSubMatrix(3, 0, Ddtr);
417 +    D.setSubMatrix(3, 3, Ddrr);
418 +
419 +    cr->setD(D);
420 +
421      std::cout << "viscosity = " << viscosity << std::endl;
422      std::cout << "temperature = " << temperature << std::endl;
423      std::cout << "center of diffusion :" << std::endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines