Root Cause
Degenerate 4-fold Voronoi vertices cause a crash in FiniteVoronoiSimulator._assemble_forces when more than three seed-point indices are found for a Voronoi vertex, observed in large systems (N=1000+). The code (v0.4.7) assumes each inner vertex connects to three cells and unpacks accordingly, leading to ValueError when this is not true:
Traceback (most recent call last):
File "xxx.py", line xxx, in <module>
diag = sim.build()
^^^^^^^^^^^
File "/xxx/lib/python3.11/site-packages/pyafv/finite_voronoi.py", line 758, in build
F = self._assemble_forces(
^^^^^^^^^^^^^^^^^^^^^^
File "/xxx/lib/python3.11/site-packages/pyafv/finite_voronoi.py", line 528, in _assemble_forces
I[t], J[t], K[t] = vertex_points[h]
^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 3)
Detailed Explanation
- Code in question:
I[t], J[t], K[t] = vertex_points[h] # blows up if len > 3
- When does this happen?
- In rare cases, Qhull returns a single vertex with 4 incident ridges — typically when 4 (or more) points are co-circular (e.g., corners of a square or crystalline patches at high N).
- This increases in likelihood at larger N due to combinatorics and relaxed crystalline formation.
Minimal Example to Reproduce
import numpy as np
import pyafv as afv
square_pts = np.array([[ 1., 1.], [-1., 1.], [-1., -1.], [ 1., -1.]]) * 0.5
params = afv.PhysicalParams(r=1.0)
sim = afv.FiniteVoronoiSimulator(square_pts, params)
diag = sim.build() # raises: ValueError: too many values to unpack (expected 3)

Root Cause
Degenerate 4-fold Voronoi vertices cause a crash in
FiniteVoronoiSimulator._assemble_forceswhen more than three seed-point indices are found for a Voronoi vertex, observed in large systems (N=1000+). The code (v0.4.7) assumes each inner vertex connects to three cells and unpacks accordingly, leading toValueErrorwhen this is not true:Detailed Explanation
Minimal Example to Reproduce