Skip to main content

Multisphere representations of mesh and voxel geometries for DEM simulations

Project description

multisphere logo

GitHub last commit GitHub issues GitHub pull requests License: GPLv3 10.1016/j.powtec.2026.122635


multisphere

multisphere creates overlapping-sphere representations of arbitrary 3D geometries based on voxelized Euclidean distance transforms (EDT) and feature-enhanced distance fields (FEDT). The algorithm is designed for Discrete Element Method (DEM) simulations, where accurate yet computationally efficient particle shape representations are essential.

The implemented method follows the MSS algorithm introduced by Buchele et al. and achieves high shape accuracy at low computational cost.

The package supports reconstruction from:

  • Triangle surface meshes (STL, PLY, OBJ)
  • Binary voxel volumes (NumPy)

Scientific Background

The multisphere algorithm is based on:

  • Voxelization of the target geometry
  • Euclidean Distance Transform
  • Peak refinement of EDT maxima
  • Iterative residual correction using a
  • Feature-Enhanced Distance Grid
  • Termination by shape accuracy, minimum radius, or maximum sphere count

This approach avoids the major drawbacks of greedy sphere removal methods, such as

  • spurious small spheres
  • symmetry violations
  • excessive runtime.

Features

  • multisphere reconstruction from:
    • Triangle meshes (STL, OBJ, PLY)
    • Binary voxel grids (NumPy)
  • Exact EDT-driven sphere placement
  • Iterative residual correction using FEDT
  • Multiple termination criteria:
    • Shape precision
    • Maximum number of spheres
    • Minimum allowed sphere radius
  • Export formats:
    • CSV (sphere centers & radii)
    • VTK (visualization)
    • STL (boolean union of spheres)
  • Optional visualization with PyVista
  • Optional Dice similarity coefficient for mesh-based validation
  • Optional boundary correction to enforce strict STL containment

Installation

Requires Python ≥ 3.10. Linux and macOS are fully supported. Windows is supported but boolean backends may require additional setup.

Core installation (no visualization, no STL boolean unions)

pip install multisphere

Full installation

pip install multisphere[full]

The full installation adds:

  • PyVista + Matplotlib for visualization
  • manifold3d for boolean STL reconstruction and Dice computation

Basic usage

Mesh based reconstruction

import multisphere as mss

mesh = mss.load_mesh("geometry.stl")

sphere_pack = mss.multisphere_from_mesh(
    mesh=mesh,
    div=150,
    padding=2,
    min_radius_vox=4,
    precision=0.90,
    min_center_distance_vox=4,
    max_spheres=100,
    confine_mesh=False,
)

mss.export_sphere_pack_to_csv(sphere_pack, "spheres.csv")
mss.export_sphere_pack_to_vtk(sphere_pack, "spheres.vtk")
mss.export_sphere_pack_to_stl(sphere_pack, "spheres.stl")

Note: STL export requires a boolean backend (manifold3d or Blender).

Voxel based reconstruction

import multisphere as mss

voxel_grid = mss.load_voxels_from_npy(
    "volume.npy",
    voxel_size=1.0,
    origin=(0.0, 0.0, 0.0),
)

sphere_pack = mss.multisphere_from_voxels(
    voxel_grid=voxel_grid,
    min_radius_vox=4,
    precision=0.95,
    min_center_distance_vox=4,
    max_spheres=100,
)

mss.export_sphere_pack_to_csv(sphere_pack, "spheres.csv")
mss.export_sphere_pack_to_vtk(sphere_pack, "spheres.vtk")

Examples

Complete working examples are located in examples/

The examples directory contains:

  • example_from_mesh.py — full mesh-to-multisphere pipeline
  • example_from_voxels.py — voxel-to-multisphere reconstruction

Limitations

Boolean STL reconstruction is numerically fragile for:

  • Very large sphere counts
  • Extreme overlaps Performance scales with voxel resolution and peak density. Reconstruction quality depends heavily on the chosen voxel resolution.

License

This project is licensed under the GNU General Public License v3.0.

You are free to use, modify, and redistribute the software under the terms of the GPL. Any derivative work must also be released under the GPL.

See the LICENSE file for full details.

multisphere depends on third-party libraries with compatible licenses:

Package License
NumPy BSD-3-Clause
SciPy BSD-3-Clause
scikit-image BSD-3-Clause
trimesh MIT
PyVista MIT
Matplotlib Matplotlib license (BSD-compatible)
manifold3d Apache-2.0

Refer to the respective projects for full license texts.

Author

Felix Buchele, Patric Müller, Thorsten Pöschel
Friedrich-Alexander-Universität Erlangen–Nürnberg (FAU)
Institute for Multiscale Simulation (MSS)

Citation

Felix Buchele, Patric Müller, Thorsten Pöschel,
Multi-Sphere-Shape generator for DEM simulations of complex-shaped particles
Powder Technology, 480, 2026, 10.1016/j.powtec.2026.122635

Felix Buchele, Patric Müller, Arash Moradian, Thorsten Pöschel,
multisphere: a Python implementation of the Multi Sphere Shape generator (MSS) for DEM simulations
Submitted to SoftwareX, https://ssrn.com/abstract=6614754

Arash Moradian, Felix Buchele, Patric Müller, Thorsten Pöschel,
GEMSS: A C++ Library for Runtime Multi-Sphere Modeling of Granular Particles in DEM Simulations
Manuscript in preparation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multisphere-1.1.1.tar.gz (38.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multisphere-1.1.1-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file multisphere-1.1.1.tar.gz.

File metadata

  • Download URL: multisphere-1.1.1.tar.gz
  • Upload date:
  • Size: 38.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for multisphere-1.1.1.tar.gz
Algorithm Hash digest
SHA256 e4a2cd7b8d3f87a01fca0be7da82cbfc76c6928a091097bacd867d37e441f9b9
MD5 d485db745eadb168b19cbdde4007cef3
BLAKE2b-256 2903901dfe98a0006a284b0c87fd5ee8aa4a7649d426f6fc5b6466317f2f964c

See more details on using hashes here.

File details

Details for the file multisphere-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: multisphere-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 39.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for multisphere-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31e158643261eaba7b7c5ebeb88cb3c3ee9b5425b973f7eed9be85361af69870
MD5 42ed93c879e1bcd211aa8c319b9062b8
BLAKE2b-256 5160ace898cab6a12fb917187fb13142eef1bc52ec693b91e46098864add5a2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page