morphogen.iga.optimization¶
Isogeometric shape optimization: the control points of the geometry as the design.
In an isogeometric analysis the geometry is its control points, and moving them moves the boundary exactly and smoothly: they are the natural variables of a shape optimization (Wall, Frenzel & Cyron 2008; Qian 2010), without the remeshing and the jagged boundaries of the methods that move the nodes of a mesh. Three levels:
the variables
x: each moves some control points of the design along given directions (ShapeDesign.variable();ShapeDesign.radial()scales the control points of a hole about its centre, with the symmetries of the cell). With thesymmetryof the pattern — mirrors, rotations (mirror(),rotation()), and the periods of the cell — a variable moves the images of its control points as well: the design keeps its symmetry, and the control points of the boundary of a cell that are a period apart move together;the design, a coarse assembly whose control points are
P(x) = P_0 + M x;the analysis, a refinement of the design (elements cut, degree raised): for given weights its control points are linear in those of the design,
Q = T P(refinement()). The geometry is the same at both levels; the design keeps few variables, the analysis its accuracy.
Sensitivities. Let A(u, v) = int (E_u + eps(u)) : D : (E_v + eps(v)) dOmega for two
fields of given unknowns and uniform strains. Moving the control point a by dQ
moves the points by V = R_a dQ; then d(dOmega) = div V dOmega and d(grad u) =
-grad u grad V, so that:
dA / dQ_a = int Sigma grad R_a dOmega,
Sigma = (eps_u : D : eps_v) 1 - grad u^T sigma_v - grad v^T sigma_u,
the energy-momentum tensor of Eshelby for the pair: the gradients are analytical, one
integral per pair of fields and no further solution. For a structure under given loads
(K u = f) the compliance c = f . u has dc/dQ = -dA(u, u)/dQ; for a periodic
cell the effective tensor is C_IJ = A(chi_I, chi_J) / |Y| with the fluctuations of
morphogen.iga.homogenization, and dC_IJ/dQ = (dA/dQ) / |Y| since each
fluctuation makes its energy stationary. The area of the material has dA/dQ_a = int
grad R_a dOmega. The chain d/dx = M^T T^T d/dQ brings them to the variables.
Optimization (optimize(), optimize_cell(), optimize_structure()):
sequential quadratic programming (SLSQP of SciPy) or the method of moving asymptotes
(morphogen.optimization.mma), with bounds on the variables that keep the patches
from folding. The objectives and constraints of a cell are functions of its effective
tensor and of its fraction of material — a modulus, Poisson’s ratio, the distance to a
target tensor —, differentiated numerically with respect to these few numbers; linear
constraints on the variables (linear) keep sizes of the geometry — the width of a
ligament, the thickness of a member — since the control points are linear in them.
- exception morphogen.iga.optimization.FoldedDesign[source]¶
Bases:
ValueErrorThe variables of a design fold one of its patches (a Jacobian that is not positive): no analysis there.
- morphogen.iga.optimization.mirror(axis: int, at: float = 0.0, dim: int = 2) tuple[ndarray, ndarray][source]¶
The mirror in the line (plane) where the coordinate
axisisat, as an operationx -> matrix x + shift(for thesymmetryof a variable).
- morphogen.iga.optimization.rotation(angle: float, centre=(0.0, 0.0)) tuple[ndarray, ndarray][source]¶
The rotation of the plane by
angle(degrees, anticlockwise) aboutcentre, as an operationx -> matrix x + shift(for thesymmetryof a variable).
- morphogen.iga.optimization.stress_tensors(flux: ndarray, dim: int, nd: int) ndarray[source]¶
The fluxes of the points as tensors (… x unknowns x dim): the stress tensors of Voigt’s components (elasticity), or the flux vectors as one row (conduction).
- morphogen.iga.optimization.energy_gradients(analysis: Analysis, fields, uniform=None) ndarray[source]¶
The derivatives of
A(u_i, u_j)(see the module) with respect to the control points of the analysis, for the fieldsfields(unknowns x m) and their uniform strainsuniform(components x m; none by default): m x m x control points x dim.
- morphogen.iga.optimization.measure_gradient(analysis: Analysis) ndarray[source]¶
The derivative of the area (volume) of the assembly with respect to its control points:
int grad R_a(control points x dim).
- class morphogen.iga.optimization.ShapeDesign(model, *, subdivisions=4, elevate=1)[source]¶
Bases:
objectA design (see the module): the coarse assembly
modeland the refinement of its analysis (subdivisionsof every element and degrees raised byelevate, one value or one per direction). Variables are added byvariable()andradial().- property n: int¶
The number of variables.
- property moves: list[tuple[ndarray, ndarray]]¶
For each variable, the control points of the design that it moves and their directions (the moves of a unit of the variable).
- variable(nodes, directions, lower: float = -inf, upper: float = inf, name: str | None = None, symmetry=None) int[source]¶
A variable that moves the control points
nodesof the design by its value times theirdirections(one vector each, or one for all); returns its index.symmetry: operations(matrix, shift)that map the design onto itself,x -> matrix x + shift(mirror(),rotation()), up to the periods of itslattice. The variable then moves the images of its control points by all the operations that these generate, along the images of their directions —nodesare those of one copy; a control point that an operation leaves in place keeps the part of its direction that the operation keeps. With an empty list, only the control points a period apart move together.
- radial(nodes, centre, lower: float = -0.3, upper: float = 0.3, symmetry: str | None = None) list[int][source]¶
Variables that scale the positions of control points about
centre:P = centre + (1 + x) (P_0 - centre),xbetweenlowerandupper. One variable per control point, or per set of control points that thesymmetryof the cell maps onto each other:"d2"(the two mirrors of a rectangle through the centre) or"d4"(those of a square, diagonals included).
- design_model(x) Multipatch[source]¶
The design moved by the variables
x.
- analysis_model(x) Multipatch[source]¶
The refined assembly of the analysis for the variables
x; aFoldedDesignif a patch of the design folds there (a negative Jacobian, its boundary included:jacobians()).
- class morphogen.iga.optimization.CellResponse(tensor: ndarray, fraction: float, d_tensor: ndarray, d_fraction: ndarray, solution: CellSolution)[source]¶
Bases:
objectThe effective
tensorof a cell and itsfractionof material for some variables, with their derivatives (d_tensor: n x n x variables;d_fraction: variables) and the solution.
- morphogen.iga.optimization.cell_response(design: ShapeDesign, x, materials, *, physics: str = 'elastic', plane: str = 'strain') CellResponse[source]¶
The effective tensor and the fraction of material of the periodic cell of a design for the variables
x, and their derivatives with respect tox.
- class morphogen.iga.optimization.StructureResponse(compliance: float, measure: float, d_compliance: ndarray, d_measure: ndarray, u: ndarray, analysis: Analysis)[source]¶
Bases:
objectThe
compliancef . uof a structure and themeasure(area, volume) of its material, with their derivatives with respect to the variables, the unknowns and the analysis.
- morphogen.iga.optimization.structure_response(design: ShapeDesign, x, materials, loads: Callable, supports: Callable, *, plane: str = 'strain') StructureResponse[source]¶
The compliance of the structure of a design under the nodal forces
loads(analysis)with the unknownssupports(analysis)fixed (functions of theAnalysis: the loads must not depend on the variables — tractions on sides that the design does not move).
- class morphogen.iga.optimization.ShapeResult(x: ndarray, design: Multipatch, analysis: Multipatch, objective: float, constraints: ndarray, iterations: int, converged: bool, history: list = <factory>, tensor: ndarray | None = None, fraction: float | None = None, time_s: float = 0.0, message: str = '')[source]¶
Bases:
objectAn optimized shape: the variables
x, thedesignand theanalysisassemblies, theobjectiveand theconstraintsthere, thehistoryof the iterations (objective, largest constraint, variables) and, for a cell, its effectivetensorandfractionof material.
- morphogen.iga.optimization.optimize(evaluate: Callable, x0, lower, upper, *, method: str = 'slsqp', maxiter: int = 100, tolerance: float = 1e-07, move: float = 0.2, callback: Callable | None = None)[source]¶
Minimize
f(x)subject tog_i(x) <= 0andlower <= x <= upper, withevaluate(x) -> (f, df, g, dg)(g: m values,dg: m x n).method:"slsqp"(sequential quadratic programming, SciPy) or"mma"(moving asymptotes).movebounds the steps as a share of the bounds: each step of MMA, and the first of SLSQP (whose objective is scaled for it; the later ones follow its estimate of the curvature). Returns(x, history, converged, message): the history holds the points that the iterations kept, andcallback(iteration, x, f, g)is called for each. A trial point whereevaluateraisesFoldedDesignis turned down: the line search of SLSQP shortens its step, the step of MMA is halved.
- morphogen.iga.optimization.optimize_cell(design: ShapeDesign, materials, objective: Callable, constraints=(), *, linear=None, x0=None, physics: str = 'elastic', plane: str = 'strain', method: str = 'slsqp', maxiter: int = 100, tolerance: float = 1e-07, move: float = 0.2, callback: Callable | None = None) ShapeResult[source]¶
The shape of a periodic cell that minimizes
objective(tensor, fraction)underconstraint(tensor, fraction) <= 0for each of theconstraints: functions of the effective tensor of the cell (Voigt’s notation) and of its fraction of material — for instancelambda c, f: -plane_constants(c)["bulk_modulus"]withlambda c, f: f - 0.6.linear = (A, b)adds the constraintsA x <= bon the variables (sizes of the geometry: the control points are linear in them); they follow the others in theconstraintsof the result, asA x - b. The variables start fromx0(zeros by default: the design as it is).
- morphogen.iga.optimization.optimize_structure(design: ShapeDesign, materials, loads: Callable, supports: Callable, *, measure: float | None = None, x0=None, plane: str = 'strain', method: str = 'slsqp', maxiter: int = 100, tolerance: float = 1e-07, move: float = 0.2, callback: Callable | None = None) ShapeResult[source]¶
The shape of a structure of smallest compliance under given loads (
structure_response()) whose material has at most the area (volume)measure(by default that of the design as it is).