morphogen.homogenization.mfront

MFront behaviours (TFEL, https://thelfer.github.io/tfel) in the solvers of morphoGen, through MGIS (MFrontGenericInterfaceSupport).

A material whose mfront names a behaviour (MFrontBehaviour: a library compiled with the generic interface, or a .mfront source that morphoGen compiles with mfront --obuild --interface=generic and caches) has its integration points integrated by MGIS along loading paths, by finite elements and on voxels, in small and finite strains: the stresses, the internal state variables and the consistent tangent of every point, the rest of the solvers unchanged (the periodic element, Newton’s method, the outputs). Its elastic constants (young and poisson, or a crystal stiffness) remain those of the reference medium of the FFT solver and of the linear problems.

Conventions. MGIS stores symmetric tensors in the order of TFEL, (11, 22, 33, 12, 13, 23) (that of Cast3M, Code_Aster and Abaqus, not the usual order of Voigt, (11, 22, 33, 23, 13, 12)), with a factor sqrt(2) on their shear components (Mandel’s normalization; the tangents likewise), and the deformation gradient and the first Piola-Kirchhoff stress in the order (11, 22, 33, 12, 21, 13, 31, 23, 32). morphoGen keeps the usual order (11, 22, 33, 23, 31, 12) with engineering shear strains, and tensors of 9 components row by row: the components are converted at the calls of MGIS only. Finite strain behaviours are loaded for the first Piola-Kirchhoff stress and its derivative with respect to the deformation gradient. The gradients of the points of a crystal go to the axes of its lattice (the orientation of its grain), the stresses and the tangents come back to the axes of the sample. The tangents are symmetrized for the conjugate gradients of the solvers whose laws all have symmetric tangents, and passed whole to GMRES otherwise (and to Newton’s method at a material point): a behaviour has a symmetric tangent when it declares one (@ProvidesSymmetricTangentOperator, which MFront writes in the traits of the behaviour, isConsistentTangentOperatorSymmetric, in the header that it generates next to the library: declared_symmetric(); the generic interface does not export it).

State. The internal state variables of MGIS live in morphoGen’s arrays of the internal variables of the points, after the change of temperature, the gradients and the thermodynamic forces at the end of the step (the start of the next one); tensors of 9 components there hold their difference to the identity, so that the natural state is zero. Every integration starts from them, so that divided steps and the iterations of Newton’s method need no special care. The cumulated plastic strain of the outputs is the internal variable plastic_strain (by default EquivalentPlasticStrain or EquivalentViscoplasticStrain when the behaviour has one), and the plastic strain tensor, in small strains, the strain minus ElasticStrain.

The parameters of a behaviour (parameters) are global to its library in the process: materials that share a behaviour share them.

MGIS and MFront are not on PyPI: conda install -c conda-forge mgis mfront (a C++ compiler, such as cxx-compiler, builds the behaviours).

morphogen.homogenization.mfront.available() → bool[source]

Whether MGIS can be imported (MFront behaviours can be integrated).

morphogen.homogenization.mfront.info() → dict[source]

MGIS and the MFront code generator (the version of TFEL), or why MFront behaviours are not available.

class morphogen.homogenization.mfront.MFrontBehaviour(library: str | None = None, source: str | None = None, behaviour: str | None = None, material_properties: tuple = (), parameters: tuple = (), external_state_variables: tuple = (), temperature: float = 293.15, plastic_strain: str | None = None)[source]

Bases: object

An MFront behaviour of a material: library (compiled with the generic interface) or source (a .mfront file, compiled on first use by compile_mfront()), behaviour (its name; by default the stem of the source), the values of its material_properties and parameters, its external_state_variables other than the temperature (constants), the absolute temperature of the natural state (the changes of temperature of the loading paths add to it) and the internal variable that gives the cumulated plastic strain of the outputs (plastic_strain).

classmethod from_config(spec) → MFrontBehaviour[source]

A mapping with library or source, and optionally behaviour, material_properties, parameters, external_state_variables (mappings of names to values), temperature and plastic_strain.

to_config() → dict[source]
morphogen.homogenization.mfront.compile_mfront(source, *, directory=None) → Path[source]

The library (generic interface) of an MFront source, built by mfront --obuild --interface=generic in a cache directory named after its stem and the hash of its contents (directory; by default MORPHOGEN_MFRONT_CACHE or ~/.cache/morphogen/mfront), and reused while the source does not change.

class morphogen.homogenization.mfront.MFrontLaw(spec: MFrontBehaviour, behaviour: object, finite: bool, n_grad: int, n_force: int, n_isv: int, identity: ndarray = <factory>, p_offset: int | None = None, elastic_offset: int | None = None, orthotropic: bool = False, symmetric: bool = False)[source]

Bases: object

A behaviour loaded by MGIS for the integration points of a material: its sizes, the offsets of its internal state variables of 9 components (stored minus the identity) and of the variables of the outputs, whether it is orthotropic (its points are turned to the axes of their grains) and whether its consistent tangent is symmetric (declared_symmetric()).

property width: int

Internal variables of a point in morphoGen’s arrays.

morphogen.homogenization.mfront.declared_symmetric(library, behaviour: str) → bool | None[source]

Whether the behaviour behaviour of the MFront library declares a symmetric consistent tangent (@ProvidesSymmetricTangentOperator): the trait isConsistentTangentOperatorSymmetric of its tridimensional hypothesis in the header include/TFEL/Material/<behaviour>.hxx that mfront --obuild writes beside the directory of the library (that of compile_mfront()); None without that header.

morphogen.homogenization.mfront.load_behaviour(spec: MFrontBehaviour, *, finite: bool) → MFrontLaw[source]

The behaviour of spec loaded by MGIS for three-dimensional points (finite strains: for the first Piola-Kirchhoff stress and its derivative with respect to F), checked against the kinematics of the solver, its material properties and parameters set.

class morphogen.homogenization.mfront.MFrontPoints(laws, kind, pmat, point_mat, rotations, finite: bool, threads=None, symmetric: bool = True)[source]

Bases: object

The integration points of the materials with an MFront behaviour, integrated by MGIS: one manager of the data of the points per material, the rotations of the points of crystals, a pool of threads. kind, pmat and point_mat are those of the points of a solver, rotations the orientation matrix of each of its materials (crystal = g @ sample); symmetric: the tangents symmetrized (for the conjugate gradients), or passed whole (for GMRES and at a material point).

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

Integration of the MFront points of the arrays of all the points (see integrate()); returns the number of points of the materials whose integration failed.

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

The same for the arrays of the MFront points only (in the order of points), on the CPU.