Skip to content

Material models

A material model is a strain energy density \(\Psi(F)\): the energy a solid stores per unit rest volume (J/m³) at deformation gradient \(F\). A material is one line, passed to solids, which take every model below, and to embedded solids and subspace bodies, which take every model but HenckyVonMises:

material = trusty.StableNeoHookean(youngs_modulus=1e6, poisson_ratio=0.3)

Notation

Symbol Meaning
\(F\) the 3 × 3 deformation gradient, from rest to current shape
\(F = R\,S\) its polar decomposition: \(R\) a rotation, \(S\) the symmetric stretch
\(I_2 = \lVert F \rVert_F^2\) the sum of the squared entries of \(F\), \(3\) at rest
\(J = \det F\) the volume ratio, \(1\) at rest
\(\mu = \dfrac{E}{2(1 + \nu)}\), \(\lambda = \dfrac{E \nu}{(1 + \nu)(1 - 2\nu)}\) the Lamé parameters (Pa), from youngs_modulus \(E\) (Pa) and poisson_ratio \(\nu\)

Every model takes youngs_modulus and poisson_ratio as keyword arguments; StableFung, FiberReinforced, HolzapfelGasserOgden and HenckyVonMises take more, listed under each. Each argument is a number, or an array with one value per element for a material that varies across the body (see Graded materials); a direction is one direction for the whole body, or one per element.

Five columns with the same stiffness, hung from their tops, stretch by different amounts under their own weight. From left to right: StableNeoHookean, NeohookeanBW, Corotational, ARAP, StableFung.

Five hanging columns, one per material

Full script: python examples/fem/hanging_materials.py
"""One hanging column per material model, stretching under its own weight.

Five soft columns (E = 10 kPa, nu = 0.45) share a mesh and density and hang
from their top faces. At these large strains the models part ways:
``StableFung`` stiffens as it stretches and stays shortest, ``Corotational``
is next, and the neo-Hookean family (``StableNeoHookean``, ``NeohookeanBW``)
and ``ARAP`` stretch furthest. A timestep of 1 s with the velocity zeroed after
every step moves each column straight to its hanging equilibrium, so
``--steps 10`` is already settled.

Usage:
    python examples/fem/hanging_materials.py              # live polyscope
    python examples/fem/hanging_materials.py --no-viewer  # print lengths
"""

from __future__ import annotations

import argparse
import sys
from pathlib import Path

import numpy as np

import trusty

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from utils import init_polyscope  # noqa: E402

E, NU = 1e4, 0.45       # soft, so the columns stretch visibly
LENGTH = 1.0            # rest length (m); the columns hang from z = LENGTH
SPACING = 0.25          # x offset between columns (m)
COLORS = [(0.94, 0.33, 0.31), (0.98, 0.70, 0.30), (0.35, 0.75, 0.70),
          (0.45, 0.60, 0.90), (0.70, 0.50, 0.85)]


def make_materials():
    return {
        "StableNeoHookean": trusty.StableNeoHookean(youngs_modulus=E, poisson_ratio=NU),
        "NeohookeanBW":     trusty.NeohookeanBW(youngs_modulus=E, poisson_ratio=NU),
        "Corotational":     trusty.Corotational(youngs_modulus=E, poisson_ratio=NU),
        "ARAP":             trusty.ARAP(youngs_modulus=E, poisson_ratio=NU),
        "StableFung":       trusty.StableFung(youngs_modulus=E, poisson_ratio=NU,
                                              mu1=2e3, gamma=4.0),
    }


def build_world(backend: str = "auto"):
    world = trusty.World(backend=backend,
                         timestep=1.0,                  # large steps with no carried-over
                         time_stepping="quasi_static")  # velocity: each one heads for equilibrium

    columns = {}
    for k, (name, material) in enumerate(make_materials().items()):
        mesh = trusty.make_beam_hex_mesh(size=(0.1, 0.1, LENGTH), res=(4, 4, 32))
        mesh = trusty.transform_mesh(mesh, t=(SPACING * k, 0.0, 0.0))
        body = trusty.fem.add_hex_solid(world, mesh, material, density=1000.0)
        z = np.asarray(mesh.vertices)[:, 2]
        trusty.constraints.add_pin(
            world, body, np.flatnonzero(np.abs(z - LENGTH) < 1e-6).tolist())  # hang from the top
        columns[name] = body
    return world, columns


def hanging_length(world, body) -> float:
    z = np.asarray(trusty.fem.positions(world, body))[:, 2]
    return float(LENGTH - z.min())


def run_viewer(world, columns, steps: int):
    ps = init_polyscope(headless=False)
    meshes = {}
    for k, (name, body) in enumerate(columns.items()):
        _, F = trusty.surface.mesh(world, body)
        m = ps.register_surface_mesh(name, trusty.fem.positions(world, body), F)
        m.set_color(COLORS[k])
        meshes[name] = (m, body)
    ps.reset_camera_to_home_view()

    state = {"i": 0, "playing": False}

    def callback():
        import polyscope.imgui as psim
        _, state["playing"] = psim.Checkbox("play", state["playing"])
        psim.SameLine()
        if (psim.Button("step") or state["playing"]) and state["i"] < steps:
            world.step()
            state["i"] += 1
            for m, body in meshes.values():
                m.update_vertex_positions(trusty.fem.positions(world, body))
        psim.Text(f"step {state['i']} / {steps}")
        for name, (_, body) in meshes.items():
            psim.Text(f"{name:<17} {hanging_length(world, body):.3f} m")

    ps.set_user_callback(callback)
    ps.show()


def main():
    ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
    ap.add_argument("--steps", type=int, default=10)
    ap.add_argument("--backend", default="auto", choices=["auto", "cpu", "accelerate", "cuda"])
    ap.add_argument("--no-viewer", action="store_true",
                    help="headless: print each column's hanging length")
    args = ap.parse_args()

    world, columns = build_world(args.backend)
    if args.no_viewer:
        for _ in range(args.steps):
            world.step()
        print(f"hanging length after {args.steps} steps (rest length {LENGTH} m)")
        for name, body in columns.items():
            print(f"  {name:<17} {hanging_length(world, body):.3f} m")
        return
    run_viewer(world, columns, args.steps)


if __name__ == "__main__":
    main()

StableNeoHookean

The default: a rubber-like solid that stays robust under large compression and inversion.

\[ \Psi = \frac{\mu}{2}(I_2 - 3) - \mu (J - 1) + \frac{\lambda + \mu}{2}(J - 1)^2 \]

The volume term's coefficient is \(\lambda + \mu\), not \(\lambda\), so that at small strain the model is linear elasticity with Lamé parameters \(\mu\) and \(\lambda\) (Smith et al. 2018).

NeohookeanBW

The classical Bonet and Wood Neo-Hookean, for matching textbook results and other codes; its energy is infinite at zero volume, so elements cannot invert.

\[ \Psi = \frac{\mu}{2}(I_2 - 3) - \mu \ln J + \frac{\lambda}{2}(\ln J)^2 \]

Corotational

Linear elasticity in a frame that rotates with the material, for stiff bodies that rotate far but deform little.

\[ \Psi = \mu \lVert F - R \rVert_F^2 + \frac{\lambda}{2}\operatorname{tr}^2(S - I) \]

ARAP

Resists only departure from a rotation, with no volume term, for shape deformation in geometry processing rather than a physical material.

\[ \Psi = \mu \lVert F - R \rVert_F^2 \]

\(\lambda\) is unused and poisson_ratio enters only through \(\mu\), so at small strain the material behaves as if \(\nu = 0\).

StableFung

Stable Neo-Hookean that stiffens exponentially as it stretches, for soft biological tissue.

\[ \Psi = \frac{\mu_0}{2}(I_2 - 3) + \frac{\hat\lambda}{2}(J - \alpha)^2 + \frac{\gamma}{2}\left(e^{\mu_1 (I_2 - 3)/2} - 1\right) \]

with \(\mu_0 = \mu\), \(\hat\lambda = \lambda + \mu_0 + \gamma \mu_1 / 2\) and \(\alpha = 1 + (\mu_0 + \gamma \mu_1 / 2) / \hat\lambda\). It also takes mu1 (\(\mu_1\), dimensionless), how fast the stiffening grows with stretch, and gamma (\(\gamma\), Pa), its scale. With gamma=0 it is StableNeoHookean up to a constant.

FiberReinforced

A soft matrix stiffened along one fiber direction that resists only stretching, for tendon, ligament and other fibrous tissue.

\[ \Psi = \Psi_{\text{StableNeoHookean}} + \Psi_f, \qquad \Psi_f = \begin{cases} \dfrac{k}{2}\left(\sqrt{I_5} - 1\right)^2 & \sqrt{I_5} \ge 1 \\ 0 & \sqrt{I_5} < 1 \end{cases} \]

where

  • \(I_5 = \lVert F a \rVert^2\) is the squared stretch along the unit rest direction \(a\), \(1\) at rest.

The fiber is slack in compression, where only the matrix resists. youngs_modulus and poisson_ratio set the matrix. It also takes fiber_modulus (\(k\), Pa), the fibers' modulus in tension, and fiber_direction (\(a\), normalized), a (1, 3) array with one direction in the rest frame or a (num_elements, 3) array with one per element.

HolzapfelGasserOgden

A soft matrix stiffened exponentially along up to three fiber families with dispersion, for arterial walls, the annulus fibrosus and other layered fibrous tissue.

\[ \Psi = C_{10}(\bar I_1 - 3) + \frac{1}{D}\left(\frac{J^2 - 1}{2} - \ln J\right) + \frac{k_1}{2 k_2} \sum_i \left(e^{k_2 \langle E_i \rangle^2} - 1\right) \]
\[ E_i = \kappa(\bar I_1 - 3) + (1 - 3\kappa)(\bar I_{4,i} - 1) \]

where

  • \(\bar I_1 = J^{-2/3} I_2\) and \(\bar I_{4,i} = J^{-2/3} \lVert F a_i \rVert^2\) are the volume-preserving (isochoric) invariants, \(3\) and \(1\) at rest, with \(a_i\) the unit rest direction of family \(i\),
  • \(\langle x \rangle = \max(x, 0)\) (the Macaulay bracket), so a family with \(E_i \le 0\) adds nothing, and
  • \(C_{10} = \mu / 2\) and \(D = 2 / K\), with \(K = E / (3(1 - 2\nu))\) the bulk modulus.

This is the law of Gasser, Ogden and Holzapfel (2006, doi:10.1098/rsif.2005.0073), in the same formulation as Abaqus, for arterial walls and other layered fibrous tissue. A family stiffens exponentially while \(E_i > 0\) and is slack otherwise, where only the matrix resists. A body has 1 to 3 families, which share \(k_1\), \(k_2\) and \(\kappa\).

youngs_modulus and poisson_ratio set the matrix. It also takes k1 (\(k_1\), Pa), k2 (\(k_2\), dimensionless) and kappa (\(\kappa\), dimensionless, in \([0, 1/3]\), default 0: perfectly aligned fibers; \(1/3\) makes the fibers isotropic). fiber_directions (\(a_i\), normalized) is a list of one array per family, each a (1, 3) array with one direction in the rest frame or a (num_elements, 3) array with one per element.

QuadraticVolume

Resists change of volume only, with no shear stiffness, for fluid-like material that flows freely in shape.

\[ \Psi = \frac{\lambda}{2}(J - 1)^2 \]

\(\mu\) is unused, so \(\lambda\) alone sets the stiffness, and poisson_ratio=0 gives none.

Hencky

Linear elasticity in logarithmic strain, for stiff solids such as metals, and the elastic part of HenckyVonMises.

\[ \Psi = \mu \lVert \varepsilon \rVert_F^2 + \frac{\lambda}{2}(\operatorname{tr} \varepsilon)^2 \]

where

  • \(\varepsilon = \ln S\) is the logarithmic (Hencky) strain.

HenckyVonMises

Hencky elasticity with von Mises plasticity and hardening, for ductile metals such as steel and aluminium that stay deformed once they yield.

\[ \Psi = \mu \lVert \varepsilon_e \rVert_F^2 + \frac{\lambda}{2}(\operatorname{tr} \varepsilon_e)^2 \]

the Hencky energy of the elastic strain \(\varepsilon_e = \ln S_e\), where \(S_e\) is the stretch of the elastic part \(F_e = F F_p^{-1}\) of the deformation and \(F_p\) is the plastic part. The material yields when \(\lVert \operatorname{dev} \tau - \beta \rVert_F\) reaches \(\sqrt{2/3}\,(\sigma_y + H_i \bar\varepsilon_p)\), where \(\tau = 2\mu\varepsilon_e + \lambda (\operatorname{tr}\varepsilon_e) I\) is the Kirchhoff stress, \(\beta\) the back stress that kinematic hardening moves, and \(\bar\varepsilon_p\) the accumulated plastic strain. It also takes yield_stress (\(\sigma_y\), Pa), isotropic_hardening (\(H_i\), Pa) and kinematic_hardening (Pa); Plasticity shows how to use it.