Solve a 2D short cantilever topology optimization problem

from __future__ import annotations

import matplotlib.pyplot as plt
from gemseo.api import configure_logger
from gemseo.api import create_scenario
from gemseo.problems.topo_opt.topopt_initialize import (
    initialize_design_space_and_discipline_to,
)
from matplotlib import colors

configure_logger()
<RootLogger root (INFO)>

Setup the topology optimization problem

Define the target volume fraction:

volume_fraction = 0.3

Define the problem type:

problem_name = "Short_Cantilever"

Define the number of elements in the x- and y- directions:

n_x = 50
n_y = 25

Define the full material Young’s modulus and Poisson’s ratio:

e0 = 1
nu = 0.3

Define the penalty of the SIMP approach:

penalty = 3

Define the minimum member size in the solution:

min_memeber_size = 1.5

Instantiate the DesignSpace and the disciplines:

design_space, disciplines = initialize_design_space_and_discipline_to(
    problem=problem_name,
    n_x=n_x,
    n_y=n_y,
    e0=e0,
    nu=nu,
    penalty=penalty,
    min_member_size=min_memeber_size,
    vf0=volume_fraction,
)

Solve the topology optimization problem

Generate a MDOScenario:

scenario = create_scenario(
    disciplines,
    formulation="DisciplinaryOpt",
    objective_name="compliance",
    design_space=design_space,
)

Add the volume fraction constraint to the scenario:

scenario.add_constraint("volume fraction", "ineq", value=volume_fraction)

Generate the XDSM:

scenario.xdsmize()
INFO - 16:56:14: Generating HTML XDSM file in : xdsm.html

Execute the scenario:

scenario.execute(input_data={"max_iter": 200, "algo": "NLOPT_MMA"})
    INFO - 16:56:14:
    INFO - 16:56:14: *** Start MDOScenario execution ***
    INFO - 16:56:14: MDOScenario
    INFO - 16:56:14:    Disciplines: DensityFilter FininiteElementAnalysis MaterialModelInterpolation VolumeFraction
    INFO - 16:56:14:    MDO formulation: DisciplinaryOpt
    INFO - 16:56:14: Optimization problem:
    INFO - 16:56:14:    minimize compliance(x)
    INFO - 16:56:14:    with respect to x
    INFO - 16:56:14:    subject to constraints:
    INFO - 16:56:14:       volume fraction(x) <= 0.3
    INFO - 16:56:14: Solving optimization problem with algorithm NLOPT_MMA:
    INFO - 16:56:14: ...   0%|          | 0/200 [00:00<?, ?it]
    INFO - 16:56:14: ...   0%|          | 1/200 [00:00<00:16, 11.74 it/sec, obj=1.46e+3]
    INFO - 16:56:14: ...   1%|          | 2/200 [00:00<00:30,  6.57 it/sec, obj=1.46e+3]
    INFO - 16:56:14: ...   2%|▏         | 3/200 [00:00<00:26,  7.32 it/sec, obj=1.45e+3]
    INFO - 16:56:14: ...   2%|▏         | 4/200 [00:00<00:24,  7.97 it/sec, obj=1.45e+3]
    INFO - 16:56:14: ...   2%|▎         | 5/200 [00:00<00:23,  8.21 it/sec, obj=1.45e+3]
    INFO - 16:56:15: ...   3%|▎         | 6/200 [00:00<00:22,  8.52 it/sec, obj=1.43e+3]
    INFO - 16:56:15: ...   4%|▎         | 7/200 [00:00<00:22,  8.64 it/sec, obj=1.4e+3]
    INFO - 16:56:15: ...   4%|▍         | 8/200 [00:00<00:21,  8.83 it/sec, obj=1.36e+3]
    INFO - 16:56:15: ...   4%|▍         | 9/200 [00:01<00:21,  8.89 it/sec, obj=1.2e+3]
    INFO - 16:56:15: ...   5%|▌         | 10/200 [00:01<00:21,  9.03 it/sec, obj=1.01e+3]
    INFO - 16:56:15: ...   6%|▌         | 11/200 [00:01<00:20,  9.06 it/sec, obj=756]
    INFO - 16:56:15: ...   6%|▌         | 12/200 [00:01<00:20,  9.18 it/sec, obj=573]
    INFO - 16:56:15: ...   6%|▋         | 13/200 [00:01<00:20,  9.20 it/sec, obj=509]
    INFO - 16:56:15: ...   7%|▋         | 14/200 [00:01<00:19,  9.30 it/sec, obj=448]
    INFO - 16:56:15: ...   8%|▊         | 15/200 [00:01<00:19,  9.32 it/sec, obj=399]
    INFO - 16:56:16: ...   8%|▊         | 16/200 [00:01<00:19,  9.40 it/sec, obj=360]
    INFO - 16:56:16: ...   8%|▊         | 17/200 [00:01<00:19,  9.41 it/sec, obj=329]
    INFO - 16:56:16: ...   9%|▉         | 18/200 [00:01<00:19,  9.47 it/sec, obj=304]
    INFO - 16:56:16: ...  10%|▉         | 19/200 [00:02<00:19,  9.49 it/sec, obj=278]
    INFO - 16:56:16: ...  10%|█         | 20/200 [00:02<00:18,  9.54 it/sec, obj=251]
    INFO - 16:56:16: ...  10%|█         | 21/200 [00:02<00:18,  9.55 it/sec, obj=231]
    INFO - 16:56:16: ...  11%|█         | 22/200 [00:02<00:18,  9.61 it/sec, obj=213]
    INFO - 16:56:16: ...  12%|█▏        | 23/200 [00:02<00:18,  9.60 it/sec, obj=193]
    INFO - 16:56:16: ...  12%|█▏        | 24/200 [00:02<00:18,  9.65 it/sec, obj=175]
    INFO - 16:56:16: ...  12%|█▎        | 25/200 [00:02<00:18,  9.64 it/sec, obj=161]
    INFO - 16:56:17: ...  13%|█▎        | 26/200 [00:02<00:17,  9.69 it/sec, obj=153]
    INFO - 16:56:17: ...  14%|█▎        | 27/200 [00:02<00:17,  9.69 it/sec, obj=148]
    INFO - 16:56:17: ...  14%|█▍        | 28/200 [00:02<00:17,  9.74 it/sec, obj=145]
    INFO - 16:56:17: ...  14%|█▍        | 29/200 [00:02<00:17,  9.75 it/sec, obj=143]
    INFO - 16:56:17: ...  15%|█▌        | 30/200 [00:03<00:17,  9.80 it/sec, obj=142]
    INFO - 16:56:17: ...  16%|█▌        | 31/200 [00:03<00:17,  9.80 it/sec, obj=141]
    INFO - 16:56:17: ...  16%|█▌        | 32/200 [00:03<00:17,  9.85 it/sec, obj=140]
    INFO - 16:56:17: ...  16%|█▋        | 33/200 [00:03<00:16,  9.85 it/sec, obj=140]
    INFO - 16:56:17: ...  17%|█▋        | 34/200 [00:03<00:16,  9.88 it/sec, obj=140]
    INFO - 16:56:17: ...  18%|█▊        | 35/200 [00:03<00:16,  9.89 it/sec, obj=139]
    INFO - 16:56:17: ...  18%|█▊        | 36/200 [00:03<00:16,  9.92 it/sec, obj=139]
    INFO - 16:56:18: ...  18%|█▊        | 37/200 [00:03<00:16,  9.93 it/sec, obj=139]
    INFO - 16:56:18: ...  19%|█▉        | 38/200 [00:03<00:16,  9.96 it/sec, obj=139]
    INFO - 16:56:18: ...  20%|█▉        | 39/200 [00:03<00:16,  9.96 it/sec, obj=139]
    INFO - 16:56:18: ...  20%|██        | 40/200 [00:04<00:16,  9.99 it/sec, obj=139]
    INFO - 16:56:18: ...  20%|██        | 41/200 [00:04<00:15,  9.99 it/sec, obj=139]
    INFO - 16:56:18: ...  21%|██        | 42/200 [00:04<00:15, 10.02 it/sec, obj=138]
    INFO - 16:56:18: ...  22%|██▏       | 43/200 [00:04<00:15, 10.02 it/sec, obj=138]
    INFO - 16:56:18: ...  22%|██▏       | 44/200 [00:04<00:15, 10.04 it/sec, obj=138]
    INFO - 16:56:18: ...  22%|██▎       | 45/200 [00:04<00:15, 10.04 it/sec, obj=138]
    INFO - 16:56:18: ...  23%|██▎       | 46/200 [00:04<00:15, 10.07 it/sec, obj=138]
    INFO - 16:56:18: ...  24%|██▎       | 47/200 [00:04<00:15, 10.07 it/sec, obj=138]
    INFO - 16:56:19: ...  24%|██▍       | 48/200 [00:04<00:15, 10.09 it/sec, obj=138]
    INFO - 16:56:19: ...  24%|██▍       | 49/200 [00:04<00:14, 10.09 it/sec, obj=138]
    INFO - 16:56:19: ...  25%|██▌       | 50/200 [00:04<00:14, 10.10 it/sec, obj=138]
    INFO - 16:56:19: ...  26%|██▌       | 51/200 [00:05<00:14, 10.10 it/sec, obj=138]
    INFO - 16:56:19: ...  26%|██▌       | 52/200 [00:05<00:14, 10.12 it/sec, obj=138]
    INFO - 16:56:19: ...  26%|██▋       | 53/200 [00:05<00:14, 10.12 it/sec, obj=138]
    INFO - 16:56:19: ...  27%|██▋       | 54/200 [00:05<00:14, 10.14 it/sec, obj=137]
    INFO - 16:56:19: ...  28%|██▊       | 55/200 [00:05<00:14, 10.14 it/sec, obj=137]
    INFO - 16:56:19: ...  28%|██▊       | 56/200 [00:05<00:14, 10.16 it/sec, obj=137]
    INFO - 16:56:19: ...  28%|██▊       | 57/200 [00:05<00:14, 10.15 it/sec, obj=137]
    INFO - 16:56:20: ...  29%|██▉       | 58/200 [00:05<00:13, 10.17 it/sec, obj=137]
    INFO - 16:56:20: ...  30%|██▉       | 59/200 [00:05<00:13, 10.17 it/sec, obj=137]
    INFO - 16:56:20: ...  30%|███       | 60/200 [00:05<00:13, 10.19 it/sec, obj=137]
    INFO - 16:56:20: ...  30%|███       | 61/200 [00:05<00:13, 10.18 it/sec, obj=137]
    INFO - 16:56:20: ...  31%|███       | 62/200 [00:06<00:13, 10.20 it/sec, obj=137]
    INFO - 16:56:20: ...  32%|███▏      | 63/200 [00:06<00:13, 10.20 it/sec, obj=137]
    INFO - 16:56:20: ...  32%|███▏      | 64/200 [00:06<00:13, 10.21 it/sec, obj=137]
    INFO - 16:56:20: ...  32%|███▎      | 65/200 [00:06<00:13, 10.21 it/sec, obj=137]
    INFO - 16:56:20: ...  33%|███▎      | 66/200 [00:06<00:13, 10.22 it/sec, obj=137]
    INFO - 16:56:20: ...  34%|███▎      | 67/200 [00:06<00:13, 10.23 it/sec, obj=137]
    INFO - 16:56:20: ...  34%|███▍      | 68/200 [00:06<00:12, 10.24 it/sec, obj=137]
    INFO - 16:56:21: ...  34%|███▍      | 69/200 [00:06<00:12, 10.24 it/sec, obj=137]
    INFO - 16:56:21: ...  35%|███▌      | 70/200 [00:06<00:12, 10.25 it/sec, obj=137]
    INFO - 16:56:21: ...  36%|███▌      | 71/200 [00:06<00:12, 10.24 it/sec, obj=137]
    INFO - 16:56:21: ...  36%|███▌      | 72/200 [00:07<00:12, 10.26 it/sec, obj=137]
    INFO - 16:56:21: ...  36%|███▋      | 73/200 [00:07<00:12, 10.26 it/sec, obj=137]
    INFO - 16:56:21: ...  37%|███▋      | 74/200 [00:07<00:12, 10.27 it/sec, obj=137]
    INFO - 16:56:21: ...  38%|███▊      | 75/200 [00:07<00:12, 10.27 it/sec, obj=137]
    INFO - 16:56:21: ...  38%|███▊      | 76/200 [00:07<00:12, 10.28 it/sec, obj=137]
    INFO - 16:56:21: ...  38%|███▊      | 77/200 [00:07<00:11, 10.28 it/sec, obj=137]
    INFO - 16:56:21: ...  39%|███▉      | 78/200 [00:07<00:11, 10.29 it/sec, obj=137]
    INFO - 16:56:22: ...  40%|███▉      | 79/200 [00:07<00:11, 10.29 it/sec, obj=137]
    INFO - 16:56:22: ...  40%|████      | 80/200 [00:07<00:11, 10.30 it/sec, obj=137]
    INFO - 16:56:22: ...  40%|████      | 81/200 [00:07<00:11, 10.30 it/sec, obj=137]
    INFO - 16:56:22: ...  41%|████      | 82/200 [00:07<00:11, 10.31 it/sec, obj=137]
    INFO - 16:56:22: ...  42%|████▏     | 83/200 [00:08<00:11, 10.26 it/sec, obj=137]
    INFO - 16:56:22: ...  42%|████▏     | 84/200 [00:08<00:11, 10.27 it/sec, obj=137]
    INFO - 16:56:22: ...  42%|████▎     | 85/200 [00:08<00:11, 10.27 it/sec, obj=137]
    INFO - 16:56:22: ...  43%|████▎     | 86/200 [00:08<00:11, 10.28 it/sec, obj=137]
    INFO - 16:56:22: ...  44%|████▎     | 87/200 [00:08<00:10, 10.28 it/sec, obj=137]
    INFO - 16:56:22: ...  44%|████▍     | 88/200 [00:08<00:10, 10.29 it/sec, obj=137]
    INFO - 16:56:22: ...  44%|████▍     | 89/200 [00:08<00:10, 10.29 it/sec, obj=137]
    INFO - 16:56:23: ...  45%|████▌     | 90/200 [00:08<00:10, 10.30 it/sec, obj=137]
    INFO - 16:56:23: ...  46%|████▌     | 91/200 [00:08<00:10, 10.29 it/sec, obj=137]
    INFO - 16:56:23: ...  46%|████▌     | 92/200 [00:08<00:10, 10.31 it/sec, obj=137]
    INFO - 16:56:23: ...  46%|████▋     | 93/200 [00:09<00:10, 10.30 it/sec, obj=137]
    INFO - 16:56:23: ...  47%|████▋     | 94/200 [00:09<00:10, 10.31 it/sec, obj=137]
    INFO - 16:56:23: ...  48%|████▊     | 95/200 [00:09<00:10, 10.31 it/sec, obj=137]
    INFO - 16:56:23: ...  48%|████▊     | 96/200 [00:09<00:10, 10.32 it/sec, obj=137]
    INFO - 16:56:23: ...  48%|████▊     | 97/200 [00:09<00:09, 10.32 it/sec, obj=137]
    INFO - 16:56:23: ...  49%|████▉     | 98/200 [00:09<00:09, 10.33 it/sec, obj=137]
    INFO - 16:56:23: ...  50%|████▉     | 99/200 [00:09<00:09, 10.33 it/sec, obj=137]
    INFO - 16:56:24: ...  50%|█████     | 100/200 [00:09<00:09, 10.33 it/sec, obj=137]
    INFO - 16:56:24: ...  50%|█████     | 101/200 [00:09<00:09, 10.33 it/sec, obj=137]
    INFO - 16:56:24: ...  51%|█████     | 102/200 [00:09<00:09, 10.34 it/sec, obj=137]
    INFO - 16:56:24: ...  52%|█████▏    | 103/200 [00:09<00:09, 10.34 it/sec, obj=137]
    INFO - 16:56:24: ...  52%|█████▏    | 104/200 [00:10<00:09, 10.34 it/sec, obj=137]
    INFO - 16:56:24: ...  52%|█████▎    | 105/200 [00:10<00:09, 10.34 it/sec, obj=137]
    INFO - 16:56:24: ...  53%|█████▎    | 106/200 [00:10<00:09, 10.35 it/sec, obj=137]
    INFO - 16:56:24: ...  54%|█████▎    | 107/200 [00:10<00:08, 10.34 it/sec, obj=137]
    INFO - 16:56:24: ...  54%|█████▍    | 108/200 [00:10<00:08, 10.35 it/sec, obj=137]
    INFO - 16:56:24: ...  55%|█████▍    | 109/200 [00:10<00:08, 10.35 it/sec, obj=137]
    INFO - 16:56:24: ...  55%|█████▌    | 110/200 [00:10<00:08, 10.36 it/sec, obj=137]
    INFO - 16:56:25: ...  56%|█████▌    | 111/200 [00:10<00:08, 10.36 it/sec, obj=137]
    INFO - 16:56:25: ...  56%|█████▌    | 112/200 [00:10<00:08, 10.37 it/sec, obj=137]
    INFO - 16:56:25: ...  56%|█████▋    | 113/200 [00:10<00:08, 10.37 it/sec, obj=137]
    INFO - 16:56:25: ...  57%|█████▋    | 114/200 [00:10<00:08, 10.38 it/sec, obj=137]
    INFO - 16:56:25: ...  57%|█████▊    | 115/200 [00:11<00:08, 10.37 it/sec, obj=137]
    INFO - 16:56:25: ...  58%|█████▊    | 116/200 [00:11<00:08, 10.37 it/sec, obj=137]
    INFO - 16:56:25: ...  58%|█████▊    | 117/200 [00:11<00:08, 10.37 it/sec, obj=137]
    INFO - 16:56:25: ...  59%|█████▉    | 118/200 [00:11<00:07, 10.38 it/sec, obj=137]
    INFO - 16:56:25: ...  60%|█████▉    | 119/200 [00:11<00:07, 10.37 it/sec, obj=137]
    INFO - 16:56:25: ...  60%|██████    | 120/200 [00:11<00:07, 10.38 it/sec, obj=137]
    INFO - 16:56:25: ...  60%|██████    | 121/200 [00:11<00:07, 10.37 it/sec, obj=137]
    INFO - 16:56:26: ...  61%|██████    | 122/200 [00:11<00:07, 10.38 it/sec, obj=137]
    INFO - 16:56:26: ...  62%|██████▏   | 123/200 [00:11<00:07, 10.37 it/sec, obj=137]
    INFO - 16:56:26: ...  62%|██████▏   | 124/200 [00:11<00:07, 10.38 it/sec, obj=137]
    INFO - 16:56:26: ...  62%|██████▎   | 125/200 [00:12<00:07, 10.38 it/sec, obj=137]
    INFO - 16:56:26: ...  63%|██████▎   | 126/200 [00:12<00:07, 10.38 it/sec, obj=137]
    INFO - 16:56:26: ...  64%|██████▎   | 127/200 [00:12<00:07, 10.38 it/sec, obj=137]
    INFO - 16:56:26: ...  64%|██████▍   | 128/200 [00:12<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:26: ...  64%|██████▍   | 129/200 [00:12<00:06, 10.38 it/sec, obj=137]
    INFO - 16:56:26: ...  65%|██████▌   | 130/200 [00:12<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:26: ...  66%|██████▌   | 131/200 [00:12<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  66%|██████▌   | 132/200 [00:12<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  66%|██████▋   | 133/200 [00:12<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  67%|██████▋   | 134/200 [00:12<00:06, 10.40 it/sec, obj=137]
    INFO - 16:56:27: ...  68%|██████▊   | 135/200 [00:12<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  68%|██████▊   | 136/200 [00:13<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  68%|██████▊   | 137/200 [00:13<00:06, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  69%|██████▉   | 138/200 [00:13<00:05, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  70%|██████▉   | 139/200 [00:13<00:05, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  70%|███████   | 140/200 [00:13<00:05, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  70%|███████   | 141/200 [00:13<00:05, 10.39 it/sec, obj=137]
    INFO - 16:56:27: ...  71%|███████   | 142/200 [00:13<00:05, 10.39 it/sec, obj=137]
    INFO - 16:56:28: ...  72%|███████▏  | 143/200 [00:13<00:05, 10.39 it/sec, obj=137]
    INFO - 16:56:28: ...  72%|███████▏  | 144/200 [00:13<00:05, 10.40 it/sec, obj=137]
    INFO - 16:56:28: ...  72%|███████▎  | 145/200 [00:13<00:05, 10.39 it/sec, obj=137]
    INFO - 16:56:28: ...  73%|███████▎  | 146/200 [00:14<00:05, 10.40 it/sec, obj=137]
    INFO - 16:56:28: ...  74%|███████▎  | 147/200 [00:14<00:05, 10.40 it/sec, obj=137]
    INFO - 16:56:28: ...  74%|███████▍  | 148/200 [00:14<00:04, 10.40 it/sec, obj=137]
    INFO - 16:56:28: ...  74%|███████▍  | 149/200 [00:14<00:04, 10.40 it/sec, obj=137]
    INFO - 16:56:28: ...  75%|███████▌  | 150/200 [00:14<00:04, 10.40 it/sec, obj=137]
    INFO - 16:56:28: ...  76%|███████▌  | 151/200 [00:14<00:04, 10.40 it/sec, obj=137]
    INFO - 16:56:28: ...  76%|███████▌  | 152/200 [00:14<00:04, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  76%|███████▋  | 153/200 [00:14<00:04, 10.40 it/sec, obj=137]
    INFO - 16:56:29: ...  77%|███████▋  | 154/200 [00:14<00:04, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  78%|███████▊  | 155/200 [00:14<00:04, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  78%|███████▊  | 156/200 [00:14<00:04, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  78%|███████▊  | 157/200 [00:15<00:04, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  79%|███████▉  | 158/200 [00:15<00:04, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  80%|███████▉  | 159/200 [00:15<00:03, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  80%|████████  | 160/200 [00:15<00:03, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  80%|████████  | 161/200 [00:15<00:03, 10.41 it/sec, obj=137]
    INFO - 16:56:29: ...  81%|████████  | 162/200 [00:15<00:03, 10.42 it/sec, obj=137]
    INFO - 16:56:29: ...  82%|████████▏ | 163/200 [00:15<00:03, 10.42 it/sec, obj=137]
    INFO - 16:56:30: ...  82%|████████▏ | 164/200 [00:15<00:03, 10.42 it/sec, obj=137]
    INFO - 16:56:30: ...  82%|████████▎ | 165/200 [00:15<00:03, 10.42 it/sec, obj=137]
    INFO - 16:56:30: ...  83%|████████▎ | 166/200 [00:15<00:03, 10.42 it/sec, obj=137]
    INFO - 16:56:30: ...  84%|████████▎ | 167/200 [00:16<00:03, 10.42 it/sec, obj=137]
    INFO - 16:56:30: ...  84%|████████▍ | 168/200 [00:16<00:03, 10.43 it/sec, obj=137]
    INFO - 16:56:30: ...  84%|████████▍ | 169/200 [00:16<00:02, 10.43 it/sec, obj=137]
    INFO - 16:56:30: ...  85%|████████▌ | 170/200 [00:16<00:02, 10.43 it/sec, obj=137]
    INFO - 16:56:30: ...  86%|████████▌ | 171/200 [00:16<00:02, 10.43 it/sec, obj=137]
    INFO - 16:56:30: ...  86%|████████▌ | 172/200 [00:16<00:02, 10.43 it/sec, obj=137]
    INFO - 16:56:30: ...  86%|████████▋ | 173/200 [00:16<00:02, 10.43 it/sec, obj=137]
    INFO - 16:56:30: ...  87%|████████▋ | 174/200 [00:16<00:02, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  88%|████████▊ | 175/200 [00:16<00:02, 10.43 it/sec, obj=137]
    INFO - 16:56:31: ...  88%|████████▊ | 176/200 [00:16<00:02, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  88%|████████▊ | 177/200 [00:16<00:02, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  89%|████████▉ | 178/200 [00:17<00:02, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  90%|████████▉ | 179/200 [00:17<00:02, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  90%|█████████ | 180/200 [00:17<00:01, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  90%|█████████ | 181/200 [00:17<00:01, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  91%|█████████ | 182/200 [00:17<00:01, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  92%|█████████▏| 183/200 [00:17<00:01, 10.44 it/sec, obj=137]
    INFO - 16:56:31: ...  92%|█████████▏| 184/200 [00:17<00:01, 10.44 it/sec, obj=137]
    INFO - 16:56:32: ...  92%|█████████▎| 185/200 [00:17<00:01, 10.44 it/sec, obj=137]
    INFO - 16:56:32: ...  93%|█████████▎| 186/200 [00:17<00:01, 10.49 it/sec, obj=Not evaluated]
    INFO - 16:56:32: Optimization result:
    INFO - 16:56:32:    Optimizer info:
    INFO - 16:56:32:       Status: None
    INFO - 16:56:32:       Message: Successive iterates of the objective function are closer than ftol_rel or ftol_abs. GEMSEO Stopped the driver
    INFO - 16:56:32:       Number of calls to the objective function by the optimizer: 186
    INFO - 16:56:32:    Solution:
    INFO - 16:56:32:       The solution is feasible.
    INFO - 16:56:32:       Objective: 136.56131771172448
    INFO - 16:56:32:       Standardized constraints:
    INFO - 16:56:32:          volume fraction - 0.3 = -1.0460364907594055e-08
    INFO - 16:56:32: *** End MDOScenario execution (time: 0:00:17.746485) ***

{'max_iter': 200, 'algo': 'NLOPT_MMA'}

Results

Post-process the optimization history:

scenario.post_process(
    "BasicHistory",
    variable_names=["compliance"],
    save=True,
    show=False,
    file_name=problem_name + "_history.png",
)
<gemseo.post.basic_history.BasicHistory object at 0x7fbc5632a310>
../../_images/Short_Cantilever_history.png

Plot the solution:

plt.ion()  # Ensure that redrawing is possible
fig, ax = plt.subplots()
im = ax.imshow(
    -scenario.optimization_result.x_opt.reshape((n_x, n_y)).T,
    cmap="gray",
    interpolation="none",
    norm=colors.Normalize(vmin=-1, vmax=0),
)
fig.show()
im.set_array(-scenario.optimization_result.x_opt.reshape((n_x, n_y)).T)
fig.canvas.draw()
plt.savefig(problem_name + "_solution.png")
topology optimization short cantilever../../_images/Short_Cantilever_solution.png

Total running time of the script: ( 0 minutes 18.317 seconds)

Gallery generated by Sphinx-Gallery