| 43 |
|
#include "applications/staticProps/SpatialStatistics.hpp" |
| 44 |
|
#include "io/DumpReader.hpp" |
| 45 |
|
#include "primitives/Molecule.hpp" |
| 46 |
+ |
#ifdef _MSC_VER |
| 47 |
+ |
#define isnan(x) _isnan((x)) |
| 48 |
+ |
#define isinf(x) (!_finite(x) && !_isnan(x)) |
| 49 |
+ |
#endif |
| 50 |
|
|
| 51 |
|
namespace OpenMD { |
| 52 |
|
|
| 141 |
|
processStuntDouble( sd, bin ); |
| 142 |
|
|
| 143 |
|
dynamic_cast<Accumulator *>(counts_->accumulator[bin])->add(1); |
| 144 |
< |
} |
| 144 |
> |
} |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
|
| 225 |
|
int n = dat->accumulator[bin]->count(); |
| 226 |
|
if (n == 0) return; |
| 227 |
|
|
| 224 |
– |
RealType r; |
| 225 |
– |
Vector3d v; |
| 226 |
– |
|
| 228 |
|
if( dat->dataType == odtReal ) { |
| 229 |
+ |
RealType r; |
| 230 |
|
dynamic_cast<Accumulator*>(dat->accumulator[bin])->getAverage(r); |
| 231 |
|
if (isinf(r) || isnan(r) ) { |
| 232 |
|
sprintf( painCave.errMsg, |
| 233 |
|
"SpatialStatistics detected a numerical error writing:\n" |
| 234 |
< |
"\t%s for bin %d", |
| 234 |
> |
"\t%s for bin %u", |
| 235 |
|
dat->title.c_str(), bin); |
| 236 |
|
painCave.isFatal = 1; |
| 237 |
|
simError(); |
| 240 |
|
os << "\t" << r; |
| 241 |
|
|
| 242 |
|
} else if ( dat->dataType == odtVector3 ) { |
| 243 |
+ |
Vector3d v; |
| 244 |
|
dynamic_cast<VectorAccumulator*>(dat->accumulator[bin])->getAverage(v); |
| 245 |
|
if (isinf(v[0]) || isnan(v[0]) || |
| 246 |
|
isinf(v[1]) || isnan(v[1]) || |
| 247 |
|
isinf(v[2]) || isnan(v[2]) ) { |
| 248 |
|
sprintf( painCave.errMsg, |
| 249 |
|
"SpatialStatistics detected a numerical error writing:\n" |
| 250 |
< |
"\t%s for bin %d", |
| 250 |
> |
"\t%s for bin %u", |
| 251 |
|
dat->title.c_str(), bin); |
| 252 |
|
painCave.isFatal = 1; |
| 253 |
|
simError(); |
| 263 |
|
int n = dat->accumulator[bin]->count(); |
| 264 |
|
if (n == 0) return; |
| 265 |
|
|
| 263 |
– |
RealType r; |
| 264 |
– |
Vector3d v; |
| 265 |
– |
|
| 266 |
|
if( dat->dataType == odtReal ) { |
| 267 |
+ |
RealType r; |
| 268 |
|
dynamic_cast<Accumulator*>(dat->accumulator[bin])->getStdDev(r); |
| 269 |
|
if (isinf(r) || isnan(r) ) { |
| 270 |
|
sprintf( painCave.errMsg, |
| 271 |
|
"SpatialStatistics detected a numerical error writing:\n" |
| 272 |
< |
"\tstandard deviation of %s for bin %d", |
| 272 |
> |
"\tstandard deviation of %s for bin %u", |
| 273 |
|
dat->title.c_str(), bin); |
| 274 |
|
painCave.isFatal = 1; |
| 275 |
|
simError(); |
| 278 |
|
os << "\t" << r; |
| 279 |
|
|
| 280 |
|
} else if ( dat->dataType == odtVector3 ) { |
| 281 |
+ |
Vector3d v; |
| 282 |
|
dynamic_cast<VectorAccumulator*>(dat->accumulator[bin])->getStdDev(v); |
| 283 |
|
if (isinf(v[0]) || isnan(v[0]) || |
| 284 |
|
isinf(v[1]) || isnan(v[1]) || |
| 285 |
|
isinf(v[2]) || isnan(v[2]) ) { |
| 286 |
|
sprintf( painCave.errMsg, |
| 287 |
|
"SpatialStatistics detected a numerical error writing:\n" |
| 288 |
< |
"\tstandard deviation of %s for bin %d", |
| 288 |
> |
"\tstandard deviation of %s for bin %u", |
| 289 |
|
dat->title.c_str(), bin); |
| 290 |
|
painCave.isFatal = 1; |
| 291 |
|
simError(); |
| 322 |
|
data_.push_back(z_); |
| 323 |
|
} |
| 324 |
|
|
| 325 |
+ |
SlabStatistics::~SlabStatistics() { |
| 326 |
+ |
} |
| 327 |
+ |
|
| 328 |
+ |
|
| 329 |
|
void SlabStatistics::processFrame(int istep) { |
| 330 |
|
RealType z; |
| 331 |
|
hmat_ = currentSnapshot_->getHmat(); |
| 348 |
|
return int(nBins_ * (pos.z() / hmat_(2,2) + 0.5)) % nBins_; |
| 349 |
|
} |
| 350 |
|
|
| 345 |
– |
|
| 351 |
|
ShellStatistics::ShellStatistics(SimInfo* info, const string& filename, |
| 352 |
|
const string& sele, int nbins) : |
| 353 |
< |
SpatialStatistics(info, filename, sele, nbins){ |
| 353 |
> |
SpatialStatistics(info, filename, sele, nbins), coordinateOrigin_(V3Zero) { |
| 354 |
|
|
| 350 |
– |
coordinateOrigin_ = V3Zero; |
| 355 |
|
binWidth_ = 1.0; |
| 356 |
< |
|
| 356 |
> |
|
| 357 |
|
r_ = new OutputData; |
| 358 |
|
r_->units = "Angstroms"; |
| 359 |
|
r_->title = "R"; |
| 370 |
|
} |
| 371 |
|
} |
| 372 |
|
|
| 373 |
+ |
ShellStatistics::~ShellStatistics() { |
| 374 |
+ |
} |
| 375 |
+ |
|
| 376 |
|
int ShellStatistics::getBin(Vector3d pos) { |
| 377 |
|
Vector3d rPos = pos - coordinateOrigin_; |
| 378 |
|
return int(rPos.length() / binWidth_); |