SPHSolver#
The SPHSolver implements Smoothed Particle Hydrodynamics for liquid simulation. It approximates fluid dynamics with particles, deriving pressure forces from local density, viscosity forces from velocity differences, and surface tension, with free-surface handling. Pick the pressure solver with pressure_solver: weakly compressible SPH ("WCSPH", the default) or divergence-free SPH ("DFSPH"). It simulates the SPH.Liquid material; see Liquid. For usage, see Beyond rigid bodies.
Options#
- class genesis.options.solvers.SPHOptions(*, dt: float | None = None, gravity: tuple[float, float, float] | None = None, particle_size: float = 0.02, pressure_solver: Literal['WCSPH', 'DFSPH'] = 'WCSPH', lower_bound: tuple[float, float, float] = (-100.0, -100.0, 0.0), upper_bound: tuple[float, float, float] = (100.0, 100.0, 100.0), hash_grid_res: tuple[float, float, float] | None = None, hash_grid_cell_size: float | None = None, max_divergence_error: float = 0.1, max_density_error_percent: float = 0.05, max_divergence_solver_iterations: int = 100, max_density_solver_iterations: int = 100) None[source]#
Options configuring the SPHSolver.
Note
If spatial hashing parameters are not given, we will compute them automatically this way: For
hash_grid_cell_size, we will set it to be thesupport_radius, which is essentially 2 *particle_size. Forhash_grid_res, if a small bound is given, it’s used for the hash grid; otherwise, we use a default value of a 150^3 cube. Any grid bigger than that will results in too many cells hence not ideal.- Parameters:
particle_size (float, optional) – Particle diameter in meters. Defaults to 0.02.
pressure_solver (str, optional) – Pressure solver type. Current supported pressure solvers are ‘WCSPH’ and ‘DFSPH’. Defaults to ‘WCSPH’.
lower_bound (tuple, shape (3,), optional) – Lower bound of the simulation domain. Defaults to (-100.0, -100.0, 0.0).
upper_bound (tuple, shape (3,), optional) – Upper bound of the simulation domain. Defaults to (100.0, 100.0, 100.0).
hash_grid_res (tuple, optional) – Size of the spatially-repetitive spatial hashing grid in meters. If none, it will be computed automatically. Defaults to None.
hash_grid_cell_size (float, optional) – Size of the lattic cell of the spatial hashing grid in meters. This should be at least 2 *
particle_size. If none, it will be computed automatically. Defaults to None.max_divergence_error (float, optional) – Maximum divergence error for DFSPH. Defaults to 0.1.
max_density_error_percent (float, optional) – Maximum density error percent for DFSPH, so 0.1 means 0.1%. Defaults to 0.05.
max_divergence_solver_iterations (int, optional) – Maximum number of iterations for the divergence solver. Defaults to 100.
max_density_solver_iterations (int, optional) – Maximum number of iterations for the density solver. Defaults to 100.
SPHSolver#
- class genesis.engine.solvers.sph_solver.SPHSolver(scene, sim, options)[source]#
Bases:
GravityMixin,TimeBasedMixin,Solver- material_cls#
alias of
Base
- property is_active#
- add_entity(idx, material, morph, surface, visualize_contact=False, name: str | None = None, desc=None) SPHEntity[source]#
- density_solve_iteration_task(i, j, ret: <quadrants.types.annotations.Template object at 0x797f40bef920>, i_b)[source]#
- cubic_kernel_plane_integral(dist)[source]#
Integral of the cubic spline smoothing kernel over the plane at distance dist from its center.
Closed form of 2 * pi * int_{|dist|}^{h} W(r) r dr. Its own integral along the plane normal equals half the kernel normalization: int_{0}^{h} of this quantity over dist is exactly 1/2, which makes forces weighted by it integrate to a per-unit-area magnitude over a covering layer of particles.
- property n_particles#
- property particle_volume#
- property particle_size#
- property particle_radius#
- property support_radius#
- property hash_grid_res#
- property hash_grid_cell_size#
- property upper_bound#
- property lower_bound#