Application Library / Mechanics

Polynomial hyperelastic rubber

A rubber block is stretched in uniaxial tension, equibiaxial tension and pure shear with a hyperelastic material defined by its strain energy polynomial.

To reproduce the case, put its notebook and accompanying inputs in the same folder. Use the Python environment set up in the installation tutorial. Start with the original parameters and compare the result with the check reported below.

STEP importUser-defined strain energyFinite strainThree load cases

Run this example yourself. The OneSimulation Runtime brings the full Python library and an MCP server for Codex and Claude Code. It starts with a seven-day trial, then from €19 per month before any applicable tax.

Start the 7-day trial Compare the plans

Polynomial hyperelastic rubber
Polynomial hyperelastic rubber. Run the notebook to produce its own figures.

What it computes

OneSimulation reads the block from a STEP file, meshes it with hexahedra and solves 3D finite-strain equilibrium with a nearly incompressible energy declared as a list of polynomial terms in the invariants, once as two-term Mooney-Rivlin and once with five terms; stress and tangent follow from the energy. The script that builds the STEP file comes with the notebook.

What it checks

In all six combinations of model and load case the nominal stress agrees with the closed-form incompressible solution within 0.042 % up to stretches of 3, 2 and 2.5, with a volume change below 4e-4.

Geometry

The notebook starts at the import of the CAD file polynomial_hyperelastic_block.step: STEP (AP242), readable by any CAD program, with the names of the faces that the boundary conditions use. Put it next to the notebook.

Geometry of the example: Polynomial hyperelastic rubber
The geometry as the notebook reads it from the STEP file and draws it.

The geometry script

The script polynomial_hyperelastic_block_geometry.py builds the geometry with the CAD objects of OneSimulation and writes the file. Change a dimension there, run it, and run the notebook again.

"""Geometry of the OneSimulation example "User-defined polynomial hyperelastic rubber".

Builds the rubber test block, a cube of 20 mm side, with the CAD objects of OneSimulation and
writes polynomial_hyperelastic_block.step. The faces keep the names x_min, x_max, y_min, y_max,
z_min and z_max.
"""

from onesim.cad.d3 import Box

Box(length=0.02, width=0.02, height=0.02).save("polynomial_hyperelastic_block.step")

The notebook

The complete notebook, cell by cell. Run it to produce the figures and the comparison printout.

A hyperelastic material is defined completely by its strain energy density. For rubber the generalised Mooney-Rivlin form, a polynomial in the isochoric invariants \(\bar I_1,\bar I_2\), is the most common choice:

\[W=\sum_{i+j\ge1}c_{ij}\,(\bar I_1-3)^i(\bar I_2-3)^j+\frac K2(J-1)^2 .\]

In OneSimulation such a material is declared by its list of terms \((i,j,c_{ij})\); stress and tangent follow from the energy. Here two models are compared:

model\(c_{10}\)\(c_{01}\)\(c_{20}\)\(c_{11}\)\(c_{02}\)
Mooney-Rivlin0.16 MPa0.01 MPa
five-term polynomial0.16 MPa0.01 MPa2 kPa0.5 kPa0.1 kPa

with a bulk modulus \(K=10^4\) times the shear modulus, so the rubber is nearly incompressible.

Setup. A cube of 20 mm side from the CAD file polynomial_hyperelastic_block.step, written by polynomial_hyperelastic_block_geometry.py with the CAD objects of OneSimulation. The faces x_min, y_min, z_min are smooth supports (rollers); the load cases move the opposite faces:

load casex_maxy_maxz_maxstretches
uniaxial tension\(u_x=(\lambda-1)L\)freefree1 to 3
equibiaxial tension\(u_x=(\lambda-1)L\)\(u_y=(\lambda-1)L\)free1 to 2
pure shear\(u_x=(\lambda-1)L\)\(u_y=0\)free1 to 2.5

Reference. For the incompressible material with \(W_1=\partial W/\partial\bar I_1\), \(W_2=\partial W/\partial\bar I_2\) the nominal stress in the loaded direction is (e.g. R.W. Ogden, Non-linear Elastic Deformations, Dover 1997)

\[P_\mathrm{uni}=2\Big(\lambda-\frac1{\lambda^2}\Big)\Big(W_1+\frac{W_2}{\lambda}\Big),\quad P_\mathrm{bi}=2\Big(\lambda-\frac1{\lambda^5}\Big)\big(W_1+\lambda^2W_2\big),\quad P_\mathrm{shear}=2\Big(\lambda-\frac1{\lambda^3}\Big)\big(W_1+W_2\big).\]
import numpy as np
from onesim.cad.exchange import load
from onesim.materials.solids import IsochoricInvariantPolynomial, QuadraticVolumeLaw
from onesim.meshing import CadHexahedralMesher
from onesim.physics.solid_mechanics import FiniteStrainSolid
from onesim.visualization import plots, theme

theme.set()

Geometry and mesh

load returns the block with its named faces. With smooth supports every load case is a homogeneous deformation, which a coarse mesh of trilinear hexahedra represents exactly.

block = load("polynomial_hyperelastic_block.step")
faces = block.boundaries
side = block.size[0]
mesh = CadHexahedralMesher(cells=(3, 3, 3)).generate(block)

view = plots.Camera(elevation=25, azimuth=-55)
fig = plots.figure(1, 2, size=(12, 5.5))
plots.geometry(
    block,
    selection={
        "rollers": faces.x_min | faces.y_min | faces.z_min,
        "pulled": faces.x_max | faces.y_max,
    },
    labels=False,
    camera=view,
    title="Rubber block",
    ax=fig[0],
)
plots.mesh(
    mesh,
    groups=("all",),
    legend=False,
    camera=view,
    title=f"{mesh.cell_count} hexahedra",
    ax=fig[1],
)
plots.show()

Model

The two materials are lists of polynomial terms; each of the six runs ramps its stretch in twelve steps. The nominal stress is the reaction on x_max over the original face area.

models = {
    "Mooney-Rivlin": ((1, 0, 0.16e6), (0, 1, 0.01e6)),
    "five-term polynomial": (
        (1, 0, 0.16e6),
        (0, 1, 0.01e6),
        (2, 0, 2e3),
        (1, 1, 0.5e3),
        (0, 2, 0.1e3),
    ),
}
cases = {
    "uniaxial tension": (3.0, ()),
    "equibiaxial tension": (2.0, ((faces.y_max, "y", lambda t: t),)),
    "pure shear": (2.5, ((faces.y_max, "y", 0.0),)),
}
supports = (
    (faces.x_min, "x", 0.0),
    (faces.y_min, "y", 0.0),
    (faces.z_min, "z", 0.0),
    (faces.x_max, "x", lambda t: t),
)
stretch = {case: np.linspace(1.0, top, 13) for case, (top, _) in cases.items()}
results = {
    (model, case): FiniteStrainSolid(
        shear_modulus=2 * (terms[0][2] + terms[1][2]),
        bulk_modulus=2e4 * (terms[0][2] + terms[1][2]),
    ).solve(
        mesh=mesh,
        times=(stretch[case] - 1) * side,
        quadrature_order=3,
        displacements=supports + extra,
        elastic_response=IsochoricInvariantPolynomial(terms),
        volume_law=QuadraticVolumeLaw(2e4 * (terms[0][2] + terms[1][2])),
    )
    for model, terms in models.items()
    for case, (top, extra) in cases.items()
}
nominal = {
    key: result.reactions[
        :, np.isclose(result.displacement_space.dof_coordinates[:, 0], side), 0
    ].sum(axis=1)
    / side**2
    for key, result in results.items()
}

Reference

The closed-form nominal stress from the derivatives of the polynomial, with the invariants of each load case.

def reference(terms, case, l):
    """Nominal stress of the incompressible polynomial material."""
    i1, i2 = {
        "uniaxial tension": (l**2 + 2 / l, 2 * l + l**-2),
        "equibiaxial tension": (2 * l**2 + l**-4, l**4 + 2 * l**-2),
        "pure shear": (l**2 + 1 + l**-2, l**2 + 1 + l**-2),
    }[case]
    w1 = sum(c * i * (i1 - 3) ** max(i - 1, 0) * (i2 - 3) ** j for i, j, c in terms)
    w2 = sum(c * j * (i1 - 3) ** i * (i2 - 3) ** max(j - 1, 0) for i, j, c in terms)
    return {
        "uniaxial tension": 2 * (l - l**-2) * (w1 + w2 / l),
        "equibiaxial tension": 2 * (l - l**-5) * (w1 + l**2 * w2),
        "pure shear": 2 * (l - l**-3) * (w1 + w2),
    }[case]

Comparison with the reference

The largest deviation of the computed nominal stress from the closed form, relative to the stress at the largest stretch, and the volume change, which shows how close to incompressible the rubber stays.

print(
    f"{'model':22s} {'load case':20s} {'P at the end [MPa]':>19s} {'closed form':>12s} {'largest deviation':>18s} {'largest |J - 1|':>16s}"
)
for (model, case), values in nominal.items():
    exact = reference(models[model], case, stretch[case])
    print(
        f"{model:22s} {case:20s} {values[-1] / 1e6:19.4f} {exact[-1] / 1e6:12.4f} {100 * np.abs(values - exact).max() / exact[-1]:17.3f} %"
        f" {np.abs(results[model, case].jacobian - 1).max():16.1e}"
    )

Figure

Nominal stress over stretch for the three load cases and both models: simulation as markers, closed form dashed.

fine = {case: np.linspace(1.0, values[-1], 200) for case, values in stretch.items()}
fig = plots.figure(1, 3, size=(18, 5.5))
for k, case in enumerate(cases):
    plots.line(
        points={model: (stretch[case], nominal[model, case] / 1e6) for model in models},
        reference={
            model: (fine[case], reference(terms, case, fine[case]) / 1e6)
            for model, terms in models.items()
        },
        xlabel="stretch λ",
        ylabel="nominal stress P [MPa]",
        title=case.capitalize(),
        legend="upper left",
        ax=fig[k],
    )
plots.show()

Going further

Fit the coefficients to measurements with the study service of OneSimulation, as in the Mooney-Rivlin example; check the Drucker stability of a fitted polynomial by running large stretches in all three load cases. Replace the block by a real part from a STEP file: the material declaration stays the same.

Original OneSimulation Showcase entry