OpenMPCD
GaussianChains.cpp
2 
5 
7 
9  const unsigned int chainLength,
10  const Simulation* const sim, DeviceMemoryManager* const devMemMgr,
11  const MPCFluid::GaussianChains* const mpcFluid_)
12  : Base(sim->getConfiguration(), mpcFluid_),
13  simulation(sim), mpcFluid(mpcFluid_),
14  squaredBondLengths(NULL)
15 {
17  {
19  new
21  chainLength, sim, devMemMgr, mpcFluid_);
22  }
23 
25  {
27  new
29  chainLength, sim, devMemMgr, mpcFluid_);
30  }
31 
32  const Configuration& config = sim->getConfiguration();
33  if(config.has("instrumentation.gaussianChains.squaredBondLengths"))
34  {
35  if(chainLength < 2)
36  {
38  Exception,
39  "Cannot measure bond lengths with less than two beads.");
40  }
41 
42  squaredBondLengths =
43  new std::vector<OnTheFlyStatisticsDDDA<MPCParticlePositionType> >();
44  squaredBondLengths->resize(chainLength - 1);
45  }
46 }
47 
49 {
50  if(squaredBondLengths)
51  {
52  mpcFluid->fetchFromDevice();
53  const unsigned int chainCount = mpcFluid->getNumberOfLogicalEntities();
54  const unsigned int particlesPerChain =
56 
57  OPENMPCD_DEBUG_ASSERT(particlesPerChain >= 2);
58 
59  for(unsigned int chain = 0; chain < chainCount; ++chain)
60  {
61  const unsigned int firstParticleID = chain * particlesPerChain;
62 
63  for(unsigned int p = 0; p < particlesPerChain - 1; ++p)
64  {
65  const Vector3D<MPCParticlePositionType> distance =
66  mpcFluid->getPosition(firstParticleID + p)
67  -
68  mpcFluid->getPosition(firstParticleID + p + 1);
69 
70  (*squaredBondLengths)[p].addDatum(
71  distance.getMagnitudeSquared());
72  }
73  }
74  }
75 }
76 
77 void GaussianChains::saveSpecific(const std::string& rundir) const
78 {
79  if(squaredBondLengths)
80  {
81  const std::string filePath =
82  rundir + "/gaussianChains--squaredBondLengths.txt";
83  std::ofstream file(filePath.c_str(), std::ios::out);
84 
85  file << "#bond-number\t" << "mean-square-bond-length\t"
86  << "sample-size\t" << "sample-standard-deviation\t"
87  << "DDDA-optimal-block-ID\t"
88  << "DDDA-optimal-standard-error-of-the-mean\t"
89  << "DDDA-optimal-standard-error-of-the-mean-is-reliable\n";
90 
91  for(std::size_t bond = 0; bond < squaredBondLengths->size(); ++bond)
92  {
93  const MPCParticlePositionType standardDeviation =
94  sqrt((*squaredBondLengths)[bond].getBlockVariance(0));
95 
96  file << bond << "\t";
97  file << (*squaredBondLengths)[bond].getSampleMean() << "\t";
98  file << (*squaredBondLengths)[bond].getSampleSize() << "\t";
99  file << standardDeviation << "\t";
100  file <<
101  (*squaredBondLengths)[bond].getOptimalBlockIDForStandardErrorOfTheMean()
102  << "\t";
103  file <<
104  (*squaredBondLengths)[bond].getOptimalStandardErrorOfTheMean()
105  << "\t";
106  file <<
107  ((*squaredBondLengths)[bond].optimalStandardErrorOfTheMeanEstimateIsReliable()
108  ? 1 : 0) << "\n";
109  }
110  }
111 }
OpenMPCD::Configuration::has
bool has(const std::string &setting) const
Returns whether a setting with the given name exists.
Definition: Configuration.hpp:509
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Base::isConfigured
static bool isConfigured(const Simulation *const sim)
Returns whether the given simulation configured this instrumentation.
Definition: Base.cpp:36
OpenMPCD::Configuration
Represents the configuration of the simulation.
Definition: Configuration.hpp:28
OPENMPCD_THROW
#define OPENMPCD_THROW(ExceptionType, message)
Throws the given ExceptionType, passing the given message along with file and line number information...
Definition: Exceptions.hpp:22
OpenMPCD::CUDA::Exception
Base CUDA exception.
Definition: CUDA/Exceptions.hpp:18
OpenMPCD::CUDA::DeviceMemoryManager
Class for managing memory on the CUDA Device.
Definition: DeviceMemoryManager.hpp:21
OpenMPCD::Vector3D
3-dimensional vector.
Definition: Vector3D.hpp:38
OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Base::isConfigured
static bool isConfigured(const Simulation *const sim)
Returns whether the given simulation configured this instrumentation.
OpenMPCD::CUDA::MPCFluid::Instrumentation::FourierTransformedVelocity::Chains
Class for measurements of Fourier-transformed velocities in MPC fluids that consist of chains of arbi...
Definition: Instrumentation/FourierTransformedVelocity/Chains.hpp:29
OPENMPCD_DEBUG_ASSERT
#define OPENMPCD_DEBUG_ASSERT(assertion)
Asserts that the given expression evaluates to true, but only if OPENMPCD_DEBUG is defined.
Definition: OPENMPCD_DEBUG_ASSERT.hpp:88
OpenMPCD::MPCParticlePositionType
FP MPCParticlePositionType
The data type for the positions of MPC particles.
Definition: Types.hpp:15
OpenMPCD::CUDA::MPCFluid::GaussianChains::getNumberOfLogicalEntities
virtual unsigned int getNumberOfLogicalEntities() const
Returns the number of logical entities in the fluid.
Definition: GaussianChains.hpp:59
OpenMPCD::CUDA::MPCFluid::Instrumentation
Namespace for instrumentation classes for MPC fluids.
Definition: CUDA/MPCFluid/Instrumentation/Base.hpp:29
OpenMPCD::CUDA::MPCFluid::Instrumentation::Base::fourierTransformedVelocity
FourierTransformedVelocity::Base * fourierTransformedVelocity
Measures Fourier-transformed velocities.
Definition: CUDA/MPCFluid/Instrumentation/Base.hpp:160
OpenMPCD::CUDA::Simulation::getConfiguration
const Configuration & getConfiguration() const
Returns the configuration.
Definition: CUDA/Simulation.hpp:81
OpenMPCD::CUDA::MPCFluid::GaussianChains::getNumberOfParticlesPerLogicalEntity
virtual unsigned int getNumberOfParticlesPerLogicalEntity() const
Returns the number of MPC particles per logical entity.
Definition: GaussianChains.hpp:69
OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Chains
Class for measurements of velocity autocorrelation in MPC fluids that consist of chains of particles.
Definition: Instrumentation/VelocityAutocorrelation/Chains.hpp:29
OpenMPCD::CUDA::MPCFluid::Base::fetchFromDevice
void fetchFromDevice() const
Copies the MPC fluid particles from the CUDA Device to the Host.
OpenMPCD::CUDA::Simulation
MPCD simulation with Molecular Dynamics on CUDA-capable GPUs.
Definition: CUDA/Simulation.hpp:48
OpenMPCD::CUDA::MPCFluid::Instrumentation::GaussianChains::GaussianChains
GaussianChains(const unsigned int chainLength, const Simulation *const sim, DeviceMemoryManager *const devMemMgr, const MPCFluid::GaussianChains *const mpcFluid_)
The constructor.
Definition: GaussianChains.cpp:8
Chains.hpp
OpenMPCD::CUDA::MPCFluid::Instrumentation::Base
Base class for MPC fluids instrumentation.
Definition: CUDA/MPCFluid/Instrumentation/Base.hpp:34
Chains.hpp
OpenMPCD::Utility::MathematicalFunctions::sqrt
OPENMPCD_CUDA_HOST_AND_DEVICE T sqrt(const T x)
Returns the sqaure root of the argument.
OpenMPCD::CUDA::MPCFluid::Instrumentation::GaussianChains::saveSpecific
virtual void saveSpecific(const std::string &rundir) const
Saves the data to the given run directory.
Definition: GaussianChains.cpp:77
GaussianChains.hpp
OpenMPCD::CUDA::MPCFluid::Instrumentation::GaussianChains::measureSpecific
virtual void measureSpecific()
Performs measurements.
Definition: GaussianChains.cpp:48
OpenMPCD::CUDA::MPCFluid::GaussianChains
Generalization of GaussianDumbbells to chains with an arbitrary number of constituent particles.
Definition: GaussianChains.hpp:38
OpenMPCD::CUDA::MPCFluid::Base::getPosition
const RemotelyStoredVector< const MPCParticlePositionType > getPosition(const unsigned int particleID) const
Returns a MPC fluid particle's position vector.
OpenMPCD::Vector3D::getMagnitudeSquared
OPENMPCD_CUDA_HOST_AND_DEVICE RealType getMagnitudeSquared() const
Returns the square of the magnitude of this vector.
Definition: Vector3D.hpp:209
OpenMPCD::CUDA::MPCFluid::Instrumentation::Base::velocityAutocorrelation
VelocityAutocorrelation::Base * velocityAutocorrelation
Measures velocity autocorrelation.
Definition: CUDA/MPCFluid/Instrumentation/Base.hpp:169