diff --git a/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionLists.H b/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionLists.H index ebffa912da..2140078e26 100644 --- a/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionLists.H +++ b/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionLists.H @@ -185,9 +185,11 @@ public: inline const referredCellList& referredInteractionList() const; - inline const List& cellSendingReferralLists() const; + inline const List& + cellSendingReferralLists() const; - inline const List& cellReceivingReferralLists() const; + inline const List& + cellReceivingReferralLists() const; inline label nInteractingProcs() const; }; diff --git a/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionListsI.H b/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionListsI.H index a3205d5aa1..e2077a52cd 100644 --- a/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionListsI.H +++ b/src/lagrangian/molecularDynamics/molecule/interactionLists/interactionListsI.H @@ -40,7 +40,8 @@ const Foam::directInteractionList& Foam::interactionLists::dil() const } -inline const Foam::referredCellList& Foam::interactionLists::referredInteractionList() const +inline const Foam::referredCellList& + Foam::interactionLists::referredInteractionList() const { return ril_; } diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C index 9c2b34ef39..181e9184f3 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C +++ b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.C @@ -85,10 +85,11 @@ bool Foam::molecule::move(molecule::trackData& td) if (td.part() == 0) { - // Leapfrog velocity adjust part, required before and after - // tracking+force part + // First leapfrog velocity adjust part, required before tracking+force part - U_ += 0.5*deltaT*A_; + v_ += 0.5*deltaT*a_; + + omega1 += 0.5*deltaT*alpha_; } else if (td.part() == 1) { @@ -99,7 +100,7 @@ bool Foam::molecule::move(molecule::trackData& td) // set the lagrangian time-step scalar dt = min(dtMax, tEnd); - dt *= trackToFace(position() + dt*U_, td); + dt *= trackToFace(position() + dt*v_, td); tEnd -= dt; stepFraction() = 1.0 - tEnd/deltaT; @@ -115,6 +116,33 @@ bool Foam::molecule::move(molecule::trackData& td) setSitePositions(td.molCloud().constProps(id_)); } + else if (td.part() == 3) + { + // Second leapfrog velocity adjust part, required after tracking+force part + + const diagTensor& I; // TAKE REFERENCE TO CONST PROP TO GET THIS + + scalar m; // TAKE REFERENCE TO CONST PROP TO GET THIS + + a_ = vector::zero; + + vector tau(vector::zero); + + forAll(siteForces_, s) + { + const vector& f = siteForces_[s]; + + a_ += f/m; + + tau += (sitePositions_[s] - position_) ^ f; + } + + alpha_ = R_ & inv(I) & R_.T() & tau; + + v_ += 0.5*deltaT*a_; + + omega_ += 0.5*deltaT*alpha_; + } else { FatalErrorIn("molecule::move(molecule::trackData& td)") << nl @@ -173,8 +201,8 @@ void Foam::molecule::hitWallPatch vector nw = wpp.faceAreas()[wpp.whichFace(face())]; nw /= mag(nw); - scalar Un = U_ & nw; -// vector Ut = U_ - Un*nw; + scalar vn = v_ & nw; +// vector vt = v_ - vn*nw; // Random rand(clock::getTime()); @@ -186,11 +214,11 @@ void Foam::molecule::hitWallPatch // { // // Diffuse reflection // -// vector tw1 = Ut/mag(Ut); +// vector tw1 = vt/mag(vt); // // vector tw2 = nw ^ tw1; // -// U_ = sqrt(wallTemp/mass_)*rand.GaussNormal()*tw1 +// V_ = sqrt(wallTemp/mass_)*rand.GaussNormal()*tw1 // + sqrt(wallTemp/mass_)*rand.GaussNormal()*tw2 // - mag(sqrt(wallTemp/mass_)*rand.GaussNormal())*nw; // } @@ -199,9 +227,9 @@ void Foam::molecule::hitWallPatch // { // Specular reflection - if (Un > 0) + if (vn > 0) { - U_ -= 2*Un*nw; + v_ -= 2*vn*nw; } // } diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C index d1d740206b..1341695907 100644 --- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C +++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C @@ -42,6 +42,401 @@ Foam::scalar Foam::moleculeCloud::elementaryCharge = 1.602176487e-19; Foam::scalar Foam::moleculeCloud::vacuumPermittivity = 8.854187817e-12; +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::moleculeCloud::buildCellOccupancy() +{ + forAll(cellOccupancy_, cO) + { + cellOccupancy_[cO].clear(); + } + + iterator mol(this->begin()); + + for + ( + mol = this->begin(); + mol != this->end(); + ++mol + ) + { + cellOccupancy_[mol().cell()].append(&mol()); + } + + forAll(cellOccupancy_, cO) + { + cellOccupancy_[cO].shrink(); + } + + il_ril().referMolecules(cellOccupancy_); +} + + +void Foam::moleculeCloud::calculatePairForce() +{ + { + iterator mol(this->begin()); + + // Real-Real interactions + vector rIJ; + + scalar rIJMag; + + scalar rIJMagSq; + + vector fIJ; + + label idI; + + label idJ; + + mol = this->begin(); + + molecule* molI = &mol(); + + molecule* molJ = &mol(); + + forAll(directInteractionList_, dIL) + { + forAll(cellOccupancy_[dIL],cellIMols) + { + molI = cellOccupancy_[dIL][cellIMols]; + + forAll(directInteractionList_[dIL], interactingCells) + { + List< molecule* > cellJ = + cellOccupancy_[directInteractionList_[dIL][interactingCells]]; + + forAll(cellJ, cellJMols) + { + molJ = cellJ[cellJMols]; + + evaluatelPair(molI, molJ); + } + } + + forAll(cellOccupancy_[dIL],cellIOtherMols) + { + molJ = cellOccupancy_[dIL][cellIOtherMols]; + + if (molJ > molI) + { + evaluatePair(molI, molJ); + } + } + } + } + } + + { + // Real-Referred interactions + + vector rKL; + + scalar rKLMag; + + scalar rKLMagSq; + + vector fKL; + + label idK; + + label idL; + + molecule* molK = &mol(); + + forAll(referredInteractionList_, rIL) + { + const List