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

Measures the autocorrelation of normal coordinates in linear polymers. More...

#include <NormalModeAutocorrelation.hpp>

Public Member Functions

 NormalModeAutocorrelation (const OpenMPCD::Configuration &configuration, const OpenMPCD::CUDA::MPCFluid::Base *const mpcFluid_)
 The constructor. More...
 
 ~NormalModeAutocorrelation ()
 The destructor. More...
 
void measure ()
 Takes measurement data. More...
 
unsigned int getMaximumCorrelationTime () const
 Returns, in units of measurement time, the maximum correlation time that is configured to be measured, i.e. More...
 
unsigned int getMeasurementCount () const
 Returns 1 plus the maximum number t may take in getAutocorrelation. More...
 
MPCParticlePositionType getAutocorrelation (const unsigned int t, const unsigned int T, const unsigned int normalMode) const
 Returns the measured value of the autocorrelation at measurement times \( t \) and \( T \), and for normal mode index \( i \). 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 autocorrelation of normal coordinates in linear polymers.

This class assumes that the MPC fluid it measures consists of linear polymer chains. It can only be used if OpenMPCD::CUDA::MPCFluid::Base::numberOfParticlesPerLogicalEntityIsConstant is true.

Let \( N_C \) correspond to the number of polymer chains in the fluid, as returned by OpenMPCD::CUDA::MPCFluid::Base::getNumberOfLogicalEntities, and let the number of particles in each chain be \( N \), as returned by OpenMPCD::CUDA::MPCFluid::Base::getNumberOfParticlesPerLogicalEntity. Then, let \( \vec{q}_i^j \left( t \right) \) be the normal mode coordinate of normal mode \( i \) of the chain \( j \) at simulation time \( t \), as defined in OpenMPCD::NormalMode, with shift parameter \( S \).

Then, this class samples, for all modes \( i \) and for configurable correlation times \( \Delta t \), the quantity

\[ C \left( t, t + \Delta t, i \right) = \frac{1}{N_C} \sum_{j=1}^{N_C} \vec{q}_i^j \left( t + \Delta t \right) \cdot \vec{q}_i^j \left( t \right) \]

via OpenMPCD::CUDA::NormalMode::getAverageNormalCoordinateAutocorrelation.

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.normalModeAutocorrelation configuration group. Within that group, measureEveryNthSweep defines \( \tau \), and autocorrelationArgumentCount defines \( N_A \); given those, the autocorrelation is measured at (simulation) correlation times

\[ \Delta t \in \left\{ 0, \tau \Delta T, 2 \tau \Delta T, \ldots, \left( N_A - 1 \right) \tau \Delta T \right\} \]

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

Furthermore, the key shift within the instrumentation.normalModeAutocorrelation configuration group specifies the shift parameter \( S \) to be used (see OpenMPCD::NormalMode for the definition of this parameter). If this key is not specified, it defaults to 0.0.

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

Definition at line 97 of file NormalModeAutocorrelation.hpp.

Constructor & Destructor Documentation

◆ NormalModeAutocorrelation()

OpenMPCD::CUDA::MPCFluid::Instrumentation::NormalModeAutocorrelation::NormalModeAutocorrelation ( 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.normalModeAutocorrelation"))`.
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.

Definition at line 23 of file NormalModeAutocorrelation.cpp.

◆ ~NormalModeAutocorrelation()

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

The destructor.

Definition at line 62 of file NormalModeAutocorrelation.cpp.

Member Function Documentation

◆ getAutocorrelation()

MPCParticlePositionType OpenMPCD::CUDA::MPCFluid::Instrumentation::NormalModeAutocorrelation::getAutocorrelation ( const unsigned int  t,
const unsigned int  T,
const unsigned int  normalMode 
) const

Returns the measured value of the autocorrelation at measurement times \( t \) and \( T \), and for normal mode index \( i \).

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 > getMaximumCorrelationTime().
OpenMPCD::InvalidArgumentExceptionThrows if normalMode is out of range.
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 or equal to t. Also, T - t must not be larger than getMaximumCorrelationTime().
[in]normalModeThe normal mode index \( i \), which must be less than or equal to mpcFluid->getNumberOfParticlesPerLogicalEntity(), where mpcFluid is the fluid passed to the constructor of this instance.

Definition at line 178 of file NormalModeAutocorrelation.cpp.

◆ getMaximumCorrelationTime()

unsigned int OpenMPCD::CUDA::MPCFluid::Instrumentation::NormalModeAutocorrelation::getMaximumCorrelationTime ( ) const

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

\( N_A - 1 \).

Definition at line 171 of file NormalModeAutocorrelation.cpp.

◆ getMeasurementCount()

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

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

Definition at line 166 of file NormalModeAutocorrelation.cpp.

◆ isConfigured()

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

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

whether the instrumentation.normalModeAutocorrelation configuration group exists.

Parameters
[in]configThe configuration to query.

Definition at line 68 of file NormalModeAutocorrelation.cpp.

◆ isValidConfiguration()

bool OpenMPCD::CUDA::MPCFluid::Instrumentation::NormalModeAutocorrelation::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 autocorrelationArgumentCount, which must be a positive integer.
Parameters
[in]groupThe configuration group to query.

Definition at line 73 of file NormalModeAutocorrelation.cpp.

◆ measure()

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

Takes measurement data.

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

Definition at line 106 of file NormalModeAutocorrelation.cpp.

◆ save() [1/2]

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

Saves the result to the given run directory.

The file within the given directory will be named normalModeAutocorrelations.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.

Definition at line 226 of file NormalModeAutocorrelation.cpp.

◆ save() [2/2]

void OpenMPCD::CUDA::MPCFluid::Instrumentation::NormalModeAutocorrelation::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, t + getMaximumCorrelationTime()] (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, for each normal mode index n, the value of getAutocorrelation(t, T, n).

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

Parameters
[out]streamThe stream to write to.

Definition at line 201 of file NormalModeAutocorrelation.cpp.


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