newton.solvers.SolverImplicitMPM#

class newton.solvers.SolverImplicitMPM(model, config)[source]#

Bases: SolverBase

Implicit MPM solver.

This solver implements an implicit MPM algorithm for granular materials, roughly following [1] but with a GPU-friendly rheology solver.

This variant of MPM is mostly interesting for very stiff materials, especially in the fully inelastic limit, but is not as versatile as more traditional explicit approaches.

[1] https://doi.org/10.1145/2897824.2925877

Parameters:
  • model (Model) – The model to solve.

  • config (Config) – The solver configuration.

Returns:

The solver.

class Config(max_iterations=250, tolerance=1e-05, strain_basis='P0', solver='gauss-seidel', warmstart_mode='auto', collider_velocity_mode='instantaneous', voxel_size=0.1, grid_type='sparse', grid_padding=0, max_active_cell_count=-1, transfer_scheme='apic', critical_fraction=0.0, air_drag=1.0, collider_normal_from_sdf_gradient=False, collider_basis='Q1')#

Bases: object

Implicit MPM solver configuration.

__init__(max_iterations=250, tolerance=1e-05, strain_basis='P0', solver='gauss-seidel', warmstart_mode='auto', collider_velocity_mode='instantaneous', voxel_size=0.1, grid_type='sparse', grid_padding=0, max_active_cell_count=-1, transfer_scheme='apic', critical_fraction=0.0, air_drag=1.0, collider_normal_from_sdf_gradient=False, collider_basis='Q1')#
air_drag: float = 1.0#

Numerical drag for the background air.

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 = 'instantaneous'#

Collider velocity computation mode. May be one of instantaneous, finite_difference.

critical_fraction: float = 0.0#

Fraction for particles under which the yield surface collapses.

grid_padding: int = 0#

Number of empty cells to add around particles when allocating the grid.

grid_type: str = 'sparse'#

Type of grid to use. May be one of sparse, dense, fixed.

max_active_cell_count: int = -1#

Maximum number of active cells to use for active subsets of dense grids. -1 means unlimited.

max_iterations: int = 250#

Maximum number of iterations for the rheology solver.

solver: str = 'gauss-seidel'#

Solver to use for the rheology solver. May be one of gauss-seidel, jacobi.

strain_basis: str = 'P0'#

Strain basis functions. May be one of P0, Q1

tolerance: float = 1e-05#

Tolerance for the rheology solver.

transfer_scheme: str = 'apic'#

Transfer scheme to use for particle-grid transfers. May be one of apic, pic.

voxel_size: float = 0.1#

Size of the grid voxels.

warmstart_mode: str = 'auto'#

Warmstart mode to use for the rheology solver. May be one of none, auto, particles, grid.

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 Pa

  • mpm:poisson_ratio: Poisson’s ratio for elasticity

  • mpm:damping: Viscous damping coefficient

  • mpm:hardening: Hardening factor for plasticity

  • mpm:friction: Friction coefficient

  • mpm:yield_pressure: Yield pressure in Pa

  • mpm:tensile_yield_ratio: Tensile yield ratio

  • mpm:yield_stress: Deviatoric yield stress in Pa

Attributes registered on State (per-particle):
  • mpm:particle_qd_grad: Velocity gradient for APIC transfer

  • mpm:particle_elastic_strain: Elastic deformation gradient

  • mpm:particle_Jp: Determinant of plastic deformation gradient

  • mpm:particle_transform: Overall deformation gradient for rendering

__init__(model, config)#
notify_model_changed(flags)#
sample_render_grains(state, grains_per_particle)#

Generate per-particle point samples used for high-resolution rendering.

Parameters:
  • state (State) – Current Newton state providing particle positions.

  • grains_per_particle (int) – Number of grains to sample per particle.

Returns:

A wp.array with shape (num_particles, grains_per_particle) of type wp.vec3 containing grain positions.

setup_collider(collider_meshes=None, collider_body_ids=None, collider_thicknesses=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_thicknesses (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)#
property collider_body_index: array#

Array mapping collider indices to body indices.

Returns:

Per-collider body index array. Value is -1 for colliders that are not bodies.

property voxel_size: float#

Grid voxel size used by the solver.