morphogen.learning.behaviour

Learned laws in the solvers of morphoGen: a material whose learned names a model (LearnedBehaviour) has its points integrated by the model, along the seam of the MFront behaviours (points of the kind MFRONT, which the kernels skip; their integration after them): at a material point, by finite elements and on voxels. The rest of the solvers is unchanged (the periodic element, Newton’s method, the outputs); the elastic constants of the material remain those of the linear problems and of the reference medium of the FFT solver (learned_material() takes those of the initial tangent of the model).

A step of a point gives the model the strain at its end, the strain and the state of the model at its start (the internal variables of the point) and the time step: the stress and the consistent tangent, and the state at its end. The tangent is exact at a material point; in volume elements it is symmetrized for the conjugate gradients when the laws of all the phases have symmetric tangents (those of the potential and of the standard model are), and kept whole for GMRES otherwise (the perceptron, the recurrent network: LearnedLaw.symmetric). In finite strains, the model of the Green-Lagrange strain E and the second Piola-Kirchhoff stress S gives the first Piola-Kirchhoff stress P = F S and its tangent dP/dF = I (x) S + F . dS/dE . dE/dF.

A learned law depends on the temperature through the thermal expansion of its material only, as morphoGen’s own behaviours do: the model sees the mechanical strain, the strain less the stress-free thermal strain alpha dT (dT from the stress-free state, the expansion tensor in the axes of the material). In finite strains the split is that of morphoGen’s Hencky points (morphogen.homogenization.finite): the mechanical logarithmic strain H_m = 1/2 ln C - alpha dT, the stress T conjugate to H = 1/2 ln C and the free energy per unit reference volume (no factor J_th). The model sees the Green-Lagrange strain of H_m, E_m = (exp(2 H_m) - I)/2 (a law of ln C sees H_m itself), its stress gives T = J_m^-T S_m and K = dT/dH = J_m^-T (dS_m/dE_m - T : d2H/dE2 (E_m)) J_m^-1 (J = dH/dE, J_m at E_m), and S = J^T T, dS/dE = J^T K J + T : d2H/dE2 (morphogen.learning.logarithmic): a law of E that is Hencky’s elasticity gives the stresses of the Hencky points. For an isotropic expansion E_m = A (E + I/2) A - I/2 and S = A S_m A (A = exp(-alpha dT): the multiplicative split F = F_m F_th, F_th = exp(alpha dT)); for an anisotropic one that split is not the Hencky points’ (the logarithms add only where C and alpha commute). Without an expansion, a change of temperature leaves the law unchanged.

A learned law runs in the axes of its material, which the orientation of its point turns as it turns crystals (crystal = g sample: Bunge angles at a material point, those of the grain of each point in polycrystals): the model sees the strain g eps g^T (g E g^T in finite strains) and its stress and tangent are turned back, sigma = g^T sigma_g g and C = T^T C_g T (T: the 6 x 6 matrix of g on the strains); a law learned once in the axes of a crystal serves every grain. Without an orientation, or with oriented: false, it runs in the axes of the sample. Order of the components at every interface: morphoGen’s Voigt order 11, 22, 33, 23, 31, 12 (engineering shears of the strains) in the data, the models, the arrays of the points and the 6 x 6 rotations; the learned points never pass TFEL’s order 12, 13, 23 of the MFront points beside them.

Slots of the internal variables of a point: the plastic strain and the cumulated plastic strain of the outputs (zero: the model has no plastic strain), the strain (or E) of the model at the end of the step (in the axes of its material), then the state of the model.

class morphogen.learning.behaviour.LearnedBehaviour(model: object, oriented: bool = True)[source]

Bases: object

A learned law of a material: model, the file of a model of morphogen.learning (.npz, save()) or the model itself; oriented: the law in the axes of its material, turned by the orientation of its point (that of its grain in a polycrystal) as a crystal is, or (false) in the axes of the sample everywhere.

classmethod from_config(spec) → LearnedBehaviour[source]

The file of a model, or a mapping model: <file> (and oriented).

to_config() → dict[source]
load() → Model[source]

The model (loaded once from its file while the file does not change).

class morphogen.learning.behaviour.LearnedLaw(spec: LearnedBehaviour, model: Model, finite: bool, expansion: ndarray | None = None)[source]

Bases: object

A learned law loaded for the points of a material: its model and kinematics, and the thermal expansion of its material (3 x 3, per unit change of temperature, in the axes of the material; None without one).

property width: int

Internal variables of a point in morphoGen’s arrays.

property symmetric: bool

that of a potential (the Hessian of its free energy) and of a standard model (of its two convex potentials), not those of the perceptron and of the recurrent network; a law that says so itself (model.symmetric: those of morphogen.homogenization.laws).

Type:

Whether the consistent tangent of the law is symmetric

morphogen.learning.behaviour.learned_law(spec, *, finite: bool, expansion=None) → LearnedLaw[source]

The learned law of spec for the points of a solver, its model checked against the kinematics (small strains, or the Green-Lagrange measures in finite strains); expansion: the thermal expansion tensor of its material (in its axes).

morphogen.learning.behaviour.finite_stress(f, s6, c6) → tuple[ndarray, ndarray][source]

The first Piola-Kirchhoff stresses (n, 9) and their tangents dP/dF (n, 9, 9; tensors row by row) of the gradients f (n, 3, 3), of the second Piola-Kirchhoff stresses s6 (n, 6) and of their tangents with respect to the Green-Lagrange strain c6 (n, 6, 6; engineering shears).

morphogen.learning.behaviour.turned(t, s, c) → tuple[ndarray, ndarray][source]

The stresses (n, 6) and tangents (n, 6, 6) of a law in the axes of its material (s, c) turned back to the axes of the sample by the 6 x 6 matrices t (n, 6, 6) of its orientations on the strains (engineering shears): T^T s and T^T c T, the work and the energy unchanged.

morphogen.learning.behaviour.thermal_split(e, heat, dtemp) → ndarray[source]

The mechanical Green-Lagrange strains (n, 6; engineering shears) of Green-Lagrange strains e (n, 6) heated by dtemp with the expansions heat (n, 3, 3), by the split of the Hencky points: the Green-Lagrange strain E_m = (exp(2 H_m) - I)/2 of the mechanical logarithmic strain H_m = 1/2 ln C - dtemp alpha (C = I + 2 E; expm1 of the eigenvalues of 2 H_m, exact to round-off near zero); NaN where C is not positive definite.

morphogen.learning.behaviour.thermal_conjugate(e, em, s, c) → tuple[ndarray, ndarray][source]

The stresses (n, 6) conjugate to the Green-Lagrange strains e (n, 6) and their tangents (n, 6, 6) of a law heated as the Hencky points are, of its stresses s and tangents c at the mechanical strains em of thermal_split(): the stress T = J_m^-T S_m conjugate to the logarithmic strain and its tangent K = dT/dH = J_m^-T (dS_m/dE_m - T : d2H/dE2 (E_m)) J_m^-1 (J = dH/dE, J_m at em), then S = J^T T and dS/dE = J^T K J + T : d2H/dE2 at e (S : dE = T : dH = S_m : dE_m: the free energy of the law per unit reference volume); the tangent symmetrized if that of the law is symmetric to the bit (a potential, a standard model).

class morphogen.learning.behaviour.LearnedPoints(laws, kind, pmat, point_mat, rotations, finite: bool, threads=None, symmetric: bool = True)[source]

Bases: object

The integration points of the materials with a learned law (those of kind MFRONT among kind, of the laws pmat), integrated by their models in the axes of their materials (rotations: the orientation of each row point_mat of the materials, crystal = g sample; the laws not oriented in the axes of the sample); the interface of MFrontPoints.

integrate(grads, dtemp, dt, old, new, stress, tangent) → int[source]

Integration of the points of learned laws among the arrays of all the points; returns the number of points whose stress is not finite.

integrate_compact(grads, dtemp, dt, old, new, stress, tangent) → int[source]

The same for the arrays of these points only (in the order of points).

morphogen.learning.behaviour.isotropic_constants(stiffness) → tuple[float, float][source]

Young’s modulus and Poisson’s ratio of the isotropic projection (Voigt’s means of the bulk and shear moduli) of a 6 x 6 stiffness (engineering shears).

morphogen.learning.behaviour.initial_tangent(model: Model) → ndarray[source]

The tangent of a model at the natural state (of its first step from it).

morphogen.learning.behaviour.learned_material(model, *, young: float | None = None, poisson: float | None = None, expansion=None)[source]

A Material of the learned law of model (a model, its file, or a LearnedBehaviour), its elastic constants (the linear problems and the reference media) those given or of the isotropic projection of its initial tangent; expansion: its thermal expansion (one coefficient, principal values or a tensor in the axes of the material), the stress-free thermal strain taken out of the strain the model sees.