Skip to content
Gian-Luca16Public

About

Convex signed singular value neural network (CSSV-NN) for isotropic hyperelasticity: learns a strain-energy density from stress data alone, with objectivity, isotropy, polyconvexity and thermodynamic consistency guaranteed by construction rather than by penalty terms. Reference implementation for Geuken et al., JMPS 203 (2025).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Convex Signed Singular Value Neural Networks (CSSV-NN)

A minimal, reproducible reference implementation of a convex signed singular value neural network for hyperelastic constitutive modelling, accompanying the paper listed under Citation.

The network learns a hyperelastic strain-energy density psi(F) from stress data alone, while satisfying three requirements by construction rather than by penalty terms:

Requirement How it is enforced
Objectivity and isotropy inputs are the singular values of F, symmetrised over the signed-SVD symmetry group
Polyconvexity convexity in the signed singular values of F, cof F and det F, imposed as non-negativity bounds on the propagating weights
Thermodynamic consistency stress is obtained as the exact derivative P = d(psi)/dF, never predicted directly

Reference vs CSSV-NN stress response


Method in brief

Features. For a deformation gradient F with singular values v1 >= v2 >= v3, seven features are formed:

x = [v1, v2, v3, v1*v2, v1*v3, v2*v3, J],    J = det F = v1*v2*v3

These are exactly the singular values of F (the first three), of the cofactor cof F (the three products), and det F. Convexity in x is therefore polyconvexity of psi, which together with the symmetrisation below yields a polyconvex isotropic energy by construction.

Symmetry. The signed SVD is unique only up to permutations of the singular values and sign flips of pairs of them. Each sample is therefore expanded into 24 symmetry-adapted inputs (6 permutations x 4 sign patterns) and the network output is averaged over all of them, so psi is exactly invariant under the symmetry group.

Convexity. In each skip-connection layer [h_prev, x], the kernel rows acting on h_prev are constrained to be non-negative while the rows acting on x stay free. A non-negative combination of convex functions composed with the convex, monotone softplus is convex, and the additional linear term in x does not break convexity. The output kernel is likewise non-negative. Because the network is trained with L-BFGS-B, these constraints are imposed as per-weight box bounds on the optimiser rather than as Keras constraints, which keeps the constrained problem exact instead of relying on projection after each step.

Loss. Training minimises the mean squared error of the first Piola-Kirchhoff stress. The stress follows from the chain rule through the feature Jacobian d(x)/dF, computed in closed form as dv_m/dF = u_m (x) w_m from the singular vectors of F.

Architecture. Three hidden layers of width 12 / 8 / 4 with softplus activation, skip connections from the input to every hidden layer, and a linear output without bias — 324 trainable parameters in total.


Installation

With conda (recommended — TensorFlow installs more reliably this way):

conda env create -f environment.yml
conda activate cssv_nn

Or with pip, into a Python 3.10 environment:

pip install -r requirements.txt

TensorFlow version. The code requires TensorFlow >=2.10,<2.16. From 2.16 onwards TensorFlow ships Keras 3, which changed the model serialisation format this example uses. It was developed and verified against TensorFlow 2.15.0 and Python 3.10.


Quickstart

python train.py          # generates the example data if missing, then trains
python plot_stress.py    # plots the trained model against the reference

train.py trains 10 random seeds and keeps the weights with the lowest validation loss ever observed, across all seeds and all iterations. A full run at default settings takes about 3 minutes on a CPU; there is no GPU requirement.

Output of a clean run:

neo_hooke_data.npz not found -- generating Neo-Hookean data...
Saved neo_hooke_data.npz: 120 total -> 96 train / 24 val

--- Seed 0 ---
  Best val: 1.3114e-04
--- Seed 1 ---
  Best val: 1.0355e-04
...
--- Seed 9 ---
  Best val: 4.9281e-05

Best seed: 3  (val loss 4.5937e-06)
Saved: neo_hooke_data_model

Useful options:

python train.py --max-iter 300            # shorter run
python train.py --data my_data.npz        # train on your own data
python plot_stress.py --model my_data_model --out fit.png

Everything is deterministic: weight initialisation uses numpy.random.default_rng(seed) and the train/validation split uses a fixed seed, so repeated runs reproduce identical numbers.


Using a trained model

import numpy as np
from predict import load_trained_model, predict_energy, predict_stress

model = load_trained_model("neo_hooke_data_model")
F = np.diag([1.3, 0.9, 1.1])

psi = predict_energy(model, F)   # strain energy density
P   = predict_stress(model, F)   # 1st Piola-Kirchhoff stress, shape (3, 3)

Training on stress data constrains psi only up to an additive constant, since only its derivative enters the loss. predict_energy therefore subtracts the energy of the undeformed state by default, giving the physically meaningful normalisation psi(I) = 0; pass subtract_reference=False for the raw network output. With that normalisation the learned energy matches the reference closely — for the example above, 0.166394 against an analytical 0.166348.


Training on your own data

Provide deformation gradients and the corresponding first Piola-Kirchhoff stresses. data_user.py computes the SVD features, the 24 symmetry inputs and the feature Jacobians, and writes the .npz file that train.py consumes:

import numpy as np
from data_user import prepare_and_save

F_arr = np.load("my_F.npy")   # shape (N, 3, 3), det(F) > 0 required
P_arr = np.load("my_P.npy")   # shape (N, 3, 3), 1st Piola-Kirchhoff stress

prepare_and_save(F_arr, P_arr, output="my_data.npz")
python train.py --data my_data.npz

Example dataset

The bundled example is a compressible Neo-Hookean (Ciarlet) material:

psi = mu/2 * (I1 - 3) - mu * ln(J) + lambda/2 * ln(J)^2
P   = mu * F + (lambda * ln(J) - mu) * F^-T

with mu = 1.0, lambda = 2.0. Data are generated on a grid of diagonal deformation gradients with stretches from 0.6 to 2.0 in steps of 0.2, giving all 120 unique combinations, split 96 / 24 into training and validation sets. Over half of these states have repeated singular values, so the degenerate case is exercised throughout.


Repository layout

File Purpose
utils.py SVD features, 24 symmetry inputs, closed-form feature Jacobian
data_neo_hooke.py Generates the compressible Neo-Hookean example dataset
data_user.py Converts your own F / P arrays into the training format
train.py Model definition, polyconvexity bounds, L-BFGS-B training loop
predict.py Evaluate a trained model: strain energy and stress
plot_stress.py Stress-stretch comparison against the reference model

Training writes two artefacts: the model directory (<dataset>_model/) and val_history.npz, holding the per-iteration validation loss of every seed under the keys seed0 ... seed9.


Implementation notes

A few choices are less obvious than they look and are worth stating explicitly, since they materially affect the results:

  • Everything runs in float64. L-BFGS-B is a double-precision algorithm and expects the objective to be accurate to near machine precision. In float32 (~7 significant digits) the line search cannot distinguish genuine improvements from rounding noise and terminates far from a stationary point, with the projected gradient still of order 1e-1.
  • Optimiser tolerances are set far below the noise floor (ftol=1e-15, gtol=1e-12) so that maxiter is the binding stopping criterion. SciPy's ftol test divides by max(|f|, 1), so once a mean-squared error drops below one the nominally relative test silently becomes an absolute one and stops early, by an amount that depends on the arbitrary scale of the loss.
  • The loss is a true mean squared error, averaged over both tensor components and samples, so its value does not depend on dataset size and training and validation losses are directly comparable.
  • Degenerate singular values need no special handling. Individual derivatives dv_m/dF are basis-dependent when singular values repeat, but because psi is symmetric in (v1, v2, v3) by construction, the degenerate gradient components are equal and only their sum enters the stress — which is basis-independent and exact.

Citation

If you use this code, please cite:

Gian-Luca Geuken, Patrick Kurzeja, David Wiedemann and Jörn Mosler. A novel neural network for isotropic polyconvex hyperelasticity satisfying the universal approximation theorem. Journal of the Mechanics and Physics of Solids 203 (2025), 106209. doi:10.1016/j.jmps.2025.106209

@article{geuken2025cssvnn,
  title   = {A novel neural network for isotropic polyconvex hyperelasticity
             satisfying the universal approximation theorem},
  author  = {Geuken, Gian-Luca and Kurzeja, Patrick and Wiedemann, David
             and Mosler, J{\"o}rn},
  journal = {Journal of the Mechanics and Physics of Solids},
  volume  = {203},
  pages   = {106209},
  year    = {2025},
  issn    = {0022-5096},
  doi     = {10.1016/j.jmps.2025.106209}
}

License

Distributed under the GNU General Public License v3.0. See LICENSE for the full text.

Copyright (C) 2026 Gian-Luca Geuken, Institute of Mechanics, TU Dortmund University.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

About

Convex signed singular value neural network (CSSV-NN) for isotropic hyperelasticity: learns a strain-energy density from stress data alone, with objectivity, isotropy, polyconvexity and thermodynamic consistency guaranteed by construction rather than by penalty terms. Reference implementation for Geuken et al., JMPS 203 (2025).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages