Skip to content

novaphy.SPHState

Particle buffers consumed by the SolverSPH pipeline. Holds fluid + boundary particles as separate channels and exposes list-of-Vec3 accessors plus NumPy-copy helpers for diagnostics.

Methods

Method Description
clear() Drop all particles and boundary samples.
ensure_buffers() Allocate / resize the internal buffers to match the configured particle count.
get_positions_as_numpy() Return fluid positions as an (N, 3) float32 NumPy array (copy).
get_velocities_as_numpy() Return fluid velocities as an (N, 3) float32 NumPy array (copy).

Properties

Property Description
num_particles Number of fluid particles.
num_boundary Number of Akinci boundary particles.
num_total num_particles + num_boundary.
positions Read-only list of fluid particle positions [m].
velocities Read-only list of fluid particle velocities [m/s].
densities Read-only per-particle SPH density estimate [kg/m³].
pressures Read-only per-particle pressure value derived from densities.
boundary_positions Read-only list of Akinci boundary particle world positions [m].
particle_world Per-particle world index (-1 denotes the global world).

Example

import novaphy

solver = novaphy.solvers.SolverSPH(model, novaphy.solvers.SPHConfig())
state  = model.state()

solver.step(state, state, None, None, 1.0 / 240.0)
solver.download_state()

sph = solver.fluid_state            # diagnostic SPHState cache
positions = sph.get_positions_as_numpy()
print("first 3 particle positions:\n", positions[:3])

Notes

  • Density / pressure are written by the solver each step; reading them outside a solver.step boundary returns the values from the previous step.
  • Boundary positions are typically populated by sample_model_boundaries — they are not regenerated automatically when the model changes.

See Also