OpenMPCD
|
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... | |
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.
OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::LogicalEntityMeanSquareDisplacement | ( | const OpenMPCD::Configuration & | configuration, |
const OpenMPCD::CUDA::MPCFluid::Base *const | mpcFluid_ | ||
) |
The constructor.
OpenMPCD::NULLPointerException | If OPENMPCD_DEBUG is defined, throws if mpcFluid_ == nullptr . |
OpenMPCD::InvalidConfigurationException | Throws if `!isValidConfiguration( configuration.getSetting( "instrumentation.logicalEntityMeanSquareDisplacement"))`. |
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if !mpcFluid_->numberOfParticlesPerLogicalEntityIsConstant() . |
[in] | configuration | The simulation configuration. |
[in] | mpcFluid_ | The fluid to measure. Must not be nullptr , and it must return true when its numberOfParticlesPerLogicalEntityIsConstant member is called. |
OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::~LogicalEntityMeanSquareDisplacement | ( | ) |
The destructor.
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 \).
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 \).
measurement time
, which is described in the documentation of this class.OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if t >= getMeasurementCount() . |
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if T >= getMeasurementCount() or T <= t or T - t > getMaximumMeasurementTime() . |
[in] | t | The first measurement time \( t \). This value must be smaller than getMeasurementCount() . |
[in] | T | The second measurement time \( T \). This value must be smaller than getMeasurementCount() and larger than t . Also, T - t must not be larger than getMaximumMeasurementTime() . |
unsigned int OpenMPCD::CUDA::MPCFluid::Instrumentation::LogicalEntityMeanSquareDisplacement::getMeasurementCount | ( | ) | const |
Returns 1
plus the maximum number t
may take in getMeanSquareDisplacement
.
|
static |
Returns whether the an attempt has been made to configure this class, i.e.
whether the instrumentation.logicalEntityMeanSquareDisplacement
configuration group exists.
[in] | config | The configuration to query. |
|
static |
Returns whether the given configuration group is a valid configuration.
For a configuration group to be valid, it must
measureEveryNthSweep
, which must be a positive integermeasurementArgumentCount
, which must be a positive integer.[in] | group | The configuration group to query. |
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.
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&)
.
[in] | rundir | Path to the directory, into which the result file will be written. |
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
.
[out] | stream | The stream to write to. |