71 |
|
RNEMD::RNEMD(SimInfo* info) : info_(info), evaluator_(info), seleMan_(info), |
72 |
|
evaluatorA_(info), seleManA_(info), |
73 |
|
commonA_(info), evaluatorB_(info), |
74 |
< |
seleManB_(info), commonB_(info), |
74 |
> |
seleManB_(info), commonB_(info), |
75 |
> |
hasData_(false), hasDividingArea_(false), |
76 |
|
usePeriodicBoundaryConditions_(info->getSimParams()->getUsePeriodicBoundaryConditions()) { |
77 |
|
|
78 |
|
trialCount_ = 0; |
557 |
|
slabWidth_ = hmat(2,2) / 10.0; |
558 |
|
|
559 |
|
if (hasSlabBCenter) |
560 |
< |
slabBCenter_ = rnemdParams->getSlabACenter(); |
560 |
> |
slabBCenter_ = rnemdParams->getSlabBCenter(); |
561 |
|
else |
562 |
|
slabBCenter_ = hmat(2,2) / 2.0; |
563 |
|
|
578 |
|
} |
579 |
|
} |
580 |
|
} |
581 |
+ |
|
582 |
|
// object evaluator: |
583 |
|
evaluator_.loadScriptString(rnemdObjectSelection_); |
584 |
|
seleMan_.setSelectionSet(evaluator_.evaluate()); |
583 |
– |
|
585 |
|
evaluatorA_.loadScriptString(selectionA_); |
586 |
|
evaluatorB_.loadScriptString(selectionB_); |
586 |
– |
|
587 |
|
seleManA_.setSelectionSet(evaluatorA_.evaluate()); |
588 |
|
seleManB_.setSelectionSet(evaluatorB_.evaluate()); |
589 |
– |
|
589 |
|
commonA_ = seleManA_ & seleMan_; |
590 |
< |
commonB_ = seleManB_ & seleMan_; |
590 |
> |
commonB_ = seleManB_ & seleMan_; |
591 |
|
} |
592 |
|
|
593 |
|
|
604 |
|
#ifdef IS_MPI |
605 |
|
} |
606 |
|
#endif |
607 |
+ |
|
608 |
+ |
// delete all of the objects we created: |
609 |
+ |
delete areaAccumulator_; |
610 |
+ |
data_.clear(); |
611 |
|
} |
612 |
|
|
613 |
|
void RNEMD::doSwap(SelectionManager& smanA, SelectionManager& smanB) { |
1151 |
|
//if w is in the right range, so should be x, y, z. |
1152 |
|
vector<StuntDouble*>::iterator sdi; |
1153 |
|
Vector3d vel; |
1154 |
< |
for (sdi = coldBin.begin(); sdi != coldBin.end(); sdi++) { |
1154 |
> |
for (sdi = coldBin.begin(); sdi != coldBin.end(); ++sdi) { |
1155 |
|
if (rnemdFluxType_ == rnemdFullKE) { |
1156 |
|
vel = (*sdi)->getVel() * c; |
1157 |
|
(*sdi)->setVel(vel); |
1162 |
|
} |
1163 |
|
} |
1164 |
|
w = sqrt(w); |
1165 |
< |
for (sdi = hotBin.begin(); sdi != hotBin.end(); sdi++) { |
1165 |
> |
for (sdi = hotBin.begin(); sdi != hotBin.end(); ++sdi) { |
1166 |
|
if (rnemdFluxType_ == rnemdFullKE) { |
1167 |
|
vel = (*sdi)->getVel(); |
1168 |
|
vel.x() *= x; |
1281 |
|
vector<RealType>::iterator ri; |
1282 |
|
RealType r1, r2, alpha0; |
1283 |
|
vector<pair<RealType,RealType> > rps; |
1284 |
< |
for (ri = realRoots.begin(); ri !=realRoots.end(); ri++) { |
1284 |
> |
for (ri = realRoots.begin(); ri !=realRoots.end(); ++ri) { |
1285 |
|
r2 = *ri; |
1286 |
|
//check if FindRealRoots() give the right answer |
1287 |
|
if ( fabs(u0 + r2 * (u1 + r2 * (u2 + r2 * (u3 + r2 * u4)))) > 1e-6 ) { |
1313 |
|
RealType diff; |
1314 |
|
pair<RealType,RealType> bestPair = make_pair(1.0, 1.0); |
1315 |
|
vector<pair<RealType,RealType> >::iterator rpi; |
1316 |
< |
for (rpi = rps.begin(); rpi != rps.end(); rpi++) { |
1316 |
> |
for (rpi = rps.begin(); rpi != rps.end(); ++rpi) { |
1317 |
|
r1 = (*rpi).first; |
1318 |
|
r2 = (*rpi).second; |
1319 |
|
switch(rnemdFluxType_) { |
1380 |
|
} |
1381 |
|
vector<StuntDouble*>::iterator sdi; |
1382 |
|
Vector3d vel; |
1383 |
< |
for (sdi = coldBin.begin(); sdi != coldBin.end(); sdi++) { |
1383 |
> |
for (sdi = coldBin.begin(); sdi != coldBin.end(); ++sdi) { |
1384 |
|
vel = (*sdi)->getVel(); |
1385 |
|
vel.x() *= x; |
1386 |
|
vel.y() *= y; |
1391 |
|
x = 1.0 + px * (1.0 - x); |
1392 |
|
y = 1.0 + py * (1.0 - y); |
1393 |
|
z = 1.0 + pz * (1.0 - z); |
1394 |
< |
for (sdi = hotBin.begin(); sdi != hotBin.end(); sdi++) { |
1394 |
> |
for (sdi = hotBin.begin(); sdi != hotBin.end(); ++sdi) { |
1395 |
|
vel = (*sdi)->getVel(); |
1396 |
|
vel.x() *= x; |
1397 |
|
vel.y() *= y; |
1669 |
|
Vector3d vel; |
1670 |
|
Vector3d rPos; |
1671 |
|
|
1672 |
< |
for (sdi = coldBin.begin(); sdi != coldBin.end(); sdi++) { |
1672 |
> |
for (sdi = coldBin.begin(); sdi != coldBin.end(); ++sdi) { |
1673 |
|
//vel = (*sdi)->getVel(); |
1674 |
|
rPos = (*sdi)->getPos() - coordinateOrigin_; |
1675 |
|
if (doLinearPart) |
1685 |
|
} |
1686 |
|
} |
1687 |
|
} |
1688 |
< |
for (sdi = hotBin.begin(); sdi != hotBin.end(); sdi++) { |
1688 |
> |
for (sdi = hotBin.begin(); sdi != hotBin.end(); ++sdi) { |
1689 |
|
//vel = (*sdi)->getVel(); |
1690 |
|
rPos = (*sdi)->getPos() - coordinateOrigin_; |
1691 |
|
if (doLinearPart) |
1735 |
|
int isd; |
1736 |
|
StuntDouble* sd; |
1737 |
|
vector<StuntDouble*> aSites; |
1735 |
– |
ConvexHull* surfaceMeshA = new ConvexHull(); |
1738 |
|
seleManA_.setSelectionSet(evaluatorA_.evaluate()); |
1739 |
|
for (sd = seleManA_.beginSelected(isd); sd != NULL; |
1740 |
|
sd = seleManA_.nextSelected(isd)) { |
1741 |
|
aSites.push_back(sd); |
1742 |
|
} |
1743 |
+ |
ConvexHull* surfaceMeshA = new ConvexHull(); |
1744 |
|
surfaceMeshA->computeHull(aSites); |
1745 |
|
areaA = surfaceMeshA->getArea(); |
1746 |
+ |
delete surfaceMeshA; |
1747 |
+ |
|
1748 |
|
} else { |
1749 |
|
if (usePeriodicBoundaryConditions_) { |
1750 |
|
// in periodic boundaries, the surface area is twice the x-y |
1758 |
|
} |
1759 |
|
} |
1760 |
|
|
1761 |
+ |
|
1762 |
+ |
|
1763 |
|
if (hasSelectionB_) { |
1764 |
|
int isd; |
1765 |
|
StuntDouble* sd; |
1766 |
|
vector<StuntDouble*> bSites; |
1760 |
– |
ConvexHull* surfaceMeshB = new ConvexHull(); |
1767 |
|
seleManB_.setSelectionSet(evaluatorB_.evaluate()); |
1768 |
|
for (sd = seleManB_.beginSelected(isd); sd != NULL; |
1769 |
|
sd = seleManB_.nextSelected(isd)) { |
1770 |
|
bSites.push_back(sd); |
1771 |
|
} |
1772 |
+ |
ConvexHull* surfaceMeshB = new ConvexHull(); |
1773 |
|
surfaceMeshB->computeHull(bSites); |
1774 |
|
areaB = surfaceMeshB->getArea(); |
1775 |
+ |
delete surfaceMeshB; |
1776 |
+ |
|
1777 |
|
} else { |
1778 |
|
if (usePeriodicBoundaryConditions_) { |
1779 |
|
// in periodic boundaries, the surface area is twice the x-y |
2013 |
|
} |
2014 |
|
} |
2015 |
|
} |
2016 |
+ |
hasData_ = true; |
2017 |
|
} |
2018 |
|
|
2019 |
|
void RNEMD::getStarted() { |
2046 |
|
|
2047 |
|
void RNEMD::writeOutputFile() { |
2048 |
|
if (!doRNEMD_) return; |
2049 |
+ |
if (!hasData_) return; |
2050 |
|
|
2051 |
|
#ifdef IS_MPI |
2052 |
|
// If we're the root node, should we print out the results |
2068 |
|
RealType time = currentSnap_->getTime(); |
2069 |
|
RealType avgArea; |
2070 |
|
areaAccumulator_->getAverage(avgArea); |
2071 |
< |
RealType Jz = kineticExchange_ / (time * avgArea) |
2072 |
< |
/ PhysicalConstants::energyConvert; |
2073 |
< |
Vector3d JzP = momentumExchange_ / (time * avgArea); |
2074 |
< |
Vector3d JzL = angularMomentumExchange_ / (time * avgArea); |
2071 |
> |
|
2072 |
> |
RealType Jz(0.0); |
2073 |
> |
Vector3d JzP(V3Zero); |
2074 |
> |
Vector3d JzL(V3Zero); |
2075 |
> |
if (time >= info_->getSimParams()->getDt()) { |
2076 |
> |
Jz = kineticExchange_ / (time * avgArea) |
2077 |
> |
/ PhysicalConstants::energyConvert; |
2078 |
> |
JzP = momentumExchange_ / (time * avgArea); |
2079 |
> |
JzL = angularMomentumExchange_ / (time * avgArea); |
2080 |
> |
} |
2081 |
|
|
2082 |
|
rnemdFile_ << "#######################################################\n"; |
2083 |
|
rnemdFile_ << "# RNEMD {\n"; |
2231 |
|
rnemdFile_ << "\t" << s; |
2232 |
|
} else{ |
2233 |
|
sprintf( painCave.errMsg, |
2234 |
< |
"RNEMD detected a numerical error writing: %s for bin %d", |
2234 |
> |
"RNEMD detected a numerical error writing: %s for bin %u", |
2235 |
|
data_[index].title.c_str(), bin); |
2236 |
|
painCave.isFatal = 1; |
2237 |
|
simError(); |
2254 |
|
isinf(s[1]) || isnan(s[1]) || |
2255 |
|
isinf(s[2]) || isnan(s[2]) ) { |
2256 |
|
sprintf( painCave.errMsg, |
2257 |
< |
"RNEMD detected a numerical error writing: %s for bin %d", |
2257 |
> |
"RNEMD detected a numerical error writing: %s for bin %u", |
2258 |
|
data_[index].title.c_str(), bin); |
2259 |
|
painCave.isFatal = 1; |
2260 |
|
simError(); |
2279 |
|
rnemdFile_ << "\t" << s; |
2280 |
|
} else{ |
2281 |
|
sprintf( painCave.errMsg, |
2282 |
< |
"RNEMD detected a numerical error writing: %s std. dev. for bin %d", |
2282 |
> |
"RNEMD detected a numerical error writing: %s std. dev. for bin %u", |
2283 |
|
data_[index].title.c_str(), bin); |
2284 |
|
painCave.isFatal = 1; |
2285 |
|
simError(); |
2301 |
|
isinf(s[1]) || isnan(s[1]) || |
2302 |
|
isinf(s[2]) || isnan(s[2]) ) { |
2303 |
|
sprintf( painCave.errMsg, |
2304 |
< |
"RNEMD detected a numerical error writing: %s std. dev. for bin %d", |
2304 |
> |
"RNEMD detected a numerical error writing: %s std. dev. for bin %u", |
2305 |
|
data_[index].title.c_str(), bin); |
2306 |
|
painCave.isFatal = 1; |
2307 |
|
simError(); |