<jupyter_start><jupyter_text>Topology optimization<jupyter_code>import math
import matplotlib.pyplot as plt

from loads import HalfBeam
from constraints import DensityConstraint
from fesolvers import CooFESolver
from topopt import Topopt
%matplotlib inline
# material properties
young = 1
poisson = 0.3

# constraints
volfrac = 0.4
xmin = 0.001
xmax = 1.0

# input parameters
nelx = 180
nely = 60

penal = 3.0
rmin = 5.4

delta = 0.02
loopy = math.inf
# loading/problem
load = HalfBeam(nelx, nely)

# constraints
density_constraint = DensityConstraint(volume_frac = volfrac, density_min = xmin, density_max = xmax)

# optimizer
verbose = False
fesolver = CooFESolver(verbose = verbose)
optimizer = Topopt(fesolver, young, poisson, verbose = verbose)
# compute
x = optimizer.init(load, density_constraint)
x, loop = optimizer.layout(load, density_constraint, x, penal, rmin, delta, loopy)
# plot
plt.figure()
plt.imshow(x, cmap=plt.cm.gray)
plt.title(str(loop) + ' loops')
plt.xticks([])
plt.yticks([])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10652591170825336, 'fraction_numerical': 0.022072936660268713, 'mean_word_length': 5.60126582278481, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '529251', 'license': 'MIT', 'n_tokens_mistral': 401, 'n_tokens_neox': 373, 'n_words': 98, 'path': 'src/example.ipynb', 'repo_name': '1iyiwei/topopt', 'size': '1042'}