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

Comparing trunk/OOPSE-4/src/integrators/SMIPDForceManager.cpp (file contents):
Revision 3504 by gezelter, Wed May 13 22:27:29 2009 UTC vs.
Revision 3517 by gezelter, Thu Jul 23 18:49:45 2009 UTC

# Line 41 | Line 41
41   #include <fstream>
42   #include <iostream>
43   #include "integrators/SMIPDForceManager.hpp"
44 #include "math/CholeskyDecomposition.hpp"
44   #include "utils/OOPSEConstant.hpp"
45   #include "math/ConvexHull.hpp"
46   #include "math/Triangle.hpp"
# Line 63 | Line 62 | namespace oopse {
62      if (!simParams->haveTargetTemp()) {
63        sprintf(painCave.errMsg,
64                "SMIPDynamics error: You can't use the SMIPD integrator\n"
65 <              "   without a targetTemp!\n");      
65 >              "\twithout a targetTemp (K)!\n");      
66        painCave.isFatal = 1;
67        painCave.severity = OOPSE_ERROR;
68        simError();
# Line 74 | Line 73 | namespace oopse {
73      if (!simParams->haveTargetPressure()) {
74        sprintf(painCave.errMsg,
75                "SMIPDynamics error: You can't use the SMIPD integrator\n"
76 <              "   without a targetPressure!\n");      
76 >              "\twithout a targetPressure (atm)!\n");      
77        painCave.isFatal = 1;
78        simError();
79      } else {
# Line 86 | Line 85 | namespace oopse {
85      if (simParams->getUsePeriodicBoundaryConditions()) {
86        sprintf(painCave.errMsg,
87                "SMIPDynamics error: You can't use the SMIPD integrator\n"
88 <              "   with periodic boundary conditions!\n");    
88 >              "\twith periodic boundary conditions!\n");    
89        painCave.isFatal = 1;
90        simError();
91      }
92      
93 <    if (!simParams->haveViscosity()) {
93 >    if (!simParams->haveThermalConductivity()) {
94        sprintf(painCave.errMsg,
95                "SMIPDynamics error: You can't use the SMIPD integrator\n"
96 <              "   without a viscosity!\n");
96 >              "\twithout a thermalConductivity (W m^-1 K^-1)!\n");
97        painCave.isFatal = 1;
98        painCave.severity = OOPSE_ERROR;
99        simError();
100      }else{
101 <      viscosity_ = simParams->getViscosity();
101 >      thermalConductivity_ = simParams->getThermalConductivity() *
102 >        OOPSEConstant::thermalConductivityConvert;
103      }
104 +
105 +    if (!simParams->haveThermalLength()) {
106 +      sprintf(painCave.errMsg,
107 +              "SMIPDynamics error: You can't use the SMIPD integrator\n"
108 +              "\twithout a thermalLength (Angstroms)!\n");
109 +      painCave.isFatal = 1;
110 +      painCave.severity = OOPSE_ERROR;
111 +      simError();
112 +    }else{
113 +      thermalLength_ = simParams->getThermalLength();
114 +    }
115      
116      dt_ = simParams->getDt();
117    
# Line 130 | Line 141 | namespace oopse {
141      StuntDouble* integrableObject;
142    
143      // Compute surface Mesh
144 +
145      surfaceMesh_->computeHull(localSites_);
146  
147      // Get total area and number of surface stunt doubles
# Line 139 | Line 151 | namespace oopse {
151      int nTriangles = sMesh.size();
152  
153      // Generate all of the necessary random forces
154 <    std::vector<Vector3d>  randNums = genTriangleForces(nTriangles, variance_);
154 >    std::vector<RealType>  randNums = genTriangleForces(nTriangles, variance_);
155  
156      // Loop over the mesh faces and apply external pressure to each
157      // of the faces
# Line 155 | Line 167 | namespace oopse {
167        unitNormal.normalize();
168        Vector3d centroid = thisTriangle.getCentroid();
169        Vector3d facetVel = thisTriangle.getFacetVelocity();
170 +      RealType thisMass = thisTriangle.getFacetMass();
171  
172 <      Mat3x3d hydroTensor = thisTriangle.computeHydrodynamicTensor(viscosity_);
172 >      // gamma is the drag coefficient normal to the face of the triangle      
173 >      RealType gamma = thermalConductivity_ * thisMass * thisArea
174 >        / (2.0 * thermalLength_ * OOPSEConstant::kB);
175 >      
176 >      RealType extPressure = - (targetPressure_ * thisArea) /
177 >        OOPSEConstant::energyConvert;
178  
179 <      hydroTensor *= OOPSEConstant::viscoConvert;
180 <      Mat3x3d S;
163 <      CholeskyDecomposition(hydroTensor, S);
179 >      RealType randomForce = randNums[thisFacet++] * sqrt(gamma);
180 >      RealType dragForce = -gamma * dot(facetVel, unitNormal);
181  
182 <      Vector3d extPressure = -unitNormal*(targetPressure_ * thisArea)/OOPSEConstant::energyConvert;      
183 <      Vector3d randomForce = S * randNums[thisFacet++];
184 <      Vector3d dragForce = -hydroTensor * facetVel;
168 <
169 <      Vector3d langevinForce = (extPressure + randomForce + dragForce);
170 <
182 >      Vector3d langevinForce = (extPressure + randomForce + dragForce) *
183 >        unitNormal;
184 >      
185        // Apply triangle force to stuntdouble vertices
186        for (vertex = vertexSDs.begin(); vertex != vertexSDs.end(); ++vertex){
187          if ((*vertex) != NULL){
# Line 181 | Line 195 | namespace oopse {
195          }  
196        }
197      }
198 <        
198 >    
199      veloMunge->removeComDrift();
200      veloMunge->removeAngularDrift();
201 <
201 >    
202      Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
203      currSnapshot->setVolume(surfaceMesh_->getVolume());    
204      ForceManager::postCalculation(needStress);  
205    }
192
206    
207 <  std::vector<Vector3d> SMIPDForceManager::genTriangleForces(int nTriangles,
207 >  
208 >  std::vector<RealType> SMIPDForceManager::genTriangleForces(int nTriangles,
209                                                               RealType variance)
210    {
211      
212      // zero fill the random vector before starting:
213 <    std::vector<Vector3d> gaussRand;
213 >    std::vector<RealType> gaussRand;
214      gaussRand.resize(nTriangles);
215 <    std::fill(gaussRand.begin(), gaussRand.end(), V3Zero);
215 >    std::fill(gaussRand.begin(), gaussRand.end(), 0.0);
216      
217   #ifdef IS_MPI
218      if (worldRank == 0) {
219   #endif
206      RealType rx, ry, rz;
220        for (int i = 0; i < nTriangles; i++) {
221 <        rx = randNumGen_.randNorm(0.0, variance);
209 <        ry = randNumGen_.randNorm(0.0, variance);
210 <        rz = randNumGen_.randNorm(0.0, variance);
211 <        gaussRand[i][0] = rx;
212 <        gaussRand[i][1] = ry;
213 <        gaussRand[i][2] = rz;
221 >        gaussRand[i] = randNumGen_.randNorm(0.0, variance);
222        }
223   #ifdef IS_MPI
224      }
# Line 220 | Line 228 | namespace oopse {
228      
229   #ifdef IS_MPI
230      if (worldRank == 0) {
231 <      MPI_Bcast(&gaussRand[0], nTriangles*3 , MPI_REALTYPE, 0, MPI_COMM_WORLD);
231 >      MPI::COMM_WORLD.Bcast(&gaussRand[0], nTriangles, MPI::REALTYPE, 0);
232      } else {
233 <      MPI_Bcast(&gaussRand[0], nTriangles*3, MPI_REALTYPE, 0, MPI_COMM_WORLD);
233 >      MPI::COMM_WORLD.Bcast(&gaussRand[0], nTriangles, MPI::REALTYPE, 0);
234      }
235   #endif
236      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines