jaxmat.constraints package#
Module contents#
Constrained parameter mappings for calibration (backed by paramax).
A material parameter \(\theta\) with physical constraints (e.g. positive) can be reparameterized so that gradient-based calibration stays in a feasible region by construction. This typically works by introducing a non-linear function \(f\) whose codomain (output domain) is the wanted constrained region, e.g. \(f: \mathbb{R} \mapsto \mathbb{R}^+\). A latent variable representation \(z_\theta\) is used under-the-hood such that \(\theta = f(z_{\theta})\) naturally satisfies the constraints.
Usage: Declare a field with Positive() or Interval(lo, hi); construct the model with
ordinary physical values, and call paramax.unwrap(model) once at the top of the loss. Every
read then sees the constrained value while the optimiser works on an unconstrained latent
representation \(z_\theta\).
class Mat(eqx.Module):
E: jax.Array = Positive()
nu: jax.Array = Interval(-1.0, 0.5)
m = Mat(E=210e3, nu=0.3) # raw values; auto-wrapped
def loss(m, target):
l = paramax.unwrap(m) # l is a model with latent values
...
- Scaled(ref=1.0)[source]#
Rescaled field storing \(\theta/\text{ref}\) (an \(O(1)\) latent variable); recover \(\theta = \text{ref} * z_{\theta}\).
Unconstrained value.
- Parameters:
ref (float)
- Positive()[source]#
Field constrained to be strictly positive (\(\theta > 0\)), via \(f(z)=\exp(z)\).
- Interval(lo, hi)[source]#
Field constrained to an open interval (\(\text{lo} < \theta < \text{hi}\)), via a scaled sigmoid.
- Parameters:
lo (float)
hi (float)
- Bounded(lo, hi)[source]#
Alias for
Interval().- Parameters:
lo (float)
hi (float)