moleculeCloudI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 inline void Foam::moleculeCloud::evaluatePair
00030 (
00031 molecule* molI,
00032 molecule* molJ
00033 )
00034 {
00035 const pairPotentialList& pairPot = pot_.pairPotentials();
00036
00037 const pairPotential& electrostatic = pairPot.electrostatic();
00038
00039 label idI = molI->id();
00040
00041 label idJ = molJ->id();
00042
00043 const molecule::constantProperties& constPropI(constProps(idI));
00044
00045 const molecule::constantProperties& constPropJ(constProps(idJ));
00046
00047 List<label> siteIdsI = constPropI.siteIds();
00048
00049 List<label> siteIdsJ = constPropJ.siteIds();
00050
00051 List<bool> pairPotentialSitesI = constPropI.pairPotentialSites();
00052
00053 List<bool> electrostaticSitesI = constPropI.electrostaticSites();
00054
00055 List<bool> pairPotentialSitesJ = constPropJ.pairPotentialSites();
00056
00057 List<bool> electrostaticSitesJ = constPropJ.electrostaticSites();
00058
00059 forAll(siteIdsI, sI)
00060 {
00061 label idsI(siteIdsI[sI]);
00062
00063 forAll(siteIdsJ, sJ)
00064 {
00065 label idsJ(siteIdsJ[sJ]);
00066
00067 if (pairPotentialSitesI[sI] && pairPotentialSitesJ[sJ])
00068 {
00069 vector rsIsJ =
00070 molI->sitePositions()[sI] - molJ->sitePositions()[sJ];
00071
00072 scalar rsIsJMagSq = magSqr(rsIsJ);
00073
00074 if(pairPot.rCutSqr(idsI, idsJ, rsIsJMagSq))
00075 {
00076 scalar rsIsJMag = mag(rsIsJ);
00077
00078 vector fsIsJ =
00079 (rsIsJ/rsIsJMag)
00080 *pairPot.force(idsI, idsJ, rsIsJMag);
00081
00082 molI->siteForces()[sI] += fsIsJ;
00083
00084 molJ->siteForces()[sJ] += -fsIsJ;
00085
00086 scalar potentialEnergy
00087 (
00088 pairPot.energy(idsI, idsJ, rsIsJMag)
00089 );
00090
00091 molI->potentialEnergy() += 0.5*potentialEnergy;
00092
00093 molJ->potentialEnergy() += 0.5*potentialEnergy;
00094
00095 vector rIJ = molI->position() - molJ->position();
00096
00097 tensor virialContribution =
00098 (rsIsJ*fsIsJ)*(rsIsJ & rIJ)/rsIsJMagSq;
00099
00100 molI->rf() += virialContribution;
00101
00102 molJ->rf() += virialContribution;
00103
00104
00105
00106
00107 }
00108 }
00109
00110 if (electrostaticSitesI[sI] && electrostaticSitesJ[sJ])
00111 {
00112 vector rsIsJ =
00113 molI->sitePositions()[sI] - molJ->sitePositions()[sJ];
00114
00115 scalar rsIsJMagSq = magSqr(rsIsJ);
00116
00117 if(rsIsJMagSq <= electrostatic.rCutSqr())
00118 {
00119 scalar rsIsJMag = mag(rsIsJ);
00120
00121 scalar chargeI = constPropI.siteCharges()[sI];
00122
00123 scalar chargeJ = constPropJ.siteCharges()[sJ];
00124
00125 vector fsIsJ =
00126 (rsIsJ/rsIsJMag)
00127 *chargeI*chargeJ*electrostatic.force(rsIsJMag);
00128
00129 molI->siteForces()[sI] += fsIsJ;
00130
00131 molJ->siteForces()[sJ] += -fsIsJ;
00132
00133 scalar potentialEnergy =
00134 chargeI*chargeJ
00135 *electrostatic.energy(rsIsJMag);
00136
00137 molI->potentialEnergy() += 0.5*potentialEnergy;
00138
00139 molJ->potentialEnergy() += 0.5*potentialEnergy;
00140
00141 vector rIJ = molI->position() - molJ->position();
00142
00143 tensor virialContribution =
00144 (rsIsJ*fsIsJ)*(rsIsJ & rIJ)/rsIsJMagSq;
00145
00146 molI->rf() += virialContribution;
00147
00148 molJ->rf() += virialContribution;
00149
00150
00151
00152
00153 }
00154 }
00155 }
00156 }
00157 }
00158
00159
00160 inline void Foam::moleculeCloud::evaluatePair
00161 (
00162 molecule* molReal,
00163 referredMolecule* molRef
00164 )
00165 {
00166 const pairPotentialList& pairPot = pot_.pairPotentials();
00167
00168 const pairPotential& electrostatic = pairPot.electrostatic();
00169
00170 label idReal = molReal->id();
00171
00172 label idRef = molRef->id();
00173
00174 const molecule::constantProperties& constPropReal(constProps(idReal));
00175
00176 const molecule::constantProperties& constPropRef(constProps(idRef));
00177
00178 List<label> siteIdsReal = constPropReal.siteIds();
00179
00180 List<label> siteIdsRef = constPropRef.siteIds();
00181
00182 List<bool> pairPotentialSitesReal = constPropReal.pairPotentialSites();
00183
00184 List<bool> electrostaticSitesReal = constPropReal.electrostaticSites();
00185
00186 List<bool> pairPotentialSitesRef = constPropRef.pairPotentialSites();
00187
00188 List<bool> electrostaticSitesRef = constPropRef.electrostaticSites();
00189
00190 forAll(siteIdsReal, sReal)
00191 {
00192 label idsReal(siteIdsReal[sReal]);
00193
00194 forAll(siteIdsRef, sRef)
00195 {
00196 label idsRef(siteIdsRef[sRef]);
00197
00198 if (pairPotentialSitesReal[sReal] && pairPotentialSitesRef[sRef])
00199 {
00200 vector rsRealsRef =
00201 molReal->sitePositions()[sReal]
00202 - molRef->sitePositions()[sRef];
00203
00204 scalar rsRealsRefMagSq = magSqr(rsRealsRef);
00205
00206 if (pairPot.rCutSqr(idsReal, idsRef, rsRealsRefMagSq))
00207 {
00208 scalar rsRealsRefMag = mag(rsRealsRef);
00209
00210 vector fsRealsRef =
00211 (rsRealsRef/rsRealsRefMag)
00212 *pairPot.force(idsReal, idsRef, rsRealsRefMag);
00213
00214 molReal->siteForces()[sReal] += fsRealsRef;
00215
00216 scalar potentialEnergy
00217 (
00218 pairPot.energy(idsReal, idsRef, rsRealsRefMag)
00219 );
00220
00221 molReal->potentialEnergy() += 0.5*potentialEnergy;
00222
00223 vector rRealRef = molReal->position() - molRef->position();
00224
00225 molReal->rf() +=
00226 (rsRealsRef*fsRealsRef)
00227 *(rsRealsRef & rRealRef)
00228 /rsRealsRefMagSq;
00229
00230
00231
00232 }
00233 }
00234
00235 if (electrostaticSitesReal[sReal] && electrostaticSitesRef[sRef])
00236 {
00237 vector rsRealsRef =
00238 molReal->sitePositions()[sReal]
00239 - molRef->sitePositions()[sRef];
00240
00241 scalar rsRealsRefMagSq = magSqr(rsRealsRef);
00242
00243 if (rsRealsRefMagSq <= electrostatic.rCutSqr())
00244 {
00245 scalar rsRealsRefMag = mag(rsRealsRef);
00246
00247 scalar chargeReal = constPropReal.siteCharges()[sReal];
00248
00249 scalar chargeRef = constPropRef.siteCharges()[sRef];
00250
00251 vector fsRealsRef =
00252 (rsRealsRef/rsRealsRefMag)
00253 *chargeReal*chargeRef
00254 *electrostatic.force(rsRealsRefMag);
00255
00256 molReal->siteForces()[sReal] += fsRealsRef;
00257
00258 scalar potentialEnergy =
00259 chargeReal*chargeRef
00260 *electrostatic.energy(rsRealsRefMag);
00261
00262 molReal->potentialEnergy() += 0.5*potentialEnergy;
00263
00264 vector rRealRef = molReal->position() - molRef->position();
00265
00266 molReal->rf() +=
00267 (rsRealsRef*fsRealsRef)
00268 *(rsRealsRef & rRealRef)
00269 /rsRealsRefMagSq;
00270
00271
00272 }
00273 }
00274 }
00275 }
00276 }
00277
00278
00279 inline bool Foam::moleculeCloud::evaluatePotentialLimit
00280 (
00281 molecule* molI,
00282 molecule* molJ
00283 ) const
00284 {
00285 const pairPotentialList& pairPot = pot_.pairPotentials();
00286
00287 const pairPotential& electrostatic = pairPot.electrostatic();
00288
00289 label idI = molI->id();
00290
00291 label idJ = molJ->id();
00292
00293 const molecule::constantProperties& constPropI(constProps(idI));
00294
00295 const molecule::constantProperties& constPropJ(constProps(idJ));
00296
00297 List<label> siteIdsI = constPropI.siteIds();
00298
00299 List<label> siteIdsJ = constPropJ.siteIds();
00300
00301 List<bool> pairPotentialSitesI = constPropI.pairPotentialSites();
00302
00303 List<bool> electrostaticSitesI = constPropI.electrostaticSites();
00304
00305 List<bool> pairPotentialSitesJ = constPropJ.pairPotentialSites();
00306
00307 List<bool> electrostaticSitesJ = constPropJ.electrostaticSites();
00308
00309 forAll(siteIdsI, sI)
00310 {
00311 label idsI(siteIdsI[sI]);
00312
00313 forAll(siteIdsJ, sJ)
00314 {
00315 label idsJ(siteIdsJ[sJ]);
00316
00317 if (pairPotentialSitesI[sI] && pairPotentialSitesJ[sJ])
00318 {
00319 vector rsIsJ =
00320 molI->sitePositions()[sI] - molJ->sitePositions()[sJ];
00321
00322 scalar rsIsJMagSq = magSqr(rsIsJ);
00323
00324 if (pairPot.rCutSqr(idsI, idsJ, rsIsJMagSq))
00325 {
00326 scalar rsIsJMag = mag(rsIsJ);
00327
00328
00329
00330
00331
00332 if (rsIsJMag < SMALL)
00333 {
00334 WarningIn("moleculeCloud::removeHighEnergyOverlaps()")
00335 << "Molecule site pair closer than "
00336 << SMALL
00337 << ": mag separation = " << rsIsJMag
00338 << ". These may have been placed on top of each"
00339 << " other by a rounding error in mdInitialise in"
00340 << " parallel or a block filled with molecules"
00341 << " twice. Removing one of the molecules."
00342 << endl;
00343
00344 return true;
00345 }
00346
00347
00348
00349
00350 if (rsIsJMag < pairPot.rMin(idsI, idsJ))
00351 {
00352 return true;
00353 }
00354
00355 if
00356 (
00357 mag(pairPot.energy(idsI, idsJ, rsIsJMag))
00358 > pot_.potentialEnergyLimit()
00359 )
00360 {
00361 return true;
00362 };
00363 }
00364 }
00365
00366 if (electrostaticSitesI[sI] && electrostaticSitesJ[sJ])
00367 {
00368 vector rsIsJ =
00369 molI->sitePositions()[sI] - molJ->sitePositions()[sJ];
00370
00371 scalar rsIsJMagSq = magSqr(rsIsJ);
00372
00373 if (pairPot.rCutMaxSqr(rsIsJMagSq))
00374 {
00375 scalar rsIsJMag = mag(rsIsJ);
00376
00377
00378
00379
00380
00381 if (rsIsJMag < SMALL)
00382 {
00383 WarningIn("moleculeCloud::removeHighEnergyOverlaps()")
00384 << "Molecule site pair closer than "
00385 << SMALL
00386 << ": mag separation = " << rsIsJMag
00387 << ". These may have been placed on top of each"
00388 << " other by a rounding error in mdInitialise in"
00389 << " parallel or a block filled with molecules"
00390 << " twice. Removing one of the molecules."
00391 << endl;
00392
00393 return true;
00394 }
00395
00396 if (rsIsJMag < electrostatic.rMin())
00397 {
00398 return true;
00399 }
00400
00401 scalar chargeI = constPropI.siteCharges()[sI];
00402
00403 scalar chargeJ = constPropJ.siteCharges()[sJ];
00404
00405 if
00406 (
00407 mag(chargeI*chargeJ*electrostatic.energy(rsIsJMag))
00408 > pot_.potentialEnergyLimit()
00409 )
00410 {
00411 return true;
00412 };
00413 }
00414 }
00415 }
00416 }
00417
00418 return false;
00419 }
00420
00421
00422 inline bool Foam::moleculeCloud::evaluatePotentialLimit
00423 (
00424 molecule* molReal,
00425 referredMolecule* molRef
00426 ) const
00427 {
00428 const pairPotentialList& pairPot = pot_.pairPotentials();
00429
00430 const pairPotential& electrostatic = pairPot.electrostatic();
00431
00432 label idReal = molReal->id();
00433
00434 label idRef = molRef->id();
00435
00436 const molecule::constantProperties& constPropReal(constProps(idReal));
00437
00438 const molecule::constantProperties& constPropRef(constProps(idRef));
00439
00440 List<label> siteIdsReal = constPropReal.siteIds();
00441
00442 List<label> siteIdsRef = constPropRef.siteIds();
00443
00444 List<bool> pairPotentialSitesReal = constPropReal.pairPotentialSites();
00445
00446 List<bool> electrostaticSitesReal = constPropReal.electrostaticSites();
00447
00448 List<bool> pairPotentialSitesRef = constPropRef.pairPotentialSites();
00449
00450 List<bool> electrostaticSitesRef = constPropRef.electrostaticSites();
00451
00452 forAll(siteIdsReal, sReal)
00453 {
00454 label idsReal(siteIdsReal[sReal]);
00455
00456 forAll(siteIdsRef, sRef)
00457 {
00458 label idsRef(siteIdsRef[sRef]);
00459
00460 if (pairPotentialSitesReal[sReal] && pairPotentialSitesRef[sRef])
00461 {
00462 vector rsRealsRef =
00463 molReal->sitePositions()[sReal]
00464 - molRef->sitePositions()[sRef];
00465
00466 scalar rsRealsRefMagSq = magSqr(rsRealsRef);
00467
00468 if (pairPot.rCutSqr(idsReal, idsRef, rsRealsRefMagSq))
00469 {
00470 scalar rsRealsRefMag = mag(rsRealsRef);
00471
00472
00473
00474
00475
00476 if (rsRealsRefMag < SMALL)
00477 {
00478 WarningIn("moleculeCloud::removeHighEnergyOverlaps()")
00479 << "Molecule site pair closer than "
00480 << SMALL
00481 << ": mag separation = " << rsRealsRefMag
00482 << ". These may have been placed on top of each"
00483 << " other by a rounding error in mdInitialise in"
00484 << " parallel or a block filled with molecules"
00485 << " twice. Removing one of the molecules."
00486 << endl;
00487
00488 return true;
00489 }
00490
00491
00492
00493
00494
00495 if (rsRealsRefMag < pairPot.rMin(idsReal, idsRef))
00496 {
00497 return true;
00498 }
00499
00500 if
00501 (
00502 mag(pairPot.energy(idsReal, idsRef, rsRealsRefMag))
00503 > pot_.potentialEnergyLimit()
00504 )
00505 {
00506 return true;
00507 };
00508 }
00509 }
00510
00511 if (electrostaticSitesReal[sReal] && electrostaticSitesRef[sRef])
00512 {
00513 vector rsRealsRef =
00514 molReal->sitePositions()[sReal]
00515 - molRef->sitePositions()[sRef];
00516
00517 scalar rsRealsRefMagSq = magSqr(rsRealsRef);
00518
00519 if (pairPot.rCutMaxSqr(rsRealsRefMagSq))
00520 {
00521 scalar rsRealsRefMag = mag(rsRealsRef);
00522
00523
00524
00525
00526
00527 if (rsRealsRefMag < SMALL)
00528 {
00529 WarningIn("moleculeCloud::removeHighEnergyOverlaps()")
00530 << "Molecule site pair closer than "
00531 << SMALL
00532 << ": mag separation = " << rsRealsRefMag
00533 << ". These may have been placed on top of each"
00534 << " other by a rounding error in mdInitialise in"
00535 << " parallel or a block filled with molecules"
00536 << " twice. Removing one of the molecules."
00537 << endl;
00538
00539 return true;
00540 }
00541
00542 if (rsRealsRefMag < electrostatic.rMin())
00543 {
00544 return true;
00545 }
00546
00547 scalar chargeReal = constPropReal.siteCharges()[sReal];
00548
00549 scalar chargeRef = constPropRef.siteCharges()[sRef];
00550
00551 if
00552 (
00553 mag
00554 (
00555 chargeReal
00556 *chargeRef
00557 *electrostatic.energy(rsRealsRefMag)
00558 )
00559 > pot_.potentialEnergyLimit()
00560 )
00561 {
00562 return true;
00563 };
00564 }
00565 }
00566 }
00567 }
00568
00569 return false;
00570 }
00571
00572
00573 inline Foam::vector Foam::moleculeCloud::equipartitionLinearVelocity
00574 (
00575 scalar temperature,
00576 scalar mass
00577 )
00578 {
00579 return sqrt(kb*temperature/mass)*vector
00580 (
00581 rndGen_.GaussNormal(),
00582 rndGen_.GaussNormal(),
00583 rndGen_.GaussNormal()
00584 );
00585 }
00586
00587
00588 inline Foam::vector Foam::moleculeCloud::equipartitionAngularMomentum
00589 (
00590 scalar temperature,
00591 const molecule::constantProperties& cP
00592 )
00593 {
00594 scalar sqrtKbT = sqrt(kb*temperature);
00595
00596 if (cP.linearMolecule())
00597 {
00598 return sqrtKbT*vector
00599 (
00600 0.0,
00601 sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal(),
00602 sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal()
00603 );
00604 }
00605 else
00606 {
00607 return sqrtKbT*vector
00608 (
00609 sqrt(cP.momentOfInertia().xx())*rndGen_.GaussNormal(),
00610 sqrt(cP.momentOfInertia().yy())*rndGen_.GaussNormal(),
00611 sqrt(cP.momentOfInertia().zz())*rndGen_.GaussNormal()
00612 );
00613 }
00614 }
00615
00616
00617
00618
00619 inline const Foam::polyMesh& Foam::moleculeCloud::mesh() const
00620 {
00621 return mesh_;
00622 }
00623
00624
00625 inline const Foam::potential& Foam::moleculeCloud::pot() const
00626 {
00627 return pot_;
00628 }
00629
00630
00631 inline const Foam::List<Foam::DynamicList<Foam::molecule*> >&
00632 Foam::moleculeCloud::cellOccupancy() const
00633 {
00634 return cellOccupancy_;
00635 }
00636
00637
00638 inline const Foam::interactionLists&
00639 Foam::moleculeCloud::il() const
00640 {
00641 return il_;
00642 }
00643
00644
00645 inline const Foam::List<Foam::molecule::constantProperties>
00646 Foam::moleculeCloud::constProps() const
00647 {
00648 return constPropList_;
00649 }
00650
00651
00652 inline const Foam::molecule::constantProperties&
00653 Foam::moleculeCloud::constProps(label id) const
00654 {
00655 return constPropList_[id];
00656 }
00657
00658
00659 inline Foam::Random& Foam::moleculeCloud::rndGen()
00660 {
00661 return rndGen_;
00662 }
00663
00664
00665
Copyright © 2000-2009 OpenCFD Ltd