OpenMPCD
HarmonicTrimers.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the OpenMPCD::CUDA::MPCFluid::HarmonicTrimers class.
4  */
5 
6 #ifndef OPENMPCD_CUDA_MPCFLUID_HARMONICTRIMERS_HPP
7 #define OPENMPCD_CUDA_MPCFLUID_HARMONICTRIMERS_HPP
8 
10 
11 namespace OpenMPCD
12 {
13 namespace CUDA
14 {
15 namespace MPCFluid
16 {
17  /**
18  * Fluid consisting of three particles, with two harmonic springs coupling them.
19  *
20  * The three particles interact with the following potential:
21  * \f[
22  * V
23  * = \frac{K_1}{2} \left( \vec{r}_1 - \vec{r}_2 \right)^2 +
24  * \frac{K_2}{2} \left( \vec{r}_2 - \vec{r}_3 \right)^2
25  * \f]
26  * where \f$ \vec{r}_i \f$ is the current position of particle \f$ i \f$.
27  *
28  * The configuration group of this fluid is expected to be named
29  * `mpc.fluid.harmonicTrimers`, and contains:
30  * - The floating-point values `springConstant1` and `springConstant2`,
31  * which define the spring constants \f$ K_1 \f$ and \f$ K_2 \f$ in the
32  * interaction potential \f$ V \f$;
33  * - The boolean value `analyticalStreaming`; currently, the only
34  * supported value is `false`, which means that molecular dynamics (MD)
35  * is going to be used to integrate the equations of motion during the
36  * streaming step;
37  * - If `analyticalStreaming` is `false`, the positive integer value
38  * `mdStepCount`, which specifies how many MD steps should be performed
39  * per MPC streaming step.
40  */
41  class HarmonicTrimers : public Base
42  {
43  public:
44  /**
45  * The constructor.
46  * @param[in] sim The simulation instance.
47  * @param[in] count The number of fluid particles.
48  * @param[in] streamingTimestep_ The timestep for a streaming step.
49  * @param[in] rng_ A random number generator to seed this instance's RNG with.
50  * @param[in] devMemMgr The Device memory manager.
51  */
52  HarmonicTrimers(const CUDA::Simulation* const sim, const unsigned int count,
53  const FP streamingTimestep_, RNG& rng_, DeviceMemoryManager* const devMemMgr);
54 
55  /**
56  * The destructor.
57  */
58  virtual ~HarmonicTrimers()
59  {
60  }
61 
62  public:
63  virtual unsigned int getNumberOfLogicalEntities() const
64  {
65  return getParticleCount() / 3;
66  }
67 
69  {
70  return true;
71  }
72 
73  virtual unsigned int getNumberOfParticlesPerLogicalEntity() const
74  {
75  return 3;
76  }
77 
78  virtual void stream();
79 
80  private:
81  /**
82  * Reads the configuration.
83  */
84  void readConfiguration();
85 
86  /**
87  * Initializes the particle positions and velocities on the host.
88  */
89  void initializeOnHost();
90 
91  private:
92  FP springConstant1; ///< The spring constant between particles 1 and 2.
93  FP springConstant2; ///< The spring constant between particles 2 and 3.
94 
95  bool streamAnalyticallyFlag; ///< Whether to use the analytical equations of motion or MD simulation.
96  unsigned int mdStepCount; ///< The number of velocity-Verlet steps in each streaming step.
97  };
98 
99 } //namespace MPCFluid
100 } //namespace CUDA
101 } //namespace OpenMPCD
102 
103 #endif
OpenMPCD::CUDA::MPCFluid::Base
Base class for MPC fluids.
Definition: CUDA/MPCFluid/Base.hpp:40
OpenMPCD::CUDA::MPCFluid::HarmonicTrimers::getNumberOfLogicalEntities
virtual unsigned int getNumberOfLogicalEntities() const
Returns the number of logical entities in the fluid.
Definition: HarmonicTrimers.hpp:63
OpenMPCD::CUDA::MPCFluid::HarmonicTrimers::numberOfParticlesPerLogicalEntityIsConstant
virtual bool numberOfParticlesPerLogicalEntityIsConstant() const
Returns whether all logical entities consist of the same number of MPC particles.
Definition: HarmonicTrimers.hpp:68
OpenMPCD::CUDA::MPCFluid::HarmonicTrimers::stream
virtual void stream()
Performs a streaming step.
OpenMPCD::CUDA::MPCFluid::HarmonicTrimers::getNumberOfParticlesPerLogicalEntity
virtual unsigned int getNumberOfParticlesPerLogicalEntity() const
Returns the number of MPC particles per logical entity.
Definition: HarmonicTrimers.hpp:73
OpenMPCD::CUDA::DeviceMemoryManager
Class for managing memory on the CUDA Device.
Definition: DeviceMemoryManager.hpp:21
Base.hpp
OpenMPCD::CUDA::MPCFluid::HarmonicTrimers::~HarmonicTrimers
virtual ~HarmonicTrimers()
The destructor.
Definition: HarmonicTrimers.hpp:58
OpenMPCD::CUDA::MPCFluid::HarmonicTrimers
Fluid consisting of three particles, with two harmonic springs coupling them.
Definition: HarmonicTrimers.hpp:41
OpenMPCD::CUDA::Simulation
MPCD simulation with Molecular Dynamics on CUDA-capable GPUs.
Definition: CUDA/Simulation.hpp:48
OpenMPCD::RNG
boost::mt11213b RNG
The random number generator type.
Definition: Types.hpp:18
OpenMPCD::CUDA::MPCFluid::Base::getParticleCount
unsigned int getParticleCount() const
Returns the number of MPC fluid particles.
Definition: CUDA/MPCFluid/Base.hpp:72
OpenMPCD::FP
double FP
Default floating point type.
Definition: Types.hpp:13
OpenMPCD::CUDA::MPCFluid::HarmonicTrimers::HarmonicTrimers
HarmonicTrimers(const CUDA::Simulation *const sim, const unsigned int count, const FP streamingTimestep_, RNG &rng_, DeviceMemoryManager *const devMemMgr)
The constructor.