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=Vec3.Zero()) 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 (read by the solver between iterations).
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; reading it between solver iterations gives intermediate PBF state, which is occasionally useful for debugging rather than production logic.

See Also