morphogen.models.nested¶
Nested models: structures placed in, or around, the phases of others.
cox_spheres: spheres clustered in the phase 1 of another model (aggregates of particles in nanocomposites, at any number of scales): a Cox (doubly stochastic) Boolean model, or hard-core spheres placed among its germs.coating: a layer of constant thickness around the phase 1 of a model (an interphase), or a shell inside it (hollow members: spheres, fibres, struts).fractal_sponge: the attractor of an iterated function system on a cubic grid (the Menger sponge, Cantor dust, the Vicsek fractal, or any set of sub-cubes), iterated a finite number of times.
Hierarchical lattices of hollow tubes are in morphogen.models.hierarchical, and
the nested operation of morphogen.models.combination fills the phase 1 of a
structure with another.
- class morphogen.models.nested.ClusteredSpheres(domain, spheres, aggregates: Microstructure, aggregate_phase=None, **kw)[source]¶
Bases:
PrimitiveUnionSpheres (phase 1) clustered in aggregates, a realization of another model; the aggregates outside the spheres may form a phase of their own.
- property phase_names: dict[int, str]¶
- voxelize(shape=None, *, voxel_size=None, grid: Grid | None = None, supersampling=1)[source]¶
Phase image (uint8), or partial volume fractions of phase 1 (float32) when
supersampling > 1(supersampling**3sub-samples per voxel).
- implicit_phases() list[int][source]¶
The phases of the realization, each described by an implicit function (
phase_level_set()), in increasing order: phase 1 and what surrounds it (the structures of more phases, or of others, say theirs).
- phase_level_set(phase: int, shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
The implicit function of a phase (see
Microstructure.phase_level_set()): the spheres by their signed distance; the aggregates, when a phase of their own, by the level set of their structure outside the spheres.
- phase_level_sets_at(points, reach: float = inf) dict[int, ndarray][source]¶
The functions of
phase_level_set()at the points: the signed distance to the spheres, and the point-wise level set of the aggregates when they form a phase of their own.
- level_set_at(points, reach: float = inf) ndarray[source]¶
The function of phase 1 (
phase_level_sets_at()).
- class morphogen.models.nested.CoxSpheres(aggregates: Model, radius: Distribution = Constant(value=1.0), local_fraction: float | None = None, intensity: float | None = None, outside_fraction: float = 0.0, hardcore: bool = False, min_gap: float = 0.0, aggregate_phase: int | None = None, *, anisotropy: Anisotropy | None = None)[source]¶
Bases:
ModelSpheres clustered in the phase 1 of another model: a Cox Boolean model.
The centres of the spheres are Poisson points of intensity
theta_1in the aggregates (the phase 1 ofaggregates, any model, Cox spheres included) andtheta_0outside, the spheres being whole (Jeulin & Moreaud 2007; Jean, Jeulin, Forest et al. 2011 for carbon black in rubber). Withhardcore, non-overlapping spheres are placed among such germs by random sequential addition instead. The fractions are local: that of the spheres within the aggregates and outside them.- phases: ClassVar[dict[int, str]] = {0: 'matrix', 1: 'spheres'}¶
Meaning of the phase indices of the voxel images.
- count_label: ClassVar[str] = 'spheres'¶
Objects counted by
expected_count()(fibres, spheres, cells…).
- property has_level_set: bool¶
Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- property supports_periodic: bool¶
Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- active_phases() dict[int, str][source]¶
Phases the realizations of this model can contain, with their names (the
phasesof the model, unless its parameters choose them).
- property mean_volume: float¶
- property intensities: tuple[float, float]¶
Intensities of the germs in and out of the aggregates (Boolean spheres).
- generate(domain: Domain, seed: int | SeedSequence | Generator | None = None) ClusteredSpheres[source]¶
One realization of the model in
domain.
- expected_count(domain: Domain) float | None[source]¶
Mean number of sphere centres in the domain (Boolean spheres).
- theory(domain: Domain | None = None) dict[str, float][source]¶
Fractions when the spheres are small compared with the aggregates (a sphere rarely straddles their boundary):
1 - p exp(-theta_1 V) - (1 - p) exp(-theta_0 V)for Boolean spheres,p f_1 + (1 - p) f_0for hard-core ones,pbeing the fraction of the aggregates.
- class morphogen.models.nested.CoatedStructure(domain, inner, thickness, side, phase, core_phase, bores=None, **kw)[source]¶
Bases:
MicrostructureA structure with a layer around its phase 1 (outside) or a shell inside it.
- property phase_names: dict[int, str]¶
- voxelize(shape=None, *, voxel_size=None, grid: Grid | None = None, supersampling=1)[source]¶
Phase image (uint8), or partial volume fractions of phase 1 (float32) when
supersampling > 1(supersampling**3sub-samples per voxel).
- level_set(shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
Hollow members (a void core): the union minus the bores (exact sets), or the shell
-t <= d <= 0of the signed distance; a coating leaves phase 1 as is.
- implicit_phases() list[int][source]¶
The phases of the realization, each described by an implicit function (
phase_level_set()), in increasing order: phase 1 and what surrounds it (the structures of more phases, or of others, say theirs).
- phase_level_set(phase: int, shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
The implicit function of a phase (see
Microstructure.phase_level_set()), from the signed distancedto the phase 1 of the structure: a coating of thicknesstis0 < d < t, a shell-t < d < 0and its cored < -t(hollow unions of spheres and segments: the union minus the bores, and the bores). The distance is exact for unions of spheres and segments; for the other structures it is that of their voxels on the grid (as in their images).
- phase_level_sets_at(points, reach: float = inf) dict[int, ndarray][source]¶
The functions of
phase_level_set()at the points, for the coatings and shells of a union of spheres and segments (whose signed distance is exact there): the same functions of that distance, or of those of the union and of its bores. The coatings of the other structures, whose distance is that of their voxels, have none.
- implicit_pieces(depth: float = 0.0) tuple[list, int] | None[source]¶
The pieces of a coated union of spheres and segments, or of its hollow members (see
morphogen.models.pieces): the primitives, then the same with their radii increased by the thickness of the coating; the bores of hollow members, then the primitives. None for the other structures.
- property lipschitz: float¶
Convert a string or number to a floating-point number, if possible.
- level_set_at(points, reach: float = inf) ndarray[source]¶
As
level_set(), at the points: the level set of the structure (coating), or the function of phase 1 ofphase_level_sets_at()(the members of a union less their bores, the shell of its signed distance).
- morphogen.models.nested.bores_of(union: PrimitiveUnion, thickness: float) PrimitiveUnion[source]¶
The same spheres and segments, thinner by
thickness(those thinner than it are left out: they stay full).
- class morphogen.models.nested.Coating(model: Model, thickness: float, side: str = 'outside', phase: int = 2, core_phase: int = 0)[source]¶
Bases:
ModelA layer of constant thickness on the phase 1 of a model.
outside: a coating (an interphase) of phasephasearound it, within the distancethickness.inside: a shell of that thickness, the core becoming the phasecore_phase(0: hollow members). Unions of spheres and segments (Boolean and hard-core spheres, fibres, strut lattices…) are coated exactly, and their members are hollowed one by one (each minus a thinner copy: bores join where members meet); other structures through the distance transform of their voxels.- phases: ClassVar[dict[int, str]] = {0: 'matrix', 1: 'phase 1 of the model', 2: 'coating'}¶
Meaning of the phase indices of the voxel images.
- property has_level_set: bool¶
Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- property supports_periodic: bool¶
Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- active_phases() dict[int, str][source]¶
Phases the realizations of this model can contain, with their names (the
phasesof the model, unless its parameters choose them).
- generate(domain: Domain, seed: int | SeedSequence | Generator | None = None) CoatedStructure[source]¶
One realization of the model in
domain.
- class morphogen.models.nested.FractalStructure(domain, cell_size, subdivisions, kept, level, **kw)[source]¶
Bases:
MicrostructurePeriodic tiling of the cube kept by an iterated function system.
- voxelize(shape=None, *, voxel_size=None, grid: Grid | None = None, supersampling=1)[source]¶
Phase image (uint8), or partial volume fractions of phase 1 (float32) when
supersampling > 1(supersampling**3sub-samples per voxel).
- level_set(shape=None, *, voxel_size=None, grid: Grid | None = None) VoxelImage[source]¶
The signed distance to the solid in the maximum norm (negative inside), clipped to a band of four voxels and to the edge of the smallest cubes: the solid is a union of such cubes, and the distance from a point to the nearest cube of the other state among the 26 around its own is the largest of its distances to the faces that separate them.
- convex_pieces()[source]¶
The structure as boxes of one phase each (the cubes of the finest level, merged greedily), clipped to the box: the pieces, their phases and their cells (the phases), for
morphogen.mesh.exact.polyhedral_mesh().
- class morphogen.models.nested.FractalSponge(pattern: str = 'menger', kept: tuple | None = None, subdivisions: int = 3, level: int = 3, cell_size: float = 1.0)[source]¶
Bases:
ModelIterated function system on a cubic grid: the Menger sponge and its kin.
The cube of edge
cell_sizeis divided intosubdivisions^3sub-cubes, of which the pattern keeps some (menger: all but the centre and the face centres, 20 of 27;vicsek: the centre and the face centres;cantor_dust: the 8 corners; orkept: indices (i, j, k)); each kept sub-cube is divided alike,leveltimes. The attractor has the similarity dimensionlog N / log k(N cubes kept of k^3); the domain is tiled by the cube.- phases: ClassVar[dict[int, str]] = {0: 'void', 1: 'solid'}¶
Meaning of the phase indices of the voxel images.
- count_label: ClassVar[str] = 'unit cells'¶
Objects counted by
expected_count()(fibres, spheres, cells…).
- property cubes: list[tuple]¶
- generate(domain: Domain, seed: int | SeedSequence | Generator | None = None) FractalStructure[source]¶
One realization of the model in
domain.