morphogen.laser.cells¶
Cellular design of laser-architectured sheets: the phases of a grid of cells, and their optimization by cellular automata and by densities (the loop of the SCOLASTIC project: a generative module, the finite elements of the load case, a local rule).
Cells. The parallel part of a specimen is a grid of square cells
(CellGrid, 1 mm by default: the width of a laser track, the increment of the
path, and a volume large enough for each cell to carry a homogenized behaviour). Each
cell holds a Phase: a flow law, a critical plastic strain (the fracture of a
brittle phase: the specimen fails when a point of it reaches it) and a cost (its share
of the treatment budget: 0 for the untreated sheet, 1 for a full treatment, between for
the mild and strong levels of a multi-level treatment). The tracks are drawn on the
blank before the specimen is cut: the end columns of the grid continue along x to the
grips (extend).
Load case. The tensile test of the specimen (tensile_test()):
the engineering curve up to the failure, the first of the maximum force (diffuse
necking) and of the fracture of a brittle point. Measures (failure_measures()):
the tensile strength reached before the failure, the failure strain (ductility),
the work absorbed up to it per unit volume (energy, MJ/m³: the plastically
dissipated energy of Wang et al. 2023), and their product with the strength. The
objective is one of them, the constraints bound the others (exponential penalties).
Sensitivities by replay. A test records the deformation gradients of the Gauss
points at every step; replaying them with the law of another phase
(replay()) gives the work and the plastic strains each
element would have seen with it, the kinematics held: the first-order change of the
force at every step if one cell alone changed its phase, and whether a brittle phase
there would have broken first. CellProblem.estimates() turns them into the value
of the objective each cell would give the design in each phase — the failure included,
which a derivative would miss (the fracture of the reinforcement that limits the
ductility, Wang et al. 2023, is a threshold). The replays of all the cells cost a few
tenths of a second; the next finite element test checks them.
Cellular automata.
beso()— the bidirectional evolutionary rule (Huang & Xie 2007, 2010; Querin, Steven & Xie 1998) on cells: the benefit of each phase over the untreated one, filtered over a radius (the neighbourhood of the automaton) and averaged with the previous iteration; the budget moves to its target byerper iteration, each cell takes the phase that maximizes its benefit minusλtimes its cost (λmeets the budget: with two phases, the cells of largest benefit are treated), at most one level per iteration and a sharemax_changeof the cells changing. Several levels of treatment (mild, strong, very strong: SCOLASTIC) are phases of increasing cost.multigrid: the cells are first coarse (4 mm, then 2 mm), each solution starting the finer grid (the multigrid automata of Abdalla, Kim & Gürdal 2004 and Zakhama et al. 2009).exchange: the phases of neighbouring cells exchanged, at a constant budget (a Kawasaki rule), the best estimates tested by finite elements.hca()— the hybrid cellular automaton of Tovar et al. (2006): continuous treatment densities (the flow stress mixes the phases by the weightx^q, the critical strain of the brittle phase grows asx^-2when the treatment is partial), each cell driven by the estimated derivative of the objective (its stimulus, averaged over the neighbourhood) towards the set point that meets the budget, a proportional controller of gainkp; the densities then rounded to the levels.topology()— density-based topology optimization (Bendsøe 1989; SIMP): the same densities filtered (Bruns & Tortorelli 2001) and projected (Wang, Lazarov & Sigmund 2011), the derivatives from the replays, the method of moving asymptotes (MMA) with the budget as constraint.
Bands and tracks. band_fractions() gives the share of a band of width t
along polylines (straight or corrugated tracks of constant width: the ideal designs of
Wang et al. 2023) in the region of each Gauss point, for CellProblem.evaluate().
CellGrid.stamp() draws polylines with a square spot of some cells,
treatable() tells whether such a spot draws a design (the minimum width of the
automata), design_tracks() gives the centre lines of the tracks that draw one (a
path for SheetCase, the process model).
What the replays miss: they hold the kinematics, so that the strain a change moves onto
its neighbours (a gap that necks, a corner that concentrates) escapes them — the
finite element tests of the automata keep only the true gains, and the derivatives of
hca() and topology() see the strength a cell adds, not the fracture it
causes next to it (docs/laser.md, §6 and §7).
- morphogen.laser.cells.OBJECTIVES = ('energy', 'strength_ductility', 'ductility', 'tensile_strength')¶
Measures of a design (
failure_measures()), the objectives among them.
- morphogen.laser.cells.SYMMETRIES = ('x', 'y', 'point')¶
mirrors about the middle of the length (
x), of the width (y), and the half turn (point).- Type:
Symmetries of the designs
- morphogen.laser.cells.MARTENSITE_CRITICAL = 0.072¶
The critical plastic strain of the laser martensite of Wang et al. (2023), fitted to the failure of their straight reinforcement (sample 1, at an engineering strain of 0.083) with the laws of
wang_phases(), averaged overFRACTURE_RADIUS.
- morphogen.laser.cells.FRACTURE_RADIUS = 1.5¶
The radius (mm) over which the plastic strain of a brittle phase is averaged (
Fracture): about the width of a track, the crack crossing it whole; with it the failure strains of the corrugated samples of Wang et al. (2023) follow their tests.
- class morphogen.laser.cells.Phase(name: str, law: FlowLaw, critical: float = inf, cost: float = 1.0)[source]¶
Bases:
objectA material state of the cells (see the module):
law,criticalplastic strain (infinite: ductile) andcostin the treatment budget.
- morphogen.laser.cells.wang_phases(critical: float = 0.072) tuple[Phase, Phase][source]¶
The phases of Wang et al. (2023, Table 3): the annealed 0.23 C steel (ferrite and pearlite, Hollomon σ0 280 MPa, K 986 MPa, n 0.24) and its laser martensite (1300, 1966, 0.06), brittle beyond
critical.
- morphogen.laser.cells.FRACTURE_RULES = ('graded', 'brittle', 'ductile')¶
Rules of the critical plastic strain of a reinforcement softer than the laser martensite (
contrast_phases()).
- morphogen.laser.cells.contrast_phases(contrast: float, fracture: str = 'graded', critical: float = 0.072) tuple[Phase, Phase][source]¶
The matrix of
wang_phases()and a reinforcement whose yield stress iscontrasttimes the matrix’s, from 1 to the contrastc_M = 1300/280of the as-quenched laser martensite (the hardest state of the steel): the Hollomon parametersσ0,Kandninterpolated linearly between those of the matrix and of the martensite at the sharea = (contrast − 1)/(c_M − 1), the states between the annealed steel and its martensite (partly transformed by an intercritical peak, or tempered), a harder state hardening less. The critical plastic strain of the reinforcement (FRACTURE_RULES):graded,critical / a²(the rule of a partial treatment, as inhca(): the martensite breaks atcritical, a softer state later);brittle,criticalwhatever the contrast;ductile, none (the necking alone). The last two bound the first.
- class morphogen.laser.cells.CellGrid(length: float, width: float, size: float = 1.0, x0: float = 0.0, y0: float = 0.0)[source]¶
Bases:
objectSquare cells of about
sizemm over[x0, x0 + length] x [y0, y0 + width](the parallel part of a specimen, the region of a structure):nyrows (along y) andnxcolumns; a design is an array(ny, nx).- property shape: tuple[int, int]¶
- property count: int¶
- locate(points, extend: bool = True) ndarray[source]¶
The cell (flat index) of each point, -1 outside the grid;
extend: the end columns continue along x beyond the parallel part.
- filter_matrix(radius: float) csr_matrix[source]¶
The neighbourhood of the automaton: weights
max(0, radius - d)between cell centres (mm), rows normalized; the identity forradius <= size.
- orbits(symmetry=(), period: float | None = None) ndarray[source]¶
The orbit of each cell under the
symmetry(SYMMETRIES) and the translation byperiod(mm, a divisor of the length in cells): a design constant on the orbits is symmetric and periodic.
- transfer(design, other: CellGrid) ndarray[source]¶
A design of this grid sampled at the cell centres of
other(multigrid).
- coverage(polylines, width: float, n: int = 6) ndarray[source]¶
The share of each cell
(ny, nx)withinwidth / 2of the polylines.
- rasterize(polylines, width: float, budget: float | None = None) ndarray[source]¶
The cells of a band of
widthalong the polylines (phase 1): those most covered, as many as thebudgetasks (default: those covered at least by half).
- stamp(polylines, width: int = 2) ndarray[source]¶
The cells a square spot of
widthcells covers along the polylines (phase 1): a designtreatable()by construction, the tracks of a laser spot.
- morphogen.laser.cells.quarter_points(mesh: QuadMesh, n: int = 4) ndarray[source]¶
Points of the quarter of each element around each of its Gauss points:
(e, 4, n², 2), regular sub-grids of the quarters of the reference square.
- morphogen.laser.cells.band_fractions(mesh: QuadMesh, polylines, width: float, n: int = 4) ndarray[source]¶
The share
(e, 4)of the region of each Gauss point withinwidth / 2of the polylines (tracks of constant width).
- morphogen.laser.cells.corrugation(specimen: Specimen, amplitude: float, period: float | None, *, count: int = 1, margin: float = 10.0, resolution: int = 64)[source]¶
The centre lines of
countcorrugated tracksy = yc + H sin(2π x / P)(periodNone: straight), evenly spread over the width, through the grips.
- morphogen.laser.cells.constant_area_width(width: float, amplitude: float, period: float | None) float[source]¶
The width of a sinusoidal track of the same area as a straight one of
width(Wang 2022: the spot shrunk by defocusing,t = t0 P / L,Lthe arc length of a period).
- morphogen.laser.cells.design_tracks(grid: CellGrid, design, width: int = 2, margin: float = 5.0, cross: bool = False) list[source]¶
The centre lines (polylines, mm) of the tracks that draw a design: the runs of treated cells of each column, linked to the runs they overlap in the next column (the straightest continuation first where a track splits), crossed at their midpoint — or, with
cross, from end to end when longer than a spot ofwidthcells (a square spot then covers every cell; a real track, wider than the spot, would treat too much) —; the tracks that reach the ends of the grid continue along x bymargin(the blank is treated before the specimen is cut).
- morphogen.laser.cells.failure_measures(strain, stress, failure, *, young: float = 210000.0, cap=None) dict[source]¶
Measures of engineering curves
stress(steps x m, or steps) on the commonstrainwith the failure strainsfailure(m, infinite: none): the maximum (diffuse necking: the uniform elongation, a parabola through the points around the largest), the failure at the first of the necking and the fracture (failure_strain, aliasductility), the strength reached before it, the work up to it (MJ/m³) and the 0.2 % proof stress.cap: the strength of the weakest cross-section (m): a curve that reaches it necks there. Arrays of length m (or floats).
- morphogen.laser.cells.phase_strength(phase: Phase, young: float = 210000.0) float[source]¶
The engineering tensile strength of a phase alone (MPa): the largest
σ(p) exp(−ε)(ε = p + σ/E) up to its necking or its critical strain.
- class morphogen.laser.cells.CellEvaluation(design: ndarray, result: TensileResult, measures: dict, value: float, membrane: Membrane | None = None, fractions: ndarray | None = None)[source]¶
Bases:
objectA design and its tensile test:
measures(failure_measures(), thebudgetused),value(the objective with the penalties of the constraints).
- class morphogen.laser.cells.CellProblem(specimen: Specimen = <factory>, phases: tuple = <factory>, size: float = 1.0, element: float = 0.5, objective: str = 'energy', constraints: dict = <factory>, penalty: float = 10.0, extend: bool = True, young: float = 210000.0, poisson: float = 0.3, max_strain: float = 0.35, failure_margin: float = 0.03, fracture_radius: float | None = 1.5, layers: int = 1, case: object = None)[source]¶
Bases:
objectThe load case of a cellular design (see the module): a
specimen(its parallel part is the grid of cells ofsizemm), thephases(phase 0: the untreated sheet), the mesh (elementmm, a divisor of the cell size), theobjective(OBJECTIVES, maximized) and theconstraints{measure: [low, high]}(penaltyexp(-penalty * relative violation)on the objective).- fractions(design) ndarray[source]¶
The shares
(e, 4, phases)of the phases at the Gauss points of a design (phase indices per cell, or for two phases the densities of the second).
- budget(design) float[source]¶
The treatment budget a design uses: the mean cost of its active cells (those that hold elements).
- evaluate(design=None, *, fractions=None, record: bool = False, q: float = 1.0) CellEvaluation[source]¶
The tensile test of a design (or of the
fractionsof the phases at the Gauss points,band_fractions());record: keep the history for the replays.
- exchanges(ev: CellEvaluation, reach: float = 1.5) tuple[ndarray, ndarray][source]¶
The estimated gain of exchanging the phases of two neighbouring cells of different phases (centres within
reachcells; two phases): the pairs(c, c')(c treated, c’ not) and their gains — the moves of a track that bends or shifts without breaking, at a constant budget (a Kawasaki rule).
- estimates(ev: CellEvaluation) ndarray[source]¶
The value of the design if each cell alone took each phase
(cells, phases)(its current phase: the design’s value), from the replays.
- phase_effects(ev: CellEvaluation, base=None) list[source]¶
For each phase, the change of the work of each cell and the strain at which it would break had it alone taken that phase (
_effects()).
- move_values(ev: CellEvaluation, base, effects, moves) ndarray[source]¶
The estimated gain of each move, a set of cells and their new phases
(cells, phases), all changed together (first order: their works add up, the first of their fractures and of the others’ counts, the cross-sections change).
- derivatives(ev: CellEvaluation, density, q: float = 1.0, step: float = 0.05)[source]¶
The derivative of the value with respect to the density of each cell (two phases), by replays of the densities
x ± step(one-sided at the bounds).
- class morphogen.laser.cells.CellOptimization(design: ndarray, evaluation: CellEvaluation, history: list = <factory>, designs: list = <factory>, time_s: float = 0.0, method: str = '', evaluations: int = 0, density: ndarray | None = None)[source]¶
Bases:
objectThe result of an automaton: the best
designand itsevaluation, thehistoryof the iterations (value, measures, budget, time) and their designs.
- morphogen.laser.cells.initial_design(grid: CellGrid, budget: float, kind: str = 'band', seed: int = 0)[source]¶
A starting design of two phases: the central
bandof rows,randomcells, or (uniform) the densities equal to the budget.
- morphogen.laser.cells.symmetrize(design, orbit) ndarray[source]¶
A design made constant on the orbits (the phase most of their cells hold).
- morphogen.laser.cells.treatable(design, width: int = 2) bool[source]¶
Whether a design (two phases) can be drawn by a spot of
widthcells: every treated cell lies in a treated square ofwidthcells (the design equals its morphological opening), and the squares join by sides or corners wherever the treated cells do (no neck thinner than the spot).
- morphogen.laser.cells.make_treatable(design, width: int = 2) ndarray[source]¶
The largest part of a design a spot of
widthcells draws (its opening).
- morphogen.laser.cells.beso(problem: CellProblem, design=None, *, budget: float | None = 0.2, er: float = 0.02, radius: float = 1.5, iterations: int = 40, step: int = 1, max_change: float | None = 0.1, averaging: bool = True, symmetry=(), period: float | None = None, tol: float = 0.001, patience: int = 6, verify: bool = True, tries: int = 3, tabu_length: int = 3, moves: str = 'swap', reach: float = 2.0, candidates: int = 4, min_width: int | None = None, multigrid=None, callback=None) CellOptimization[source]¶
The bidirectional evolutionary automaton on the cells (see the module), from a
design(default: the central band of thebudget) towards thebudget(mean cost of the cells); the cells change by orbits of thesymmetryand of the translation byperiod(the failure of a periodic pattern moves to the next period if one alone changes).moves:swap— the BESO rule: the estimated benefit of each phase of each orbit over the untreated sheet, filtered overradius(mm) and averaged with the previous iteration; each orbit takes the phase of largest benefit minusλtimes its cost (λmeets the budget, which moves byerper iteration), at moststeplevels and a sharemax_changeof the cells changing.verify: at the budget, the new design replaces the current one only if its finite element test does not lower the value (the replays hold the kinematics: a gap in a track that necks, a corner where the strain concentrates escape them); refused, the changes are halved,triestimes, then their orbits keep their phase fortabu_lengthiterations.exchange(two phases, at the budget) — the exchanges of the phases of two orbits with neighbouring cells (withinreachcells), a track that bends or shifts without breaking (a Kawasaki rule): thecandidatesof largest estimated gains are tested by finite elements, the best taken if it raises the value, the others tabu.
min_width(cells, two phases): only designs a spot of this width draws are tried (treatable()): without it the automaton breaks the tracks into islands and corner contacts that carry no load and cannot be made.Stops when the value stalls for
patienceiterations or nothing changes.multigrid: the coarser cell sizes (mm) to solve first, e.g.(2, 1).
- morphogen.laser.cells.hca(problem: CellProblem, density=None, *, budget: float = 0.24, kp: float = 0.25, radius: float = 1.5, q: float = 2.0, iterations: int = 30, move: float = 0.2, levels: int | None = None, tol: float = 0.002, callback=None) CellOptimization[source]¶
The hybrid cellular automaton (see the module) on the treatment densities of two phases: each cell’s stimulus, the derivative of the value (from the replays) averaged over its neighbourhood, drives its density by
kp(relative to the largest stimulus, at mostmove) towards the set point that meets thebudget; finally rounded tolevels(default: the two phases, at the budget).
- morphogen.laser.cells.round_design(density, budget: float | None = None, levels: int | None = None)[source]¶
Densities rounded to two phases (the largest at the
budget: the share of cells treated) or tolevels+ 1 equally spaced levels (phase indices).
- morphogen.laser.cells.topology(problem: CellProblem, density=None, *, budget: float = 0.24, radius: float = 1.5, q: float = 2.0, beta: float = 1.0, beta_max: float = 16.0, iterations: int = 40, move: float = 0.15, tol: float = 0.002, callback=None) CellOptimization[source]¶
Density-based topology optimization (see the module): the densities filtered over
radiusand projected (betadoubled every 10 iterations up tobeta_max), the mixturew^q, the derivatives of the replays, MMA under the budget constraint; the result rounded to two phases at the budget.