jaxmat.parameters package#
- parameter(default=<object object>, *, dtype=<class 'jax.numpy.float64'>, **kwargs)[source]#
Declare a material coefficient field.
A coefficient may be supplied either as
a constant (
int/float/array), cast todtype; oran
AbstractParameterlaw (e.g.Arrhenius,Affine,Expression), which is stored unchanged and resolved later by a wrapper such asTemperatureDependent.
Noneis also passed through, so optional coefficients work. Use this for every quantity aconstitutive_updatereads as a material property (moduli, yield stresses, relaxation times, hardening coefficients, shape exponents, …). This is what makes a behavior composable with input-dependent wrappers.Examples
E: float = parameter(default=210e3)acceptsMyMat(E=210e3)(isothermal) orMyMat(E=Arrhenius(A=..., Q=...))(temperature-dependent), with no other change.
Input-dependent parameters#
Temperature- (or any external variable-) dependent material parameters.
A parameter is either a plain constant or an expression p(T) carrying its own
fitting parameters (subclass AbstractParameter, implement evaluate).
evaluate_parameters(model, T) returns a copy of any model in which every
AbstractParameter field has been replaced by its scalar value p.evaluate(T)
– constant fields untouched – so all existing model methods work unchanged.
Temperature is only the default: a parameter may depend on any named external state
variable(s) through depends_on, resolved with keyword arguments,
E = Affine(ref=210e3, slope=-5e3, T_ref=0.0, depends_on="phi") # porosity-dependent
k = Expression(fn=law, depends_on=("T", "phi")) # law(T, phi)
resolved = evaluate_parameters(model, T=400.0, phi=0.1)
- class AbstractParameter[source]#
Bases:
ModuleA scalar material parameter that depends on temperature, or on other external state variables named by
depends_on.-
depends_on:
Union[str,tuple[str,...]] = 'T'# Name(s) of the external state variable(s) the parameter depends on;
evaluatereceives their values in this order. Defaults to temperature"T".
- property variables: tuple[str, ...]#
depends_onas a tuple of names.
-
depends_on:
- class Constant[source]#
Bases:
AbstractParameterA constant value (explicitly temperature-independent).
-
value:
Array#
-
value:
- class Affine[source]#
Bases:
AbstractParameterLinear law
\[p(T) = p_{\textrm{ref}} + s (T-T_{\textrm{ref}})\]-
ref:
Array# Reference value \(p_{\textrm{ref}}\)
-
slope:
Array# Slope \(s\)
-
T_ref:
Array= 273.15# Reference temperature \(T_{\textrm{ref}}\)
-
ref:
- class Polynomial[source]#
Bases:
AbstractParameterPolynomial law
\[p(T) = \sum_k c_k (T - T_{\textrm{ref}})^k\]-
coeffs:
Array# Polynomial coefficients, ordered from low to high order.
-
T_ref:
Array= 273.15#
-
coeffs:
- class Arrhenius[source]#
Bases:
AbstractParameterArrhenius activation energy law
\[p(T) = A\,\exp(-Q / (R\,T))\]-
A:
Array# Arrhenius factor.
-
Q:
Array# Activation energy
-
R:
Array= 8.314462618# Universal gas constant $R=8.314462618 textrm{J}.textrm{K}^{-1}.textrm{mol}^{-1}.
-
A:
- class Expression[source]#
Bases:
AbstractParameterWrap any
callable/eqx.Modulewith signaturefn(T) -> scalaras a parameter.With several variables,
fnreceives them in the order ofdepends_on, e.g.Expression(fn=law, depends_on=("T", "phi"))evaluateslaw(T, phi).-
fn:
Module#
-
fn:
- parameter_dependencies(model)[source]#
Names of the external variables on which the parameters of
modeldepend.- Return type:
set[str]
- evaluate_parameters(model, T=None, /, **variables)[source]#
Materialize every
AbstractParameterinmodelat the given external variables.Temperature can be passed positionally, other variables by name:
evaluate_parameters(model, 400.0),evaluate_parameters(model, T=400.0, phi=0.1). A model without parameter laws is returned unchanged.For an isothermal analysis, resolve once and use the result as an ordinary constant model:
isothermal = evaluate_parameters(model, T_fixed)
Constraints#
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)