BCC soft-beam lattice — screen a cubic surrogate for a compliant support¶
1. Define the surrogate¶
This example demonstrates how Rend can discover an effective constitutive law for a lattice metamaterial with cubic symmetry.
The dataset contains homogenized stress responses obtained from numerical simulations under uniaxial, equibiaxial, planar, volumetric and simple shear loading.
As an illustrative application, consider a compliant lattice support subjected to compression and shear. Compare candidate models using an overall \(R^2\) of at least 0.90, coverage of the configured deformation ranges, and a maximum shear stress error of 0.20 kPa at \(\gamma=0.5\).
2. Prepare the lattice data¶
The five BCC simulation tables provide deformation gradients, first Piola stresses and energy. Project the diagonal and shear components into the CSV and divide stresses by 1000 to convert Pa to kPa. Keep both \(P_{11}\) and the constrained-direction reaction \(P_{22}\) from the planar simulations using biaxial rows with \(\lambda_2=1\). Use \(J\) and negative mean Cauchy stress for the volumetric rows. Preserve the tabulated lateral response on the uniaxial compression path, including its nonmonotonic stretch. Original simulation data.
| Loading path in the CSV | Compression rows | Tension rows | Shear rows |
|---|---|---|---|
| Uniaxial | 53 | 101 | — |
| Equibiaxial | 75 | 61 | — |
| Planar | 14 | 101 | — |
| Volumetric | 69 | 78 | — |
Simple shear fs |
— | — | 101 |
TestType,Tag,Stretch_1,Stretch_2,Stretch_3,Stress_1,Stress_2
uniaxial,uniaxial_compression,0.74,1.019265,1.019265,-0.2817907,
3. Configure and run Rend¶
Configure Rend¶
Use COMPRESSIBLE_CUBIC with the three fixed lattice axes. Turn on tag balancing to give shorter and lower-amplitude branches more influence in the fit. Use up to 5,000 generations with a variance-scaled target of 1e-3. Probe uniaxial stretch 0.74–1.50, biaxial stretch 0.63–1.30, planar stretch 0.935–1.50, and shear 0–0.50. The 653 fitting rows include volumetric data, and the script leaves that probe range unset.
This fit uses a focused set of post-search checks for the stress derivative, objectivity, cubic symmetry and finite domain. The optional search-time and FEM checks are deferred for this screening stage. Export JSON to compare responses in the lattice frame.
Run the tutorial¶
Install the Rend wheel, then save bcc.csv and soft_beam.py in the same folder. You can also copy the script below into a file named soft_beam.py. Open a terminal in that folder and run:
python soft_beam.py
For your first run, set max_generations=500 and live_plot=True to observe the search. Use the full generation limit of 5,000 for a longer search, then compare the fit and validation results in result.html.
Complete Python script
"""Exploratory cubic-symmetry fit to BCC lattice simulations."""
from pathlib import Path
from rend import (
PostSearchChecks,
ConstitutiveChecks,
DeformationRange as Range,
GroupWeighting,
MaterialProfile,
MaterialRegressor,
StressUnit,
ValidationRanges,
)
CSV = "bcc.csv"
if __name__ == "__main__":
regressor = MaterialRegressor(
csv_path=Path(__file__).with_name(CSV),
name="BCC beam lattice – cubic surrogate",
profile=MaterialProfile.COMPRESSIBLE_CUBIC,
material_directions=((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)),
stress_unit=StressUnit.KPA,
max_generations=5000, # Use 500 for a first exploratory run.
live_plot=False, # Set True to watch the search progress.
verbose=True,
target_mse=1e-3,
validation_ranges=ValidationRanges(
uniaxial=Range(0.74, 1.50),
biaxial=Range(0.63, 1.30),
planar=Range(0.935, 1.50),
shear=Range(0.0, 0.50),
volumetric=None,
),
post_search_checks=PostSearchChecks(
constitutive=ConstitutiveChecks(
stress=True,
tangent=False,
objectivity=True,
stress_covariance=False,
material_symmetry=True,
reference=False,
domain=True,
max_states=50,
),
),
group_weighting=GroupWeighting(balance_tags=True),
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¶
| Generation cap | Rows | Curves | Elapsed | Returned models |
|---|---|---|---|---|
| 5,000 | 653 | 9 | 1 h 58 min 39 s | 12 |
Elapsed time includes report generation. Run python scripts/run_examples.py --only soft_beam from a source checkout to save the CSV, script and run record alongside the report.
4. Compare the candidates¶
| Model | Why inspect it | Complexity | Weighted MSE (kPa²) | Overall \(R^2\) | Configured probe coverage |
|---|---|---|---|---|---|
| 1 | Lowest weighted MSE and highest overall \(R^2\) | 36 | 0.0075403 | 0.87914 | Biaxial gap below 0.685 |
| 3 | Lowest weighted MSE among models with full sampled coverage | 28 | 0.012749 | 0.77279 | All configured intervals covered |
Open result.html and expand Sampled applicability for model 1. Its biaxial interval starts at about 0.685, short of the configured lower bound of 0.63. Model 3 has a smaller search tree and covers all four configured probe intervals. Compare the two models by loading branch to see what the extra coverage costs in fit accuracy.

Model 1. The planar tension and compression tags appear in the biaxial panel.
Under R² by loading mode and tag, model 1 scores 0.91332 for the uniaxial mode overall and 0.32644 on the compression branch alone. Inspect the branch you plan to use before judging the model from the pooled score.
Check the shear endpoint¶
The fs branch gives \(P_{12}=1.414\) kPa at \(\gamma=0.5\). Evaluate both exported laws at that same deformation and compare the absolute error with the 0.20 kPa limit.
| Model | Shear \(R^2\) | Predicted \(P_{12}\) at \(\gamma=0.5\) (kPa) | Absolute error (kPa) |
|---|---|---|---|
| 1 | −0.42136 | 0.600 | 0.814 |
| 3 | −1.608 | 0.334 | 1.080 |

Simple shear along the recorded fs path. Both laws increasingly undershoot the simulated stress as shear grows.
Cubic surrogate: equations, branch scores and checks
| Loading | Branch | Model 1 | Model 3 |
|---|---|---|---|
| Uniaxial | All tags | 0.91332 | 0.7414 |
| Biaxial | All tags | 0.8965 | 0.76181 |
| Shear | All tags | -0.42136 | -1.608 |
| Volumetric | All tags | 0.81118 | 0.79902 |
| Uniaxial | uniaxial_compression | 0.32644 | -1.0941 |
| Uniaxial | uniaxial_tension | 0.73755 | 0.21763 |
| Biaxial | 1:1_compression | -0.19568 | -3.5093 |
| Biaxial | 1:1_tension | 0.58418 | 0.17179 |
| Biaxial | planar_compression | 0.052397 | -0.46509 |
| Biaxial | planar_tension | 0.89539 | 0.70439 |
| Shear | fs | -0.42136 | -1.608 |
| Volumetric | volumetric_compression | 0.58844 | 0.37168 |
| Volumetric | volumetric_tension | -0.13736 | -0.20163 |
| Reported check | Model 1 | Model 3 |
|---|---|---|
| Sampled strong ellipticity | Not run | Not run |
| Reference tangent PSD | Not run | Not run |
| Float64 audit | Passed | Passed |
| Stress | Passed | Passed |
| Tangent | Not run | Not run |
| Frame indifference | Passed | Passed |
| Stress covariance | Not run | Not run |
| Material symmetry | Passed | Passed |
| Reference state | Not run | Not run |
| Energy domain | Passed | Passed |
| FEM kinematics | Not run | Not run |
| 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 3 |
|---|---|---|
| Uniaxial (λ) | λ = 0.6839697732–10000 | λ = 0.005018352119–10000 |
| Biaxial (λ) | λ = 0.684921875–2145.415669 (coverage gap) | λ = 0.005018352119–10000 |
| Planar (λ) | λ = 0.0004725314008–1568.198324 | λ = 0.005018352119–199.2092312 |
| Shear (γ) | γ = -1000–1000 | γ = -198.8716556–198.8716556 |
| Volumetric (J) | J = 0.3269117072–1000000 | J = 1.844639711e-06–1000000 |
Here \(J_7\) is evaluated on the three fixed lattice axes. Permuting these axes gives the same sum of squares.
Model 1: model_001.json
Original report equation
Model 3: model_003.json
Original report equation
5. Apply the result and check its limits¶
All 12 candidates fall short of the overall \(R^2\) gate. Both highlighted models also miss the shear-endpoint tolerance. In fs shear, \(J_7-3=2\gamma^2+\gamma^4\), so the common squared \(J_7\) term contributes to shear stress from order \(\gamma^3\) onward. The initial slope comes from \(J_2\) in Model 1 and \(\bar I_1\) in Model 3. Use their exports to compare the recorded paths.
- Load
model_001.jsonormodel_003.jsonwith the material axes aligned to the lattice. To reproduce the shear check, start from the identity, set \(F_{12}=0.5\), and compare the resulting \(P_{12}\) with the finalfsrow in the CSV. - Compare the two biaxial stress components separately on the compression branch. Check the lowest recorded stretch against each model's sampled interval before using its stress prediction there.
- Rerun with explicit
GroupWeightingtag weights in place of tag balancing, increasing the emphasis onfsand the biaxial compression branches. Compare the \(0.20\) kPa shear-endpoint limit and biaxial coverage before raising the search budget. For a candidate that meets the screening criteria, use an independent combined compression–shear path and a solver check before applying the law to the support.