Skip to main content

warpSPHPlotting

warpSPHPlotting is a visualization layer for SPH particle data built on top of warpSPHCore. It is designed to make SPH field inspection easy while keeping plotting configurable and update-friendly.

The library centers around two functions:

  • visualizeParticlesNew(...): build a plot from particle state, quantity, and plotting options.
  • updatePlot(...): update an existing visualization state with new quantities and/or styling.

This repository also includes a full notebook demo in demo.ipynb and generated outputs in output/.

What This Library Does

  • Visualizes particle scalar fields as scatter plots.
  • Visualizes scalar fields on a regular grid (interpolated from particles).
  • Applies SPH operations (for example gradients) during plotting.
  • Maps vector/tensor quantities to scalars for coloring (x, y, L2, etc.).
  • Overlays streamlines for vector fields.
  • Supports stateful updates of an existing figure for interactive workflows.

Installation

From this repository:

pip install -e .

Notebook extras:

pip install -e .[notebooks]

Core API

from warpSPHPlotting import (
    visualizeParticlesNew,
    updatePlot,
    PlottingOptions,
    GridVisualization,
    Mapping,
    PlotScaling,
    ColorMap,
    StreamLineLocation,
)

Main Inputs

  • particleState: warpSPHCore.ParticleState
  • domain: warpSPHCore.DomainDescription
  • quantity: tensor to visualize (scalar or vector; can be mapped)
  • options: PlottingOptions(...) for rendering and operation behavior

Main Output

visualizeParticlesNew returns a VisualizationState object containing figure/axis handles, filtered particle states, and artist handles used by updatePlot.

Minimal Example

import matplotlib.pyplot as plt
from warpSPHPlotting import visualizeParticlesNew, PlottingOptions, ColorMap

fig, ax = plt.subplots(1, 1, figsize=(6, 5))

state = visualizeParticlesNew(
    fig,
    ax,
    particleState=particleState,
    domain=domain,
    quantity=f_smoothed,
    options=PlottingOptions(
        colorMap=ColorMap.rocket,
        markerSize=4,
        plotTitle="Smoothed Quantity",
    ),
)

fig.tight_layout()

Stateful Update Example

from warpSPHPlotting import updatePlot, ColorMap

updatePlot(
    state,
    particles=particleState,
    domain=domain,
    quantity=-f_smoothed,
    colorMap=ColorMap.viridis,
)

1) Linear Gradient Validation

Computes a known linear field gradient with WarpSPH and compares against analytical reference.

Linear gradient comparison

2) WarpSPH vs DiffSPH Gradient Comparison

Visual side-by-side comparison of gradient components and their differences.

Smoothed gradient comparison

3) Scatter vs Grid Visualization

Shows the same smoothed scalar field as direct particle scatter and as a grid-mapped field.

Smoothed quantity visualization

4) Updating an Existing Plot State

Demonstrates stateful update of the same visualization object with new quantity/style settings.

Updated smoothed quantity visualization

5) On-the-fly Plotting Operation + Mapping

Computes gradient during plotting and maps to component views (Mapping.x, Mapping.y).

Smoothed gradient visualization

6) Grid + Streamlines

Shows mapped magnitude coloring with streamline overlay, sampled before mapping.

Gradient streamlines before mapping

7) Streamline Figure Update

Stateful update of the streamline visualization.

Updated gradient streamlines

Typical Workflow

  1. Build or load particleState and domain from your SPH pipeline.
  2. Choose a quantity (scalar or vector) to inspect.
  3. Configure PlottingOptions:
    • colormap/scaling
    • optional plottingOperation
    • optional mapping
    • optional GridVisualization and streamlines
  4. Call visualizeParticlesNew(...).
  5. Reuse returned state with updatePlot(...) for iterative inspection.

Notes

  • mapping is essential when visualizing vector quantities as a color field.
  • Grid visualization is often easier to read for dense particle sets.
  • updatePlot is useful for simulation loops where geometry stays fixed but values change.

Running the Demo

Open and run all cells in demo.ipynb. The notebook saves figures into output/.

Metadata

Release files for warpSPHPlotting 0.6.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 warpSPHPlotting 0.6.0
File Size Uploaded
warpsphplotting-0.6.0.tar.gz 58.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for warpSPHPlotting 0.6.0
File Interpreter ABI Platform
warpsphplotting-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 123.2 kB

Release files / warpsphplotting-0.6.0.tar.gz

Download URL warpsphplotting-0.6.0.tar.gz
Size 58.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ab3bdb7e30f8769539110aa94cae3d0de4914dfb6e9287bbafdb0680079f496c
BLAKE2b-256 checksum
How to use checksums
d22caf9ece68ef48dd25f3360c6c292fa3fbbc76f528a84cc0fd2dc9d8586f25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / warpsphplotting-0.6.0-py3-none-any.whl

Download URL warpsphplotting-0.6.0-py3-none-any.whl
Size 65.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44744cab9e6fdc8c22aef7b8029947172893f4df44f96cf2035960aae199d4ee
BLAKE2b-256 checksum
How to use checksums
ea76cec93606b453fc562a48dd48f946dd28f2ae03c7ea9f3401f4e912dbc2cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

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