newton.solvers.SolverImplicitMPM#
- class newton.solvers.SolverImplicitMPM(model, config, temporary_store=None, verbose=None, enable_timers=False)[source]#
Bases:
SolverBaseImplicit MPM solver for granular and elasto-plastic materials.
Implements an implicit Material Point Method (MPM) algorithm roughly following [1], extended with a GPU-friendly rheology solver supporting pressure-dependent yield (Drucker-Prager), viscosity, dilatancy, and isotropic hardening/softening.
This variant is particularly well-suited for very stiff materials and the fully inelastic limit. It is less versatile than traditional explicit MPM but offers unconditional stability with respect to the time step.
Call
register_custom_attributes()on yourModelBuilderbefore building the model to enable the MPM-specific per-particle material parameters and state variables (e.g.mpm:young_modulus,mpm:friction,mpm:particle_elastic_strain).[1] https://doi.org/10.1145/2897824.2925877
- Parameters:
model (Model) – The model to simulate.
config (Config) – Solver configuration. See
SolverImplicitMPM.Config.temporary_store (TemporaryStore | None) – Optional Warp FEM temporary store for reusing scratch allocations across steps.
verbose (bool | None) – Enable verbose solver output. Defaults to
wp.config.verbose.enable_timers (bool) – Enable per-section wall-clock timings.
- class Config(max_iterations=250, tolerance=0.0001, solver='gauss-seidel', warmstart_mode='auto', collider_velocity_mode='forward', voxel_size=0.1, grid_type='sparse', grid_padding=0, max_active_cell_count=-1, transfer_scheme='apic', integration_scheme='pic', critical_fraction=0.0, air_drag=1.0, collider_normal_from_sdf_gradient=False, collider_basis='Q1', strain_basis='P0', velocity_basis='Q1')#
Bases:
objectConfiguration for
SolverImplicitMPM.Per-particle properties can be configured using custom attributes on the Model. See
SolverImplicitMPM.register_custom_attributes()for details.- __init__(max_iterations=250, tolerance=0.0001, solver='gauss-seidel', warmstart_mode='auto', collider_velocity_mode='forward', voxel_size=0.1, grid_type='sparse', grid_padding=0, max_active_cell_count=-1, transfer_scheme='apic', integration_scheme='pic', critical_fraction=0.0, air_drag=1.0, collider_normal_from_sdf_gradient=False, collider_basis='Q1', strain_basis='P0', velocity_basis='Q1')#
- collider_basis: str = 'Q1'#
P0 (piecewise constant), Q1 (trilinear), S2 (quadratic serendipity), pic8 (particle-based with max 8 points per cell)
- Type:
Collider basis function string. Examples
- collider_normal_from_sdf_gradient: bool = False#
Compute collider normals from sdf gradient rather than closest point
- collider_velocity_mode: str = 'forward'#
Collider velocity computation mode, may be one of ‘forward’ or ‘backward’. ‘forward’ uses the current velocity, ‘backward’ uses the previous timestep position. Deprecated aliases ‘instantaneous’ (=’forward’) and ‘finite_difference’ (=’backward’) are also accepted.
- integration_scheme: str = 'pic'#
Integration scheme controlling shape-function support. May be one of pic, gimp.
- max_active_cell_count: int = -1#
Maximum number of active cells to use for active subsets of dense grids. -1 means unlimited.
- solver: str = 'gauss-seidel'#
Solver to use for the rheology solver. May be one of gauss-seidel, jacobi, cg.
- transfer_scheme: str = 'apic'#
Transfer scheme to use for particle-grid transfers. May be one of apic, pic.
- classmethod register_custom_attributes(builder)#
Register MPM-specific custom attributes in the ‘mpm’ namespace.
This method registers per-particle material parameters and state variables for the implicit MPM solver.
- Attributes registered on Model (per-particle):
mpm:young_modulus: Young’s modulus in Pampm:poisson_ratio: Poisson’s ratio for elasticitympm:damping: Elastic damping relaxation time in secondsmpm:friction: Friction coefficientmpm:yield_pressure: Yield pressure in Pampm:tensile_yield_ratio: Tensile yield ratiompm:yield_stress: Deviatoric yield stress in Pampm:hardening: Hardening factor for plasticitympm:hardening_rate: Hardening rate for plasticitympm:softening_rate: Softening rate for plasticitympm:dilatancy: Dilatancy factor for plasticitympm:viscosity: Viscosity for plasticity [Pa·s]
- Attributes registered on State (per-particle):
mpm:particle_qd_grad: Velocity gradient for APIC transfermpm:particle_elastic_strain: Elastic deformation gradientmpm:particle_Jp: Determinant of plastic deformation gradientmpm:particle_stress: Cauchy stress tensor [Pa]mpm:particle_transform: Overall deformation gradient for rendering
- __init__(model, config, temporary_store=None, verbose=None, enable_timers=False)#
- collect_collider_impulses(state)#
Collect current collider impulses and their application positions.
- Returns a tuple of 3 arrays:
Impulse values in world units.
Collider positions in world units.
Collider id, that can be mapped back to the model’s body ids using the
collider_body_indexproperty.
- notify_model_changed(flags)#
- project_outside(state_in, state_out, dt, gap=None)#
Project particles outside of colliders, and adjust their velocity and velocity gradients
- Parameters:
state_in (State) – The input state.
state_out (State) – The output state. Only particle_q, particle_qd, and particle_qd_grad are written.
dt (float) – The time step, for extrapolating the collider end-of-step positions from its current position and velocity.
gap (float | None) – Maximum distance for closest-point queries. If None, the default is the voxel size times sqrt(3).
- sample_render_grains(state, grains_per_particle)#
Generate per-particle point samples used for high-resolution rendering.
- setup_collider(collider_meshes=None, collider_body_ids=None, collider_margins=None, collider_friction=None, collider_adhesion=None, collider_projection_threshold=None, model=None, body_com=None, body_mass=None, body_inv_inertia=None, body_q=None)#
Configure collider geometry and material properties.
By default, collisions are set up against all shapes in the model with
newton.ShapeFlags.COLLIDE_PARTICLES. Use this method to customize collider sources, materials, or to read colliders from a different model.- Parameters:
collider_meshes (list[Mesh] | None) – Warp triangular meshes used as colliders.
collider_body_ids (list[int] | None) – For dynamic colliders, per-mesh body ids.
collider_margins (list[float] | None) – Per-mesh signed distance offsets (m).
collider_friction (list[float] | None) – Per-mesh Coulomb friction coefficients.
collider_adhesion (list[float] | None) – Per-mesh adhesion (Pa).
collider_projection_threshold (list[float] | None) – Per-mesh projection threshold (m).
model (Model | None) – The model to read collider properties from. Default to solver’s model.
body_com (array | None) – For dynamic colliders, per-body center of mass.
body_mass (array | None) – For dynamic colliders, per-body mass. Pass zeros for kinematic bodies.
body_inv_inertia (array | None) – For dynamic colliders, per-body inverse inertia.
body_q (array | None) – For dynamic colliders, per-body initial transform.
- step(state_in, state_out, control, contacts, dt)#
Advance the simulation by one time step.
Transfers particle data to the grid, solves the implicit rheology system, and transfers the result back to update particle positions, velocities, and stress.
- Parameters:
state_in (State) – Input state at the start of the step.
state_out (State) – Output state written with updated particle data. May be the same object as
state_infor in-place stepping.control (Control) – Control input (unused; material parameters come from the model).
contacts (Contacts) – Contact information (unused; collisions are handled internally).
dt (float) – Time step duration [s].
- update_particle_frames(state_prev, state, dt, min_stretch=0.25, max_stretch=2.0)#
Update per-particle deformation frames for rendering and projection.
Integrates the particle deformation gradient using the velocity gradient and clamps its principal stretches to the provided bounds for robustness.
- update_render_grains(state_prev, state, grains, dt)#
Advect grain samples with the grid velocity and keep them inside the deformed particle.