Fluid Object#
Use FluidObject for a fixed initial sample of liquid
particles. The manager samples the source at declaration and binds the
particle state during sim.prepare(). The particle count stays fixed
throughout the scene lifetime.
Fluids require Newton on CUDA with DexUni’s nested DFSPH component and gradients disabled. All fluid objects in one scene share density and particle spacing. Use separate scenes for fluids and cable, cloth, or soft-body assets. See DexUni: Unified Physics for Embodied AI for solver configuration.
Configuration#
Pass FluidObjectCfg to sim.add_fluid_object(cfg).
Field |
Default |
Meaning |
|---|---|---|
|
Required |
Unique identifier for one logical fluid batch. |
|
|
Rest density in kg/m³, shared by scene fluids. |
|
|
Initial particle lattice spacing in metres. |
|
|
Optional particle radius passed to the native descriptor. |
|
Common placement defaults |
Initial placement relative to each environment. |
|
|
Local particle positions or a volume sampling recipe. |
|
|
Particle or reconstructed-surface appearance. |
Initial particle sources#
Configure FluidSpawnCfg with one source kind.
|
Source fields |
|---|---|
|
Supply exactly one of |
|
|
|
|
|
|
|
Ordered |
|
|
Volume sources support fill_level in (0, 1] and an inward
clearance. fill_level clips the complete source Z extent before
sampling. max_particles bounds the sampling allocation.
spawn.initial_velocity supplies the local initial velocity.
spawn.reference_uid can name an already declared rigid object. The
manager composes that object’s initial pose with the fluid placement once.
After preparation the fluid moves according to its own particle state.
Setup and initialization#
This example samples a small box of water in two environments using physics-only rendering. It reads the particle state and restores environment zero after one update.
from embodichain.lab.sim import SimulationManager, SimulationManagerCfg
from embodichain.lab.sim.cfg import (
FluidObjectCfg,
FluidRenderCfg,
FluidSpawnCfg,
NewtonPhysicsCfg,
RenderCfg,
)
sim = SimulationManager(
SimulationManagerCfg(
headless=True,
num_envs=2,
physics_cfg=NewtonPhysicsCfg(
device="cuda:0",
physics_dt=0.001,
num_substeps=2,
solver_cfg={"solver_type": "dexuni"},
),
render_cfg=RenderCfg(renderer="no-render"),
)
)
try:
water = sim.add_fluid_object(
FluidObjectCfg(
uid="water",
particle_spacing=0.01,
spawn=FluidSpawnCfg(kind="box", size=(0.04, 0.04, 0.04)),
init_pos=(0.0, 0.0, 0.5),
render=FluidRenderCfg(mode="none"),
)
)
sim.prepare()
sim.update(step=1, render_final_step=False)
state = water.data.particle_state_w # (2, water.num_particles, 6)
water.reset(env_ids=[0])
finally:
sim.destroy(exit_process=False)
SimulationManager.flush_cleanup_queue()
Particle state and reset#
State properties return independent world-frame snapshots after
preparation. They already include environment origins. Let
E = water.num_instances and N = water.num_particles.
Property |
Shape or unit |
Meaning |
|---|---|---|
|
|
Current positions in metres. |
|
|
Current velocities in m/s. |
|
|
Position followed by velocity. |
|
|
Initial state retained at binding. |
|
kg |
|
|
m³ |
|
Use write_particle_state_to_sim(state, env_ids=...) for a finite
floating tensor (selected E, N, 6). Rows follow the selected environment
order. Writes invalidate captured graphs and supported solver history.
Density diagnostics refresh on the next physical update.
reset(env_ids=...) restores initial particle positions and velocities.
reset_to_pose(pose_w, env_ids=...) places the saved local sample at
selected world-frame xyz + xyzw poses. Both operations preserve the
particle count and leave the simulation clock at its current value.
Rendering and coupling#
Use RenderCfg(renderer="no-render") together with
FluidRenderCfg(mode="none") for physics-only runs. Native fluid display
requires renderer="fast-rt" or "rt", selected before the first World
in the process. Display modes "particles" and "mesh_surface" use the
same physical particle state. Optional render.clip_below_z affects the
display copy.
The current DFSPH component receives one-way interaction from rigid
geometry. Rigid bodies in these scenes use DexUni’s pure MuJoCo rigid path.
Viscosity, surface tension, and iteration settings belong under
NewtonPhysicsCfg.solver_cfg.sph_cfg.