morphogen.learning.data

Training data: random strain paths and the responses of a behaviour along them.

A path starts from the natural state and joins segments random strains linearly, each segment in increments steps: a random walk (each strain the previous one plus a random step, held within the amplitude) or independent strains (each component uniform within the amplitude). The volumetric part of the strains is scaled by volumetric: the volumetric strains of metals are elastic and small, those of porous media are not. The responses come from a material point ( simulate_point()) or from any solver of the paths of a microstructure (the homogenized response of NonlinearFFTProblem or of NonlinearFEProblem), at the planned steps of each path (the steps that a solver divides are dropped).

In small strains the data are the strain (engineering shears) and the stress; in finite strains the Green-Lagrange strain E = (F^T F - I) / 2 (engineering shears) and the second Piola-Kirchhoff stress S = J F^-1 sigma F^-T, objective measures conjugate to each other, whatever the rotation of the gradient (the upper triangular gradients of the paths, their Cauchy stresses).

morphogen.learning.data.KINDS = ('walk', 'linear')

The kinds of random paths

morphogen.learning.data.MEASURES = ('small', 'green-lagrange')

small strains (the strain, the stress) or finite strains (the Green-Lagrange strain, the second Piola-Kirchhoff stress)

Type:

The measures of the data

morphogen.learning.data.PAIRS = ((0, 0), (1, 1), (2, 2), (1, 2), (2, 0), (0, 1))

The Voigt pairs (11, 22, 33, 23, 31, 12)

morphogen.learning.data.random_paths(n: int, *, segments: int = 4, increments: int = 10, amplitude: float = 0.01, volumetric: float = 0.2, kind: str = 'walk', components=None, free=False, rate: float | None = None, seed: int = 0) → list[LoadingPath][source]

n random strain paths of segments linear segments of increments steps.

The strains at the ends of the segments: with kind="walk" a random walk (steps of tensor components uniform, of standard deviation amplitude / sqrt(segments), the components held within amplitude), with kind="linear" independent strains (tensor components uniform within amplitude); their volumetric part scaled by volumetric. components: the components driven (names "11" … or Voigt indices; by default all six), the others held at zero strain but those of free (components, or True for all of them), left free (zero stress): a tension-torsion test drives 11 and 12 and frees 22 and 33. A model learns the responses to the components of its data only: the paths it runs must hold the others likewise. rate: the largest strain rate of a component on each segment (the segments then last the time of their strain), by default a unit time each.

morphogen.learning.data.gradient_tensor(h) → ndarray[source]

The deformation gradients F (n, 3, 3) of the components 11, 22, 33, 23, 13, 12 of the upper triangular displacement gradients of the paths in finite strains (n, 6).

morphogen.learning.data.green_lagrange(f) → ndarray[source]

The Green-Lagrange strains (n, 6; engineering shears) of gradients F (n, 3, 3).

morphogen.learning.data.second_piola(f, cauchy) → ndarray[source]

The second Piola-Kirchhoff stresses (n, 6) of the gradients F (n, 3, 3) and the Cauchy stresses (n, 6).

class morphogen.learning.data.Dataset(times: ndarray, strain: ndarray, stress: ndarray, measure: str = 'small', info: dict = <factory>)[source]

Bases: object

Responses along paths: the times (paths x points), the strain and the stress (paths x points x 6, Voigt; engineering shears), the first point of each path the natural state, in small strains or (measure="green-lagrange") the Green-Lagrange strain and the second Piola-Kirchhoff stress; info: how they were made (the behaviour, the paths).

property n_paths: int
property n_points: int
subset(index) → Dataset[source]

The paths of index.

split(validation: float = 0.2, *, seed: int = 0) → tuple[Dataset, Dataset][source]

The paths shuffled (seed) into a training set and a validation set of the fraction validation of them (at least one path each).

save(path) → Path[source]

The data in an .npz file (their info as JSON).

morphogen.learning.data.measures(result: PathResult, rows=None) → tuple[ndarray, ndarray, str][source]

The strain and the stress of a response (its rows) in the measure of its kinematics: small strains, or the Green-Lagrange strain and the second Piola-Kirchhoff stress (finite strains).

morphogen.learning.data.responder(source, kinematics: str = 'small', orientation=None) → Callable[[LoadingPath], PathResult][source]

The response to a path of source: a material (a Material or its configuration) at a material point (turned by the Bunge angles orientation of a crystal), or a callable path -> PathResult (a microstructure).

morphogen.learning.data.generate(source, paths, *, kinematics: str = 'small', info: dict | None = None, callback: Callable[[int, int], None] | None = None) → Dataset[source]

The responses of source (see responder(): a material at a material point, or a callable path -> PathResult of a microstructure) along paths (loading paths or their specifications, all of the same numbers of steps), at their planned steps. callback(done, total) after each path (it may raise Stopped).

class morphogen.learning.data.Scales(strain: float, stress: float, increment: float, time: float)[source]

Bases: object

The normalization of the data: the root mean squares of the strain, of the stress, of the strain increments and the mean time step of a training set. The networks see the strains and the increments divided by theirs and give stresses divided by theirs: scalars, which keep the isotropy of the data and the potential of the stresses (Potential).

to_dict() → dict[source]