jaxmat.materials.multiphysics module#

Generic multiphysics behaviors.

A multiphysics behavior declares its variables once, as a Physics built by make_physics(), and implements a single response method. The state class, the packing of inputs and outputs, the recording of every variable in the new state, and the consistent tangent blocks are all derived from that declaration:

POROELASTICITY = make_physics(
    "Poroelasticity",
    gradients={"strain": SymmetricTensor2, "p": 0.0},
    fluxes={"stress": SymmetricTensor2, "zeta": 0.0},
)

class LinearBiot(MultiphysicsBehavior):
    physics = POROELASTICITY
    elasticity: AbstractLinearElastic
    b: float = parameter()
    M: float = parameter()

    def response(self, x, state, dt):
        sig = self.elasticity.C @ x.strain - self.b * x.p * Id
        zeta = self.b * x.strain.tr + x.p / self.M
        return (sig, zeta), state.internal

The library does not fix any multiphysics declaration: each behavior declares the variables it exchanges, with the names and conventions of its own formulation. Coupled physics are declared as a whole rather than composed: thermo-poromechanics, for instance, is one physics with gradients (strain, p), fluxes (stress, zeta) and the external variable T.

Material parameters may depend on any declared external variable (see jaxmat.parameters): they are resolved at the current values before response.

class MultiphysicsBehavior[source]#

Bases: AbstractBehavior

Behavior whose variables are declared by a Physics.

Subclasses set the class attribute physics and implement response(). They write no state class and no state.update boilerplate.

constitutive_update(inputs, state, dt) takes the gradients followed by the external variables, as a tuple in declaration order, a dict, or the physics’ Inputs named tuple, even when there is a single input. It always returns the fluxes as the physics’ Fluxes named tuple, together with the new state in which every input and flux has been recorded.

Variable-dependent parameters (jaxmat.parameters) of the behavior, including those of its sub-modules, are resolved at the current values of the declared external variables before response() is called. A parameter depending on an undeclared variable raises an error.

physics: ClassVar[Physics]#

Declaration of the gradients, fluxes and external variables.

make_internal_state()[source]#

No internal state variables by default.

init_state(Nbatch=None)[source]#

Initialize the state generated for physics, optionally batched.

abstract response(x, state, dt)[source]#

Compute the fluxes and the new internal state.

Parameters:
  • x (Inputs) – Named tuple of the current gradients and external variables, e.g. x.strain, x.p, x.T.

  • state (AbstractState) – State at the beginning of the step: previous values are state.strain, state.stress…, internal variables are state.internal.

  • dt (float) – Time increment.

Returns:

  • fluxes (tuple, dict or Fluxes) – Fluxes in declaration order.

  • internal (AbstractState or None) – New internal state.

constitutive_update(inputs, state, dt)[source]#
tangent(inputs, state, dt)[source]#

Consistent tangent blocks d flux / d gradient, by forward-mode autodiff.

Returns a dict keyed by (flux_name, gradient_name). Tensors are differentiated in their stored (Mandel) representation, so the strain-stress block of a small-strain behavior is the usual (6, 6) Mandel tangent; a block involving a scalar drops the corresponding dimension.