diff --git a/doc/index.rst b/doc/index.rst index 0345cbb0..b840d45a 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -56,6 +56,7 @@ Contents module-azplugins-external module-azplugins-flow module-azplugins-pair + module-azplugins-wall .. toctree:: :maxdepth: 1 diff --git a/doc/module-azplugins-wall.rst b/doc/module-azplugins-wall.rst new file mode 100644 index 00000000..86cdab8b --- /dev/null +++ b/doc/module-azplugins-wall.rst @@ -0,0 +1,23 @@ +.. Copyright (c) 2018-2020, Michael P. Howard +.. Copyright (c) 2021-2025, Auburn University +.. Part of azplugins, released under the BSD 3-Clause License. + +azplugins.wall +-------------- + +.. rubric:: Overview + +.. py:currentmodule:: hoomd.azplugins.wall + +.. autosummary:: + :nosignatures: + + LJ93 + +.. rubric:: Details + +.. automodule:: hoomd.azplugins.wall + :synopsis: Wall potentials. + :members: LJ93 + :no-inherited-members: + :show-inheritance: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ebde4dd5..64a36dde 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,6 +32,7 @@ set(python_files external.py flow.py pair.py + wall.py ) # TODO: Add names of all bond evaluators @@ -48,6 +49,11 @@ set(_pair_evaluators PerturbedLennardJones ) +# TODO: Add names of all wall evaluators +set(_wall_evaluators + LJ93 + ) + # TODO: Add names of all dpd evaluators set(_dpd_evaluators GeneralWeight @@ -96,6 +102,25 @@ foreach(_evaluator ${_pair_evaluators}) endif() endforeach() +# process wall potentials +foreach(_evaluator ${_wall_evaluators}) + configure_file(export_PotentialExternalWall.cc.inc + export_PotentialExternalWall${_evaluator}.cc + @ONLY) + set(_${COMPONENT_NAME}_sources ${_${COMPONENT_NAME}_sources} export_PotentialExternalWall${_evaluator}.cc) + + if (ENABLE_HIP) + configure_file(export_PotentialExternalWallGPU.cc.inc + export_PotentialExternalWall${_evaluator}GPU.cc + @ONLY) + configure_file(PotentialExternalWallGPUKernel.cu.inc + PotentialExternalWall${_evaluator}GPUKernel.cu + @ONLY) + set(_${COMPONENT_NAME}_sources ${_${COMPONENT_NAME}_sources} export_PotentialExternalWall${_evaluator}GPU.cc) + set(_${COMPONENT_NAME}_cu_sources ${_${COMPONENT_NAME}_cu_sources} PotentialExternalWall${_evaluator}GPUKernel.cu) + endif() +endforeach() + # process DPD potentials foreach(_evaluator ${_dpd_evaluators}) configure_file(export_PotentialPairDPDThermo.cc.inc diff --git a/src/PotentialExternalWallGPUKernel.cu.inc b/src/PotentialExternalWallGPUKernel.cu.inc new file mode 100644 index 00000000..8ce70ab1 --- /dev/null +++ b/src/PotentialExternalWallGPUKernel.cu.inc @@ -0,0 +1,33 @@ +// Copyright (c) 2018-2020, Michael P. Howard +// Copyright (c) 2021-2025, Auburn University +// Part of azplugins, released under the BSD 3-Clause License. + +// Adapted from hoomd/md/export_PotentialExternalWallGPUKernel.cu.inc of HOOMD-blue. +// Copyright (c) 2009-2024 The Regents of the University of Michigan. +// Part of HOOMD-blue, released under the BSD 3-Clause License. + +// See CMakeLists.txt for the source of these variables to be processed by CMake's +// configure_file(). + +// clang-format off +#include "hoomd/md/PotentialExternalGPU.cuh" +#include "hoomd/md/EvaluatorWalls.h" +#include "WallEvaluator@_evaluator@.h" + +#define EVALUATOR_CLASS hoomd::md::EvaluatorWalls +// clang-format on + +namespace hoomd + { +namespace md + { +namespace kernel + { +template __attribute__((visibility("default"))) hipError_t +gpu_compute_potential_external_forces( + const external_potential_args_t& external_potential_args, + const typename EVALUATOR_CLASS::param_type* d_params, + const typename EVALUATOR_CLASS::field_type* d_field); + } // end namespace kernel + } // end namespace md + } // end namespace hoomd diff --git a/src/WallEvaluatorLJ93.h b/src/WallEvaluatorLJ93.h index 74fa224b..662d629b 100644 --- a/src/WallEvaluatorLJ93.h +++ b/src/WallEvaluatorLJ93.h @@ -10,91 +10,94 @@ #ifndef AZPLUGINS_WALL_EVALUATOR_LJ_93_H_ #define AZPLUGINS_WALL_EVALUATOR_LJ_93_H_ -#ifndef NVCC -#include -#endif - -#include "hoomd/HOOMDMath.h" +#include "PairEvaluator.h" -#ifdef NVCC +#ifdef __HIPCC__ #define DEVICE __device__ #else #define DEVICE #endif +namespace hoomd + { namespace azplugins { namespace detail { -//! Evaluates the Lennard-Jones 9-3 wall force +//! Define the paramter type used by this wall potential evaluator +struct WallParametersLJ93 : public PairParameters + { +#ifndef __HIPCC__ + WallParametersLJ93() : sigma_3(0), A(0) { } + + WallParametersLJ93(pybind11::dict v, bool managed = false) + { + auto sigma(v["sigma"].cast()); + A = v["A"].cast(); + + sigma_3 = sigma * sigma * sigma; + } + + pybind11::dict asDict() + { + pybind11::dict v; + v["sigma"] = std::cbrt(sigma_3); + v["A"] = A; + return v; + } +#endif // __HIPCC__ + + Scalar sigma_3; //!< Lennard-Jones sigma + Scalar A; //!< Hamaker constant + } + +#if HOOMD_LONGREAL_SIZE == 32 + __attribute__((aligned(8))); +#else + __attribute__((aligned(16))); +#endif + +//! Class for evaluating the Lennard-Jones 9-3 wall force /*! * WallEvaluatorLJ93 computes the Lennard-Jones 9-3 wall potential, which is derived from * integrating the standard Lennard-Jones potential between a point particle and a half plane: * - * \f[ V(r) = \varepsilon \left( \frac{2}{15}\left(\frac{\sigma}{r}\right)^9 - - * \left(\frac{\sigma}{r}\right)^3 \right) \f] + * \f[ V(r) = A \left[ \frac{2}{15}\left(\frac{\sigma}{r}\right)^9 - + * \left(\frac{\sigma}{r}\right)^3 \right] \f] * - * where \f$\sigma\f$ is the diameter of Lennard-Jones particles in the wall, and \f$ \varepsilon - * \f$ is the effective Hamaker constant \f$ \varepsilon = (2/3) \pi \varepsilon_{\rm LJ} \rho_{\rm - * w} \sigma^3 \f$ with \f$\varepsilon_{\rm LJ}\f$ the energy of interaction and \f$\rho_{\rm w}\f$ - * the density of particles in the wall. Evaluation of this energy is simplified into the following + * where \f$\sigma\f$ is the diameter of Lennard-Jones particles in the wall, and \f$ A \f$ is the + * Hamaker constant \f$ A = (2/3) \pi \varepsilon_{\rm LJ} \rho_{\rm w} \sigma^3 \f$ with + * \f$\varepsilon_{\rm LJ}\f$ the energy of interaction and \f$\rho_{\rm w}\f$ the density of + * particles in the wall. Evaluation of this energy is simplified into the following * parameters: * - * - \verbatim lj1 = (2.0/15.0) * epsilon * pow(sigma,9.0) \endverbatim - * - \verbatim lj2 = epsilon * pow(sigma,3.0) \endverbatim + * - \verbatim lj1 = (2.0/15.0) * A * pow(sigma,9.0) \endverbatim + * - \verbatim lj2 = A * pow(sigma,3.0) \endverbatim * * The force acting on the particle is then - * \f[ F(r)/r = \frac{\varepsilon}{r^2} \left ( \frac{6}{5}\left(\frac{\sigma}{r}\right)^9 - 3 + * \f[ F(r)/r = \frac{A}{r^2} \left ( \frac{6}{5}\left(\frac{\sigma}{r}\right)^9 - 3 * \left(\frac{\sigma}{r}\right)^3 \right) \f] */ -class WallEvaluatorLJ93 +class WallEvaluatorLJ93 : public PairEvaluator { public: - //! Define the parameter type used by this wall potential evaluator - typedef Scalar2 param_type; + typedef WallParametersLJ93 param_type; //! Constructor /*! - * \param _rsq Squared distance between particles + * \param _rsq Sqaured distance between particles * \param _rcutsq Cutoff radius squared - * \param _params Pair potential parameters, given by typedef above + * \param _params Wall potential paramters, given by typedef above * * The functor initializes its members from \a _params. */ DEVICE WallEvaluatorLJ93(Scalar _rsq, Scalar _rcutsq, const param_type& _params) - : rsq(_rsq), rcutsq(_rcutsq), lj1(_params.x), lj2(_params.y) - { - } - - //! LJ 9-3 doesn't use diameter - DEVICE static bool needsDiameter() + : PairEvaluator(_rsq, _rcutsq) { - return false; + lj1 = (Scalar(2.0) / Scalar(15.0)) * _params.A * _params.sigma_3 * _params.sigma_3 + * _params.sigma_3; + lj2 = _params.A * _params.sigma_3; } - //! Accept the optional diameter values - /*! - * \param di Diameter of particle - * \param dj Dummy diameter - * - * \note The way HOOMD computes wall forces by recycling evaluators requires that we give - * a second diameter, even though this is meaningless for the potential. - */ - DEVICE void setDiameter(Scalar di, Scalar dj) { } - - //! LJ 9-3 doesn't use charge - DEVICE static bool needsCharge() - { - return false; - } - //! Accept the optional charge values - /*! - * \param qi Charge of particle - * \param qj Dummy charge - * - * \note The way HOOMD computes wall forces by recycling evaluators requires that we give - * a second charge, even though this is meaningless for the potential. - */ - DEVICE void setCharge(Scalar qi, Scalar qj) { } //! Evaluate the force and energy /*! @@ -135,7 +138,7 @@ class WallEvaluatorLJ93 return false; } -#ifndef NVCC +#ifndef __HIPCC__ //! Return the name of this potential static std::string getName() { @@ -143,14 +146,14 @@ class WallEvaluatorLJ93 } #endif - protected: - Scalar rsq; //!< Stored rsq from the constructor - Scalar rcutsq; //!< Stored rcutsq from the constructor - Scalar lj1; //!< lj1 parameter extracted from the params passed to the constructor - Scalar lj2; //!< lj2 parameter extracted from the params passed to the constructor + private: + Scalar lj1; + Scalar lj2; }; + } // end namespace detail } // end namespace azplugins + } // end namespace hoomd #undef DEVICE #endif // AZPLUGINS_WALL_EVALUATOR_LJ_93_H_ diff --git a/src/WallPotentials.cu b/src/WallPotentials.cu deleted file mode 100644 index b58296f1..00000000 --- a/src/WallPotentials.cu +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2018-2020, Michael P. Howard -// Copyright (c) 2021-2025, Auburn University -// Part of azplugins, released under the BSD 3-Clause License. - -/*! - * \file WallPotentials.cu - * \brief Defines the driver functions for computing wall forces on the GPU - * - * The driver function must have an explicit template instantiation for each - * evaluator. The template must be in the global namespace that is used by hoomd. - */ - -#include "WallPotentials.h" -#include "hoomd/md/EvaluatorWalls.h" -#include "hoomd/md/PotentialExternalGPU.cuh" - -//! Evaluator for colloid (integrated Lennard-Jones) wall potential -template cudaError_t gpu_cpef>( - const external_potential_args_t& external_potential_args, - const typename EvaluatorWalls::param_type* d_params, - const typename EvaluatorWalls::field_type* d_field); - -//! Evaluator for Lennard-Jones 9-3 wall potential -template cudaError_t gpu_cpef>( - const external_potential_args_t& external_potential_args, - const typename EvaluatorWalls::param_type* d_params, - const typename EvaluatorWalls::field_type* d_field); diff --git a/src/WallPotentials.h b/src/WallPotentials.h deleted file mode 100644 index 456741da..00000000 --- a/src/WallPotentials.h +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2018-2020, Michael P. Howard -// Copyright (c) 2021-2025, Auburn University -// Part of azplugins, released under the BSD 3-Clause License. - -/*! - * \file WallPotentials.h - * \brief Convenience inclusion of all wall potential evaluators. - * - * In HOOMD-blue, wall potentials are templated on a base class ForceCompute called - * PotentialExternal (via a templated EvaluatorWall functor). This avoids code duplication of basic - * routines. - * - * To add a new wall potential, take the following steps: - * 1. Create an evaluator functor for your potential, for example WallEvaluatorMyGreatPotential.h. - * This file should be added to the list of includes below. You can follow one of the other - * evaluator functors as an example for the details. - * - * 2. Explicitly instantiate a template for a CUDA driver for your potential in WallPotentials.cu. - * - * 3. Expose the wall potential on the python level in module.cc with export_wall_potential and add - * the mirror python object to wall.py. - * - * 4. Write a unit test for the potential in test-py. Two types of tests should be conducted: one - * that checks that all methods work on the python object, and one that validates the force and - * energy for the particle at a fixed distance from the wall. - */ - -#ifndef AZPLUGINS_WALL_POTENTIALS_H_ -#define AZPLUGINS_WALL_POTENTIALS_H_ - -// All wall potential evaluators should be included here -#include "WallEvaluatorColloid.h" -#include "WallEvaluatorLJ93.h" - -/* - * The code below handles python exports using a templated function, and so should - * not be compiled in NVCC. - */ -#ifndef NVCC -#include "hoomd/extern/pybind/include/pybind11/pybind11.h" - -#include "hoomd/md/EvaluatorWalls.h" -#include "hoomd/md/PotentialExternal.h" -#ifdef ENABLE_CUDA -#include "hoomd/md/PotentialExternalGPU.h" -#endif - -namespace azplugins - { -namespace detail - { -//! Convenience function to export wall potential to python -/*! - * \param m Python module - * \param name Name of CPU class - * \tparam evaluator Wall potential evaluator functor - * - * A CPU object called \a name is exported to python, along with an - * object for the wall parameters (name_params) and convenience method - * for creating the parameters (make_name_params()). If CUDA is enabled, - * a corresponding GPU class called nameGPU is exported. - */ -template void export_wall_potential(pybind11::module& m, const std::string& name) - { - namespace py = pybind11; - typedef ::EvaluatorWalls wall_evaluator; - typedef ::PotentialExternal wall_potential_cpu; - export_PotentialExternal(m, name); - -#ifdef ENABLE_CUDA - typedef ::PotentialExternalGPU wall_potential_gpu; - export_PotentialExternalGPU(m, name + "GPU"); -#endif // ENABLE_CUDA - - py::class_>( - m, - (wall_evaluator::getName() + "_params").c_str()) - .def(py::init<>()) - .def_readwrite("params", &wall_evaluator::param_type::params) - .def_readwrite("rextrap", &wall_evaluator::param_type::rextrap) - .def_readwrite("rcutsq", &wall_evaluator::param_type::rcutsq); - m.def(std::string("make_" + wall_evaluator::getName() + "_params").c_str(), - &make_wall_params); - } - - } // end namespace detail - } // end namespace azplugins -#endif // NVCC - -#endif // AZPLUGINS_WALL_POTENTIALS_H_ diff --git a/src/__init__.py b/src/__init__.py index a7ca8a70..3e71abf0 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -4,6 +4,6 @@ """azplugins.""" -from hoomd.azplugins import bond, compute, external, flow, pair +from hoomd.azplugins import bond, compute, external, flow, pair, wall __version__ = "1.2.0" diff --git a/src/export_PotentialExternalWall.cc.inc b/src/export_PotentialExternalWall.cc.inc new file mode 100644 index 00000000..f5146221 --- /dev/null +++ b/src/export_PotentialExternalWall.cc.inc @@ -0,0 +1,33 @@ +// Copyright (c) 2018-2020, Michael P. Howard +// Copyright (c) 2021-2025, Auburn University +// Part of azplugins, released under the BSD 3-Clause License. + +// Adapted from hoomd/md/export_PotentialExternalWall.cc.inc of HOOMD-blue. +// Copyright (c) 2009-2024 The Regents of the University of Michigan. +// Part of HOOMD-blue, released under the BSD 3-Clause License. + +// See CMakeLists.txt for the source of these variables to be processed by CMake's +// configure_file(). + +// clang-format off +#include "hoomd/md/PotentialExternal.h" +#include "hoomd/md/EvaluatorWalls.h" +#include "WallEvaluator@_evaluator@.h" + +#define EVALUATOR_CLASS hoomd::md::EvaluatorWalls +#define EXPORT_FUNCTION export_PotentialExternalWall@_evaluator@ +// clang-format on + +namespace hoomd + { +namespace azplugins + { +namespace detail + { +void EXPORT_FUNCTION(pybind11::module& m) + { + hoomd::md::detail::export_PotentialExternal(m, "WallsPotential@_evaluator@"); + } + } // end namespace detail + } // end namespace azplugins + } // end namespace hoomd diff --git a/src/export_PotentialExternalWallGPU.cc.inc b/src/export_PotentialExternalWallGPU.cc.inc new file mode 100644 index 00000000..efc653a8 --- /dev/null +++ b/src/export_PotentialExternalWallGPU.cc.inc @@ -0,0 +1,39 @@ +// Copyright (c) 2018-2020, Michael P. Howard +// Copyright (c) 2021-2025, Auburn University +// Part of azplugins, released under the BSD 3-Clause License. + +// Adapted from hoomd/md/export_PotentialExternalWallGPU.cc.inc of HOOMD-blue. +// Copyright (c) 2009-2024 The Regents of the University of Michigan. +// Part of HOOMD-blue, released under the BSD 3-Clause License. + +// See CMakeLists.txt for the source of these variables to be processed by CMake's +// configure_file(). + +// clang-format off +#include "hoomd/md/PotentialExternalGPU.h" +#include "hoomd/md/EvaluatorWalls.h" +#include "WallEvaluator@_evaluator@.h" + +#define EVALUATOR_CLASS hoomd::md::EvaluatorWalls +#define EXPORT_FUNCTION export_PotentialExternalWall@_evaluator@GPU +// clang-format on + +namespace hoomd + { + +// Use CPU class from another compilation unit to reduce compile time and compiler memory usage. +extern template class md::PotentialExternal; + +namespace azplugins + { +namespace detail + { +void EXPORT_FUNCTION(pybind11::module& m) + { + hoomd::md::detail::export_PotentialExternalGPU( + m, + "WallsPotential@_evaluator@GPU"); + } + } // end namespace detail + } // end namespace azplugins + } // end namespace hoomd diff --git a/src/module.cc b/src/module.cc index 90e25494..ec89000f 100644 --- a/src/module.cc +++ b/src/module.cc @@ -77,6 +77,9 @@ void export_PotentialPairPerturbedLennardJones(pybind11::module&); // dpd void export_PotentialPairDPDThermoGeneralWeight(pybind11::module&); +// wall +void export_PotentialExternalWallLJ93(pybind11::module&); + #ifdef ENABLE_HIP // bond void export_ImagePotentialBondHarmonicGPU(pybind11::module&); @@ -102,6 +105,9 @@ void export_PotentialPairPerturbedLennardJonesGPU(pybind11::module&); // dpd void export_PotentialPairDPDThermoGeneralWeightGPU(pybind11::module&); +// wall +void export_PotentialExternalWallLJ93GPU(pybind11::module&); + #endif // ENABLE_HIP } // namespace detail @@ -141,6 +147,9 @@ PYBIND11_MODULE(_azplugins, m) // dpd pair export_PotentialPairDPDThermoGeneralWeight(m); + // wall + export_PotentialExternalWallLJ93(m); + #ifdef ENABLE_HIP // bond export_ImagePotentialBondHarmonicGPU(m); @@ -166,5 +175,8 @@ PYBIND11_MODULE(_azplugins, m) // dpd pair export_PotentialPairDPDThermoGeneralWeightGPU(m); + // wall + export_PotentialExternalWallLJ93GPU(m); + #endif // ENABLE_HIP } diff --git a/src/pytest/CMakeLists.txt b/src/pytest/CMakeLists.txt index 1c6f60ba..157b326b 100644 --- a/src/pytest/CMakeLists.txt +++ b/src/pytest/CMakeLists.txt @@ -8,6 +8,7 @@ set(test_files test_pair.py test_pair_aniso.py test_pair_dpd.py + test_wall.py ) # Copy tests to the install directory. diff --git a/src/pytest/test_wall.py b/src/pytest/test_wall.py new file mode 100644 index 00000000..98add731 --- /dev/null +++ b/src/pytest/test_wall.py @@ -0,0 +1,83 @@ +# Copyright (c) 2018-2020, Michael P. Howard +# Copyright (c) 2021-2025, Auburn University +# Part of azplugins, released under the BSD 3-Clause License. + +"""Wall potential unit tests.""" + +import collections + +import hoomd +import hoomd.azplugins +import numpy + +import pytest + +PotentialTestCase = collections.namedtuple( + "PotentialTestCase", + ["potential", "params", "position", "energy", "force"], +) + +potential_tests = [] + +# Lennard Jones 9-3 +potential_tests += [ + # test the calculation of force and potential + PotentialTestCase( + hoomd.azplugins.wall.LJ93, + {"sigma": 1.0, "A": 1.0, "r_cut": 3.0}, + (0, 0, 1.5), + -0.2558, + -0.5718, + ), + PotentialTestCase( + hoomd.azplugins.wall.LJ93, + {"sigma": 1.0, "A": 1.0, "r_cut": 3.0}, + (0, 0, 3.5), + 0, + 0, + ), +] + + +@pytest.mark.parametrize( + "potential_test", potential_tests, ids=lambda x: x.potential.__name__ +) +def test_energy_and_force( + simulation_factory, one_particle_snapshot_factory, potential_test +): + """Test energy and force evaluation.""" + # make one particle test configuration + sim = simulation_factory( + one_particle_snapshot_factory(position=potential_test.position, L=20) + ) + + # setup dummy NVE integrator + integrator = hoomd.md.Integrator(dt=0.001) + nve = hoomd.md.methods.ConstantVolume(hoomd.filter.All()) + integrator.methods = [nve] + + # setup wall potential + wall = hoomd.wall.Plane(origin=(0, 0, 0), normal=(0, 0, 1)) + potential = potential_test.potential(walls=[wall]) + potential.params["A"] = potential_test.params + integrator.forces = [potential] + + # calculate energies and forces + sim.operations.integrator = integrator + sim.run(0) + + # test that parameters are still correct after attach runs + for attr in potential_test.params: + assert potential.params["A"][attr] == potential_test.params[attr] + + # test that the energies match reference values, half goes to each particle + energies = potential.energies + e = potential_test.energy + if sim.device.communicator.rank == 0: + numpy.testing.assert_array_almost_equal(energies, e, decimal=4) + + # test that the forces match reference values, should be directed along z + forces = potential.forces + f = potential_test.force + if sim.device.communicator.rank == 0: + numpy.testing.assert_array_almost_equal(forces, [[0, 0, f]], decimal=4) diff --git a/src/wall.py b/src/wall.py new file mode 100644 index 00000000..71524f14 --- /dev/null +++ b/src/wall.py @@ -0,0 +1,75 @@ +# Copyright (c) 2018-2020, Michael P. Howard +# Copyright (c) 2021-2025, Auburn University +# Part of azplugins, released under the BSD 3-Clause License. + +"""Wall potentials.""" + +from hoomd.azplugins import _azplugins +from hoomd.data.parameterdicts import TypeParameterDict +from hoomd.data.typeparam import TypeParameter +from hoomd.md.external import wall + + +class LJ93(wall.WallPotential): + r"""Lennard-Jones 9-3 wall potential. + + Args: + walls (`list` [`hoomd.wall.WallGeometry`]) : A list of wall definitions. + + `LJ93` is Lennard-Jones 9-3 wall potential, which is derived from integrating + the standard Lennard-Jones potential between a point particle and a half plane: + + .. math:: + + U(r) = A \left[\frac{2}{15} \left(\frac{\sigma}{r} \right)^9 + - \left(\frac{\sigma}{r}\right)^3 \right] + + where: + + * :math:`\sigma` - diameter of Lennard-Jones particles in the wall + * :math:`A` - Hamaker constant, related to the Lennard-Jones parameters as + :math:`A = \frac{2}{3} \pi \varepsilon \sigma^3 \rho`, where :math:`\rho` + is the number density of particles in the wall and + :math:`\varepsilon` is the Lennard-Jones energy parameter. + + Example:: + + walls = [hoomd.wall.Plane(origin=(0, 0, 0), normal=(0, 1, 0))] + lj93 = azplugins.wall.LJ93(walls=walls) + lj93.params["A"] = dict( + sigma=1.0, + A=2 * numpy.pi / 3, # rho = 1, epsilon = 1, sigma = 1 + r_cut=3.0, + ) + + .. py:attribute:: params + + The `LJ93` potential parameters. The dictionary has the following + keys: + + * ``A`` (`float`, **required**) - Hamaker constant + :math:`A` :math:`[\mathrm{energy}]` + * ``sigma`` (`float`, **required**) - Lennard-Jones particle size + :math:`\sigma` :math:`[\mathrm{length}]` + * ``r_cut`` (`float`, **required**) - The cut off distance for + the wall potential :math:`[\mathrm{length}]` + * ``r_extrap`` (`float`, **optional**) - The distance to + extrapolate the potential, defaults to 0. + :math:`[\mathrm{length}]`. + + Type: :class:`~hoomd.data.typeparam.TypeParameter` [``particle_type``], `dict`] + """ + + _ext_module = _azplugins + _cpp_class_name = "WallsPotentialLJ93" + + def __init__(self, walls): + super().__init__(walls) + params = TypeParameter( + "params", + "particle_types", + TypeParameterDict( + A=float, sigma=float, r_cut=float, r_extrap=0.0, len_keys=1 + ), + ) + self._add_typeparam(params)