Flow-matching prior for hyperelastic strain-energy surfaces
This repository holds trained flow-matching models for hyperelastic strain-energy surfaces, with their training database, evaluation pools and training records.
- Status. The repository is private for now. It will be made public together with the code.
- License. The license will be specified upon release.
- Code. The code will be released upon acceptance at https://github.com/stvsun/flow-matching-hyperelasticity
(scripts in
Argon_flowmatching/flow_hyperelastic/andArgon_examples/).
The canonical model is argon_v2_G3_s2027_ft3600 (SetAttention dual-branch point/grid velocity network with target-space x1hat stress-gradient supervision on G3, trained for 12,017 total epochs via warm-start cosine continuation and selected at epoch 11,237; the earlier 8,417-epoch checkpoint selected at epoch 8,067 and 5,600-epoch checkpoint selected at epoch 5,300 are also archived under argon_v2_G3_s2027_cont3000/ and argon_v2_G3_s2027/). It generates ensembles of strain-energy surfaces for
isotropic, incompressible, rubber-like solids, conditioned on a few nominal-stress measurements in uniaxial
tension, pure shear and equibiaxial tension. A generated surface can be exported as a triangulated
constitutive mesh for an explicit material point method (MPM) solver.
Contents
| Path | Content |
|---|---|
canonical/checkpoint_selected.pt |
The canonical flow model (epoch 11237). It holds the EMA weights used for sampling (ema_model_state), the raw weights (model_state), norm_params, flow_config and grid_config (with the grid signature). SHA-256 c0ea384b70ff91b5cd0a928a714dd529f21a1f107378f13e5fe99fa760e65e48. |
canonical/CANONICAL_MODEL.json |
The record of the canonical model: the SHA-256 and size of every file under canonical/, the grid identity, the training record, the selection evidence and the headline metrics. |
canonical/db/ |
The training database, hyperelastic_db.npz (SHA-256 22af1d2062c46e406918e27be90cbcbf29dc7255861585c10593df3760e3a534), and metadata.json. |
canonical/pools/ |
The frozen synthetic laws, drawn afresh from the 13 training families and not used in training. validation/ holds the 65 laws of suite V. test/ holds the 130 laws of suites S0 and S1. manifest.json describes both. |
canonical/grid_axes/ |
The λ1 and λ3 axes of the grid G3 (G3_X14_lambda{1,3}.npy, float64, 64 nodes each) and their construction (G3_X14.json). |
canonical/training_record/ |
args.json, run_manifest.json, metrics.jsonl (one row per epoch) and split_indices.json (the training / held-out split). |
nn_baseline/ |
The deterministic U-Net baseline trained on G3. It contains checkpoint_selected.pt, training_record/ and grid.json. |
ablation/<run>/ |
Three other from-scratch flow models: G0_scratch_s2026, G1_scratch_s2026 and G3_scratch_s2026. Each directory contains checkpoint_selected.pt, run_manifest.json, args.json and grid.json. |
SHA256SUMS |
The SHA-256 of every file listed above, including this README (not of SHA256SUMS itself or of the hub's .gitattributes). |
To check a download, run sha256sum -c SHA256SUMS from the repository root.
Model
Architecture
The velocity network is a two-dimensional U-Net (SimpleUNet2D in flow_unet.py) with 23.1 M
parameters (23,115,009).
- Encoder. Four stages with 64, 128, 256 and 512 channels.
- Residual blocks. Every residual block is modulated by FiLM. The FiLM inputs come from a sinusoidal embedding of 1000 t.
- Attention. Multi-head self-attention runs at 16×16 and 8×8.
- Output. A 3×3 convolution produces a one-channel velocity, which is multiplied by the admissibility mask.
- Dropout. 0.1 during training.
The network has eight input channels:
[x_t, M_dom, P_u, M_u, P_s, M_s, P_e, M_e]
x_tis the rectified-flow state.M_domis the admissibility mask.P_mandM_mare the normalized nominal-stress observations P/μ0 of mode m (uniaxial, pure shear, equibiaxial), placed on the grid, and their presence masks.
The stress observations enter only through these channels. No value of the generated surface is overwritten.
Generated field
The generated field is the standardized value of log(1 + W/μ0) on a 64×64 grid of principal stretches
(λ1, λ3), with λ2 = 1/(λ1 λ3). The standardization constants are stored in the checkpoint's norm_params:
w_mean = 1.652304768562317 and w_std = 0.852834165096283. A generated state x maps back to the energy as
W = μ0 · (exp(w_std · x + w_mean) − 1).
Sampler
The paper's sampler has these steps:
- μ0 is estimated by a neo-Hookean fit to the observations with λ ≤ 1.1, averaged over the modes.
- The initial noise is masked by
M_dom. - The flow is integrated with 50 midpoint (RK2) steps, without guidance. The state outside the admissible domain is set to zero after every step.
- The energy is recovered as above. Then the strict S3 average is applied: the surface is averaged over the six permutations of (λ1, λ2, λ3), using only the permuted images whose interpolation stencil lies inside the admissible domain.
- The stresses are evaluated on a triangulated mesh in (ln λ1, ln λ3), with fixed cell diagonals and vertex-averaged gradients.
No smoothing is applied, and the generated surface is not corrected toward the data.
Grid G3
G3 is a 64 × 64 graded grid with λ1 ∈ [0.5, 5.25] and λ3 ∈ [0.09, 2].
Near the reference state. Both axes belong to one logarithmic lattice λ = exp(k ln2/14):
- k = −14..11 on λ1 (0.5 to 1.724);
- k = −24..14 on λ3 (0.305 to 2).
λ = 1 is a node of both axes.
Beyond the lattice. λ1 continues to 5.25 with a graded tail. λ3 continues down to 0.09 with nearly logarithmic intervals.
Admissible nodes. A node is admissible if 0.09 ≤ λk ≤ 5.25 for every principal stretch; 3631 of the 4096 nodes are admissible.
Grid signature.
49477989276e2c865f398b47f25f222a571e799884bde8cc8580810d40513fb8. It is the sha256 of the λ1 axis as<f8bytes, the λ3 axis as<f8bytes, the mask as uint8 bytes (C order, shape 64 × 64) and the representation nameprincipal_stretchas utf-8, in that order. The same signature is stored in:- the checkpoint;
- the database;
- both pools;
- the run manifest.
The sampling and evaluation code compares the grid signature of a checkpoint with that of the database it is given. It stops when the two differ, unless it is told otherwise.
Training data
canonical/db/hyperelastic_db.npz holds 2600 surfaces of W/μ0 on the admissible nodes of G3, 200 per family.
The 13 families are:
- Neo-Hookean
- Yeoh
- Gent
- Arruda–Boyce
- Pucci–Saccomandi
- Mooney–Rivlin
- Gent–Thomas
- Carroll
- Isihara
- Haines–Wilson
- Hart-Smith
- Alexander
- Lopez-Pamies
The parameters were drawn by Latin hypercube sampling around parameter centers calibrated to Treloar's rubber. All 2600 draws passed the admissibility filter. μ0 ranges from 0.208 to 1.025 MPa (median 0.350).
The file also holds the nominal-stress paths of each surface: 48 points per mode, normalized by μ0.
For historical reasons, the arrays I1_* and I2_* hold the λ1 and λ3 coordinates.
Training recipe
Initialization. Random, with seed 2027.
Loss. The objective is the flow-matching velocity MSE plus two penalties on negative second differences of the reconstructed field along the three loading paths:
- a squared penalty, with weight 1;
- an L1 penalty, with weight 3.
No smoothness, stress or reference-state terms are used.
Optimizer. AdamW with weight decay 1e-4 and gradient clipping at norm 1.
Learning rate. 2e-4, with cosine annealing to 2e-6.
Mixed precision and EMA. bf16 AMP, with an EMA of the weights (decay 0.999).
Batch. 64 per GPU on 3 A100-40GB GPUs (global batch 192).
Epochs. 5600.
Observations. 3–15 per example, placed at the table positions.
Observation dropout. p_uncond = 0.1.
Time sampling. Logit-normal, mixed with uniform sampling with probability 0.2.
Minibatch optimal transport. Mask-aware minibatch OT pairing of noise and data.
Shear-modulus augmentation. ln s ~ N(0, 0.2²), clipped at ±2σ. The augmentation scales the stress channels and the target W/μ0 by the same factor.
Split. 2340 training and 260 held-out surfaces, stratified by family (split seed 2026).
Checkpoint selection. Every 50 epochs, the trainer scores the EMA weights on the 65 validation laws (suite V). It keeps the checkpoint with the lowest held-out equibiaxial stress error E_P among those whose validation MSE is within 1.02× the best. For this run, that is epoch 5300 of 5600.
- At epoch 5300, the validation MSE is 1.10e-3.
- The held-out E_P is 0.032 / 0.017 / 0.031 in uniaxial tension / pure shear / equibiaxial tension.
- Both are computed on the normalized log(1 + W/μ0) field.
Compute. 3 × NVIDIA A100-SXM4-40GB (Columbia Euler cluster). Wall time 2 h 32 min, or 7.62 GPU-hours. Software: Python 3.8.10, torch 2.4.1+cu121 and numpy 1.24.4.
Choice of the canonical model. The canonical model was chosen on V only, among the trained variants, by a rule fixed before the comparison. Compared with the from-scratch G1 model, it is more accurate on V in equibiaxial tension: −0.15 points, with a 95 % interval of [−0.28, −0.03]. It is less accurate in no mode. The test suites were not used for the choice.
Evaluation protocol
Real data (suite T). Suite T uses Treloar's primary 1944 tables for uniaxial tension, pure shear and equibiaxial tension.
- Source. The digital archive
treloarjonesdata.zipdistributed by R. W. Ogden (SHA-2566fffbaee0b53fa0af434034990b294e791c0d9448780026a09176e5831b1c108). The data are converted to nominal stress in MPa. They are not redistributed here. - Points used. Only points whose loading path lies inside the domain are used: 13 of 25 (uniaxial), 14 of 14 (pure shear) and 12 of 17 (equibiaxial), up to λ = 4.76, 4.97 and 3.03.
- Folds. Each mode is split by interleaved three-fold cross-validation. Fold k conditions on the points whose table index i satisfies i mod 3 ≠ k. It scores the points with i mod 3 = k and λ ≥ 1.1. This gives 11, 12 and 9 scored points per mode.
- Modulus. μ0 is estimated in each fold from that fold's conditioning points.
- Ensembles. Each fold uses 200 members for each of 3 seeds.
Synthetic suites. The synthetic suites use laws of the 13 training families with fresh parameters, not seen in training.
- S0. 130 laws, with 10 noise-free conditioning points per mode and the exact μ0.
- S1. The same laws at Treloar's in-grid positions, with the fold design of T, 2 % multiplicative noise on the conditioning stresses and an estimated μ0.
- V. 65 further laws with the design of S1. V is used only for checkpoint selection and conformal calibration.
The synthetic suites use 32 members per law.
Metric. The metric is the NRMSE of the ensemble-mean nominal stress, in % of the true stress range of each case and mode. The synthetic suites report the mean over laws. Calibration is the fraction of scored values inside the central 90 % interval of the members, before and after split-conformal calibration on V. Paired differences carry 95 % bootstrap intervals, resampled per scored point for T and per law, clustered by family, for S0, S1 and V.
Baselines. Two classical laws are fitted to exactly the same conditioning points:
- a six-term Ogden series, with exponents α ∈ {−2, −1, 1, 2, 3, 4} and ridge 1e-3;
- a neo-Hookean solid at the fold's μ0.
All models are evaluated with the same mesh evaluator. The evaluator floor is the error of the exact law passed through that evaluator.
Caveat on T. Suite T is not independent of the prior. The parameter centers of the database families were calibrated to Treloar's data, whereas the classical fits see only the conditioning points of each fold.
Results
All values below are NRMSE in % (uniaxial / pure shear / equibiaxial), from the evaluation of these checkpoints under the protocol described above.
| Model | T (Treloar, CV) | S1 | S0 | V |
|---|---|---|---|---|
Flow, canonical argon_v2_G3_s2027_ft3600 (base/none) |
1.58 / 1.13 / 3.01 | 0.57 / 0.64 / 0.91 | 0.29 / 0.18 / 0.22 | 0.58 / 0.65 / 0.95 |
Flow, canonical (base/mesh_ls) |
1.32 / 0.94 / 2.38 | 0.61 / 0.70 / 0.93 | 0.22 / 0.12 / 0.16 | 0.63 / 0.72 / 0.97 |
| Ogden, six terms | 0.95 / 0.86 / 3.71 | 0.79 / 0.84 / 2.25 | 0.25 / 0.20 / 0.28 | 0.82 / 0.84 / 1.93 |
| Neo-Hookean | 19.07 / 14.83 / 3.21 | 16.73 / 13.37 / 7.46 | 19.14 / 10.15 / 7.59 | 20.98 / 14.92 / 7.50 |
| Exact law (evaluator floor) | 0.037 / 0.041 / 0.087 | 0.040 / 0.042 / 0.118 | 0.047 / 0.061 / 0.160 | 0.040 / 0.042 / 0.118 |
Flow − Ogden, paired (base/none, points) |
+0.63* / +0.27 / −0.70 | −0.22* / −0.20* / −1.34* | +0.04 / −0.02 / −0.07 | −0.24* / −0.19* / −0.98* |
* The 95 % bootstrap interval excludes zero. On T, the intervals are [+0.20, +1.06], [−0.20, +0.76] and [−3.58, +2.07].
On T, the largest pointwise errors of the flow are 2.73 / 2.06 / 5.42 % of the stress range.
Coverage of the central 90 % interval.
| Suite | Raw | After split-conformal calibration on V |
|---|---|---|
| T (Treloar) | 0.06 / 0.56 / 0.26 | 0.36 / 0.58 / 0.44 |
| S1 | 0.75 / 0.78 / 0.67 | 0.91 / 0.92 / 0.92 (widths 2.1 / 2.0 / 2.7 % of the stress range) |
| S0 | 0.96 / 0.99 / 1.00 | 0.99 / 1.00 / 1.00 |
Deterministic U-Net baseline (nn_baseline/). The baseline has the same backbone and the same
eight-channel input. It was trained on the same database and split to regress the normalized log(1 + W/μ0)
field in one pass. Other settings:
- 1500 epochs, selected at epoch 1500 by the flow trainer's rule;
- seed 2026;
- 1.9 GPU-hours.
| T | S1 | S0 | |
|---|---|---|---|
| U-Net | 1.15 / 1.76 / 2.94 | 0.93 / 1.05 / 1.02 | 1.90 / 1.52 / 1.79 |
| U-Net − flow, paired | −0.31* / +0.61 / +0.15 | +0.17 / +0.21* / +0.03 | +1.36* / +1.25* / +1.29* |
MPM small-strain check. The mesh loader evaluates each mesh at strains of 1e-3, 1e-2 and 5e-2. The tests are positive and negative simple shear, uniaxial tension and uniaxial compression. Each response is compared, one side at a time, with a neo-Hookean solid of modulus μ0.
- Flag criteria. A mesh is flagged when a ratio is non-positive, lies outside [0.5, 2], or deviates from 1 by more than 25 %.
- Result. All 21 exported meshes of the canonical model pass: the 20 members conditioned on Treloar's data, and their mean. The largest one-sided deviation is 0.016.
Ablation checkpoints (ablation/). Each ablation checkpoint was trained with the same command and the same
training code as the canonical model. Only the grid (with its database and validation pool), the seed and the
run name differ.
Each grid.json gives the full axes, the signature, the admissible-node count, the mask hash and the SHA-256
of the training database. The G0 and G1 databases are not included, so sampling from those two checkpoints
requires a database on their grid.
| Run | Grid | Signature | λ1 × λ3, spacing | Admissible nodes | Selected epoch | T | S1 | V |
|---|---|---|---|---|---|---|---|---|
G0_scratch_s2026 |
G0 | 66ffa3b9… |
[0.5, 5] × [0.1, 2], linear / linear | 4022 | 5300 | 1.89 / 1.94 / 5.01 | 1.09 / 0.88 / 4.30 | 1.10 / 0.88 / 4.24 |
G1_scratch_s2026 |
G1 | ae973a86… |
[0.5, 5.25] × [0.09, 2], linear / log | 3829 | 5600 | 1.50 / 1.22 / 3.30 | 0.85 / 0.88 / 1.12 | 0.84 / 0.89 / 1.16 |
G3_scratch_s2026 |
G3 | 49477989… |
as the canonical model | 3631 | 4350 | 1.55 / 1.39 / 3.20 | 0.78 / 0.92 / 1.04 | 0.81 / 0.92 / 1.08 |
canonical G3_scratch_s2027 |
G3 | 49477989… |
graded (above) | 3631 | 5300 | 1.47 / 1.16 / 2.78 | 0.76 / 0.85 / 0.99 | 0.73 / 0.87 / 1.01 |
Intended use
- Research on generative constitutive modeling: generating ensembles of isotropic, incompressible hyperelastic strain-energy surfaces from sparse nominal-stress data in uniaxial tension, pure shear and equibiaxial tension.
- Exporting generated surfaces as mesh-based constitutive models for explicit MPM simulations.
- Reproducing the evaluation reported above.
Limitations
Calibration fails on Treloar's measured data. After conformal calibration on V, the 90 % intervals cover only 0.36 / 0.58 / 0.30 of Treloar's scored points. On the real data, the error is a bias shared by the members:
- the raw central 90 % intervals are only 1.05 / 1.14 / 1.48 % of the stress range wide;
- the NRMSE of their mean is 1.47 / 1.16 / 2.78 %.
The ensemble bands show the variability of the learned prior given the data. They are not calibrated prediction intervals for real rubber. Calibration holds only on the synthetic suites.
The prior is limited to 13 families. The families are isotropic, incompressible, rubber-like laws whose parameter centers were calibrated to Treloar's rubber. The model has not been trained on compressible, anisotropic, inelastic or rate-dependent behaviour.
- Outside these families, the error grows. Without retraining, synthetic Yeoh laws of a polyurea and a polyurethane (μ0 = 5.00 and 1.50 MPa) are reproduced to 6.41 / 2.63 / 3.68 % and 13.20 / 4.61 / 7.71 %.
- A six-term Ogden fit to the same points is more accurate in every mode on both materials.
The model is less accurate than a six-term Ogden fit on Treloar's uniaxial and pure-shear data.
- The paired differences are +0.52 points in uniaxial tension (interval excludes zero) and +0.30 points in pure shear (interval includes zero).
- In equibiaxial tension, the difference (−0.93) is not significant.
- Because the prior was calibrated to Treloar's data, this comparison already favours the flow.
- With 11, 12 and 9 scored points per mode, differences of a few tenths of a point are within the sampling uncertainty.
An ensemble does not bring a more accurate mean. The deterministic U-Net with the same backbone is about as accurate on T and S1. The flow's advantage is the ensemble, which costs 100 network evaluations per member.
The domain is bounded. Energies are generated only for 0.09 ≤ λk ≤ 5.25, with λ1 ∈ [0.5, 5.25] and λ3 ∈ [0.09, 2]. Beyond this domain, the MPM constitutive query continues the surface monotonically along rays through the reference state; that continuation is not learned.
Stress from the mesh is not an exact derivative. Stresses come from vertex-averaged gradients of the piecewise-linear mesh. They differ from the finite-difference derivative of the interpolated energy by about 3.9 % (median over the exported members). A consistent tangent for implicit solvers would need further work.
Mesh schema and units. Use the mesh schema v2 (the default of the exporters), which stores W/μ0 together with μ0 in pascals. Meshes in the legacy schema store the MPa numeral of μ0, and must not be read by an SI solver.
How to load and sample
The code will be released with the paper at https://github.com/stvsun/flow-matching-hyperelasticity. The scripts are
in flow_hyperelastic_v2/flow_hyperelastic/.
While this repository is private, downloading needs a token of an account that the owner has granted access.
from huggingface_hub import snapshot_download
root = snapshot_download("stvsun/flow-matching-hyperelastic", allow_patterns=["canonical/*"])
Check the files against the record.
export FLOW_CANONICAL_ROOT=<root>/canonical
export FLOW_CANONICAL_RECORD=<root>/canonical/CANONICAL_MODEL.json
python flow_hyperelastic_v2/flow_hyperelastic/canonical_model.py verify
Sample one mode from a CSV file. The CSV has a header row and two columns: stretch, and nominal stress in
MPa. The paper's sampler settings are the command-line defaults, except --n_steps (the default is 20; the
paper uses 50).
cd flow_hyperelastic_v2/flow_hyperelastic
python generate_flow.py \
--checkpoint <root>/canonical/checkpoint_selected.pt \
--db_path <root>/canonical/db/hyperelastic_db.npz \
--experiment my_uniaxial_test.csv --mode uniaxial --stress_type nominal \
--n_samples 200 --sampling conditioned --n_steps 50 \
--smooth_sigma 0 --corrector_backend none \
--output_dir generated_models/ --device cuda
Condition on several modes and apply the strict S3 average (Python). generate_flow.py does not apply the
S3 average itself.
import sys
sys.path.insert(0, "flow_hyperelastic_v2/flow_hyperelastic")
from generate_flow import generate_ensemble
from generate_rubber_ensemble import symmetrize_s3
tests = [ # nominal stress in MPa
{"mode": "uniaxial", "stretch": lam_u, "stress": P_u, "stress_type": "nominal"},
{"mode": "pure_shear", "stretch": lam_s, "stress": P_s, "stress_type": "nominal"},
{"mode": "equibiaxial", "stretch": lam_e, "stress": P_e, "stress_type": "nominal"},
]
res = generate_ensemble(f"{root}/canonical/checkpoint_selected.pt",
f"{root}/canonical/db/hyperelastic_db.npz", tests,
n_samples=200, sampling_method="conditioned", n_steps=50,
smooth_sigma=0.0, corrector_backend="none", device="cuda")
W = symmetrize_s3(res["W_all"], res["I1_2d"], res["I2_2d"], res["mask"], mode="strict")
mu0 = res["observations"]["mu0"] # MPa; W has shape (n_samples, 64, 64), in MPa, on the (lambda1, lambda3) grid
Export MPM meshes. The following command exports the MPM meshes of the paper: 20 members plus their mean, conditioned on Treloar's data.
python generate_rubber_ensemble.py \
--checkpoint <root>/canonical/checkpoint_selected.pt \
--db_path <root>/canonical/db/hyperelastic_db.npz \
--n_samples 20 --n_steps 50 --output_dir <ens_dir> --device cuda --seed 2026 \
--treloar_data primary --mesh_coords log_stretch --mesh_schema v2 --reference_patch mooney \
--s3_symmetrize --s3_mode strict
The U-Net baseline is loaded by compare_nn_vs_flow.load_nn_baseline. Its checkpoint stores only
ema_model_state.
Citation
A reference will be added when the accompanying publication is available.