Surface correction weights for 3-D peridynamics (bond-based, state-based LPS, and correspondence NOSB-PD) with mesh quality diagnostics
Project description
perifit
Surface correction weights for 3-D peridynamics (state-based LPS, bond-based, and correspondence NOSB-PD) with mesh quality diagnostics
perifit computes optimised nodal influence weights that eliminate
the surface/boundary effect in three-dimensional peridynamics.
Supported models:
| Model | CLI flag | Operator rows | Notes |
|---|---|---|---|
| OSB-PD (ordinary state-based, LPS) | --model osb |
109 | Poisson-unrestricted |
| BB-PD (bond-based) | --model bb |
54 | ν = 1/4 in 3D |
| NOSB-PD (non-ordinary, correspondence) | --model nosb |
36 | Material-independent |
Provide any 3-D mesh → get per-node weights in formats ready for Peridigm, PeriLab, or generic CSV / DAT / VTK.
Background
In peridynamics, nodes near the domain boundary have truncated horizon neighbourhoods. This reduces their effective stiffness and causes displacement errors that do not vanish under mesh refinement at fixed horizon-to-spacing ratio m = δ/Δx — the so-called surface effect.
perifit implements an operator-matching framework for state-based (LPS), bond-based
(solid), and correspondence (NOSB-PD) models. For each node, a local overdetermined least-squares
problem is solved to find a scalar influence weight wᵢ such that the
truncated neighbourhood operators reproduce their full-sphere continuum
counterparts. The per-node weights are coupled through a global sparse
linear system solved by BiCGSTAB.
The weights are purely geometric. Material constants (G for state-based, c for bond-based) appear as common prefactors in both the local ML matrix and the analytical targets and cancel exactly after per-row normalisation. For the correspondence model, the operator rows are material-independent by construction (no radial singularity, no constitutive constants). Consequently, E, ν, and any other material constant are not required — only the mesh geometry and the horizon matter.
Results
Convergence and preprocessing time (state-based LPS)
(a) Displacement error convergence for the state-based LPS model on a unit bar under uniaxial tension (m = 3). The corrected weights (solid lines) recover first-order convergence across all Poisson ratios, while standard LPS (dashed) stagnates due to the surface effect. (b) Weight computation time scales near-linearly with the number of nodes.
Mesh quality diagnostics (state-based LPS)
(a) Rocker-arm geometry (1,699 nodes) colored by LPS weight values. (b) Outlier nodes flagged by the built-in diagnostics (2σ threshold). (c) Cleaned mesh after removing the 69 flagged nodes — weight distribution is now uniform and well-conditioned.
Installation
pip install perifit
With optional dependencies for specific mesh formats:
pip install "perifit[hdf5]" # PeriLab HDF5 output
pip install "perifit[exodus]" # Exodus mesh input
pip install "perifit[gmsh]" # Gmsh / Abaqus / VTU input
pip install "perifit[all]" # everything
Quick start
Built-in demo (no mesh needed)
perifit --demo
Runs on the bundled 1000-node structured cube mesh and writes
csv, dat, and vtk output to ./perifit_output/.
Python API
import numpy as np
from perifit import compute_weights, write_weights
# Build your mesh (or load it — see below)
dx = 0.05
xs = np.arange(dx / 2, 1.0, dx)
gx, gy, gz = np.meshgrid(xs, xs, xs, indexing='ij')
coords = np.column_stack([gx.ravel(), gy.ravel(), gz.ravel()])
# OSB-PD / LPS (default model is "bb"):
volumes = np.full(len(coords), dx**3)
weights = compute_weights(coords, volumes, horizon=3 * dx, model='osb')
# BB-PD:
weights = compute_weights(coords, volumes, horizon=3 * dx, model='bb')
# NOSB-PD (material-independent):
weights = compute_weights(coords, volumes, horizon=3 * dx, model='nosb')
# Export to any format
write_weights(
coords, volumes, weights,
outdir='./output',
formats=['csv', 'vtk', 'peridigm', 'perilab'],
)
Load from a mesh file
from perifit import load_mesh, compute_weights, write_weights
# Supported: .csv .dat .txt .npy .npz .vtk .vtu .exo .g .msh .inp
coords, volumes = load_mesh('my_mesh.exo')
weights = compute_weights(coords, volumes, horizon=3 * dx, model='osb')
write_weights(coords, volumes, weights,
outdir='./weights',
formats=['peridigm', 'perilab', 'csv'])
Mesh quality diagnostics
from perifit import compute_weights
from perifit.quality import diagnose_weights, clean_mesh
weights = compute_weights(coords, volumes, horizon=delta)
# Diagnose: flag negative weights and statistical outliers
diag = diagnose_weights(weights, threshold_sigma=2.0)
print(diag.summary)
# Clean: remove flagged nodes
result = clean_mesh(coords, volumes, weights, threshold_sigma=2.0)
print(f"Removed {result.original_n - result.cleaned_n} nodes")
Command-line interface
# OSB-PD / LPS
perifit --mesh nodes.csv --model osb
# BB-PD (default)
perifit --mesh nodes.csv --model bb
# NOSB-PD (material-independent weights)
perifit --mesh nodes.csv --model nosb
# Specify horizon-to-spacing ratio (default is 3)
perifit --mesh nodes.csv --m-ratio 4 --output csv,vtk
# Provide the horizon explicitly instead
perifit --mesh solid.exo --horizon 0.005 --output peridigm
# Diagnose mesh quality after computing weights
perifit --mesh cube.csv --diagnose
# Clean mesh (remove negative/outlier weight nodes)
perifit --mesh cube.csv --clean --threshold-sigma 2.0
# Show all options
perifit --help
Supported input formats
| Extension | Format | Notes |
|---|---|---|
.csv, .txt, .dat |
Plain text | Columns: x, y, z[, volume] |
.npy |
NumPy array | Shape (N, 3) or (N, 4) |
.npz |
NumPy archive | Keys: coords[, volumes] |
.vtk |
Legacy VTK ASCII | Unstructured or structured |
.vtu |
VTK XML | Requires pyvista or meshio |
.exo, .g |
Exodus II | Requires netCDF4 or meshio |
.msh |
Gmsh v2/v4 | Requires meshio |
.inp |
Abaqus | Requires meshio |
Supported output formats
| Format | Description |
|---|---|
csv |
node_id, x, y, z, volume, weight |
dat |
Space-delimited text |
vtk |
Legacy ASCII VTK for ParaView / VisIt |
peridigm |
Text mesh + weight CSV + YAML input snippet |
perilab |
HDF5 mesh with Nodal_Surface_Correction field + YAML snippet |
Applying the weights in your solver
The bond-averaged influence weight is
w̄ᵢⱼ = (wᵢ + wⱼ) / 2
Replace every occurrence of the unit influence function ω(ξ) = 1
in your PD discretisation with w̄ᵢⱼ. The Peridigm and PeriLab
output files include a YAML template showing exactly where to hook in
the field.
Auto-inference of dx, volumes, and horizon
The nodal spacing dx is always estimated automatically as the
median nearest-neighbour distance (KD-tree, O(N log N)).
This is used to:
- Set nodal volumes to
dx³when not provided. - Compute the horizon as
delta = m_ratio × dxwhen--horizonis not given. - Check consistency when both
--horizonand--m-ratioare supplied.
Input modes
--horizon |
--m-ratio |
Behaviour |
|---|---|---|
| not given | not given | horizon = 3 × dx (default m=3) |
| not given | given | horizon = m_ratio × dx |
| given | not given | horizon used directly |
| given | given | horizon used; warning if inconsistent with m_ratio × dx |
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perifit-2.0.1.tar.gz.
File metadata
- Download URL: perifit-2.0.1.tar.gz
- Upload date:
- Size: 47.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad84db2213c6cfd1f20aa7a2394bb768a1ac7341c4b024ecbe8f641ff15ab7c2
|
|
| MD5 |
2dda17300096a52a0a2a92b562b28b41
|
|
| BLAKE2b-256 |
4a2ec980a4ca1300f3bbdafe7f182cc83dbb66f23a6e43b2af53927502d85a55
|
File details
Details for the file perifit-2.0.1-py3-none-any.whl.
File metadata
- Download URL: perifit-2.0.1-py3-none-any.whl
- Upload date:
- Size: 38.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5929bcccc330d06eefbedc7d6db1fb02933004ddae942f1938edfc745adaa380
|
|
| MD5 |
579c9ad3de623456c7df8c68432d08ad
|
|
| BLAKE2b-256 |
9c63a971c048f7fae2e4f14888d78df55d94a51f5bf65f3a37f5b0de3e1bc5c1
|