From 34899f919bb415514aa75f690eb160f33abe4f11 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 5 Dec 2024 10:17:56 -0500 Subject: [PATCH 1/6] Validate that NEC integators can be executed. --- hoomd/hpmc/pytest/CMakeLists.txt | 3 ++- hoomd/hpmc/pytest/test_nec.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 hoomd/hpmc/pytest/test_nec.py diff --git a/hoomd/hpmc/pytest/CMakeLists.txt b/hoomd/hpmc/pytest/CMakeLists.txt index 1c1f9ac70c..abecd740b0 100644 --- a/hoomd/hpmc/pytest/CMakeLists.txt +++ b/hoomd/hpmc/pytest/CMakeLists.txt @@ -13,9 +13,10 @@ set(files __init__.py test_shape_updater.py test_shape_utils.py test_move_size_tuner.py + test_nec.py test_pair_lennard_jones.py test_pair_expanded_gaussian.py - test_pair_lj_gauss.py + test_pair_lj_gauss.py test_pair_opp.py test_pair_step.py test_pair_union.py diff --git a/hoomd/hpmc/pytest/test_nec.py b/hoomd/hpmc/pytest/test_nec.py new file mode 100644 index 0000000000..60e5d88ee2 --- /dev/null +++ b/hoomd/hpmc/pytest/test_nec.py @@ -0,0 +1,11 @@ +# Copyright (c) 2009-2024 The Regents of the University of Michigan. +# Part of HOOMD-blue, released under the BSD 3-Clause License. + +import hoomd + +def test_nec(simulation_factory, lattice_snapshot_factory): + snap = lattice_snapshot_factory(particle_types=["A"]) + simulation = simulation_factory(snap) + simulation.operations.integrator = hoomd.hpmc.nec.integrate.Sphere() + simulation.run(10) + From 0b75683251b0c7f3d3c5856a66709f631c4eb635 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 5 Dec 2024 10:18:09 -0500 Subject: [PATCH 2/6] Remove spurious future import. --- hoomd/hpmc/compute.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/hoomd/hpmc/compute.py b/hoomd/hpmc/compute.py index b1361aefdf..fede9c0b37 100644 --- a/hoomd/hpmc/compute.py +++ b/hoomd/hpmc/compute.py @@ -7,8 +7,6 @@ particles and `SDF` samples the pressure. """ -from __future__ import print_function - from hoomd import _hoomd from hoomd.operation import Compute from hoomd.hpmc import _hpmc From 2b0b1d63a9a5fa92283c52ad0bc6ef2cd6c88d46 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 5 Dec 2024 10:21:21 -0500 Subject: [PATCH 3/6] Fix and test Python initialization of NEC. --- hoomd/hpmc/nec/integrate.py | 2 +- hoomd/hpmc/pytest/test_nec.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hoomd/hpmc/nec/integrate.py b/hoomd/hpmc/nec/integrate.py index 4e6a6ab324..bbec925d40 100644 --- a/hoomd/hpmc/nec/integrate.py +++ b/hoomd/hpmc/nec/integrate.py @@ -72,7 +72,7 @@ def __init__( nselect=1, ): # initialize base class - super().__init__(default_d, default_a, 0.5, nselect) + super().__init__(default_d, default_a, 0.5, nselect, 1.0) # Set base parameter dict for hpmc chain integrators param_dict = ParameterDict( diff --git a/hoomd/hpmc/pytest/test_nec.py b/hoomd/hpmc/pytest/test_nec.py index 60e5d88ee2..5c34c66905 100644 --- a/hoomd/hpmc/pytest/test_nec.py +++ b/hoomd/hpmc/pytest/test_nec.py @@ -6,6 +6,8 @@ def test_nec(simulation_factory, lattice_snapshot_factory): snap = lattice_snapshot_factory(particle_types=["A"]) simulation = simulation_factory(snap) - simulation.operations.integrator = hoomd.hpmc.nec.integrate.Sphere() + sphere = hoomd.hpmc.nec.integrate.Sphere() + sphere.shape['A'] = {'diameter': 1.0} + simulation.operations.integrator = sphere simulation.run(10) From 1d72e142bc52615e6603fc6f2b536bea2db54991 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 5 Dec 2024 11:07:58 -0500 Subject: [PATCH 4/6] Fix NEC integrators. --- hoomd/hpmc/IntegratorHPMCMonoNEC.h | 74 ++++++++++++++++-------------- hoomd/hpmc/pytest/test_nec.py | 4 +- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/hoomd/hpmc/IntegratorHPMCMonoNEC.h b/hoomd/hpmc/IntegratorHPMCMonoNEC.h index c15a45fcd5..e0c6a33ae7 100644 --- a/hoomd/hpmc/IntegratorHPMCMonoNEC.h +++ b/hoomd/hpmc/IntegratorHPMCMonoNEC.h @@ -275,17 +275,12 @@ template void IntegratorHPMCMonoNEC::update(uint64_t timeste this->m_exec_conf->msg->notice(10) << "HPMCMonoEC update: " << timestep << std::endl; IntegratorHPMC::update(timestep); - // get needed vars - ArrayHandle h_counters(this->m_count_total, - access_location::host, - access_mode::readwrite); - hpmc_counters_t& counters = h_counters.data[0]; - - ArrayHandle h_nec_counters(m_nec_count_total, - access_location::host, - access_mode::readwrite); - hpmc_nec_counters_t& nec_counters = h_nec_counters.data[0]; - m_nec_count_step_start = h_nec_counters.data[0]; + { + ArrayHandle h_nec_counters(m_nec_count_total, + access_location::host, + access_mode::readwrite); + m_nec_count_step_start = h_nec_counters.data[0]; + } const BoxDim& box = this->m_pdata->getBox(); unsigned int ndim = this->m_sysdef->getNDimensions(); @@ -294,29 +289,6 @@ template void IntegratorHPMCMonoNEC::update(uint64_t timeste count_pressurevirial = 0.0; count_movelength = 0.0; - // access interaction matrix - ArrayHandle h_overlaps(this->m_overlaps, - access_location::host, - access_mode::read); - ArrayHandle h_image(this->m_pdata->getImages(), - access_location::host, - access_mode::readwrite); - - // access particle data - ArrayHandle h_postype(this->m_pdata->getPositions(), - access_location::host, - access_mode::readwrite); - ArrayHandle h_velocities(this->m_pdata->getVelocities(), - access_location::host, - access_mode::readwrite); - ArrayHandle h_orientation(this->m_pdata->getOrientationArray(), - access_location::host, - access_mode::readwrite); - - // access move sizes - ArrayHandle h_d(this->m_d, access_location::host, access_mode::read); - ArrayHandle h_a(this->m_a, access_location::host, access_mode::read); - uint16_t seed = this->m_sysdef->getSeed(); // loop over local particles nselect times @@ -333,6 +305,40 @@ template void IntegratorHPMCMonoNEC::update(uint64_t timeste // update the image list this->updateImageList(); + // get needed vars + ArrayHandle h_counters(this->m_count_total, + access_location::host, + access_mode::readwrite); + hpmc_counters_t& counters = h_counters.data[0]; + + ArrayHandle h_nec_counters(m_nec_count_total, + access_location::host, + access_mode::readwrite); + hpmc_nec_counters_t& nec_counters = h_nec_counters.data[0]; + + // access interaction matrix + ArrayHandle h_overlaps(this->m_overlaps, + access_location::host, + access_mode::read); + ArrayHandle h_image(this->m_pdata->getImages(), + access_location::host, + access_mode::readwrite); + + // access particle data + ArrayHandle h_postype(this->m_pdata->getPositions(), + access_location::host, + access_mode::readwrite); + ArrayHandle h_velocities(this->m_pdata->getVelocities(), + access_location::host, + access_mode::readwrite); + ArrayHandle h_orientation(this->m_pdata->getOrientationArray(), + access_location::host, + access_mode::readwrite); + + // access move sizes + ArrayHandle h_d(this->m_d, access_location::host, access_mode::read); + ArrayHandle h_a(this->m_a, access_location::host, access_mode::read); + // loop through N particles in a shuffled order for (unsigned int cur_chain = 0; cur_chain < this->m_pdata->getN() * m_update_fraction; cur_chain++) diff --git a/hoomd/hpmc/pytest/test_nec.py b/hoomd/hpmc/pytest/test_nec.py index 5c34c66905..22a5c2bac8 100644 --- a/hoomd/hpmc/pytest/test_nec.py +++ b/hoomd/hpmc/pytest/test_nec.py @@ -3,11 +3,11 @@ import hoomd + def test_nec(simulation_factory, lattice_snapshot_factory): snap = lattice_snapshot_factory(particle_types=["A"]) simulation = simulation_factory(snap) sphere = hoomd.hpmc.nec.integrate.Sphere() - sphere.shape['A'] = {'diameter': 1.0} + sphere.shape["A"] = {"diameter": 1.0} simulation.operations.integrator = sphere simulation.run(10) - From 5a06d249103a3f5694c051e0213139f9a66427bb Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 5 Dec 2024 11:14:20 -0500 Subject: [PATCH 5/6] Document NEC fix. --- CHANGELOG.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 66851357f7..fec4e48f2c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,15 @@ Change Log 5.x --- +5.0.1 (not yet released) +^^^^^^^^^^^^^^^^^^^^^^^^ + +*Fixed* + +* Prevent ``missing 1 required positional argument: 'kT'`` errors when using NEC integrators + (`#1965 `__) + + 5.0.0 (2024-12-02) ^^^^^^^^^^^^^^^^^^ From 661d39e1b4f2be2144d96bc67b410ecf25631a14 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 5 Dec 2024 11:34:02 -0500 Subject: [PATCH 6/6] Execute NEC test in serial. --- hoomd/hpmc/pytest/test_nec.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hoomd/hpmc/pytest/test_nec.py b/hoomd/hpmc/pytest/test_nec.py index 22a5c2bac8..c8f2b5ac30 100644 --- a/hoomd/hpmc/pytest/test_nec.py +++ b/hoomd/hpmc/pytest/test_nec.py @@ -2,8 +2,10 @@ # Part of HOOMD-blue, released under the BSD 3-Clause License. import hoomd +import pytest +@pytest.mark.serial def test_nec(simulation_factory, lattice_snapshot_factory): snap = lattice_snapshot_factory(particle_types=["A"]) simulation = simulation_factory(snap)