Skip to content

Commit 6f11b20

Browse files
authored
[MISC] Add warning message for stable time step in SPH solver (Genesis-Embodied-AI#1925)
1 parent 9716f98 commit 6f11b20

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

genesis/engine/solvers/sph_solver.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def __init__(self, scene, sim, options):
4444
# boundary
4545
self.setup_boundary()
4646

47+
# Coefficient for computing stable timestep
48+
self._stable_dt_coef = 1.0
49+
4750
def setup_boundary(self):
4851
self.boundary = CubeBoundary(
4952
lower=self._lower_bound,
@@ -134,6 +137,19 @@ def build(self):
134137
for entity in self.entities:
135138
entity._add_to_solver()
136139

140+
# Compute stable timestep for the given particle properties (mu) and support radius and print warning
141+
# if the current timestep is larger than the stable timestep. This formula is derived from
142+
# [_task_compute_non_pressure_forces] function, which computes the acceleration due to non-pressure forces.
143+
stable_dt = (
144+
self._stable_dt_coef * (0.01 * self._support_radius**2) / self.particles_info.mu.to_numpy().max()
145+
)
146+
if self.substep_dt > stable_dt:
147+
gs.logger.warning(
148+
f"Current timestep ({self.substep_dt:.4g}) is larger than the stable timestep "
149+
f"({stable_dt:.4g}) for SPH solver. "
150+
"Please consider reducing the timestep, liquid viscosity (mu), or increasing the particle size."
151+
)
152+
137153
# TODO: Support per-particle density
138154
self._density0 = self.particles_info[0].rho
139155

0 commit comments

Comments
 (0)