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 to dtype; or

  • an AbstractParameter law (e.g. Arrhenius, Affine, Expression), which is stored unchanged and resolved later by a wrapper such as TemperatureDependent.

None is also passed through, so optional coefficients work. Use this for every quantity a constitutive_update reads 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) accepts MyMat(E=210e3) (isothermal) or MyMat(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: Module

A 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; evaluate receives their values in this order. Defaults to temperature "T".

property variables: tuple[str, ...]#

depends_on as a tuple of names.

abstract evaluate(*values)[source]#
class Constant[source]#

Bases: AbstractParameter

A constant value (explicitly temperature-independent).

value: Array#
evaluate(T)[source]#
class Affine[source]#

Bases: AbstractParameter

Linear 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}}\)

evaluate(T)[source]#
class Polynomial[source]#

Bases: AbstractParameter

Polynomial 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#
evaluate(T)[source]#
class Arrhenius[source]#

Bases: AbstractParameter

Arrhenius 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}.

evaluate(T)[source]#
class Expression[source]#

Bases: AbstractParameter

Wrap any callable / eqx.Module with signature fn(T) -> scalar as a parameter.

With several variables, fn receives them in the order of depends_on, e.g. Expression(fn=law, depends_on=("T", "phi")) evaluates law(T, phi).

fn: Module#
evaluate(*values)[source]#
has_parameter_dependence(model)[source]#

True if model contains any unresolved AbstractParameter.

parameter_dependencies(model)[source]#

Names of the external variables on which the parameters of model depend.

Return type:

set[str]

evaluate_parameters(model, T=None, /, **variables)[source]#

Materialize every AbstractParameter in model at 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
    ...
Unconstrained()[source]#

Unconstrained field.

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)