๐ง Particle Emitters#
Emitters generate particles for fluid and material simulations (SPH, MPM, PBD).
Creating an Emitter#
import genesis as gs
import numpy as np
gs.init()
scene = gs.Scene(
sim_options=gs.options.SimOptions(dt=4e-3, substeps=10),
sph_options=gs.options.SPHOptions(particle_size=0.02),
)
scene.add_entity(gs.morphs.Plane())
emitter = scene.add_emitter(
material=gs.materials.SPH.Liquid(),
max_particles=100000,
surface=gs.surfaces.Glass(color=(0.7, 0.85, 1.0, 0.7)),
)
scene.build()
Supported Materials#
gs.materials.SPH.Liquid()- SPH fluidgs.materials.MPM.Liquid()- MPM liquidgs.materials.MPM.Sand()- Granular materialgs.materials.PBD.Liquid()- Position-based fluid
Directional Emission#
for step in range(500):
emitter.emit(
pos=np.array([0.5, 0.5, 2.0]), # Nozzle position
direction=np.array([0.0, 0.0, -1.0]), # Emission direction
speed=5.0, # Particle speed
droplet_shape="circle", # Shape: circle, sphere, square, rectangle
droplet_size=0.1, # Radius or side length
)
scene.step()
Droplet Shapes#
Shape |
|
Description |
|---|---|---|
|
|
Cylindrical stream |
|
|
Spherical droplet |
|
|
Cubic droplet |
|
|
Rectangular stream |
Omnidirectional Emission#
Emit particles radially from a spherical source:
emitter.emit_omni(
pos=(0.5, 0.5, 1.0),
source_radius=0.1,
speed=2.0,
)
Dynamic Emission#
for i in range(1000):
# Oscillating direction
direction = np.array([0.0, np.sin(i / 10) * 0.3, -1.0])
emitter.emit(
pos=np.array([0.5, 0.0, 2.0]),
direction=direction,
speed=8.0,
droplet_shape="rectangle",
droplet_size=[0.03, 0.05],
)
scene.step()
Multiple Emitters#
emitter1 = scene.add_emitter(
material=gs.materials.MPM.Liquid(),
max_particles=500000,
surface=gs.surfaces.Rough(color=(0.0, 0.9, 0.4, 1.0)),
)
emitter2 = scene.add_emitter(
material=gs.materials.MPM.Liquid(),
max_particles=500000,
surface=gs.surfaces.Rough(color=(0.0, 0.4, 0.9, 1.0)),
)
for step in range(500):
emitter1.emit(pos=np.array([0.3, 0.5, 2.0]), direction=np.array([0, 0, -1]), speed=3.0, droplet_shape="circle", droplet_size=0.1)
emitter2.emit(pos=np.array([0.7, 0.5, 2.0]), direction=np.array([0, 0, -1]), speed=3.0, droplet_shape="circle", droplet_size=0.1)
scene.step()
Notes#
Emitters must be added before
scene.build()Particles recycle when
max_particlesis reachedNot compatible with differentiable simulation (
requires_grad=True)
Whatโs Next#
Beyond Rigid Bodies - fluids, cloth, and deformable body simulation
Soft Robots - muscle-actuated soft and hybrid robots