Solver#
Time integration solvers for physics simulation
This module implements semi-implicit (symplectic Euler) time integration for tetrahedral FEM simulation. The integration scheme updates velocities using forces at the current position, then updates positions using the new velocities:
The undamped, unclamped, contact-free core is a first-order symplectic method. The solver also applies damping, velocity limiting, and contact response.
- class diffsim.solver.SemiImplicitSolver(dt=0.01, gravity=-9.8, damping=0.99, substeps=4, enable_self_collision=False, collision_method='simplified')[source]#
Bases:
objectSemi-implicit (symplectic Euler) solver for dynamic FEM simulation
This solver implements a first-order semi-implicit integration scheme. Velocities are updated using forces at the current position, then positions are updated using the new velocities. Its core update is symplectic; damping, clamping, constraints, and contact make the complete implemented map non-symplectic.
The integration follows:
\[ \begin{align}\begin{aligned}\mathbf{v}^{n+1} &= \mathbf{v}^n + h \, \mathbf{M}^{-1} (\mathbf{f}_{\text{elastic}}(\mathbf{x}^n) + \mathbf{f}_{\text{gravity}} + \mathbf{f}_{\text{contact}})\\\mathbf{x}^{n+1} &= \mathbf{x}^n + h \, \mathbf{v}^{n+1}\end{aligned}\end{align} \]where \(h = \Delta t / \text{substeps}\) is the substep size.
- __init__(dt=0.01, gravity=-9.8, damping=0.99, substeps=4, enable_self_collision=False, collision_method='simplified')[source]#
Initialize solver
- Parameters:
dt – time step size
gravity – gravity acceleration (m/s^2)
damping – velocity damping factor applied per substep
substeps – number of substeps per timestep
enable_self_collision – enable self-collision detection
collision_method – must be
'simplified'; useIPCImplicitEulerSolverfor frictionless IPC
- step(mesh, material, positions, velocities, masses, fixed_vertices=None)[source]#
Perform one semi-implicit time step with stability controls
- Parameters:
mesh – TetrahedralMesh object
material – Material model (e.g., StableNeoHookean)
positions – \((N, 3)\) current positions
velocities – \((N, 3)\) current velocities
masses – \((N,)\) vertex masses
fixed_vertices – list of fixed vertex indices
- Returns:
\((N, 3)\) updated positions new_velocities: \((N, 3)\) updated velocities
- Return type:
new_positions