Skip to content

trusty.mpm

MPM (CDPI) particle bodies (CPU / Accelerate / CUDA).

MpmMaterial

The material every particle of an MPM body shares: MaterialModel.QuadraticVolume (a fluid) or MaterialModel.StableNeoHookean (an elastic solid; MpmScheme.Cdpi on the cpu and accelerate backends only).

density property writable

density: float

Mass density (kg/m^3).

mu property writable

mu: float

Shear modulus (Pa), read by StableNeoHookean.

lam property writable

lam: float

First Lame parameter (Pa); for QuadraticVolume, the bulk modulus.

model property writable

model: MaterialModel

The constitutive model: MaterialModel.QuadraticVolume or MaterialModel.StableNeoHookean.

MpmScheme

Bases: Enum

Cdpi class-attribute instance-attribute

Cdpi = 0

Lite class-attribute instance-attribute

Lite = 1

WallNoSlipConfig

beta property writable

beta: float

quad_order property writable

quad_order: int

add_mpm_particles

add_mpm_particles(
    world: World,
    positions: ndarray[float64, (N, M)],
    particle_volume: float,
    material: MpmMaterial,
    *,
    scheme: MpmScheme | str = MpmScheme.Cdpi,
    cell_size: float = 0.05,
    cdpi_domain_scale: float = 0.5,
    project_positive_definite: bool = True,
    particle_contact_radius: float = 0.0,
    friction_mu: float = 0.0,
) -> int

Add an MPM body; its presence activates the MPM module. positions is a (P, 3) array of particle positions; all particles share particle_volume and material. Raises on a material.model MPM does not run. The keyword arguments are the body's scheme, background grid and solver settings; scheme takes an MpmScheme or 'cdpi' / 'lite'. friction_mu is the body's surface Coulomb coefficient (>= 0); 0 is frictionless. One MPM body per world.

read_grid_cells

read_grid_cells(
    simulator: World,
) -> tuple[ndarray[int32, (N, M)], float]

Return (ijks, cell_size) for the live active sparse grid. ijks is an (N, 3) int32 array of cell integer coordinates; the cell with index (i, j, k) spans world AABB ([ics, (i+1)cs] x [jcs, (j+1)cs] x [kcs, (k+1)cs]). Returns an empty array before initialize() or for non-MPM simulators.

read_particles

read_particles(world: World) -> ndarray[float64, (N, M)]

Return the current particle positions of the (single) MPM body as a (P, 3) array. Empty if the world has no MPM body.

attach_wall_noslip

attach_wall_noslip(
    world: World, config: WallNoSlipConfig = ...
) -> None

Enable the variational wall no-slip penalty on this world. Attach walls via trusty.contact.add_wall(world, name, V, F); the MPM module emits this term at simulator initialize().