Skip to main content

simgeometry

Geometry primitives for numerical simulations: bounded domains, structured grids, MPI domain decomposition, and 1D, 2D, and 3D shapes. Box, ball, and polygon containment have NumPy, Pyccel, CUDA, and Metal implementations. Originally developed for Picnic.

Install

pip install simgeometry

For development, install this checkout with pip install -e '.[test]'. NumPy, cunumpy, maybempi, mpiarray and scope-profiler are runtime dependencies. Matplotlib is optional. Install simgeometry[plot] for plotting, labelled evaluation and surface meshing, or simgeometry[interactive] for interactive 3D clipping with PyVista. Install simgeometry[mpi] for MPI, simgeometry[pyccel] for compiled CPU containment kernels, or simgeometry[gpu] for CUDA.

Example

from simgeometry.grid import Grid
from simgeometry.objects import Circle

boundary = Circle(midpoint=(0.5, 0.5), radius=0.25)
grid = Grid(ndim=2, lower_bound=(0, 0), upper_bound=(1, 1), num_gridpoints=(32, 32))
mask = boundary.node_mask(grid)

SimulationDomain accepts field and particle boundary objects through their get_bc(dir=..., side=...).bc_type interface. Applications may supply a seeded random function with BoundingBox.random and an accelerated particle boundary implementation with SimulationDomain.boundary_kernel.

Inspect, slice, and compose

from simgeometry import Sphere

shell = Sphere((0, 0, 0), 1) - Sphere((0, 0, 0), 0.4)
shell.show_3d(opacity=0.6)
shell.slice(z=0.2).show()
inside = shell.evaluate(x=[0, 0.8], y=0, z=0)

Shapes support named collections, Boolean operations, affine transforms, surface queries, point sampling, mesh export, cut-edge geometry and approximate cell/face fractions. See the executed examples and API guide for examples and the accuracy limits of sampled operations.

Level sets, solids of revolution and conductors

from simgeometry import GeometryCollection, Tube

ring = lambda z: Tube((0, 0, z - 0.4), (0, 0, z + 0.4), 1.0, 1.6, fillet=0.1)
lens = GeometryCollection(
    {"entrance": ring(-1.2), "focus": ring(0.0), "exit": ring(1.2)},
    voltages={"entrance": 0.0, "focus": 10e3, "exit": 0.0},
)
scan = lens.with_voltages(focus=lambda t: 10e3 * min(t / 1e-6, 1.0))
values = scan.dirichlet_values(grid, t=0.5e-6)  # labels and voltages per node
distance = lens["focus"].level_set(points)  # exact signed distance

Cylinder, Tube, Cone and Torus take any axis. Analytic shapes have a level_set(points), negative inside, with level_set_exact where it is the Euclidean signed distance; Booleans and transforms propagate it. Edge crossings refine it with a few secant steps instead of bisecting contains, and signed_distance returns an exact one directly. The conductors example builds an Einzel lens.

Preview a domain decomposition

from simgeometry import Sphere
from simgeometry.domain_decomposition import DomainDecomposition

preview = DomainDecomposition.preview(8, decompose=[True, True, True])
preview.proc_sizes  # [2, 2, 2], as on 8 MPI ranks
boxes = preview.subdomain_boxes((0, 0, 0), (2, 1, 1), (33, 17, 17))
preview.show_3d((0, 0, 0), (2, 1, 1), (33, 17, 17), shape=Sphere((1, 0.5, 0.5), 0.35))

DomainDecomposition.preview(size) computes the split a size-rank run would use without a communicator, for inspection and planning: index ranges, subdomains and owner ranks for every rank. show_3d draws one box per rank (with simgeometry[interactive]) and show one rectangle per rank of a 2D decomposition. See the parallel grids example.

Profiling

simgeometry ships scope-profiler regions for its expensive operations (simgeometry.node_mask, simgeometry.crossings, simgeometry.to_mesh, …). They are off by default and cost almost nothing. Turn them on in an application that profiles itself with the simgeometry tag:

import scope_profiler as sp

sp.setup(enable_tags=["simgeometry"])

or SCOPE_PROFILER_ENABLE_TAGS=simgeometry, or scope-profiler run --enable-tag simgeometry.

Development

pytest src/simgeometry/tests

Documentation: https://max-models.github.io/simgeometry/

Metadata

Release files for simgeometry 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simgeometry 0.2.0
File Size Uploaded Provenance Actions
simgeometry-0.2.0.tar.gz 136.8 kB With provenance Details for simgeometry-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simgeometry 0.2.0
File Interpreter ABI Platform Actions
simgeometry-0.2.0-py3-none-any.whl Python 3 none any Details for simgeometry-0.2.0-py3-none-any.whl

Total release size: 314.2 kB

Release files / simgeometry-0.2.0.tar.gz

Download URL simgeometry-0.2.0.tar.gz
Size 136.8 kB
Tags Source
SHA-256 checksum
How to use checksums
61c44f413721fce5d3355cb41df48c62d5ddb6fa6de673707c95c833269f96d9
BLAKE2b-256 checksum
How to use checksums
ca9aa0b85d22d514bda45756eea85e229a21dda431cebb7436597026b2939fc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / simgeometry-0.2.0-py3-none-any.whl

Download URL simgeometry-0.2.0-py3-none-any.whl
Size 177.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3767468fcd1ff92d12f631ec78ca1c0c098388c1c7e5c83945b102f6ea1788a
BLAKE2b-256 checksum
How to use checksums
381889cb510edc40efa9dd61043a5ea1acc5ac396334ed664c5605d75bad7ea0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for simgeometry 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for simgeometry-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page