upxo.pxtal.twinned_simple_3d.island_twin_3d module
island_twin_3d.py
Island Twin Introduction – isolated, Sigma3-oriented twin inclusions that touch no boundary of whatever grain/region contains them, carved as bounded oblate ellipsoids (thin along the {111} habit-plane normal, like the real slab twins, but bounded in-plane so they never reach the container’s own edge – the one thing TwinGenerator3D’s own plane-slab carving can never produce, see its introduce_twin_lamella_3d: an infinite-plane cut through a finite grain always touches that grain’s boundary by construction).
Runs strictly AFTER Structure Cleaning (Topology Cleaning), on the final cleaned post-twin structure – never before, and never interleaved with it: an island’s own surface voxels touch nothing of the same label on any face (isolated by construction), which is exactly the shape StructureCleaner3D._fast_clean_spikes is built to erase. Placing islands only after cleaning is done means that erosion risk never arises.
Size: the short (thickness) axis is bootstrap-sampled from the SAME EBSD thickness array (twin_thickness[‘thick_um’]) the lamella twins use, for consistency; the long (in-plane) axis is this short axis times island_aspect_ratio – an explicit, user-adjustable multiplier, not a separately-calibrated distribution. Calibrating island size against EBSD’s own 2D island-twin statistics (not just thickness) needs a dedicated EBSD characterization function that does not exist yet; this aspect-ratio approach is a deliberate, honest placeholder until that exists, not a disguised “real” calibration.
- upxo.pxtal.twinned_simple_3d.island_twin_3d.introduce_island_twin_3d(lgi: ndarray, container_gid: int, center, normal, half_thickness: float, half_width: float, next_gid: int, container_coords: ndarray | None = None)[source]
Carve a single bounded, oblate-ellipsoid island twin out of container_gid’s own voxels in a 3D lgi array.
Membership test: for each container voxel, its signed distance along normal (d_n) and its in-plane radial distance from center (d_r) must satisfy (d_n/half_thickness)^2 + (d_r/half_width)^2 <= 1 – the short axis (half_thickness) runs along the {111} habit-plane normal, matching the slab twins’ own orientation convention; the two long in-plane axes are both half_width (an oblate spheroid, thin like a real twin plate).
Parameters mirror pxtalops.twin3d.introduce_twin_lamella_3d’s shape (lgi, container id, geometry, next_gid) but add the second, in-plane-bounding radius that makes this an island instead of a slab.
- Returns:
island_voxels – Global voxel coordinates of the carved region, or None if no voxels were selected.
- Return type:
ndarray (N, 3) or None
- class upxo.pxtal.twinned_simple_3d.island_twin_3d.IslandTwinIntroducer(lgi_clean: ndarray, all_quats_clean: Dict[int, ndarray], twin_role_clean: Dict[int, str], twin_parent_of_clean: Dict[int, int], voxel_size: float, category_probs: Dict[str, float], island_vf_target: float = 0.0, twin_thickness: Dict | None = None, island_aspect_ratio: float = 4.0, thick_scale_factor: float = 1.0, twin_orient_scatter_deg: float = 1.5, max_attempts_per_island: int = 20, max_total_attempts: int = 2000, rng_seed: int | None = None)[source]
Bases:
objectIntroduces island twins into a final, cleaned post-twin structure.
- Parameters:
lgi_clean – StructureCleaner3D’s own output attributes – the structure this operates on and extends in place.
all_quats_clean – StructureCleaner3D’s own output attributes – the structure this operates on and extends in place.
twin_role_clean – StructureCleaner3D’s own output attributes – the structure this operates on and extends in place.
twin_parent_of_clean – StructureCleaner3D’s own output attributes – the structure this operates on and extends in place.
voxel_size (float) – Physical voxel edge length (same units as twin_thickness/ island_vf_target apply in).
category_probs (dict) – {‘remaining_parent’, ‘non_host’, ‘primary_twin’} -> probability, for whichever subset the user selected (missing/zero-probability categories are simply never drawn from). Must sum to 1 over the selected categories.
island_vf_target (float) – Target ADDITIONAL volume fraction from islands alone, relative to the structure’s total voxel count – additive on top of whatever the existing twins already achieved, not drawn from the same budget. 0 (the default) introduces no islands at all.
twin_thickness (dict) – Same EBSD twin-thickness dict ({‘thick_um’: array, …}) TwinGenerator3D consumes – islands’ short axis bootstrap-samples from this SAME array, for consistency with the lamella twins.
island_aspect_ratio (float) – long (in-plane) axis / short (thickness) axis – see module docstring for why this, not a separately-calibrated distribution.
thick_scale_factor (float) – Same role as TwinGenerator3D’s twin_thick_scale_factor, applied to the sampled thickness before computing the long axis from it.
twin_orient_scatter_deg (float) – Same meaning as TwinGenerator3D’s – Gaussian scatter added to the exact Sigma3 orientation relationship.
max_attempts_per_island (int) – Retries (a fresh category + container grain + size + placement each time) before giving up on one island and moving to the next.
max_total_attempts (int) – Hard safety cap on attempts across ALL islands combined, in case island_vf_target is unreachable (e.g. too few/too small eligible regions) – stops instead of looping forever.
rng_seed (int or None)