morphogen.homogenization.core

Types shared by the solvers: boundary conditions, loadings, solutions.

morphogen.homogenization.core.boundary_condition(name: str) → str[source]

Canonical name of a boundary condition (accepts aliases such as ‘pbc’, ‘utg’).

morphogen.homogenization.core.VOIGT_NAMES = ('11', '22', '33', '23', '31', '12')

Names of the Voigt components (elasticity) and of the vector components (conduction).

class morphogen.homogenization.core.Loading(kind: str, value: tuple[float, ...], controls: tuple[bool, ...] | None = None, temperature: float = 0.0, physics: str | None = None)[source]

Bases: object

Macroscopic loading.

kind is strain or stress (6 Voigt components, order 11 22 33 23 31 12, engineering shear strains) for elasticity, gradient or flux (3 components) for the transport phenomena of a scalar potential (heat or electrical conduction, dielectric or magnetic polarization, diffusion), or mixed: component i is a strain (gradient) where controls[i] is true, a stress (flux) where it is false. The components of the macroscopic strain are then unknowns of the problem, dual to those of the macroscopic stress (their reactions are V Sigma), as the degrees of freedom of the periodic element of Z-set (see superpose()). temperature is a uniform change of temperature from the stress-free state (elasticity: thermal strains of the materials that expand). physics: "elastic" for the loadings of 6 components; for those of 3, the transport phenomenon they load (TRANSPORT, "thermal" by default): a problem takes the gradients and fluxes of any of them, and homogenize() solves each named loading with the problem of its physics.

classmethod strain(value, *, temperature: float = 0.0) → Loading[source]

Imposed strain: a 3 x 3 tensor or 6 Voigt components (engineering shears).

classmethod gradient(value, *, physics: str = 'thermal') → Loading[source]

Imposed gradient of the potential of a transport phenomenon (3 components).

classmethod flux(value, *, physics: str = 'thermal') → Loading[source]

Imposed flux of a transport phenomenon (3 components; flux = -K gradient).

classmethod mixed(strain=None, stress=None, *, gradient=None, flux=None, temperature: float = 0.0, physics: str | None = None) → Loading[source]

Strain prescribed on some components, stress on the others (or gradient and flux): each as a mapping ({"11": 0.01, "23": 0}; conduction {"1": ...}) or a sequence with None where the other one is prescribed. Every component must be prescribed exactly once. Example, uniaxial tension along 1 with free lateral contraction: Loading.mixed(strain={"11": 0.01}, stress={"22": 0, "33": 0, "23": 0, "31": 0, "12": 0}).

classmethod uniaxial(axis: int, *, strain=None, stress=None, temperature: float = 0.0)[source]

Tension along axis: its strain (or stress) prescribed, the other stress components zero (free lateral contraction).

classmethod from_spec(spec) → Loading[source]

Loading of a configuration mapping: strain and/or stress (elasticity) or gradient and/or flux (a transport phenomenon: physics, thermal by default), each a mapping of components or a full list, and temperature. Components not given are free: zero stress (flux). {"strain": {"11": 0.01}} is a uniaxial tension, {"temperature": 1} a free thermal expansion, {"physics": "electrical", "gradient": {"1": 1}} a potential gradient along x, the currents across it free.

classmethod parse(text: str) → Loading[source]

Loading of a compact text: E11=0.01 S22=0 dT=10 (strain E, stress S), G1=1 Q2=0 (gradient, flux; of the transport phenomenon physics=electrical, thermal by default); components not given are free.

property array: ndarray
property strain_controlled: ndarray

Components prescribed as strains (gradients); the others are stresses (fluxes).

to_dict() → dict[source]
morphogen.homogenization.core.superpose(problem, loading: Loading) → tuple[ndarray, ndarray, SolveInfo][source]

Solution of a loading that mixes the components a boundary condition prescribes (problem.native: strains, or stresses for static conditions) with their duals.

The macroscopic native components are the extra unknowns of the problem, dual to the others: their reactions are the volume times the averages of the dual field, R = V Sigma for strain components. A linear problem condenses them exactly: the responses to unit native loadings (problem._unit(j), cached) and to a unit change of temperature give the matrix M (the apparent stiffness, or compliance) and the vector r of dual = M x + r dT; the unknown components of x solve the prescribed rows, and the field is the sum of the unit fields. Returns x, the field and the work done.

class morphogen.homogenization.core.PhaseStatistics(phase: int, fraction: float, mean: dict[str, ndarray], std: dict[str, ndarray])[source]

Bases: object

Volume fraction, means and standard deviations of the fields in one phase.

to_dict() → dict[source]
class morphogen.homogenization.core.Solution(physics: str, bc: str, loading: Loading, strain: ndarray, stress: ndarray, energy: float, material_fraction: float, phases: list[PhaseStatistics], info: SolveInfo, fields: dict[str, ndarray] | None = None, support: object | None = None)[source]

Bases: object

Volume averages over the box of one solved problem.

Elasticity: strain is the macroscopic strain E (imposed, or the average strain under SUBC), stress the average stress Sigma (voids count as zero), both 3 x 3 tensors, and energy the average of sigma : eps (twice the elastic energy density). Conduction, and every transport phenomenon of a scalar potential (physics: TRANSPORT): strain is the macroscopic gradient G, stress the average flux Q (q = -k grad T) and energy the average of k grad T . grad T.

fields: dict[str, ndarray] | None = None

element means of strain and stress (or gradient and flux) and energy density, plus the nodal displacement (temperature) of finite element solutions

Type:

local fields (with fields=True)

support: object | None = None

the mesh (TetMesh, porous phases removed) or image (VoxelImage) of the fields

to_dict() → dict[source]
class morphogen.homogenization.core.MacroscopicLoadings[source]

Bases: object

Solution of macroscopic loadings by a problem that solves for the components its boundary condition prescribes (_field(x, dt)) and evaluates the averages of a field (_dual, _evaluate); other components are condensed by superpose().

property native: str

strains (gradients), or stresses (fluxes) for static conditions.

Type:

What the boundary condition prescribes

native_mask(loading: Loading) → ndarray[source]

Components of a loading that the boundary condition prescribes directly.

solve(loading: Loading, *, fields: bool = False) → Solution[source]

Solve for a macroscopic loading: what the boundary condition prescribes (strains, or stresses under subc), or any mix of strain and stress components under kubc, periodic and subc, by condensation of the macroscopic unknowns (superpose()).