jaxmat.state module#

class AbstractState[source]#

Bases: Module

Abstract base class representing mechanical states.

add(**changes)[source]#

Utility method to add values such as new_state = state.add(stress=dsig).

update(**changes)[source]#

Utility method to update values such as new_state = state.update(stress=sig).

class SmallStrainState[source]#

Bases: AbstractState

State representation for small-strain behaviors.

This class stores the current strain \(\beps\) and stress \(\bsig\) tensors under the assumption of infinitesimal (small) deformations. It also supports internal state variables such as plastic strain, damage, or other material history quantities through the internal attribute.

internal#

Nested state object representing internal variables (e.g., plastic strain, hardening variables, etc.). Defaults to None.

Type:

AbstractState, optional

strain#

Symmetric second-rank strain tensor \(\beps\) (small-strain assumption).

Type:

SymmetricTensor2

stress#

Symmetric second-rank Cauchy stress tensor \(\bsig\).

Type:

SymmetricTensor2

Notes

epsSymmetricTensor2

Alias for strain, allows accessing via state.eps.

sigSymmetricTensor2

Alias for stress, allows accessing via state.sig.

internal: AbstractState = None#
strain: SymmetricTensor2#
stress: SymmetricTensor2#
property eps#

Alias for strain.

property sig#

Alias for stress.

PK1_to_PK2(F, PK1)[source]#

Convert the first Piola-Kirchhoff stress tensor (PK1) to the second Piola-Kirchhoff stress tensor (PK2). Enforce symmetry explicitly.

PK1_to_Cauchy(F, PK1)[source]#

Convert the first Piola-Kirchhoff stress tensor (PK1) to the Cauchy stress tensor. Enforce symmetry explicitly.

class FiniteStrainState[source]#

Bases: AbstractState

State representation for finite-strain continuum mechanics.

This class encapsulates the deformation gradient \(\bF\) (F) and first Piola-Kirchhoff stress \(\bP\) (PK1), along with optional internal variables. It provides convenience properties for converting between common stress measures: second Piola-Kirchhoff \(\bS\) (PK2) and Cauchy \(\bsig\) (sig) stresses.

internal#

Nested internal state representing material history or additional constitutive information. Defaults to None.

Type:

AbstractState, optional

F#

Deformation gradient \(\bF\). Initialized as the identity tensor.

Type:

Tensor2

PK1#

First Piola-Kirchhoff stress tensor \(\bP\).

Type:

Tensor2

Notes

PK2SymmetricTensor2

Second Piola-Kirchhoff stress tensor \(\bS\), computed via PK1_to_PK2().

sigSymmetricTensor2

Cauchy stress tensor \(\bsig\), computed via PK1_to_Cauchy().

CauchySymmetricTensor2

Alias for sig.

internal: AbstractState = None#
F: Tensor2#
PK1: Tensor2#
property PK2#
property sig#
property Cauchy#
make_batched(module, Nbatch)[source]#

Broadcasts all leaf arrays of a single unbatched module into a batched version.

Parameters:
  • module (eqx.module) – An instance of an equinox Module (e.g., State) with array leaves.

  • Nbatch (int) – The number of batch items to broadcast.

  • Returns – A new instance of the same class, with each array field having shape (Nbatch, …).

Return type:

Module

class Scalar[source]#

Bases: object

Initializer of a scalar state variable (hashable, so it can key the state factory).

default: float = 0.0#
class Vector[source]#

Bases: object

Initializer of a vector state variable of dimension dim.

dim: int = 3#
default: float = 0.0#
class Physics[source]#

Bases: object

Declaration of the variables exchanged by a (multiphysics) behavior.

Following the terminology:

  • gradients are the driving inputs whose conjugates are computed by the behavior (strain \(\beps\), deformation gradient \(\bF\), pore pressure \(p\), temperature gradient…);

  • fluxes are the computed outputs, the thermodynamic forces conjugate to the gradients (stress \(\bsig\), fluid content \(\zeta\), heat flux \(\boldsymbol{q}\)…);

  • external variables are known inputs with no conjugate output (temperature \(T\)…).

Internal state variables are not declared here: they keep living in state.internal.

A Physics is immutable and hashable, and is built with make_physics(). The corresponding state class, input and flux containers are generated on first use and cached, so equal declarations always give the same classes (stable pytree structures for jit, scan and serialization).

name: str#
gradients: tuple#
fluxes: tuple#
external: tuple = ()#
aliases: tuple = ()#
property gradient_names#
property flux_names#
property external_names#
property input_names#

gradients, then external variables.

Type:

Names of the inputs of constitutive_update

property State#

The state class (an AbstractState) storing all variables and internal.

property Inputs#

Named tuple of the inputs (gradients, then external variables).

property Fluxes#

Named tuple of the fluxes.

make_inputs(inputs)[source]#

Accept Inputs, a positional tuple or a dict, even for a single input.

make_fluxes(fluxes)[source]#

Accept Fluxes, a positional tuple or a dict, even for a single flux.

make_physics(name, *, gradients, fluxes, external=None, aliases=None)[source]#

Declare the variables of a behavior and get the matching state class for free.

Each variable is declared by name with an initializer: a tensor class (SymmetricTensor2), a zero-argument factory (Tensor2.identity), a number (a scalar with that initial value) or Vector. Gradients and fluxes are listed in matching (conjugate) order.

POROELASTICITY = make_physics(
    "Poroelasticity",
    gradients={"strain": SymmetricTensor2, "p": 0.0},
    fluxes={"stress": SymmetricTensor2, "zeta": 0.0},
    aliases={"eps": "strain", "sig": "stress"},
)
state = POROELASTICITY.State()  # fields: internal, strain, p, stress, zeta
Return type:

Physics

Parameters:
  • name (str)

  • gradients (dict[str, Any])

  • fluxes (dict[str, Any])

  • external (dict[str, Any] | None)

  • aliases (dict[str, str] | None)

make_state(name, **variables)[source]#

Shortcut for make_physics(name, **variables).State.

Return type:

type[AbstractState]

Parameters:

name (str)