OpenMPCD
Public Member Functions | Static Public Member Functions | List of all members
OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement Class Reference

Measures the mean square displacement of logical entities in an MPC fluid. More...

#include <LogicalEntityMeanSquareDisplacement.hpp>

Public Member Functions

 LogicalEntityMeanSquareDisplacement (const OpenMPCD::Configuration &configuration, const OpenMPCD::CUDA::MPCFluid::Base *const mpcFluid_)
 The constructor. More...
 
 ~LogicalEntityMeanSquareDisplacement ()
 The destructor. More...
 
void measure ()
 Takes measurement data. More...
 
unsigned int getMaximumMeasurementTime () const
 Returns, in units of measurement time, the maximum measurement time that is configured to be measured, i.e. More...
 
unsigned int getMeasurementCount () const
 Returns 1 plus the maximum number t may take in getMeanSquareDisplacement. More...
 
MPCParticlePositionType getMeanSquareDisplacement (const unsigned int t, const unsigned int T) const
 Returns the measured mean square displacement \( C \left( t, t + \Delta t \right) \) between measurement times \( t \) and \( T \). More...
 
void save (std::ostream &stream)
 Saves the result to the given stream. More...
 
void save (const std::string &rundir)
 Saves the result to the given run directory. More...
 

Static Public Member Functions

static bool isConfigured (const Configuration &config)
 Returns whether the an attempt has been made to configure this class, i.e. More...
 
static bool isValidConfiguration (const Configuration::Setting &group)
 Returns whether the given configuration group is a valid configuration. More...
 

Detailed Description

Measures the mean square displacement of logical entities in an MPC fluid.

This class can only be used if OpenMPCD::CUDA::MPCFluid::Base::numberOfParticlesPerLogicalEntityIsConstant is true.

Let \( \vec{R}_i \) be the center of mass for the logical entity \( i \), with \( i \in \left[0, N_L - 1 \right]\), where \( N_L \) is the return value of OpenMPCD::CUDA::MPCFluid::Base::getNumberOfLogicalEntities.

Then, this class samples, for configurable times \( \Delta t \), the quantity

\[ C \left( t, t + \Delta t \right) = \frac{1}{N_L} \sum_{i=1}^{N_L} \left( \vec{R}_i \left( t + \Delta t \right) - \vec{R}_i \left( t \right) \right)^2 \]

In order to avoid floating-point arithmetic in specifying times, and in order to decouple this class from the CUDA::Simulation class, time is measured in this class as the number of times measure has completed, not counting those calls that have no effect because of the measureEveryNthSweep configuration option (see below). As an example, take measureEveryNthSweep to be 3. Then, the first execution of measure will perform a measurement, and that point in simulation time will be referred to as measurement time 0. The next two calls to measure will again have no effect, while the following (i.e. the fourth) call will be at measurement time 1. The fifth and sixth calls will again have no effect, and so forth.

This class is configured via the instrumentation.logicalEntityMeanSquareDisplacement configuration group. Within that group, measureEveryNthSweep defines \( \tau \), and measurementArgumentCount defines \( N_A \); given those, the mean square displacement is measured at (simulation) times

\[ \Delta t \in \left\{ \tau \Delta T, 2 \tau \Delta T, \ldots, N_A \tau \Delta T \right\} \]

where \( \Delta T \) is the simulation time between consecutive sweeps. Consequently, in measurement time, \( \Delta t \in \left\{ 1, 2, \ldots, N_A \right\} \).

For analysis of the produced results, see MPCDAnalysis.LogicalEntityMeanSquareDisplacement.

Definition at line 86 of file LogicalEntityMeanSquareDisplacement.hpp.

Constructor & Destructor Documentation

◆ LogicalEntityMeanSquareDisplacement()

OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::LogicalEntityMeanSquareDisplacement ( const OpenMPCD::Configuration configuration,
const OpenMPCD::CUDA::MPCFluid::Base *const  mpcFluid_ 
)

The constructor.

Exceptions
OpenMPCD::NULLPointerExceptionIf OPENMPCD_DEBUG is defined, throws if mpcFluid_ == nullptr.
OpenMPCD::InvalidConfigurationExceptionThrows if `!isValidConfiguration( configuration.getSetting( "instrumentation.logicalEntityMeanSquareDisplacement"))`.
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if !mpcFluid_->numberOfParticlesPerLogicalEntityIsConstant().
Parameters
[in]configurationThe simulation configuration.
[in]mpcFluid_The fluid to measure. Must not be nullptr, and it must return true when its numberOfParticlesPerLogicalEntityIsConstant member is called.

◆ ~LogicalEntityMeanSquareDisplacement()

OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::~LogicalEntityMeanSquareDisplacement ( )

The destructor.

Member Function Documentation

◆ getMaximumMeasurementTime()

unsigned int OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::getMaximumMeasurementTime ( ) const

Returns, in units of measurement time, the maximum measurement time that is configured to be measured, i.e.

\( N_A \).

◆ getMeanSquareDisplacement()

MPCParticlePositionType OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::getMeanSquareDisplacement ( const unsigned int  t,
const unsigned int  T 
) const

Returns the measured mean square displacement \( C \left( t, t + \Delta t \right) \) between measurement times \( t \) and \( T \).

Note
The times are given in units of the measurement time, which is described in the documentation of this class.
Exceptions
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if t >= getMeasurementCount().
OpenMPCD::InvalidArgumentExceptionIf OPENMPCD_DEBUG is defined, throws if T >= getMeasurementCount() or T <= t or T - t > getMaximumMeasurementTime().
Parameters
[in]tThe first measurement time \( t \). This value must be smaller than getMeasurementCount().
[in]TThe second measurement time \( T \). This value must be smaller than getMeasurementCount() and larger than t. Also, T - t must not be larger than getMaximumMeasurementTime().

◆ getMeasurementCount()

unsigned int OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::getMeasurementCount ( ) const

Returns 1 plus the maximum number t may take in getMeanSquareDisplacement.

◆ isConfigured()

static bool OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::isConfigured ( const Configuration config)
static

Returns whether the an attempt has been made to configure this class, i.e.

whether the instrumentation.logicalEntityMeanSquareDisplacement configuration group exists.

Parameters
[in]configThe configuration to query.

◆ isValidConfiguration()

static bool OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::isValidConfiguration ( const Configuration::Setting group)
static

Returns whether the given configuration group is a valid configuration.

For a configuration group to be valid, it must

  • contain the key measureEveryNthSweep, which must be a positive integer
  • contain the key measurementArgumentCount, which must be a positive integer.
Parameters
[in]groupThe configuration group to query.

◆ measure()

void OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::measure ( )

Takes measurement data.

This function is to be called by the OpenMPCD::CUDA::Simulation instance after every sweep.

◆ save() [1/2]

void OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::save ( const std::string &  rundir)

Saves the result to the given run directory.

The file within the given directory will be named logicalEntityMeanSquareDisplacement.data, and will be created if it does not exist, or truncated if it does. Parent directories will be created as needed. The file's contents will correspond to the output of save(std::ostream&).

Parameters
[in]rundirPath to the directory, into which the result file will be written.

◆ save() [2/2]

void OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::save ( std::ostream &  stream)

Saves the result to the given stream.

For each value t in the range [0, getMeasurementCount()), and for each value T in the range [t + 1, t + getMaximumMeasurementTime()] (except for those where T >= getMeasurementCount()), a line will be written to the output stream, with the following fields, separated by tab characters: First, the current value of t, followed by the value of T - t, followed by the value of getMeanSquareDisplacement(t, T).

The numeric values will be written with precision std::numeric_limits<OpenMPCD::FP>::digits10 + 2.

Parameters
[out]streamThe stream to write to.

The documentation for this class was generated from the following file: