|
10 | 10 | #ifndef AZPLUGINS_WALL_EVALUATOR_LJ_93_H_ |
11 | 11 | #define AZPLUGINS_WALL_EVALUATOR_LJ_93_H_ |
12 | 12 |
|
13 | | -#ifndef NVCC |
14 | | -#include <string> |
15 | | -#endif |
16 | | - |
17 | | -#include "hoomd/HOOMDMath.h" |
| 13 | +#include "PairEvaluator.h" |
18 | 14 |
|
19 | | -#ifdef NVCC |
| 15 | +#ifdef __HIPCC__ |
20 | 16 | #define DEVICE __device__ |
21 | 17 | #else |
22 | 18 | #define DEVICE |
23 | 19 | #endif |
24 | 20 |
|
| 21 | +namespace hoomd |
| 22 | + { |
25 | 23 | namespace azplugins |
26 | 24 | { |
27 | 25 | namespace detail |
28 | 26 | { |
29 | | -//! Evaluates the Lennard-Jones 9-3 wall force |
| 27 | +//! Define the paramter type used by this wall potential evaluator |
| 28 | +struct WallParametersLJ93 : public PairParameters |
| 29 | + { |
| 30 | +#ifndef __HIPCC__ |
| 31 | + WallParametersLJ93() : sigma_3(0), A(0) { } |
| 32 | + |
| 33 | + WallParametersLJ93(pybind11::dict v, bool managed = false) |
| 34 | + { |
| 35 | + auto sigma(v["sigma"].cast<Scalar>()); |
| 36 | + A = v["A"].cast<Scalar>(); |
| 37 | + |
| 38 | + sigma_3 = sigma * sigma * sigma; |
| 39 | + } |
| 40 | + |
| 41 | + pybind11::dict asDict() |
| 42 | + { |
| 43 | + pybind11::dict v; |
| 44 | + v["sigma"] = std::cbrt(sigma_3); |
| 45 | + v["A"] = A; |
| 46 | + return v; |
| 47 | + } |
| 48 | +#endif // __HIPCC__ |
| 49 | + |
| 50 | + Scalar sigma_3; //!< Lennard-Jones sigma |
| 51 | + Scalar A; //!< Hamaker constant |
| 52 | + } |
| 53 | + |
| 54 | +#if HOOMD_LONGREAL_SIZE == 32 |
| 55 | + __attribute__((aligned(8))); |
| 56 | +#else |
| 57 | + __attribute__((aligned(16))); |
| 58 | +#endif |
| 59 | + |
| 60 | +//! Class for evaluating the Lennard-Jones 9-3 wall force |
30 | 61 | /*! |
31 | 62 | * WallEvaluatorLJ93 computes the Lennard-Jones 9-3 wall potential, which is derived from |
32 | 63 | * integrating the standard Lennard-Jones potential between a point particle and a half plane: |
33 | 64 | * |
34 | | - * \f[ V(r) = \varepsilon \left( \frac{2}{15}\left(\frac{\sigma}{r}\right)^9 - |
35 | | - * \left(\frac{\sigma}{r}\right)^3 \right) \f] |
| 65 | + * \f[ V(r) = A \left[ \frac{2}{15}\left(\frac{\sigma}{r}\right)^9 - |
| 66 | + * \left(\frac{\sigma}{r}\right)^3 \right] \f] |
36 | 67 | * |
37 | | - * where \f$\sigma\f$ is the diameter of Lennard-Jones particles in the wall, and \f$ \varepsilon |
38 | | - * \f$ is the effective Hamaker constant \f$ \varepsilon = (2/3) \pi \varepsilon_{\rm LJ} \rho_{\rm |
39 | | - * w} \sigma^3 \f$ with \f$\varepsilon_{\rm LJ}\f$ the energy of interaction and \f$\rho_{\rm w}\f$ |
40 | | - * the density of particles in the wall. Evaluation of this energy is simplified into the following |
| 68 | + * where \f$\sigma\f$ is the diameter of Lennard-Jones particles in the wall, and \f$ A \f$ is the |
| 69 | + * Hamaker constant \f$ A = (2/3) \pi \varepsilon_{\rm LJ} \rho_{\rm w} \sigma^3 \f$ with |
| 70 | + * \f$\varepsilon_{\rm LJ}\f$ the energy of interaction and \f$\rho_{\rm w}\f$ the density of |
| 71 | + * particles in the wall. Evaluation of this energy is simplified into the following |
41 | 72 | * parameters: |
42 | 73 | * |
43 | | - * - \verbatim lj1 = (2.0/15.0) * epsilon * pow(sigma,9.0) \endverbatim |
44 | | - * - \verbatim lj2 = epsilon * pow(sigma,3.0) \endverbatim |
| 74 | + * - \verbatim lj1 = (2.0/15.0) * A * pow(sigma,9.0) \endverbatim |
| 75 | + * - \verbatim lj2 = A * pow(sigma,3.0) \endverbatim |
45 | 76 | * |
46 | 77 | * The force acting on the particle is then |
47 | | - * \f[ F(r)/r = \frac{\varepsilon}{r^2} \left ( \frac{6}{5}\left(\frac{\sigma}{r}\right)^9 - 3 |
| 78 | + * \f[ F(r)/r = \frac{A}{r^2} \left ( \frac{6}{5}\left(\frac{\sigma}{r}\right)^9 - 3 |
48 | 79 | * \left(\frac{\sigma}{r}\right)^3 \right) \f] |
49 | 80 | */ |
50 | | -class WallEvaluatorLJ93 |
| 81 | +class WallEvaluatorLJ93 : public PairEvaluator |
51 | 82 | { |
52 | 83 | public: |
53 | | - //! Define the parameter type used by this wall potential evaluator |
54 | | - typedef Scalar2 param_type; |
| 84 | + typedef WallParametersLJ93 param_type; |
55 | 85 |
|
56 | 86 | //! Constructor |
57 | 87 | /*! |
58 | | - * \param _rsq Squared distance between particles |
| 88 | + * \param _rsq Sqaured distance between particles |
59 | 89 | * \param _rcutsq Cutoff radius squared |
60 | | - * \param _params Pair potential parameters, given by typedef above |
| 90 | + * \param _params Wall potential paramters, given by typedef above |
61 | 91 | * |
62 | 92 | * The functor initializes its members from \a _params. |
63 | 93 | */ |
64 | 94 | DEVICE WallEvaluatorLJ93(Scalar _rsq, Scalar _rcutsq, const param_type& _params) |
65 | | - : rsq(_rsq), rcutsq(_rcutsq), lj1(_params.x), lj2(_params.y) |
66 | | - { |
67 | | - } |
68 | | - |
69 | | - //! LJ 9-3 doesn't use diameter |
70 | | - DEVICE static bool needsDiameter() |
| 95 | + : PairEvaluator(_rsq, _rcutsq) |
71 | 96 | { |
72 | | - return false; |
| 97 | + lj1 = (Scalar(2.0) / Scalar(15.0)) * _params.A * _params.sigma_3 * _params.sigma_3 |
| 98 | + * _params.sigma_3; |
| 99 | + lj2 = _params.A * _params.sigma_3; |
73 | 100 | } |
74 | | - //! Accept the optional diameter values |
75 | | - /*! |
76 | | - * \param di Diameter of particle |
77 | | - * \param dj Dummy diameter |
78 | | - * |
79 | | - * \note The way HOOMD computes wall forces by recycling evaluators requires that we give |
80 | | - * a second diameter, even though this is meaningless for the potential. |
81 | | - */ |
82 | | - DEVICE void setDiameter(Scalar di, Scalar dj) { } |
83 | | - |
84 | | - //! LJ 9-3 doesn't use charge |
85 | | - DEVICE static bool needsCharge() |
86 | | - { |
87 | | - return false; |
88 | | - } |
89 | | - //! Accept the optional charge values |
90 | | - /*! |
91 | | - * \param qi Charge of particle |
92 | | - * \param qj Dummy charge |
93 | | - * |
94 | | - * \note The way HOOMD computes wall forces by recycling evaluators requires that we give |
95 | | - * a second charge, even though this is meaningless for the potential. |
96 | | - */ |
97 | | - DEVICE void setCharge(Scalar qi, Scalar qj) { } |
98 | 101 |
|
99 | 102 | //! Evaluate the force and energy |
100 | 103 | /*! |
@@ -135,22 +138,22 @@ class WallEvaluatorLJ93 |
135 | 138 | return false; |
136 | 139 | } |
137 | 140 |
|
138 | | -#ifndef NVCC |
| 141 | +#ifndef __HIPCC__ |
139 | 142 | //! Return the name of this potential |
140 | 143 | static std::string getName() |
141 | 144 | { |
142 | 145 | return std::string("lj93"); |
143 | 146 | } |
144 | 147 | #endif |
145 | 148 |
|
146 | | - protected: |
147 | | - Scalar rsq; //!< Stored rsq from the constructor |
148 | | - Scalar rcutsq; //!< Stored rcutsq from the constructor |
149 | | - Scalar lj1; //!< lj1 parameter extracted from the params passed to the constructor |
150 | | - Scalar lj2; //!< lj2 parameter extracted from the params passed to the constructor |
| 149 | + private: |
| 150 | + Scalar lj1; |
| 151 | + Scalar lj2; |
151 | 152 | }; |
| 153 | + |
152 | 154 | } // end namespace detail |
153 | 155 | } // end namespace azplugins |
| 156 | + } // end namespace hoomd |
154 | 157 |
|
155 | 158 | #undef DEVICE |
156 | 159 | #endif // AZPLUGINS_WALL_EVALUATOR_LJ_93_H_ |
0 commit comments