Skip to content

novaphy.ParticleState

Structure-of-arrays particle storage used by the SolverPBF pipeline (and by stand-alone PBFSolver users). Holds fluid particle positions, velocities, densities, and PBF Lagrange multipliers, plus optional per-particle mass and rest- density fields for multi-material setups.

Methods

Method Description
init(initial_positions, initial_velocity=[0, 0, 0]) Initialize the buffers from a list of starting positions and a uniform initial velocity.
clear() Drop all particle data.

Properties

Property Description
num_particles Number of fluid particles.
positions List of particle world-frame positions [m].
velocities List of particle world-frame velocities [m/s].
densities Per-particle density estimate [kg/m³].
lambdas PBF density-constraint Lagrange multipliers retained after a solver step.
particle_masses Per-particle mass [kg]. Empty when a single-material init was used.
rest_densities Per-particle rest density ρ₀ [kg/m³]. Empty for single-material setups.
particle_world Per-particle world index (-1 denotes the global world).

Example

import numpy as np
import novaphy

ps = novaphy.ParticleState()
positions = np.array(
    [[i * 0.05, 1.0, 0.0] for i in range(64)], dtype=np.float32
)
ps.init(positions, initial_velocity=np.array([0, 0, 0], dtype=np.float32))

print(ps.num_particles, "particles initialized")
print("first density:", ps.densities[0] if ps.num_particles else "n/a")

Notes

  • The ordering between positions / velocities / densities is identical — index i always refers to the same particle across all channels.
  • lambdas is owned by the solver. Python can inspect the copied vector after or between complete solver steps; the public step call does not expose callbacks between its internal iterations.

See Also