using TopOpt, LinearAlgebra
using StatsFuns: logsumexp
using WGLMakie
WGLMakie.activate!(; resize_to=:parent)
using Bonito
if haskey(ENV, "QUARTO_PROJECT_DIR")
Bonito.Page(exportable=true, offline=true)
else
Bonito.browser_display()
end
display_app(app) = display(app)Global Stress: Relaxation and Aggregation for Stress Constraints
Description
This tutorial solves the classical stress-constrained topology optimization problem: minimize volume subject to a von Mises stress limit,
\[\min_{\rho}\; V(\rho) \quad \text{s.t.} \quad \sigma^{vm}_e \le \sigma_{\lim} \;\; \forall e\]
Stress constraints are fundamentally harder than compliance constraints for two independent reasons (Verbart et al., 2017; Le et al., 2010):
- Singular optima. The microscopic stress \(\sigma = C_0 : \varepsilon\) stays finite as an element’s density \(\rho \to 0\), so the stress constraint blocks any gradient-driven path that removes a load-bearing member: the true optima lie in degenerate subspaces that gradient methods cannot reach (Sved & Ginos, 1968; Cheng & Guo, 1997).
- Locality. Stress is an element-wise state variable, giving thousands of local constraints — as many as there are design variables — which is expensive to handle directly (see the
local_stresstutorial).
The standard toolkit, demonstrated here, combines:
- Relaxation to remove the singularity: the qp-approach uses a relaxed stress \(\tilde\sigma_e = \rho_e^{q}\,\sigma_e\) with \(q < p\) (Bruggi, 2008; Le et al., 2010 use \(q = 1/2\) with SIMP \(p = 3\)), while ε-relaxation replaces the constraint by \(\rho_e(\sigma_e/\sigma_{\lim} - 1) \le \epsilon\) (Cheng & Guo, 1997; Duysinx & Bendsøe, 1998). Both make the constraint automatically satisfied at sufficiently low density.
- Aggregation to collapse the local constraints into one global smooth measure: the p-norm (Duysinx & Sigmund, 1998) or the Kreisselmeier–Steinhauser (KS) function (Yang & Chen, 1996), with adaptive normalization to control the true maximum (Le et al., 2010).
We compare three formulations on the classical L-bracket benchmark. All three produce the signature feature of stress-constrained design — the rounded re-entrant corner, which a compliance-driven design keeps sharp: the relaxed-stress p-mean with adaptive normalization, the conservative KS upper bound, and ε-relaxation of the microscopic stress enforced by the augmented Lagrangian.
Setup
WGLMakie.activate!(; resize_to=:parent) selects the browser renderer and fills the Quarto output column. Bonito.Page(exportable=true, offline=true) embeds the assets needed by visualize(...; static=true) in the Quarto output, so the visualization does not require a running Julia process.
The benchmark problem
The L-bracket: fixed top edge, downward load at the end of the horizontal arm. The re-entrant corner is a stress concentrator, which is what makes this the standard stress benchmark.
A point force on a continuum produces a singular stress field that the mesh regularizes to ~f / element_size; the resulting “peak stress” is a mesh-dependent load-introduction artifact, not a property of the topology. We therefore distribute the load over 5 nodes with load_width, which removes the singularity. (Alternatives used in the literature: exclude a fixed region around the load from the aggregation, or use regional stress measures.)
E, ν, f = 1.0, 0.3, 1.0
problem = LBeam(
;
length=50, height=50, upperslab=25, lowerslab=25, E=E, ν=ν, force=f,
load_width=5, # distribute the load over 5 nodes
)
xmin = 1e-3
# Fixed SIMP exponent p = 3, as standard for stress problems (Le et al., 2010)
solver = FEASolver(DirectSolver, problem; xmin=xmin, penalty=PowerPenaltyFun(3.0))
filter = DensityFilterFun(solver; rmin=2.0)
volfrac = VolumeFun(solver)
N = length(solver.vars)Microscopic vs. relaxed stress
von_mises_stress_function computes the microscopic stress \(\sigma = C_0 : \varepsilon\) with the base Young’s modulus (the physically consistent choice for porous materials; Duysinx & Bendsøe, 1998). Because it is finite at zero density, it exhibits the singularity problem. Passing stress_exponent = q > 0 returns instead the relaxed stress \(\tilde\sigma_e = \rho_e^q \sigma_e\), which vanishes at zero density and thereby makes singular optima reachable. The relaxation acts on the physical density (not the penalized stiffness density), so it is independent of the SIMP exponent p used for the stiffness.
σ_micro = von_mises_stress_function(solver)
σ_rel = von_mises_stress_function(solver; stress_exponent=0.5)
x_solid = ones(N)
σ_solid = σ_rel(filter(PseudoDensities(x_solid)))
println("peak stress of the solid L-bracket: ", maximum(σ_solid))peak stress of the solid L-bracket: 0.5984185129580194
The stress limit
The stress limit is a material property, not a multiple of the solid design’s average stress: fully-stressed low-volume designs run hotter than the solid block. Here we set σ_lim to 1.75× the solid block’s peak, which places the optimum at roughly 40–60% volume — the interesting regime for this benchmark.
σlim = 1.75 * maximum(σ_solid)
obj = x -> volfrac(filter(PseudoDensities(x)))
alg = MMA87(; dualoptimizer=ConjugateGradient())
function run_chunks(
constr, x0, chunks, maxiter; update! = (x, j) -> nothing, label = "", keep_best = true
)
model = Model(obj)
addvar!(model, zeros(N), ones(N))
add_ineq_constraint!(model, constr)
x = copy(x0)
for j in 1:chunks
update!(x, j)
tol = j == chunks ? Nonconvex.Tolerance(; kkt=1e-4) : Nonconvex.Tolerance(; kkt=1e-3)
options = MMAOptions(; maxiter, tol, keep_best)
r = optimize(model, alg, x; options)
x = r.minimizer
println("$label chunk $j: V=$(round(obj(x), digits=3)), constr=$(round(constr(x), digits=4))")
end
return x
endApproach 1: relaxed stress + normalized p-norm + adaptive normalization
The normalized p-norm \(\sigma_{PN} = \big(\frac{1}{N}\sum_e \tilde\sigma_e^P\big)^{1/P}\) is a lower bound on the maximum stress (equality only for a uniform stress state), so it cannot be constrained directly. Following Le et al. (2010), we rescale it by an adaptive factor \(c \approx \max(\tilde\sigma)/\sigma_{PN}\) — updated between optimization chunks — so that \(c\,\sigma_{PN}\) tracks the true maximum. The p-norm’s gradient is spread over all moderately stressed elements, which makes this the most robust of the three formulations in practice.
P = 8
c = Ref(maximum(σ_solid) / (norm(σ_solid, P) / N^(1 / P)))
constr_pnorm = x -> begin
s = σ_rel(filter(PseudoDensities(x)))
c[] * (norm(s, P) / N^(1 / P)) / σlim - 1
end
# Adaptive normalization: c tracks max(σ̃)/σ_PN between chunks
update_pnorm! = x -> begin
s = σ_rel(filter(PseudoDensities(x)))
c[] = maximum(s) / (norm(s, P) / N^(1 / P))
end
x1 = run_chunks(constr_pnorm, x_solid, 4, 70; update! = (x, j) -> update_pnorm!(x), label = "p-norm")[ Info: iter obj Δobj violation kkt_residual [ Info: 0 1.0e+00 Inf 0.0e+00 4.3e-01 [ Info: 1 6.6e-01 3.4e-01 1.8e-01 1.2e-02 [ Info: 2 4.8e-01 1.8e-01 3.0e+00 4.0e-01 [ Info: 3 1.5e-01 3.3e-01 4.7e+01 4.5e-01 [ Info: 4 5.4e-02 9.7e-02 1.0e+02 8.0e-02 [ Info: 5 8.5e-02 3.1e-02 5.3e+01 1.7e+01 [ Info: 6 5.0e-02 3.5e-02 5.9e+01 6.7e-02 [ Info: 7 1.2e-01 6.7e-02 5.2e+01 1.0e+01 [ Info: 8 7.5e-02 4.3e-02 5.4e+01 1.9e-01 [ Info: 9 3.8e-02 3.7e-02 7.7e+01 6.6e-02 [ Info: 10 8.7e-02 5.0e-02 4.9e+01 9.6e+00 [ Info: 11 1.4e-01 4.9e-02 3.8e+01 7.6e+00 [ Info: 12 1.5e-01 8.3e-03 3.9e+01 7.7e+00 [ Info: 13 1.5e-01 6.0e-03 3.5e+01 6.9e+00 [ Info: 14 2.0e-01 5.2e-02 3.0e+01 5.9e+00 [ Info: 15 3.2e-01 1.2e-01 2.6e+01 1.4e+02 [ Info: 16 3.9e-01 7.0e-02 2.4e+01 1.3e+02 [ Info: 17 3.2e-01 7.1e-02 2.3e+01 1.2e+02 [ Info: 18 3.4e-01 2.3e-02 1.9e+01 9.8e+01 [ Info: 19 1.5e-01 1.9e-01 3.8e+01 1.5e-02 [ Info: 20 2.5e-01 9.9e-02 2.2e+01 2.9e+01 [ Info: 21 4.1e-01 1.6e-01 7.7e+00 9.9e+00 [ Info: 22 4.3e-01 1.4e-02 4.5e+00 5.9e+00 [ Info: 23 4.6e-01 3.0e-02 3.4e+00 4.4e+00 [ Info: 24 5.2e-01 6.7e-02 2.0e+00 2.7e+01 [ Info: 25 5.8e-01 5.3e-02 1.2e+00 1.7e+01 [ Info: 26 6.2e-01 4.1e-02 8.2e-01 1.2e+01 [ Info: 27 6.6e-01 4.1e-02 5.6e-01 7.8e+00 [ Info: 28 6.7e-01 1.1e-02 3.8e-01 5.3e+00 [ Info: 29 6.9e-01 2.0e-02 3.2e-01 4.5e+00 [ Info: 30 6.5e-01 3.6e-02 4.1e-01 5.7e+00 [ Info: 31 5.4e-01 1.1e-01 1.8e+00 3.2e-01 [ Info: 32 3.9e-01 1.5e-01 4.0e+00 4.5e-01 [ Info: 33 2.9e-01 1.0e-01 1.4e+01 1.5e-01 [ Info: 34 1.7e-01 1.2e-01 3.2e+01 2.6e-02 [ Info: 35 1.4e-01 3.8e-02 4.4e+01 9.1e-02 [ Info: 36 1.7e-01 3.1e-02 2.7e+01 9.3e-01 [ Info: 37 3.1e-01 1.5e-01 1.6e+01 1.1e+02 [ Info: 38 2.9e-01 2.4e-02 1.1e+01 7.6e+01 [ Info: 39 3.4e-01 5.3e-02 1.3e+01 9.1e+01 [ Info: 40 2.2e-01 1.2e-01 1.7e+01 1.9e-01 [ Info: 41 1.7e-01 5.1e-02 1.6e+01 1.1e-01 [ Info: 42 2.6e-01 8.6e-02 7.9e+00 5.2e+00 [ Info: 43 3.0e-01 4.6e-02 5.6e+00 3.7e+00 [ Info: 44 3.3e-01 2.7e-02 4.5e+00 3.0e+00 [ Info: 45 3.4e-01 9.3e-03 3.9e+00 2.6e+00 [ Info: 46 3.4e-01 2.6e-03 3.3e+00 2.2e+00 [ Info: 47 3.6e-01 1.3e-02 2.8e+00 1.9e+00 [ Info: 48 3.7e-01 1.3e-02 2.4e+00 1.6e+00 [ Info: 49 3.8e-01 1.2e-02 2.1e+00 1.4e+00 [ Info: 50 3.9e-01 1.1e-02 1.8e+00 1.2e+00 [ Info: 51 4.0e-01 1.1e-02 1.5e+00 1.0e+00 [ Info: 52 4.1e-01 1.0e-02 1.3e+00 8.7e-01 [ Info: 53 4.2e-01 1.0e-02 1.1e+00 7.5e-01 [ Info: 54 4.3e-01 8.8e-03 9.6e-01 6.3e-01 [ Info: 55 4.4e-01 9.3e-03 8.1e-01 5.4e-01 [ Info: 56 5.2e-01 8.2e-02 5.9e-01 3.0e+01 [ Info: 57 5.5e-01 3.1e-02 4.9e-01 2.5e+01 [ Info: 58 5.7e-01 1.8e-02 3.5e-01 1.7e+01 [ Info: 59 6.1e-01 3.4e-02 2.6e-01 1.3e+01 [ Info: 60 6.2e-01 1.1e-02 1.9e-01 9.4e+00 [ Info: 61 6.3e-01 1.1e-02 1.3e-01 6.4e+00 [ Info: 62 6.4e-01 1.2e-02 7.0e-02 3.5e+00 [ Info: 63 6.7e-01 2.8e-02 2.4e-02 1.8e+00 [ Info: 64 6.0e-01 6.6e-02 7.8e-02 1.0e-01 [ Info: 65 5.1e-01 9.3e-02 5.4e-01 8.4e-02 [ Info: 66 3.9e-01 1.2e-01 2.2e+00 1.2e-01 [ Info: 67 2.6e-01 1.3e-01 9.4e+00 9.0e-02 [ Info: 68 1.5e-01 1.1e-01 3.7e+01 8.1e-02 [ Info: 69 1.4e-01 1.7e-02 4.4e+01 2.9e-01 [ Info: 70 2.8e-01 1.4e-01 1.6e+01 4.5e+01 p-norm chunk 1: V=0.601, constr=0.078 [ Info: iter obj Δobj violation kkt_residual [ Info: 0 6.0e-01 Inf 0.0e+00 1.6e-01 [ Info: 1 4.5e-01 1.5e-01 6.6e-01 7.4e-02 [ Info: 2 2.9e-01 1.6e-01 4.0e+00 2.2e-01 [ Info: 3 1.7e-01 1.2e-01 4.3e+01 5.9e-01 [ Info: 4 6.1e-02 1.1e-01 8.4e+01 2.3e-02 [ Info: 5 2.5e-02 3.6e-02 6.3e+01 1.9e-02 [ Info: 6 3.1e-02 5.3e-03 9.3e+01 9.9e-01 [ Info: 7 1.4e-02 1.6e-02 6.1e+01 3.5e-02 [ Info: 8 5.6e-02 4.1e-02 4.0e+01 6.8e+00 [ Info: 9 6.7e-02 1.2e-02 5.4e+01 9.1e+00 [ Info: 10 3.5e-02 3.2e-02 7.9e+01 1.7e+01 [ Info: 11 1.2e-01 8.7e-02 4.9e+01 3.3e+02 [ Info: 12 8.2e-02 4.0e-02 4.7e+01 3.2e+02 [ Info: 13 1.7e-01 9.2e-02 4.4e+01 3.0e+02 [ Info: 14 2.0e-01 2.6e-02 2.8e+01 2.0e+02 [ Info: 15 2.0e-01 1.6e-04 2.2e+01 3.4e+00 [ Info: 16 1.5e-01 4.9e-02 2.2e+01 3.3e+00 [ Info: 17 1.8e-01 3.3e-02 1.8e+01 2.8e+00 [ Info: 18 1.9e-01 8.9e-03 1.8e+01 2.8e+01 [ Info: 19 2.1e-01 1.8e-02 2.9e+01 4.5e+01 [ Info: 20 2.2e-01 1.1e-02 3.2e+01 9.1e+00 [ Info: 21 1.5e-01 7.0e-02 2.4e+01 6.8e+00 [ Info: 22 2.1e-01 6.2e-02 1.7e+01 4.9e+00 [ Info: 23 2.2e-01 4.5e-03 1.9e+01 5.4e+00 [ Info: 24 1.9e-01 3.2e-02 1.8e+01 5.0e+00 [ Info: 25 2.6e-01 7.1e-02 1.3e+01 2.5e+01 [ Info: 26 3.0e-01 4.2e-02 1.3e+01 2.4e+01 [ Info: 27 2.8e-01 1.7e-02 1.7e+01 3.2e+01 [ Info: 28 2.9e-01 4.8e-03 2.7e+01 5.1e+01 [ Info: 29 2.5e-01 3.3e-02 3.2e+01 6.1e+01 [ Info: 30 2.4e-01 1.9e-02 3.2e+01 6.1e+01 [ Info: 31 2.4e-01 1.1e-03 3.1e+01 5.8e+01 [ Info: 32 2.5e-01 8.3e-03 3.1e+01 5.8e+01 [ Info: 33 2.7e-01 2.8e-02 2.7e+01 5.0e+01 [ Info: 34 2.4e-01 2.9e-02 2.8e+01 5.4e+01 [ Info: 35 2.2e-01 2.5e-02 2.5e+01 4.7e+01 [ Info: 36 2.1e-01 1.2e-02 2.6e+01 4.9e+01 [ Info: 37 2.3e-01 2.1e-02 2.0e+01 3.8e+01 [ Info: 38 2.1e-01 1.4e-02 2.0e+01 3.7e+01 [ Info: 39 2.1e-01 8.1e-03 2.1e+01 4.4e+01 [ Info: 40 2.0e-01 1.1e-02 1.4e+01 2.7e+01 [ Info: 41 2.3e-01 3.4e-02 1.2e+01 3.5e+01 [ Info: 42 1.8e-01 4.9e-02 1.4e+01 4.8e-03 [ Info: 43 1.8e-01 3.4e-03 1.2e+01 8.6e-01 [ Info: 44 1.8e-01 2.4e-04 1.9e+01 1.4e+00 [ Info: 45 1.6e-01 2.3e-02 1.4e+01 6.0e-03 [ Info: 46 1.7e-01 1.3e-02 1.1e+01 1.2e+00 [ Info: 47 1.8e-01 6.2e-03 1.0e+01 1.0e+00 [ Info: 48 1.8e-01 6.2e-03 9.1e+00 9.4e-01 [ Info: 49 1.9e-01 9.9e-03 8.1e+00 8.4e-01 [ Info: 50 2.0e-01 8.1e-03 7.2e+00 7.5e-01 [ Info: 51 2.1e-01 8.2e-03 6.4e+00 6.7e-01 [ Info: 52 2.2e-01 1.1e-02 5.6e+00 5.8e-01 [ Info: 53 2.3e-01 8.0e-03 4.9e+00 5.1e-01 [ Info: 54 2.4e-01 1.1e-02 4.2e+00 4.3e-01 [ Info: 55 2.9e-01 4.5e-02 3.0e+00 1.9e+01 [ Info: 56 3.2e-01 3.5e-02 2.1e+00 1.3e+01 [ Info: 57 3.5e-01 2.6e-02 1.7e+00 1.0e+01 [ Info: 58 3.7e-01 2.3e-02 1.3e+00 8.1e+00 [ Info: 59 4.0e-01 2.5e-02 1.0e+00 6.4e+00 [ Info: 60 4.2e-01 2.0e-02 8.3e-01 5.1e+00 [ Info: 61 4.4e-01 2.4e-02 6.9e-01 4.3e+00 [ Info: 62 4.6e-01 1.9e-02 5.8e-01 3.6e+00 [ Info: 63 4.7e-01 1.5e-02 4.8e-01 3.0e+00 [ Info: 64 4.9e-01 1.5e-02 3.9e-01 2.4e+00 [ Info: 65 5.0e-01 1.2e-02 3.1e-01 1.9e+00 [ Info: 66 5.1e-01 1.4e-02 2.3e-01 1.4e+00 [ Info: 67 5.2e-01 1.1e-02 1.7e-01 1.0e+00 [ Info: 68 5.4e-01 1.1e-02 1.1e-01 6.6e-01 [ Info: 69 5.9e-01 5.3e-02 8.5e-02 8.2e+00 [ Info: 70 5.1e-01 8.2e-02 2.6e-01 4.0e-01 p-norm chunk 2: V=0.601, constr=-0.1556 [ Info: iter obj Δobj violation kkt_residual [ Info: 0 6.0e-01 Inf 0.0e+00 1.6e-01 [ Info: 1 4.5e-01 1.5e-01 6.6e-01 7.4e-02 [ Info: 2 2.9e-01 1.6e-01 4.0e+00 2.2e-01 [ Info: 3 1.7e-01 1.2e-01 4.3e+01 5.9e-01 [ Info: 4 6.1e-02 1.1e-01 8.4e+01 2.3e-02 [ Info: 5 2.5e-02 3.6e-02 6.3e+01 1.9e-02 [ Info: 6 3.1e-02 5.3e-03 9.3e+01 9.9e-01 [ Info: 7 1.4e-02 1.6e-02 6.1e+01 3.5e-02 [ Info: 8 5.6e-02 4.1e-02 4.0e+01 6.8e+00 [ Info: 9 6.7e-02 1.2e-02 5.4e+01 9.1e+00 [ Info: 10 3.5e-02 3.2e-02 7.9e+01 1.7e+01 [ Info: 11 1.2e-01 8.7e-02 4.9e+01 3.3e+02 [ Info: 12 8.2e-02 4.0e-02 4.7e+01 3.2e+02 [ Info: 13 1.7e-01 9.2e-02 4.4e+01 3.0e+02 [ Info: 14 2.0e-01 2.6e-02 2.8e+01 2.0e+02 [ Info: 15 2.0e-01 1.6e-04 2.2e+01 3.4e+00 [ Info: 16 1.5e-01 4.9e-02 2.2e+01 3.3e+00 [ Info: 17 1.8e-01 3.3e-02 1.8e+01 2.8e+00 [ Info: 18 1.9e-01 8.9e-03 1.8e+01 2.8e+01 [ Info: 19 2.1e-01 1.8e-02 2.9e+01 4.5e+01 [ Info: 20 2.2e-01 1.1e-02 3.2e+01 9.1e+00 [ Info: 21 1.5e-01 7.0e-02 2.4e+01 6.8e+00 [ Info: 22 2.1e-01 6.2e-02 1.7e+01 4.9e+00 [ Info: 23 2.2e-01 4.5e-03 1.9e+01 5.4e+00 [ Info: 24 1.9e-01 3.2e-02 1.8e+01 5.0e+00 [ Info: 25 2.6e-01 7.1e-02 1.3e+01 2.5e+01 [ Info: 26 3.0e-01 4.2e-02 1.3e+01 2.4e+01 [ Info: 27 2.8e-01 1.7e-02 1.7e+01 3.2e+01 [ Info: 28 2.9e-01 4.8e-03 2.7e+01 5.1e+01 [ Info: 29 2.5e-01 3.3e-02 3.2e+01 6.1e+01 [ Info: 30 2.4e-01 1.9e-02 3.2e+01 6.1e+01 [ Info: 31 2.4e-01 1.1e-03 3.1e+01 5.8e+01 [ Info: 32 2.5e-01 8.3e-03 3.1e+01 5.8e+01 [ Info: 33 2.7e-01 2.8e-02 2.7e+01 5.0e+01 [ Info: 34 2.4e-01 2.9e-02 2.8e+01 5.4e+01 [ Info: 35 2.2e-01 2.5e-02 2.5e+01 4.7e+01 [ Info: 36 2.1e-01 1.2e-02 2.6e+01 4.9e+01 [ Info: 37 2.3e-01 2.1e-02 2.0e+01 3.8e+01 [ Info: 38 2.1e-01 1.4e-02 2.0e+01 3.7e+01 [ Info: 39 2.1e-01 8.1e-03 2.1e+01 4.4e+01 [ Info: 40 2.0e-01 1.1e-02 1.4e+01 2.7e+01 [ Info: 41 2.3e-01 3.4e-02 1.2e+01 3.5e+01 [ Info: 42 1.8e-01 4.9e-02 1.4e+01 4.8e-03 [ Info: 43 1.8e-01 3.4e-03 1.2e+01 8.6e-01 [ Info: 44 1.8e-01 2.4e-04 1.9e+01 1.4e+00 [ Info: 45 1.6e-01 2.3e-02 1.4e+01 6.0e-03 [ Info: 46 1.7e-01 1.3e-02 1.1e+01 1.2e+00 [ Info: 47 1.8e-01 6.2e-03 1.0e+01 1.0e+00 [ Info: 48 1.8e-01 6.2e-03 9.1e+00 9.4e-01 [ Info: 49 1.9e-01 9.9e-03 8.1e+00 8.4e-01 [ Info: 50 2.0e-01 8.1e-03 7.2e+00 7.5e-01 [ Info: 51 2.1e-01 8.2e-03 6.4e+00 6.7e-01 [ Info: 52 2.2e-01 1.1e-02 5.6e+00 5.8e-01 [ Info: 53 2.3e-01 8.0e-03 4.9e+00 5.1e-01 [ Info: 54 2.4e-01 1.1e-02 4.2e+00 4.3e-01 [ Info: 55 2.9e-01 4.5e-02 3.0e+00 1.9e+01 [ Info: 56 3.2e-01 3.5e-02 2.1e+00 1.3e+01 [ Info: 57 3.5e-01 2.6e-02 1.7e+00 1.0e+01 [ Info: 58 3.7e-01 2.3e-02 1.3e+00 8.1e+00 [ Info: 59 4.0e-01 2.5e-02 1.0e+00 6.4e+00 [ Info: 60 4.2e-01 2.0e-02 8.3e-01 5.1e+00 [ Info: 61 4.4e-01 2.4e-02 6.9e-01 4.3e+00 [ Info: 62 4.6e-01 1.9e-02 5.8e-01 3.6e+00 [ Info: 63 4.7e-01 1.5e-02 4.8e-01 3.0e+00 [ Info: 64 4.9e-01 1.5e-02 3.9e-01 2.4e+00 [ Info: 65 5.0e-01 1.2e-02 3.1e-01 1.9e+00 [ Info: 66 5.1e-01 1.4e-02 2.3e-01 1.4e+00 [ Info: 67 5.2e-01 1.1e-02 1.7e-01 1.0e+00 [ Info: 68 5.4e-01 1.1e-02 1.1e-01 6.6e-01 [ Info: 69 5.9e-01 5.3e-02 8.5e-02 8.2e+00 [ Info: 70 5.1e-01 8.2e-02 2.6e-01 4.0e-01 p-norm chunk 3: V=0.601, constr=-0.1556 [ Info: iter obj Δobj violation kkt_residual [ Info: 0 6.0e-01 Inf 0.0e+00 1.6e-01 [ Info: 1 4.5e-01 1.5e-01 6.6e-01 7.4e-02 [ Info: 2 2.9e-01 1.6e-01 4.0e+00 2.2e-01 [ Info: 3 1.7e-01 1.2e-01 4.3e+01 5.9e-01 [ Info: 4 6.1e-02 1.1e-01 8.4e+01 2.3e-02 [ Info: 5 2.5e-02 3.6e-02 6.3e+01 1.9e-02 [ Info: 6 3.1e-02 5.3e-03 9.3e+01 9.9e-01 [ Info: 7 1.4e-02 1.6e-02 6.1e+01 3.5e-02 [ Info: 8 5.6e-02 4.1e-02 4.0e+01 6.8e+00 [ Info: 9 6.7e-02 1.2e-02 5.4e+01 9.1e+00 [ Info: 10 3.5e-02 3.2e-02 7.9e+01 1.7e+01 [ Info: 11 1.2e-01 8.7e-02 4.9e+01 3.3e+02 [ Info: 12 8.2e-02 4.0e-02 4.7e+01 3.2e+02 [ Info: 13 1.7e-01 9.2e-02 4.4e+01 3.0e+02 [ Info: 14 2.0e-01 2.6e-02 2.8e+01 2.0e+02 [ Info: 15 2.0e-01 1.6e-04 2.2e+01 3.4e+00 [ Info: 16 1.5e-01 4.9e-02 2.2e+01 3.3e+00 [ Info: 17 1.8e-01 3.3e-02 1.8e+01 2.8e+00 [ Info: 18 1.9e-01 8.9e-03 1.8e+01 2.8e+01 [ Info: 19 2.1e-01 1.8e-02 2.9e+01 4.5e+01 [ Info: 20 2.2e-01 1.1e-02 3.2e+01 9.1e+00 [ Info: 21 1.5e-01 7.0e-02 2.4e+01 6.8e+00 [ Info: 22 2.1e-01 6.2e-02 1.7e+01 4.9e+00 [ Info: 23 2.2e-01 4.5e-03 1.9e+01 5.4e+00 [ Info: 24 1.9e-01 3.2e-02 1.8e+01 5.0e+00 [ Info: 25 2.6e-01 7.1e-02 1.3e+01 2.5e+01 [ Info: 26 3.0e-01 4.2e-02 1.3e+01 2.4e+01 [ Info: 27 2.8e-01 1.7e-02 1.7e+01 3.2e+01 [ Info: 28 2.9e-01 4.8e-03 2.7e+01 5.1e+01 [ Info: 29 2.5e-01 3.3e-02 3.2e+01 6.1e+01 [ Info: 30 2.4e-01 1.9e-02 3.2e+01 6.1e+01 [ Info: 31 2.4e-01 1.1e-03 3.1e+01 5.8e+01 [ Info: 32 2.5e-01 8.3e-03 3.1e+01 5.8e+01 [ Info: 33 2.7e-01 2.8e-02 2.7e+01 5.0e+01 [ Info: 34 2.4e-01 2.9e-02 2.8e+01 5.4e+01 [ Info: 35 2.2e-01 2.5e-02 2.5e+01 4.7e+01 [ Info: 36 2.1e-01 1.2e-02 2.6e+01 4.9e+01 [ Info: 37 2.3e-01 2.1e-02 2.0e+01 3.8e+01 [ Info: 38 2.1e-01 1.4e-02 2.0e+01 3.7e+01 [ Info: 39 2.1e-01 8.1e-03 2.1e+01 4.4e+01 [ Info: 40 2.0e-01 1.1e-02 1.4e+01 2.7e+01 [ Info: 41 2.3e-01 3.4e-02 1.2e+01 3.5e+01 [ Info: 42 1.8e-01 4.9e-02 1.4e+01 4.8e-03 [ Info: 43 1.8e-01 3.4e-03 1.2e+01 8.6e-01 [ Info: 44 1.8e-01 2.4e-04 1.9e+01 1.4e+00 [ Info: 45 1.6e-01 2.3e-02 1.4e+01 6.0e-03 [ Info: 46 1.7e-01 1.3e-02 1.1e+01 1.2e+00 [ Info: 47 1.8e-01 6.2e-03 1.0e+01 1.0e+00 [ Info: 48 1.8e-01 6.2e-03 9.1e+00 9.4e-01 [ Info: 49 1.9e-01 9.9e-03 8.1e+00 8.4e-01 [ Info: 50 2.0e-01 8.1e-03 7.2e+00 7.5e-01 [ Info: 51 2.1e-01 8.2e-03 6.4e+00 6.7e-01 [ Info: 52 2.2e-01 1.1e-02 5.6e+00 5.8e-01 [ Info: 53 2.3e-01 8.0e-03 4.9e+00 5.1e-01 [ Info: 54 2.4e-01 1.1e-02 4.2e+00 4.3e-01 [ Info: 55 2.9e-01 4.5e-02 3.0e+00 1.9e+01 [ Info: 56 3.2e-01 3.5e-02 2.1e+00 1.3e+01 [ Info: 57 3.5e-01 2.6e-02 1.7e+00 1.0e+01 [ Info: 58 3.7e-01 2.3e-02 1.3e+00 8.1e+00 [ Info: 59 4.0e-01 2.5e-02 1.0e+00 6.4e+00 [ Info: 60 4.2e-01 2.0e-02 8.3e-01 5.1e+00 [ Info: 61 4.4e-01 2.4e-02 6.9e-01 4.3e+00 [ Info: 62 4.6e-01 1.9e-02 5.8e-01 3.6e+00 [ Info: 63 4.7e-01 1.5e-02 4.8e-01 3.0e+00 [ Info: 64 4.9e-01 1.5e-02 3.9e-01 2.4e+00 [ Info: 65 5.0e-01 1.2e-02 3.1e-01 1.9e+00 [ Info: 66 5.1e-01 1.4e-02 2.3e-01 1.4e+00 [ Info: 67 5.2e-01 1.1e-02 1.7e-01 1.0e+00 [ Info: 68 5.4e-01 1.1e-02 1.1e-01 6.6e-01 [ Info: 69 5.9e-01 5.3e-02 8.5e-02 8.2e+00 [ Info: 70 5.1e-01 8.2e-02 2.6e-01 4.0e-01 p-norm chunk 4: V=0.601, constr=-0.1556
1875-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
⋮
1.0
1.0
1.0
1.0
1.0
0.5589469809493967
0.6405280765858787
0.9538838462674111
0.6561644098074775
Approach 2: relaxed stress + KS aggregation
The KS function \(\sigma_{KS} = \max(s) + \log\sum_e e^{\gamma(s_e - \max(s))}/\gamma\) is an upper bound on the maximum, with slack at most log(N)/γ — so no normalization factor is needed, and σ_KS ≤ σ_lim certifies max(σ̃) ≤ σ_lim. Its conservatism is well known: the optimum keeps extra material and the true maximum stress ends well below the limit. The solid design satisfies the KS bound at γ = 10, so the optimization warm-starts from a feasible point; γ = 20 makes the gradient too sharp for MMA to stay feasible.
γ = 10.0
constr_ks = x -> begin
s = σ_rel(filter(PseudoDensities(x))) ./ σlim
logsumexp(γ .* s) / γ - 1
end
# Warm-start from the solid design, which satisfies the KS bound at this γ.
x2 = run_chunks(constr_ks, x_solid, 2, 80; label = "KS")[ Info: iter obj Δobj violation kkt_residual [ Info: 0 1.0e+00 Inf 0.0e+00 9.7e-02 [ Info: 1 7.7e-01 2.3e-01 0.0e+00 7.0e-03 [ Info: 2 6.9e-01 7.6e-02 2.7e-03 2.8e-03 [ Info: 3 6.5e-01 4.1e-02 0.0e+00 2.7e-03 [ Info: 4 6.2e-01 3.1e-02 0.0e+00 2.7e-03 [ Info: 5 6.0e-01 1.9e-02 0.0e+00 3.4e-03 [ Info: 6 5.9e-01 1.4e-02 0.0e+00 2.9e-03 [ Info: 7 5.8e-01 1.1e-02 0.0e+00 2.0e-03 [ Info: 8 5.7e-01 7.5e-03 0.0e+00 1.3e-03 [ Info: 9 5.6e-01 5.5e-03 0.0e+00 9.1e-04 KS chunk 1: V=0.564, constr=-0.0007 [ Info: iter obj Δobj violation kkt_residual [ Info: 0 5.6e-01 Inf 0.0e+00 6.7e-04 [ Info: 1 5.6e-01 4.5e-03 0.0e+00 8.8e-04 [ Info: 2 5.6e-01 4.1e-03 0.0e+00 9.4e-04 [ Info: 3 5.5e-01 4.7e-03 0.0e+00 1.2e-03 [ Info: 4 5.4e-01 5.8e-03 0.0e+00 1.8e-03 [ Info: 5 5.4e-01 7.6e-03 0.0e+00 2.0e-03 [ Info: 6 5.3e-01 6.9e-03 0.0e+00 1.6e-03 [ Info: 7 5.2e-01 5.6e-03 0.0e+00 1.5e-03 [ Info: 8 5.2e-01 6.5e-03 0.0e+00 3.0e-03 [ Info: 9 5.1e-01 8.4e-03 0.0e+00 1.7e-03 [ Info: 10 5.0e-01 6.9e-03 0.0e+00 1.7e-03 [ Info: 11 5.0e-01 6.5e-03 0.0e+00 7.9e-04 [ Info: 12 4.9e-01 3.8e-03 0.0e+00 5.0e-04 [ Info: 13 4.9e-01 2.0e-03 0.0e+00 4.7e-04 [ Info: 14 4.9e-01 1.7e-03 0.0e+00 5.0e-04 [ Info: 15 4.9e-01 1.6e-03 0.0e+00 5.9e-04 [ Info: 16 4.9e-01 1.6e-03 0.0e+00 5.7e-04 [ Info: 17 4.8e-01 9.5e-04 0.0e+00 4.2e-04 [ Info: 18 4.8e-01 6.4e-04 0.0e+00 4.4e-04 [ Info: 19 4.8e-01 5.1e-04 0.0e+00 3.9e-04 [ Info: 20 4.8e-01 3.7e-04 0.0e+00 4.0e-04 [ Info: 21 4.8e-01 3.6e-04 0.0e+00 4.3e-04 [ Info: 22 4.8e-01 4.2e-04 0.0e+00 3.6e-04 [ Info: 23 4.8e-01 4.0e-04 0.0e+00 3.8e-04 [ Info: 24 4.8e-01 3.3e-04 0.0e+00 3.2e-04 [ Info: 25 4.8e-01 2.7e-04 0.0e+00 3.2e-04 [ Info: 26 4.8e-01 1.8e-04 0.0e+00 3.2e-04 [ Info: 27 4.8e-01 1.5e-04 0.0e+00 2.9e-04 [ Info: 28 4.8e-01 1.2e-04 0.0e+00 2.8e-04 [ Info: 29 4.8e-01 1.3e-04 0.0e+00 2.9e-04 [ Info: 30 4.8e-01 1.4e-04 0.0e+00 3.2e-04 [ Info: 31 4.8e-01 1.3e-04 0.0e+00 3.3e-04 [ Info: 32 4.8e-01 1.1e-04 0.0e+00 3.2e-04 [ Info: 33 4.8e-01 5.2e-05 3.6e-06 3.5e-04 [ Info: 34 4.8e-01 3.0e-05 0.0e+00 3.1e-04 [ Info: 35 4.8e-01 3.2e-05 0.0e+00 3.1e-04 [ Info: 36 4.8e-01 3.3e-05 0.0e+00 3.0e-04 [ Info: 37 4.8e-01 3.7e-05 0.0e+00 2.9e-04 [ Info: 38 4.8e-01 4.0e-05 0.0e+00 1.2e-04 [ Info: 39 4.8e-01 2.6e-05 0.0e+00 9.7e-05 KS chunk 2: V=0.48, constr=-0.0
1875-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
⋮
0.0
0.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
Verbart et al. (2017) relax the KS bound: subtracting the worst-case slack log(N)/γ turns it into a lower bound, Ψ_KS^L = KS − log(N)/γ ≤ max(σ̃), and a normalization factor c = max(σ̃)/Ψ_KS^L, updated at every iteration, rescales it to track the true maximum — the KS counterpart of the adaptive p-mean of Approach 1. The constraint becomes c·Ψ_KS^L ≤ σ_lim. This removes most of the conservatism: the design below ends lighter and closer to the stress limit than the plain KS result above.
Ψ_KS_L(x) = logsumexp(γ .* (σ_rel(filter(PseudoDensities(x))) ./ σlim)) / γ - log(N) / γ
c_ks = Ref(maximum(σ_rel(filter(PseudoDensities(x_solid))) ./ σlim) / Ψ_KS_L(x_solid))
constr_ks_l = x -> c_ks[] * Ψ_KS_L(x) - 1
# Iterative normalization: c tracks max(σ̃)/Ψ_KS^L between chunks.
x2l = run_chunks(
constr_ks_l, x_solid, 4, 70;
update! = (x, j) -> (c_ks[] = maximum(σ_rel(filter(PseudoDensities(x))) ./ σlim) / Ψ_KS_L(x)),
label = "normalized KS",
)[ Info: iter obj Δobj violation kkt_residual [ Info: 0 1.0e+00 Inf 0.0e+00 4.3e-01 [ Info: 1 7.6e-01 2.4e-01 0.0e+00 7.7e-03 [ Info: 2 6.7e-01 8.3e-02 2.0e-02 4.7e-03 [ Info: 3 6.3e-01 4.6e-02 2.5e-02 6.6e-03 [ Info: 4 5.9e-01 3.5e-02 1.9e-02 5.4e-03 [ Info: 5 5.8e-01 1.4e-02 0.0e+00 6.6e-04 normalized KS chunk 1: V=0.578, constr=-0.0016 [ Info: iter obj Δobj violation kkt_residual [ Info: 0 5.8e-01 Inf 0.0e+00 3.1e-01 [ Info: 1 4.8e-01 1.0e-01 4.6e-02 6.2e-03 [ Info: 2 4.5e-01 2.1e-02 9.0e-02 1.5e-02 [ Info: 3 4.4e-01 1.4e-02 3.8e-01 7.1e-02 [ Info: 4 2.9e-01 1.5e-01 1.8e+01 8.4e-01 [ Info: 5 1.7e-01 1.2e-01 3.7e+01 2.2e-02 [ Info: 6 9.7e-02 7.3e-02 1.5e+02 1.2e-01 [ Info: 7 4.5e-02 5.2e-02 1.9e+02 2.4e-02 [ Info: 8 4.4e-02 2.5e-04 2.2e+02 8.2e+00 [ Info: 9 1.3e-02 3.1e-02 2.8e+02 1.1e-02 [ Info: 10 7.2e-03 6.0e-03 3.1e+02 2.1e-02 [ Info: 11 1.6e-02 9.0e-03 2.3e+02 2.7e+00 [ Info: 12 2.6e-02 9.5e-03 2.0e+02 2.4e+00 [ Info: 13 1.7e-02 8.6e-03 2.1e+02 3.2e+00 [ Info: 14 7.3e-03 9.8e-03 2.9e+02 1.3e-02 [ Info: 15 1.7e-02 9.4e-03 2.4e+02 5.8e+00 [ Info: 16 3.4e-02 1.8e-02 2.2e+02 5.7e+00 [ Info: 17 5.5e-02 2.1e-02 1.8e+02 4.5e+00 [ Info: 18 3.8e-02 1.7e-02 2.2e+02 5.5e+00 [ Info: 19 7.1e-02 3.2e-02 1.4e+02 3.5e+00 [ Info: 20 6.1e-02 9.8e-03 1.4e+02 3.5e+00 [ Info: 21 2.4e-02 3.7e-02 2.4e+02 4.9e-02 [ Info: 22 6.8e-02 4.4e-02 1.3e+02 8.8e+00 [ Info: 23 7.3e-02 4.7e-03 1.1e+02 7.3e+00 [ Info: 24 8.6e-02 1.4e-02 1.4e+02 9.3e+00 [ Info: 25 8.8e-02 1.9e-03 1.8e+02 1.2e+01 [ Info: 26 1.2e-01 2.8e-02 1.1e+02 7.5e+00 [ Info: 27 1.2e-01 4.4e-03 7.4e+01 5.0e+00 [ Info: 28 1.7e-01 5.3e-02 8.2e+01 5.5e+00 [ Info: 29 1.1e-01 6.4e-02 9.8e+01 6.6e+00 [ Info: 30 4.8e-02 6.2e-02 1.5e+02 1.3e-02 [ Info: 31 2.9e-02 1.8e-02 1.7e+02 4.2e-02 [ Info: 32 5.8e-02 2.9e-02 1.4e+02 1.3e+01 [ Info: 33 7.0e-02 1.2e-02 1.1e+02 9.9e+00 [ Info: 34 1.0e-01 3.5e-02 8.7e+01 8.1e+00 [ Info: 35 8.4e-02 2.1e-02 8.9e+01 8.3e+00 [ Info: 36 1.2e-01 3.8e-02 1.1e+02 1.0e+01 [ Info: 37 9.6e-02 2.7e-02 9.5e+01 8.8e+00 [ Info: 38 1.2e-01 2.7e-02 1.3e+02 1.2e+01 [ Info: 39 1.3e-01 2.4e-03 7.4e+01 6.9e+00 [ Info: 40 1.2e-01 9.3e-03 6.3e+01 5.9e+00 [ Info: 41 1.1e-01 4.3e-03 1.1e+02 1.0e+01 [ Info: 42 6.1e-02 5.1e-02 1.1e+02 5.4e-02 [ Info: 43 1.1e-01 4.9e-02 8.5e+01 2.5e+01 [ Info: 44 1.6e-01 4.5e-02 6.1e+01 1.8e+01 [ Info: 45 1.5e-01 9.4e-03 6.9e+01 2.0e+01 [ Info: 46 1.5e-01 8.7e-03 7.4e+01 2.2e+01 [ Info: 47 1.0e-01 5.3e-02 1.4e+02 9.9e-02 [ Info: 48 8.5e-02 1.6e-02 1.1e+02 1.9e+01 [ Info: 49 1.0e-01 1.4e-02 1.0e+02 2.3e+01 [ Info: 50 7.4e-02 2.6e-02 9.6e+01 1.1e-02 [ Info: 51 7.6e-02 2.7e-03 1.1e+02 7.7e+00 [ Info: 52 9.8e-02 2.1e-02 7.9e+01 6.5e+00 [ Info: 53 1.1e-01 1.1e-02 8.2e+01 5.9e+00 [ Info: 54 1.0e-01 7.9e-03 7.9e+01 5.7e+00 [ Info: 55 1.2e-01 2.0e-02 7.1e+01 8.5e+00 [ Info: 56 1.2e-01 3.7e-03 7.4e+01 5.3e+00 [ Info: 57 1.1e-01 3.8e-03 7.0e+01 5.1e+00 [ Info: 58 1.1e-01 5.9e-03 7.1e+01 5.8e+00 [ Info: 59 1.1e-01 2.7e-03 7.6e+01 5.5e+00 [ Info: 60 1.2e-01 7.9e-03 5.9e+01 4.3e+00 [ Info: 61 1.1e-01 4.9e-03 6.1e+01 4.4e+00 [ Info: 62 1.1e-01 4.6e-04 5.9e+01 4.2e+00 [ Info: 63 1.2e-01 6.1e-03 6.0e+01 4.3e+00 [ Info: 64 1.2e-01 3.7e-03 6.3e+01 5.4e+00 [ Info: 65 1.1e-01 4.9e-03 6.1e+01 4.4e+00 [ Info: 66 1.2e-01 1.3e-02 5.6e+01 4.1e+00 [ Info: 67 1.2e-01 2.9e-03 6.3e+01 4.6e+00 [ Info: 68 1.2e-01 3.2e-03 5.9e+01 4.3e+00 [ Info: 69 1.1e-01 7.1e-03 6.3e+01 4.5e+00 [ Info: 70 1.2e-01 6.0e-03 5.4e+01 3.9e+00 normalized KS chunk 2: V=0.475, constr=0.0459 [ Info: iter obj Δobj violation kkt_residual [ Info: 0 4.8e-01 Inf 0.0e+00 2.2e-01 [ Info: 1 4.1e-01 6.9e-02 7.5e-02 9.4e-03 [ Info: 2 3.7e-01 3.7e-02 6.3e+00 8.6e-01 [ Info: 3 1.6e-01 2.0e-01 3.0e+01 1.0e-01 [ Info: 4 5.7e-02 1.1e-01 1.8e+02 6.3e-02 [ Info: 5 1.7e-02 4.0e-02 2.3e+02 1.0e-02 [ Info: 6 2.6e-03 1.4e-02 1.8e+02 4.2e-03 [ Info: 7 2.0e-03 5.9e-04 2.6e+02 9.9e-03 [ Info: 8 7.1e-03 5.0e-03 1.9e+02 7.3e-01 [ Info: 9 1.1e-02 4.2e-03 1.7e+02 4.7e-01 [ Info: 10 4.6e-03 6.7e-03 2.6e+02 1.1e+00 [ Info: 11 5.9e-03 1.4e-03 1.9e+02 1.2e-01 [ Info: 12 2.4e-02 1.8e-02 1.6e+02 1.0e+02 [ Info: 13 2.3e-02 1.1e-03 1.5e+02 9.6e+01 [ Info: 14 5.2e-02 2.9e-02 1.5e+02 5.3e+01 [ Info: 15 3.5e-02 1.6e-02 1.4e+02 5.1e+01 [ Info: 16 8.5e-02 4.9e-02 1.1e+02 6.4e+01 [ Info: 17 1.4e-01 5.6e-02 1.1e+02 4.0e+01 [ Info: 18 7.0e-02 7.0e-02 1.0e+02 5.4e+01 [ Info: 19 1.3e-01 6.2e-02 1.0e+02 4.2e+01 [ Info: 20 1.5e-01 1.6e-02 1.1e+02 4.0e+01 [ Info: 21 1.1e-01 3.9e-02 1.1e+02 3.8e+01 [ Info: 22 9.5e-02 1.6e-02 9.4e+01 3.3e+01 [ Info: 23 1.6e-01 6.7e-02 1.0e+02 3.3e+01 [ Info: 24 1.2e-01 4.3e-02 9.5e+01 3.4e+01 [ Info: 25 1.7e-01 5.2e-02 1.1e+02 3.5e+01 [ Info: 26 1.5e-01 1.6e-02 7.7e+01 2.5e+01 [ Info: 27 1.3e-01 2.1e-02 1.2e+02 4.0e+01 [ Info: 28 1.7e-01 3.2e-02 7.2e+01 2.3e+01 [ Info: 29 1.0e-01 6.2e-02 6.8e+01 2.6e-02 [ Info: 30 1.4e-01 3.7e-02 6.9e+01 6.4e+00 [ Info: 31 1.5e-01 5.1e-03 5.8e+01 5.4e+00 [ Info: 32 1.5e-01 6.9e-03 8.6e+01 8.0e+00 [ Info: 33 1.1e-01 4.1e-02 8.1e+01 3.1e-01 [ Info: 34 8.8e-02 2.4e-02 7.1e+01 9.2e-03 [ Info: 35 1.1e-01 2.4e-02 1.2e+02 5.4e+00 [ Info: 36 1.1e-01 1.3e-04 6.7e+01 2.3e+00 [ Info: 37 9.8e-02 1.4e-02 6.8e+01 2.3e+00 [ Info: 38 9.4e-02 3.8e-03 8.2e+01 2.8e+00 [ Info: 39 9.0e-02 4.5e-03 7.1e+01 1.3e-01 [ Info: 40 1.2e-01 3.1e-02 5.6e+01 8.2e+01 [ Info: 41 1.4e-01 1.8e-02 5.4e+01 8.4e+01 [ Info: 42 1.0e-01 3.8e-02 5.6e+01 1.9e-01 [ Info: 43 8.9e-02 1.1e-02 7.1e+01 2.3e-01 [ Info: 44 7.9e-02 1.1e-02 1.0e+02 5.6e-01 [ Info: 45 7.3e-02 6.0e-03 7.5e+01 1.2e-01 [ Info: 46 6.8e-02 4.2e-03 7.5e+01 1.3e-01 [ Info: 47 6.4e-02 4.3e-03 8.1e+01 2.0e-01 [ Info: 48 6.3e-02 8.1e-04 7.1e+01 1.2e-01 [ Info: 49 6.1e-02 2.6e-03 7.9e+01 2.4e-01 [ Info: 50 5.8e-02 3.1e-03 8.0e+01 1.3e-01 [ Info: 51 5.7e-02 2.4e-04 7.8e+01 1.3e-01 [ Info: 52 5.7e-02 3.6e-04 7.7e+01 1.9e-01 [ Info: 53 5.6e-02 7.6e-04 8.1e+01 1.8e-01 [ Info: 54 5.3e-02 3.4e-03 7.8e+01 1.3e-01 [ Info: 55 5.2e-02 4.7e-04 8.0e+01 1.8e-01 [ Info: 56 5.2e-02 6.2e-04 7.7e+01 1.3e-01 [ Info: 57 5.0e-02 1.7e-03 7.9e+01 1.9e-01 [ Info: 58 5.0e-02 3.0e-04 7.7e+01 1.3e-01 [ Info: 59 4.8e-02 1.5e-03 7.9e+01 1.9e-01 [ Info: 60 4.8e-02 5.2e-05 7.6e+01 1.5e-01 [ Info: 61 4.6e-02 1.9e-03 8.5e+01 1.5e-01 [ Info: 62 4.5e-02 1.3e-03 9.8e+01 2.4e-01 [ Info: 63 4.3e-02 2.5e-03 9.0e+01 2.1e-01 [ Info: 64 4.3e-02 1.9e-04 8.6e+01 1.5e-01 [ Info: 65 4.3e-02 1.2e-04 9.1e+01 2.0e-01 [ Info: 66 4.3e-02 2.5e-04 8.8e+01 1.5e-01 [ Info: 67 4.1e-02 2.0e-03 9.7e+01 2.4e-01 [ Info: 68 3.9e-02 2.0e-03 1.0e+02 1.8e-01 [ Info: 69 3.8e-02 1.6e-03 9.8e+01 2.3e-01 [ Info: 70 3.8e-02 3.7e-04 9.9e+01 1.8e-01 normalized KS chunk 3: V=0.407, constr=0.0747 [ Info: iter obj Δobj violation kkt_residual [ Info: 0 4.1e-01 Inf 0.0e+00 7.1e-02 [ Info: 1 3.5e-01 5.7e-02 6.3e+00 7.6e-01 [ Info: 2 1.1e-01 2.3e-01 3.3e+01 1.2e-01 [ Info: 3 2.8e-02 8.6e-02 2.2e+02 7.8e-02 [ Info: 4 2.1e-03 2.6e-02 1.6e+02 3.3e-03 [ Info: 5 2.7e-05 2.1e-03 1.0e+02 2.1e-02 [ Info: 6 0.0e+00 2.7e-05 2.8e+01 5.9e-04 [ Info: 7 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 8 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 9 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 10 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 11 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 12 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 13 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 14 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 15 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 16 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 17 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 18 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 19 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 20 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 21 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 22 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 23 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 24 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 25 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 26 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 27 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 28 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 29 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 30 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 31 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 32 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 33 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 34 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 35 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 36 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 37 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 38 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 39 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 40 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 41 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 42 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 43 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 44 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 45 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 46 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 47 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 48 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 49 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 50 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 51 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 52 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 53 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 54 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 55 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 56 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 57 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 58 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 59 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 60 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 61 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 62 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 63 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 64 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 65 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 66 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 67 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 68 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 69 0.0e+00 0.0e+00 2.8e+01 5.9e-04 [ Info: 70 0.0e+00 0.0e+00 2.8e+01 5.9e-04 normalized KS chunk 4: V=0.407, constr=-0.0708
1875-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
⋮
0.0
0.026613186738070744
0.2984152877582033
0.4827702386687279
0.5905162047013838
0.655168503235404
0.7165315127151423
0.7839002602583457
0.8280217084434275
Approach 3: ε-relaxation of the microscopic stress
ε-relaxation acts on the constraint rather than the stress measure: \(g_e = \rho_e(\sigma_e/\sigma_{\lim} - 1) - \epsilon \le 0\), with the true microscopic stress. At zero density the constraint reads \(-\epsilon \le 0\) — always satisfied — and as \(\epsilon \to 0\) the original local constraints are recovered. We pass the raw filtered densities (no xmin floor): g is linear in ρ, which keeps it AD-safe and floor-independent. The relaxed values are signed and there is one per element. Aggregating them with a KS function or a p-mean makes the problem intractable for plain MMA (it stalls at a large violation) and for IPOPT with first-order derivatives (it cannot maintain the aggregate bound), so we enforce them as the local constraints they are with the augmented Lagrangian method (NonconvexAugLagLab), the same solver used in the local_stress tutorial. We drive ε down with a continuation (0.25 → 0.05 → 0.02 → 0.01): each stage re-solves from the previous design, which tightens the true stress bound and removes the disconnected gray regions a single fixed ε leaves behind. Driving ε → 0 recovers the original local constraints, though the global optimum of the relaxed problem can jump discontinuously (Stolpe & Svanberg, 2001) — which is why ε-relaxation is paired with augmented-Lagrangian solvers (Fancello & Pereira, 2006).
using NonconvexAugLagLab
import NonconvexCore
εs = [0.25, 0.05, 0.02, 0.01]
εref = Ref(εs[1])
g_eps = x -> begin
xfil = filter(PseudoDensities(x))
epsilon_relaxed(σ_micro(xfil), xfil.x, σlim, εref[]) ./ εref[]
end
x3 = copy(x_solid)
for εv in εs
εref[] = εv
model_eps = Model(obj)
addvar!(model_eps, zeros(N), ones(N))
add_ineq_constraint!(model_eps, g_eps)
vm, x0f, _ = NonconvexCore.tovecmodel(model_eps, x3)
ws_eps = Workspace(vm, NonconvexAugLagLab.AugLagAlg(), x0f;
options=NonconvexAugLagLab.AugLagOptions(;
max_iter=20, sub_options=(; max_iter=100, tol=1e-6, linesearch=:trustregion),
),
)
global x3 = NonconvexCore.optimize!(ws_eps).minimizer
println("ε=$εv: V=$(round(obj(x3), digits=3)), max g=$(round(maximum(g_eps(x3)), digits=4))")
endε=0.25: V=0.482, max g=0.0
ε=0.05: V=0.446, max g=0.0
ε=0.02: V=0.387, max g=0.0
ε=0.01: V=0.373, max g=0.0001
Results and verification
function report(label, x, constr)
topo = collect(filter(PseudoDensities(x)).x)
srel = σ_rel(filter(PseudoDensities(x)))
smic = σ_micro(filter(PseudoDensities(x)))
solid = topo .> 0.5
smic_solid = smic[solid]
# A non-binary final design (every filtered density ≤ 0.5) has no solid
# elements to report a microscopic stress on.
max_micro = isempty(smic_solid) ? NaN : maximum(smic_solid)
println(
"$label: V = $(round(obj(x), digits=3)), aggregate constraint = $(round(constr(x), digits=4)), " *
"max relaxed σ = $(round(maximum(srel), digits=3)), " *
"max microscopic σ (solid elements) = $(isnan(max_micro) ? "n/a (no solid elements)" : round(max_micro, digits=3)), " *
"σlim = $(round(σlim, digits=3))",
)
return topo
end
topo1 = report("p-norm ", x1, constr_pnorm)
topo2 = report("KS ", x2, constr_ks)
topo2l = report("norm. KS ", x2l, constr_ks_l)
topo3 = report("ε-relaxed", x3, x -> maximum(g_eps(x)))p-norm : V = 0.601, aggregate constraint = -0.1556, max relaxed σ = 0.884, max microscopic σ (solid elements) = 1.042, σlim = 1.047
KS : V = 0.48, aggregate constraint = -0.0, max relaxed σ = 0.691, max microscopic σ (solid elements) = 0.691, σlim = 1.047
norm. KS : V = 0.407, aggregate constraint = -0.0708, max relaxed σ = 0.973, max microscopic σ (solid elements) = 0.982, σlim = 1.047
ε-relaxed: V = 0.373, aggregate constraint = 0.0001, max relaxed σ = 1.058, max microscopic σ (solid elements) = 1.068, σlim = 1.047
1875-element Vector{Float64}:
0.0
0.0
0.0
0.0
0.0
0.0
0.001768154675425695
0.010228015818876262
0.030730909459723718
0.06782572386610201
⋮
0.005670029103707743
0.03248253022177103
0.09702658108420767
0.20213568336451979
0.3474395177120248
0.5287773423868802
0.7079437371580458
0.8249766079757777
0.865681504725406
All four runs end feasible for their own constraint. The p-mean’s adaptive factor c was estimated on the previous chunk, so the true maximum relaxed stress is about 1% above σlim. The plain KS upper bound is conservative by construction: its maximum relaxed stress stays near 0.7·σlim and the design keeps more material. The normalized (lower-bound) KS removes most of that conservatism and lands close to the p-mean design. The ε-relaxed run satisfies every local constraint (max g ≈ 0) with a maximum relaxed stress above σlim — the bound applies to the microscopic stress with a per-element slack σ_e ≤ σlim(1 + ε/ρ_e), not to the relaxed measure.
Connectivity verification
Every design must remain a single connected structure — a stress-driven design with floating islands would not be a usable result:
grid = problem.ch.dh.grid
function connectivity(topo; threshold=0.4)
solid = findall(topo .> threshold)
isempty(solid) && return (0, 0)
parent = collect(1:length(solid))
function root(i)
while parent[i] != i
parent[i] = parent[parent[i]]
i = parent[i]
end
return i
end
edges = Dict{Tuple{Int,Int},Vector{Int}}()
for (i, c) in enumerate(solid)
cell = grid.cells[c]
for e in 1:4
a, b = minmax(cell.nodes[e], cell.nodes[mod1(e + 1, 4)])
push!(get!(() -> Int[], edges, (a, b)), i)
end
end
for v in values(edges), i in 1:length(v), j in (i + 1):length(v)
ra, rb = root(v[i]), root(v[j])
parent[ra] = rb
end
counts = Dict{Int,Int}()
for i in eachindex(solid)
r = root(i)
counts[r] = get(counts, r, 0) + 1
end
return maximum(values(counts)), length(counts)
end
for (name, x) in (("p-norm ", x1), ("KS ", x2), ("normalized KS", x2l), ("ε-relaxed ", x3))
topo = collect(filter(PseudoDensities(x)).x)
largest, ncomp = connectivity(topo)
println("$name: connected = $(ncomp == 1) (largest component $largest at threshold 0.4)")
endp-norm : connected = true (largest component 1253 at threshold 0.4)
KS : connected = true (largest component 980 at threshold 0.4)
normalized KS: connected = true (largest component 1086 at threshold 0.4)
ε-relaxed : connected = true (largest component 975 at threshold 0.4)
The microscopic stress is reported over solid elements only: with a density filter, the gray boundary layer is penalized material whose true stress exceeds the relaxed measure by \(\rho^{-q}\), a well-documented artifact of filtered SIMP stress evaluation (da Silva et al., 2019).
fig = visualize(problem; static=true, topology=topo1, default_exagg_scale=0.0)
display_app(fig)fig = visualize(problem; static=true, topology=topo2l, default_exagg_scale=0.0)
display_app(fig)fig = visualize(problem; static=true, topology=topo3, default_exagg_scale=0.0)
display_app(fig)Discussion
- Relaxation is not optional. Without
stress_exponent(orepsilon_relaxed), the microscopic stress is finite in vanishing material and the stress-constrained problem has singular optima that MMA cannot reach — the optimization stalls or collapses. - Aggregation bounds. The plain p-norm and the KS function are upper bounds on the maximum stress: constraining them is conservative and needs no normalization. The normalized form
N^(-1/P) * norm(σ, P)used here is a lower bound (the p-mean), so it must be rescaled by an adaptive factorc ≈ max(σ̃)/σ_PN— which inherits a one-chunk lag and can leave the true maximum slightly above the limit. - The KS slack
log(N)/γis conservative by design: atγ = 10the bound is satisfied at the solid design, MMA stays feasible throughout, and the result keeps more material at a lower peak stress than the p-mean design. The known remedy is Verbart et al.’s lower-bound KS with a normalization factor updated at each iteration, which recovers most of the lost design freedom (the normalized-KS run above). A sharperγ(e.g. 20) concentrates the gradient on the few peak elements and MMA can no longer stay feasible. - ε-relaxation pairs with an AL solver. The local, signed constraints are enforced by
NonconvexAugLagLabunder anεcontinuation that tightens the true boundσ ≤ σlim(1 + ε)on solid elements; the reported relaxed stress exceedsσlimbecause the bound applies to the microscopic stress. A single fixedεleaves gray, disconnected regions, which the continuation removes. - Point loads and supports are singular stress sources; distribute them (
load_widthhere) or exclude their vicinity from the aggregation. - Deeper discussion of the theory and the failure modes of the naive formulation: see
STRESS_CONSTRAINED_TO.mdin the repository root.
Hyper-parameter guide
The choices above are the reliable defaults, not one-off tuning. The main parameters and their sensible ranges:
| Parameter | Default here | Range | Effect of increasing it |
|---|---|---|---|
stress_exponent (q) |
0.5 | 0.3–0.5 | stronger relaxation: ρ^q vanishes faster at low density |
SIMP p |
3.0 | fixed | keep fixed at 3 (continuation from p=1 collapses) |
σlim (stress limit) |
1.75× solid peak | 1.5–2× solid peak | larger feasible set; the constraint binds less |
p-norm P |
8 | 6–12 | tighter to max, but gradient concentrates |
KS γ |
10 | 8–15 | tighter bound; too sharp and MMA leaves the feasible region |
ε (ε-relaxation) |
continuation 0.25→0.01 | 0.1–0.5 start | shrink it in stages; a single fixed ε leaves gray, disconnected regions |
filter rmin |
2.0 | 1.5–3 elements | smoother designs, wider gray layer |
load_width |
5 | 3–8 | distribute the point load to remove its stress singularity |
The most common failure is an infeasible problem at the solid design (the stress limit is below the solid block’s peak), which parks the optimizer at x = 1; always calibrate σlim from the solid design first. The second is a point load/support dominating the aggregation — distribute the load (load_width) or exclude its vicinity.
References
- Le, Norato, Bruns, Ha & Tortorelli (2010). Stress-based topology optimization for continua. Struct. Multidiscip. Optim. 41:605–620.
- Duysinx & Bendsøe (1998). Topology optimization of continuum structures with local stress constraints. Int. J. Numer. Meth. Eng. 43:1453–1478.
- Cheng & Guo (1997). ε-relaxed approach in structural topology optimization. Struct. Optim. 13:258–266.
- Bruggi (2008). On an alternative approach to stress constraints relaxation in topology optimization. Struct. Multidiscip. Optim. 36:125–141.
- Duysinx & Sigmund (1998). New developments in handling stress constraints in optimal material distribution. 7th AIAA/USAF/NASA/ISSMo Symp.
- Yang & Chen (1996). Stress-based topology optimization. Struct. Optim. 12:98–105.
- Verbart, Langelaar & van Keulen (2017). A unified aggregation and relaxation approach for stress-constrained topology optimization. Struct. Multidiscip. Optim. 55:663–679.
- Stolpe & Svanberg (2001). On the trajectories of the epsilon-relaxation approach for stress-constrained truss topology optimization. Struct. Multidiscip. Optim. 21:140–151.
- da Silva, Beck & Sigmund (2019). Stress-constrained topology optimization considering uniform manufacturing uncertainties. Comput. Methods Appl. Mech. Eng. 344:512–537.
- Sved & Ginos (1968). Structural optimization under multiple loading. Int. J. Mech. Sci. 10:803–805.