Skip to content

Synthetic compressible foam — comparing two formulations

1. Define the screening case

This example compares two synthetic compressible foam formulations using the same search settings. Both datasets contain tensile and compressive measurements generated from known hyperelastic material laws.

As an illustrative application, consider an instrument isolation pad subjected to compression and occasional tension.

Compare models using an overall \(R^2\) of at least 0.98, the enabled validation checks, and coverage of the configured uniaxial deformation range. In the compression interval \(0.48\leq\lambda\leq0.68\), require a maximum absolute stress error of 0.02 MPa.

2. Prepare tension and compression data

Use foam.csv for Foam A and foam_mid.csv for Foam B. Each synthetic CSV has 81 tensile and 81 compressive observations, spanning axial stretch 0.48–1.28. The generator uses a compressible neo-Hookean energy with different shear and volumetric coefficients for the two formulations. It solves for equal lateral stretches on the two traction-free faces and writes axial nominal stress in MPa.

TestType,Tag,Stretch_1,Stretch_2,Stretch_3,Stress_1,Stress_2
uniaxial,tension,1,1,1,0,

3. Configure and run Rend

Configure Rend

Use COMPRESSIBLE_ISOTROPIC to allow volume change without assigning preferred axes. Keep uniform weights, uniaxial probes from 0.48 to 1.28 and a variance-scaled target of 1e-2 for both formulations. Add Operator.SOFTPLUS with SearchConfig so candidate laws may represent smooth changes in slope. In this example the synthetic reference law is known, so a Softplus term reflects how the candidate fits the curve.

Use reference stability screening, the independent constitutive checks including tangent, and the FEM kinematic check for this first comparison. Defer the more expensive FEM checks until a candidate is selected for a fixture study. Export one material JSON per candidate so the selected laws can be evaluated at matching axial stretches.

Run the tutorial

Install the Rend wheel, then save foam.csv and foam.py in the same folder. You can also copy the script below into a file named foam.py. Open a terminal in that folder and run:

python foam.py

To try the second foam, save foam_mid.csv as foam.csv in a separate folder with the same script and run the same command.

The script uses a maximum of 5,000 generations for both foam formulations. For your first run, set max_generations=500 and live_plot=True. Open the generated result.html to compare the models before repeating the procedure for the second dataset.

Complete Python script

"""Synthetic compressible foam in unconfined tension and compression."""

from pathlib import Path

from rend import (
    SearchPhysicsChecks,
    PostSearchChecks,
    ConstitutiveChecks,
    DeformationRange as Range,
    FEChecks,
    MaterialProfile,
    MaterialRegressor,
    Operator,
    SearchConfig,
    StressUnit,
    ValidationRanges,
)

CSV = "foam.csv"


if __name__ == "__main__":
    regressor = MaterialRegressor.advanced(
        search=SearchConfig(add_operators=(Operator.SOFTPLUS,)),
        csv_path=Path(__file__).with_name(CSV),
        name="Synthetic compressible foam",
        profile=MaterialProfile.COMPRESSIBLE_ISOTROPIC,
        stress_unit=StressUnit.MPA,
        max_generations=5000,  # Use 500 for a first exploratory run.
        verbose=True,
        live_plot=False,  # Set True to watch the search progress.
        target_mse=1e-2,
        validation_ranges=ValidationRanges(
            uniaxial=Range(0.48, 1.28),
            biaxial=None,
            planar=None,
            shear=None,
            volumetric=None,
        ),
        search_checks=SearchPhysicsChecks(
            reference_stability=True,
        ),
        post_search_checks=PostSearchChecks(
            constitutive=ConstitutiveChecks(
                stress=True,
                tangent=True,
                objectivity=True,
                stress_covariance=True,
                material_symmetry=True,
                reference=True,
                domain=True,
                max_states=18,
            ),
            fe=FEChecks(kinematic=True, robustness=False, benchmark=False, convergence=False),
        ),
        export_json=True,
        export_uhyper=False,
    )
    result = regressor.run()
    if result.error:
        raise RuntimeError(result.error)
    if result.cancelled:
        raise SystemExit(130)
    print("Report:", result.report_path)

Recorded runs

Run Generation cap Recorded stop Rows Curves Elapsed Returned models
Foam A 1,200 Target at 116 162 2 6 min 10 s 8
Foam B 1,200 Target at 159 162 2 11 min 50 s 9

Elapsed time includes discovery, report generation and exports. The variance-scaled target can stop a search before its cap.

4. Compare the candidates

Run Model Why inspect it Complexity Weighted MSE (MPa²) Overall R² Configured coverage gaps
Foam A 1 Lowest weighted MSE 24 2.9912e-05 0.99728 —
Foam A 2 Simpler comparison above the pooled R² gate 22 0.00078079 0.9818 —
Foam B 1 Lowest weighted MSE 46 2.404e-05 0.99527 —
Foam B 6 Simpler candidate within the compression error limit 19 0.00048918 0.98764 —

All four models pass the enabled checks and cover the configured uniaxial range.

Both Foam A models achieve the required overall \(R^2\), but their maximum errors in compression exceed 0.02 MPa. Both Foam B models meet the compression error requirement.

For Foam B, Model 1 gives a lower mean absolute compression error and smaller lateral stresses. Model 6 is simpler, but its maximum absolute lateral stress is 0.0444 MPa, compared with 0.00983 MPa for Model 1.

Foam B Model 1 predicts −0.331 MPa at the deepest compression, against −0.316 MPa in the CSV. Its compressive fit has R² of 0.99736, while its tensile fit is weaker at 0.81341. The pressure panels show the predicted mean Cauchy pressure alongside the pressure inferred from the axial observations and the traction-free assumption.

Evaluate the 31 compression rows per formulation in the common interval. The lateral target is zero.

Candidate Compression MAE (MPa) Compression peak error (MPa) Peak absolute lateral stress (MPa)
Foam A, model 1 0.0091567 0.022768 0.0066364
Foam A, model 2 0.017473 0.028384 0.047979
Foam B, model 1 0.0043581 0.0149 0.0098281
Foam B, model 6 0.016706 0.01782 0.044448

Foam A, model 1 compared with the supplied stress observations

Foam A, model 1.

Foam A, model 2 compared with the supplied stress observations

Foam A, model 2.

Foam A: equations, branch scores and checks
Loading or tag Model 1 Model 2
Uniaxial 0.99728 0.9818
tension 0.96738 0.66604
compression 0.99444 0.97144
Reported check Model 1 Model 2
Sampled strong ellipticity Not run Not run
Reference tangent PSD Passed Passed
Float64 audit Passed Passed
Stress Passed Passed
Tangent Passed Passed
Frame indifference Passed Passed
Stress covariance Passed Passed
Material symmetry Passed Passed
Reference state Passed Passed
Energy domain Passed Passed
FEM kinematics Passed Passed
FEM robustness Not run Not run
Affine patch benchmark Not run Not run
Free-DOF convergence Not run Not run
Sampled common interval Model 1 Model 2
Uniaxial λ 0.03339719087–1.628407572 λ 0.04427849024–1.61474453
Biaxial λ 0.4116954756–1.306646715 λ 0.3398011762–1.297627694
Planar λ 0.4427849024–2.251589149 λ 0.4447279916–2.232158257
Shear γ -1.821467911–1.821467911 γ -1.800528106–1.790058204
Volumetric J 2.587922657e-05–1.743282946 J 4.016992953e-05–1.726390151

Model 1: model_001.json

\[ W(\mathbf F)=\frac{(\bar I_1-3)+c_1}{c_2-(I_2-3)^2}-\frac{c_1}{c_2}. \]
\[ c_1=1.32343936,\qquad c_2=11.28378201 \]
Original report equation
\[ W_{\mathrm{raw}}(\mathbf F)=\frac{(1.32343936 + (\bar{I}_1(F) - 3))}{(11.28378201 - ((I_2(C(F)) - 3))^2)} - 0.11728686 \]

Model 2: model_002.json

\[ W(\mathbf F)=\frac{\bar I_1-3}{c_1-(I_2-3)^2}. \]
\[ c_1=10.46961021 \]
Original report equation
\[ W_{\mathrm{raw}}(\mathbf F)=\frac{(\bar{I}_1(F) - 3)}{(10.46961021 - ((I_2(C(F)) - 3))^2)} - 0.00000000 \]

Foam B, model 1 compared with the supplied stress observations

Foam B, model 1.

Foam B, model 6 compared with the supplied stress observations

Foam B, model 6.

Foam B: equations, branch scores and checks
Loading or tag Model 1 Model 6
Uniaxial 0.99527 0.98764
tension 0.81341 0.76656
compression 0.99736 0.97971
Reported check Model 1 Model 6
Sampled strong ellipticity Not run Not run
Reference tangent PSD Passed Passed
Float64 audit Passed Passed
Stress Passed Passed
Tangent Passed Passed
Frame indifference Passed Passed
Stress covariance Passed Passed
Material symmetry Passed Passed
Reference state Passed Passed
Energy domain Passed Passed
FEM kinematics Passed Passed
FEM robustness Not run Not run
Affine patch benchmark Not run Not run
Free-DOF convergence Not run Not run
Sampled common interval Model 1 Model 6
Uniaxial λ 0.005018352119–10000 λ 0.005018352119–2.099782522
Biaxial λ 0.005018352119–10000 λ 0.005018352119–2.100320564
Planar λ 0.005018352119–199.2092312 λ 0.005018352119–1.820730912
Shear γ -278.4382586–278.4382586 γ -2.241435768–2.241435768
Volumetric J 1e-06–65277.19124 J 7.329014711e-06–1000000

Model 1: model_001.json

\[ \begin{aligned} W(\mathbf F)&=c_1\bigl(\Phi(\mathbf F)-\Phi(\mathbf I)\bigr),\\ \Phi(\mathbf F)&=\operatorname{softplus}\!\left( c_2\operatorname{softplus}\bigl((J-1)^2,c_3(\bar I_1-3)\bigr),\; c_4(\bar I_1-3)\right). \end{aligned} \]
\[ \begin{aligned} c_1&=0.79855961,\qquad c_2=0.91526920\\ c_3&=0.08556993468796,\qquad c_4=0.07998126848511 \end{aligned} \]
Original report equation
\[ W_{\mathrm{raw}}(\mathbf F)=(0.79855961 \cdot \mathrm{softplus}((0.91526920 \cdot \mathrm{softplus}(((J(C(F)) - 1))^2, \frac{((\bar{I}_1(F) - 3) \cdot 0.41003683)}{4.79183292})), \frac{((\bar{I}_1(F) - 3) \cdot 0.38277912)}{4.78585958})) - 0.04231743 \]

Model 6: model_006.json

\[ W(\mathbf F)=\frac{\bar I_1-3}{(I_1-3)+c_1}. \]
\[ c_1=14.82256126 \]
Original report equation
\[ W_{\mathrm{raw}}(\mathbf F)=\frac{(\bar{I}_1(F) - 3)}{((I_1(C(F)) - 3) - -14.82256126)} - 0.00000000 \]

5. Apply the result and check its limits

Start the compression comparison with Foam B's Model 1. Its nested softplus terms combine an explicit volume-change term with the first isochoric invariant. It gives the lower peak axial and lateral errors of the two Foam B candidates. If tension also matters, rerun with balanced tag weights and check both branches separately. The current tensile \(R^2\) is 0.81341.

The Foam A energies share a denominator in the second invariant. Both exceed the 0.02 MPa peak-error limit in deep compression. For the next Foam A run, upweight the final compression rows with EdgeWeighting and use a tighter target_mse. Compare the new law on the same axial and lateral stress checks, including the final force estimate.

  1. Keep a report and the selected material JSON for each formulation. Evaluate each candidate at its own recorded transverse stretches for the same axial stretches. Compare axial stress and secants on the common compression interval, then multiply nominal stress by the zone's reference area to estimate its axial force.
  2. Check the lateral stress against zero for the unconfined configuration. The pressure projection is inferred from axial stress and the free-surface assumption. Verify volumetric behavior independently before using the law near a hard stop, where contact can restrict lateral deformation.
  3. Compare the stress and tangent at matched material points before using the geometry in a solver. Rate-dependent or repeated-load behavior requires separate data.