OpenMPCD
|
Base class for measurements of velocity autocorrelation in MPC fluids. More...
#include <Base.hpp>
Classes | |
class | Snapshot |
Represents a snapshot of the MPC fluid constituent velocities. More... | |
Public Member Functions | |
virtual | ~Base () |
The destructor. More... | |
void | measure () |
Performs measurements. More... | |
void | save (const std::string &rundir) const |
Saves the data to the given run directory. More... | |
Static Public Member Functions | |
static bool | isConfigured (const Simulation *const sim) |
Returns whether the given simulation configured this instrumentation. More... | |
Protected Member Functions | |
Base (const Simulation *const sim, DeviceMemoryManager *const devMemMgr, const MPCFluid::Base *const mpcFluid_, const unsigned int numberOfConstituents_) | |
The constructor. More... | |
virtual void | populateCurrentVelocities ()=0 |
Populates the Device buffer with the current velocities of the fluid constituents. More... | |
Protected Attributes | |
const Simulation *const | simulation |
The simulation instance. More... | |
DeviceMemoryManager *const | deviceMemoryManager |
The Device memory manager. More... | |
const MPCFluid::Base *const | mpcFluid |
The fluid to measure. More... | |
const unsigned int | numberOfConstituents |
The number of logical constituents (e.g. pairs, triplets, ...) in the fluid. More... | |
FP | measurementTime |
The maximum time between snapshots. More... | |
std::vector< Snapshot * > | snapshots |
The snapshots of the fluid constituent velocities. More... | |
MPCParticleVelocityType * | currentVelocities |
Current velocities of the fluid constituents. More... | |
std::deque< boost::tuple< FP, FP, MPCParticleVelocityType > > | autocorrelations |
Collection of tuples consisting of, in that order, \( t_i \), \( t_j \), and \( V \left( t_i, t_j \right) \). More... | |
Base class for measurements of velocity autocorrelation in MPC fluids.
This class and its subclasses aid in measuring the velocity autocorrelation function of the fluid constituents' centers of mass, i.e.
\[ \left< \vec{v} \left( t \right) \cdot \vec{v} \left( 0 \right) \right> = \frac{ 1 }{ N_{\textrm{logical entites}} } \sum_{k = 0}^{N_{\textrm{logical entites}} - 1} \left< \vec{v}_k \left( t \right) \cdot \vec{v}_k \left( 0 \right) \right> \]
where \( N_{\textrm{logical entites}} \) is the number of logical entities in the fluid (see OpenMPCD::CUDA::MPCFluid::Base
), \( \vec{v}_k \left( t \right) \) is the velocity of the center of mass of the logical entity with index \( k \) at simulation time \( t \), and the angle brackets denote expectation values.
To approximate this quantity, the center of mass velocities of the logical entities are stored in snapshots periodically. Then, each time measure
is called, the quantity
\[ V \left( t_i, t \right) = \frac{ 1 }{ N_{\textrm{logical entites}} } \sum_{k = 0}^{N_{\textrm{logical entites}} - 1} \vec{v}_k \left( t_i \right) \cdot \vec{v}_k \left( t \right) \]
is calculated, i.e. the sample average of the inner product of a logical entity's center of mass velocity at the current time \( t \) with that same logical entity's center of mass velocity at snapshot time \( t_i \), for all currently available snapshots \( i \).
At most, snapshotCount
(see configuration options below) many snapshots are stored at any point in time. Every time measure
is called, before the \( V \left( t_i, t \right) \) are calculated as described above, the following procedure takes place:
snapshotCount
snapshots have already been created, the latest snapshot time is subtracted from the current simulation time. If that difference is larger than measurementTime / snapshotCount - 1e-6
, a new snapshot is taken and stored after the previously taken snapshot.snapshotCount
many snapshots before the call to measure
, all of the snapshots are iterated over. For each such snapshot, if the difference between the current simulation time and that snapshot's time is greater than measurementTime + 1e-6
, that snapshot is overridden in place with the current state and simulation time. The order of snapshots in memory, as described above, is of consequence for the order in which measurements are written by the save
function.Given this, the velocity autocorrelation function \( \left< \vec{v} \left( t \right) \cdot \vec{v} \left( 0 \right) \right> \) can be approximated as the average of all \( V \left( t_i, t_j \right) \) where \( t_j - t_i = t \).
However, this last step is currently not performed by this class; instead, it computes \( V \left( t_i, t_j \right) \) and stores them, along with \( t_i \) and \( t_j \).
This class and its subclasses are configured via the instrumentation.velocityAutocorrelation
configuration group, which consists of the following settings:
snapshotCount
, a positive integer, determines the maximum number of snapshots stored in memory at any given time.measurementTime
, which is a floating-point value that is approximately the maximal time for which the correlation function is measured; see above for details. Definition at line 110 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
The constructor.
OpenMPCD::InvalidConfigurationException | Throws if the configuration is invalid. |
OpenMPCD::NULLPointerException | If OPENMPCD_DEBUG is defined, throws if any of the pointer arguments is a nullptr . |
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if numberOfConstituents_ == 0 . |
[in] | sim | The simulation instance. |
[in] | devMemMgr | The Device memory manager instance. |
[in] | mpcFluid_ | The MPC fluid to measure. |
[in] | numberOfConstituents_ | The number of logical constituents (e.g. pairs, triplets, ...) in the fluid. |
|
virtual |
The destructor.
|
static |
Returns whether the given simulation configured this instrumentation.
[in] | sim | The simulation instance. |
NULLPointerException | Throws if sim is nullptr . |
void OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Base::measure | ( | ) |
Performs measurements.
|
protectedpure virtual |
Populates the Device buffer with the current velocities of the fluid constituents.
Implemented in OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Chains, OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Doublets, OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Simple, and OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Triplets.
void OpenMPCD::CUDA::MPCFluid::Instrumentation::VelocityAutocorrelation::Base::save | ( | const std::string & | rundir | ) | const |
Saves the data to the given run directory.
The given run directory is created if necessary, and so is the data file therein; if the data file already exists, it will be truncated.
Multiple lines will be written to the file, each consisting of three tab-separated columns: The first column corresponds to the simulation time \( t_i \) of a snapshot \( i \); the second column to the simulation time \( t_j \ge t_i \) ; and finally, the third column contains \( V \left( t_i, t_j \right) \). One such line will be written for every measured \( V \) (see class documentation for details).
The lines are ordered by ascending \( t_j \) first, and then by ascending snapshot position in memory (see class documentation for details).
[in] | rundir | The path to the run directory. Within that directory, the data will be saved to the file velocityAutocorrelations.data . |
|
protected |
Collection of tuples consisting of, in that order, \( t_i \), \( t_j \), and \( V \left( t_i, t_j \right) \).
Definition at line 320 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
Current velocities of the fluid constituents.
Definition at line 318 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
The Device memory manager.
Definition at line 309 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
The maximum time between snapshots.
Definition at line 315 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
The fluid to measure.
Definition at line 310 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
The number of logical constituents (e.g. pairs, triplets, ...) in the fluid.
Definition at line 312 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
The simulation instance.
Definition at line 308 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.
|
protected |
The snapshots of the fluid constituent velocities.
Definition at line 317 of file CUDA/MPCFluid/Instrumentation/VelocityAutocorrelation/Base.hpp.