Skip to content

Commit 2887c13

Browse files
authored
Merge pull request #2163 from Harry-Zhu-45/trunk-patch
Export‑name validation and conflict resolution for FreeVolume
2 parents 8d81747 + a18b7e0 commit 2887c13

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Change Log
1616

1717
* Use the provided alpha parameter in ``make_pppm_coulomb_forces``
1818
(`#2153 <https://github.com/glotzerlab/hoomd-blue/pull/2153>`__).
19+
* Add a unit test to verify that the export name of ``hoomd.hpmc.compute.FreeVolume``, and resolved the existing export name conflicts (`#2163 <https://github.com/glotzerlab/hoomd-blue/pull/2163>`__).
1920

2021
5.4.0 (2025-09-26)
2122
^^^^^^^^^^^^^^^^^^^^

hoomd/hpmc/module_convex_spheropolyhedron.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace detail
3232
void export_convex_spheropolyhedron(pybind11::module& m)
3333
{
3434
export_IntegratorHPMCMono<ShapeSpheropolyhedron>(m, "IntegratorHPMCMonoSpheropolyhedron");
35-
export_ComputeFreeVolume<ShapeSpheropolyhedron>(m, "ComputeFreeVolumeSpheropolyhedron");
35+
export_ComputeFreeVolume<ShapeSpheropolyhedron>(m, "ComputeFreeVolumeConvexSpheropolyhedron");
3636
export_ComputeSDF<ShapeSpheropolyhedron>(m, "ComputeSDFConvexSpheropolyhedron");
3737
export_UpdaterMuVT<ShapeSpheropolyhedron>(m, "UpdaterMuVTConvexSpheropolyhedron");
3838
export_UpdaterGCA<ShapeSpheropolyhedron>(m, "UpdaterGCAConvexSpheropolyhedron");
@@ -48,7 +48,9 @@ void export_convex_spheropolyhedron(pybind11::module& m)
4848
#ifdef ENABLE_HIP
4949

5050
export_IntegratorHPMCMonoGPU<ShapeSpheropolyhedron>(m, "IntegratorHPMCMonoSpheropolyhedronGPU");
51-
export_ComputeFreeVolumeGPU<ShapeSpheropolyhedron>(m, "ComputeFreeVolumeSpheropolyhedronGPU");
51+
export_ComputeFreeVolumeGPU<ShapeSpheropolyhedron>(
52+
m,
53+
"ComputeFreeVolumeConvexSpheropolyhedronGPU");
5254
export_UpdaterGCAGPU<ShapeSpheropolyhedron>(m, "UpdaterGCAConvexSpheropolyhedronGPU");
5355

5456
#endif

hoomd/hpmc/module_spheropolygon.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace detail
2929
void export_spheropolygon(pybind11::module& m)
3030
{
3131
export_IntegratorHPMCMono<ShapeSpheropolygon>(m, "IntegratorHPMCMonoSpheropolygon");
32-
export_ComputeFreeVolume<ShapeSpheropolygon>(m, "ComputeFreeVolumeSpheropolygon");
32+
export_ComputeFreeVolume<ShapeSpheropolygon>(m, "ComputeFreeVolumeConvexSpheropolygon");
3333
export_ComputeSDF<ShapeSpheropolygon>(m, "ComputeSDFConvexSpheropolygon");
3434
export_UpdaterMuVT<ShapeSpheropolygon>(m, "UpdaterMuVTConvexSpheropolygon");
3535
export_UpdaterGCA<ShapeSpheropolygon>(m, "UpdaterGCAConvexSpheropolygon");
@@ -38,7 +38,7 @@ void export_spheropolygon(pybind11::module& m)
3838

3939
#ifdef ENABLE_HIP
4040
export_IntegratorHPMCMonoGPU<ShapeSpheropolygon>(m, "IntegratorHPMCMonoSpheropolygonGPU");
41-
export_ComputeFreeVolumeGPU<ShapeSpheropolygon>(m, "ComputeFreeVolumeSpheropolygonGPU");
41+
export_ComputeFreeVolumeGPU<ShapeSpheropolygon>(m, "ComputeFreeVolumeConvexSpheropolygonGPU");
4242
export_UpdaterGCAGPU<ShapeSpheropolygon>(m, "UpdaterGCAConvexSpheropolygonGPU");
4343
#endif
4444
}

hoomd/hpmc/module_union_convex_polyhedron.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void export_union_convex_polyhedron(pybind11::module& m)
3434
"IntegratorHPMCMonoConvexPolyhedronUnion");
3535
export_ComputeFreeVolume<ShapeUnion<ShapeSpheropolyhedron>>(
3636
m,
37-
"ComputeFreeVolumeConvexPolyhedronUnion");
37+
"ComputeFreeVolumeConvexSpheropolyhedronUnion");
3838
export_ComputeSDF<ShapeUnion<ShapeSpheropolyhedron>>(m,
3939
"ComputeSDFConvexSpheropolyhedronUnion");
4040
export_UpdaterMuVT<ShapeUnion<ShapeSpheropolyhedron>>(m,
@@ -52,7 +52,7 @@ void export_union_convex_polyhedron(pybind11::module& m)
5252
"IntegratorHPMCMonoConvexPolyhedronUnionGPU");
5353
export_ComputeFreeVolumeGPU<ShapeUnion<ShapeSpheropolyhedron>>(
5454
m,
55-
"ComputeFreeVolumeConvexPolyhedronUnionGPU");
55+
"ComputeFreeVolumeConvexSpheropolyhedronUnionGPU");
5656
export_UpdaterGCAGPU<ShapeUnion<ShapeSpheropolyhedron>>(
5757
m,
5858
"UpdaterGCAConvexSpheropolyhedronUnionGPU");

hoomd/hpmc/pytest/test_compute_free_volume.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,42 @@ def test_2d_free_volume(simulation_factory):
114114
f = free_volume.free_volume
115115
if snapshot.communicator.rank == 0:
116116
assert f == pytest.approx(expected=100 * 100 - math.pi, rel=1e-3)
117+
118+
119+
def test_free_volume_export_name_matches_integrator(
120+
device, simulation_factory, two_particle_snapshot_factory, valid_args
121+
):
122+
integrator = valid_args[0]
123+
args = valid_args[1]
124+
n_dimensions = valid_args[2]
125+
126+
if isinstance(integrator, tuple):
127+
inner_integrator = integrator[0]
128+
integrator = integrator[1]
129+
inner_mc = inner_integrator()
130+
for i in range(len(args["shapes"])):
131+
# This will fill in default values for the inner shape objects
132+
inner_mc.shape["A"] = args["shapes"][i]
133+
args["shapes"][i] = inner_mc.shape["A"].to_base()
134+
135+
if integrator == hoomd.hpmc.integrate.Sphinx and isinstance(
136+
device, hoomd.device.GPU
137+
):
138+
pytest.skip("Sphinx does not build on the GPU by default.")
139+
140+
mc = integrator()
141+
mc.shape["A"] = args
142+
sim = simulation_factory(two_particle_snapshot_factory(dimensions=n_dimensions))
143+
assert sim.operations.integrator is None
144+
sim.operations.add(mc)
145+
sim.operations._schedule()
146+
147+
free_vol = hoomd.hpmc.compute.FreeVolume(test_particle_type="A", num_samples=10)
148+
sim.operations.computes.append(free_vol)
149+
150+
try:
151+
sim.run(1)
152+
except AttributeError as e:
153+
pytest.fail(
154+
f"FreeVolume export class name mismatch for {integrator.__name__}: {e}"
155+
)

sphinx-doc/credits.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ The following people have contributed to HOOMD-blue:
8989
* Michael Howard, Auburn University
9090
* Michaela Bush, Auburn University
9191
* Mike Henry, Boise State University
92+
* Ming Zhu, Wuhan University
9293
* Nathan Horst
9394
* Nipuli Gunaratne, University of Michigan
9495
* Nicholas Cal Craven, Vanderbilt University

0 commit comments

Comments
 (0)