# Soft Body Simulation and Multi-Physics Coupling in Newton: A Technical Guide

> Explore GPU-accelerated soft body simulation and multi-physics coupling in Newton. Learn how its unified architecture shares data between XPBD and MPM solvers for efficient performance.

- Repository: [Newton Physics/newton](https://github.com/newton-physics/newton)
- Tags: technical-guide
- Published: 2026-03-19

---

**Newton enables GPU-accelerated soft body simulation and multi-physics coupling through a unified Model architecture that shares particle data, contact forces, and state arrays between XPBD and implicit MPM solvers.**

Newton is a GPU-accelerated physics engine built on NVIDIA Warp that unifies rigid bodies, deformable objects, and granular materials under a single API. The `newton-physics/newton` repository provides specialized solvers for soft body simulation and multi-physics coupling, allowing complex scenarios like robots walking on sand or soft objects interacting with cloth.

## Unified Model Architecture for Multi-Physics

Newton's multi-physics capabilities rely on a centralized data container that decouples geometry from solvers.

### The Model Class

The `newton.Model` class in [`newton/_src/sim/model.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/sim/model.py) holds all simulation state in device-resident Warp arrays. It manages per-entity arrays such as `particle_q` (positions), `body_q` (rigid transforms), and `shape_material_*`. For soft body simulation, the Model stores particle masses, velocities, and custom material attributes allocated through attribute registration.

### Attribute Registration System

Solvers register custom namespaces on the Model before particle creation. For example, `SolverImplicitMPM.register_custom_attributes` adds the `"mpm"` namespace to `Model.attribute_frequency` and `Model.attribute_assignment`, allocating fields like `mpm.Jp` (plastic deformation determinant) and `mpm.sigma_yield`. This allows the MPM solver to coexist with XPBD soft bodies on the same particle set.

## Soft Body Simulation with XPBD

Newton implements Extended Position-Based Dynamics (XPBD) for deformable objects, cloth, and cables.

### SolverXPBD Implementation

The `SolverXPBD` class in [`newton/_src/solvers/xpbd/solver_xpbd.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/xpbd/solver_xpbd.py) provides a semi-implicit, constraint-based integration scheme. It projects particles onto constraint manifolds for distance, bending, and volume preservation. The solver interprets soft-body contact parameters defined on the Model: `soft_contact_ke` (stiffness), `soft_contact_kd` (damping), and `soft_contact_mu` (friction).

### Contact Reduction and Stability

XPBD handles contact reduction through `shape_collision_aabb_*` arrays to ensure stable interaction between soft bodies and other entities. The solver operates directly on `particle_q` and `particle_qd` arrays within the shared Model, enabling zero-copy interaction with MPM or rigid-body solvers.

## Implicit MPM for Granular Materials

Newton's Material-Point-Method solver handles sand, snow, and visco-elastic fluids.

### SolverImplicitMPM Algorithm

The `SolverImplicitMPM` class in [`newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py) implements an implicit MPM algorithm optimized for GPU execution. Each simulation step involves:

1. **Binning**: Particles are sorted into a regular grid using `particle_grid` hash parameters
2. **Rasterization**: Mass and momentum are transferred to grid nodes
3. **System Assembly**: A global linear system is constructed for the implicit velocity update
4. **Newton Solve**: The coupled system is solved for velocity updates
5. **Advection**: Particle positions `particle_q` are updated using the new velocities

### Multi-Physics Coupling Patterns

The MPM solver enables two-way coupling with rigid bodies and soft objects. In [`newton/examples/mpm/example_mpm_anymal.py`](https://github.com/newton-physics/newton/blob/main/newton/examples/mpm/example_mpm_anymal.py), an ANYmal robot interacts with an implicit-MPM sand floor. The solver rasterizes collider geometry each sub-step via `rasterize_collider` and projects particles outside rigid shapes, while contact forces are written back to the Model's contact arrays for consumption by the rigid-body dynamics.

## Implementing Soft Body and MPM Coupling

The following example demonstrates creating a soft ball that interacts with an MPM sand floor using Newton's unified API.

```python
import newton
from newton.solvers import SolverImplicitMPM, SolverXPBD

# ----------------------------------------------------------------------

# 1️⃣ Build the model – a soft ball made of particles + a sand floor

# ----------------------------------------------------------------------

builder = newton.ModelBuilder()

# Add sand particles (MPM)

sand_builder = builder.add_world(name="sand")
SolverImplicitMPM.register_custom_attributes(sand_builder)
sand_builder.add_particles_sphere(
    center=[0, 0, 0.2], radius=1.0, spacing=0.02,
    material="granular",
)

# Add soft ball particles (XPBD)

soft_builder = builder.add_world(name="soft")
soft_builder.add_particles_sphere(
    center=[0, 0, 1.0], radius=0.1, spacing=0.02,
    material="neo_hookean",
)

# Finalize – allocate all arrays on GPU

model = builder.finalize(device="cuda:0")

# ----------------------------------------------------------------------

# 2️⃣ Create solvers

# ----------------------------------------------------------------------

mpm_solver = SolverImplicitMPM(model, SolverImplicitMPM.Config())
xpbd_solver = SolverXPBD(model, SolverXPBD.Config(
    soft_body_relaxation=0.9,  # soft‑body damping

))

# ----------------------------------------------------------------------

# 3️⃣ Run a coupled simulation loop

# ----------------------------------------------------------------------

for step in range(200):
    # 1. Update any moving colliders (e.g., robot pose) – not needed here

    # 2. Step the sand (MPM) – this writes contact forces into `model`

    mpm_solver.step()
    # 3. Step the soft ball (XPBD) – consumes the contacts from step 2

    xpbd_solver.step()
    # 4. (Optional) Render / write USD output

```

### Key Implementation Details

`SolverImplicitMPM.register_custom_attributes` must be called before adding MPM particles to prepare the `mpm` namespace on the Model. Both solvers operate on the same `model` instance, enabling automatic sharing of contact forces and world state. The simulation loop can be extended with additional solvers such as `SolverMuJoCo` for articulated robots without architectural changes.

## Key Source Files and Implementation Details

| File | Purpose | Link |
|------|---------|------|
| [`newton/_src/sim/model.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/sim/model.py) | Core data container; defines particle/shape/world arrays and attribute registration. | [model.py](https://github.com/newton-physics/newton/blob/main/newton/_src/sim/model.py) |
| [`newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py) | Implements the implicit MPM algorithm, including rasterization, solver setup, and particle advection. | [solver_implicit_mpm.py](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py) |
| [`newton/_src/solvers/xpbd/solver_xpbd.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/xpbd/solver_xpbd.py) | Extended Position-Based Dynamics for soft bodies, cloth, and cables. Handles contact reduction and constraint projection. | [solver_xpbd.py](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/xpbd/solver_xpbd.py) |
| [`newton/examples/multiphysics/example_softbody_gift.py`](https://github.com/newton-physics/newton/blob/main/newton/examples/multiphysics/example_softbody_gift.py) | Demonstrates a soft-body gift falling onto a cloth surface with XPBD. | [example_softbody_gift.py](https://github.com/newton-physics/newton/blob/main/newton/examples/multiphysics/example_softbody_gift.py) |
| [`newton/examples/mpm/example_mpm_anymal.py`](https://github.com/newton-physics/newton/blob/main/newton/examples/mpm/example_mpm_anymal.py) | Two-way coupling of the ANYmal robot with an implicit-MPM sand floor. Shows collider registration and joint control. | [example_mpm_anymal.py](https://github.com/newton-physics/newton/blob/main/newton/examples/mpm/example_mpm_anymal.py) |
| [`newton/_src/solvers/solver.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/solver.py) | Base class `SolverBase` that defines the common API (`step`, `reset`, `finalize`). | [solver.py](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/solver.py) |

## Getting Started with Newton

Install Newton and run the multi-physics examples to see soft body simulation and MPM coupling in action.

```bash

# Install Newton with example extras

pip install "newton[examples]"

# Run a soft-body + sand demo (GPU preferred)

python -m newton.examples mpm_anymal --viewer gl

# Or run the soft-ball-onto-cloth demo

python -m newton.examples softbody_dropping_to_cloth --viewer usd --output-path ball_cloth.usd

```

Use `--device cuda:0` to force GPU execution or `--device cpu` for CPU fallback. The `--viewer` flag selects the output visualizer (`gl`, `usd`, `rerun`, `null`).

## Extending the Framework

1. **Add a new material** – Extend `SolverImplicitMPM.register_custom_attributes` or create a new attribute namespace and allocate per-particle fields (`model.attribute_frequency["my_material"] = Model.AttributeFrequency.PARTICLE`).

2. **Custom coupling** – Implement a lightweight collider update function inside your simulation loop that modifies `model.shape_transform` or `model.body_q` before the MPM step.

3. **Differentiable simulation** – All solvers expose their internal fields as Warp tensors; gradients flow automatically through the `step` call, enabling gradient-based optimization or learning-based control.

## Summary

- Newton provides **unified soft body simulation and multi-physics coupling** through a shared `Model` architecture that eliminates data transfer between solvers.
- The **XPBD solver** ([`newton/_src/solvers/xpbd/solver_xpbd.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/xpbd/solver_xpbd.py)) handles deformable objects using constraint-based dynamics with parameters like `soft_contact_ke` and `soft_body_relaxation`.
- The **implicit MPM solver** ([`newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py)) simulates granular materials via binning, rasterization, and Newton solves, registering custom attributes like `mpm.Jp` for plastic deformation.
- **Two-way coupling** occurs automatically when multiple solvers operate on the same `Model` instance, as demonstrated in [`example_mpm_anymal.py`](https://github.com/newton-physics/newton/blob/main/example_mpm_anymal.py) and [`example_softbody_dropping_to_cloth.py`](https://github.com/newton-physics/newton/blob/main/example_softbody_dropping_to_cloth.py).
- All solvers are **fully differentiable** through NVIDIA Warp, enabling gradient-based control and optimization.

## Frequently Asked Questions

### How does Newton handle contact between soft bodies and MPM materials?

Newton handles contact through the shared `Model` data structure. When `SolverImplicitMPM` executes its `step()` method, it writes contact forces into the Model's contact arrays. Subsequently, `SolverXPBD` consumes these same arrays during its constraint projection phase. This zero-copy approach ensures stable two-way coupling between granular materials and deformable objects without manual data synchronization.

### What is the difference between XPBD and MPM solvers in Newton?

**XPBD** (Extended Position-Based Dynamics) in [`newton/_src/solvers/xpbd/solver_xpbd.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/xpbd/solver_xpbd.py) is a constraint-based, semi-implicit method ideal for soft bodies, cloth, and cables. It projects particles onto constraint manifolds and uses parameters like `soft_contact_ke` for contact stiffness.

**MPM** (Material Point Method) in [`newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py) is a hybrid Eulerian-Lagrangian method for granular materials and fluids. It uses grid rasterization, implicit Newton solves, and tracks plastic deformation via attributes like `mpm.Jp`.

### Can I couple Newton with robotic simulators like MuJoCo?

Yes. Newton provides `SolverMuJoCo` (following the `SolverBase` API in [`newton/_src/solvers/solver.py`](https://github.com/newton-physics/newton/blob/main/newton/_src/solvers/solver.py)) that can operate alongside MPM and XPBD solvers on the same Model. In [`example_mpm_anymal.py`](https://github.com/newton-physics/newton/blob/main/example_mpm_anymal.py), the ANYmal robot from MuJoCo interacts with an MPM sand floor, demonstrating two-way coupling where the robot's feet deform the sand and the sand exerts reaction forces on the robot's joints.

### Is Newton's soft body simulation differentiable for machine learning?

Yes. All solvers expose internal fields as NVIDIA Warp tensors, making the simulation fully differentiable. Gradients flow automatically through the `step()` call, allowing gradient-based optimization of soft body parameters, control policies, or material properties. This enables learning-based control for soft robots and optimization of granular material interactions without finite-difference approximations.