Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the demo for volume projection in topology optimization #490

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions demos/documented/topology_optimization/projection/config.ini
Original file line number Diff line number Diff line change
@@ -1,58 +1,22 @@
[StateSystem]
is_linear = True
newton_rtol = 1e-11
newton_atol = 1e-13
newton_iter = 50
newton_damped = True
newton_inexact = False
newton_verbose = False
picard_iteration = False
picard_rtol = 1e-10
picard_atol = 1e-12
picard_iter = 10
picard_verbose = False

[OptimizationRoutine]
algorithm = bfgs
rtol = 1e-10
atol = 0.0
max_iter = 1000
gradient_method = direct
gradient_tol = 1e-9
soft_exit = True

[LineSearch]
;method = polynomial
initial_stepsize = 1e-3
safeguard_stepsize = False
epsilon_armijo = 1e-20
beta_armijo = 2.0

[AlgoLBFGS]
bfgs_memory_size = 5
use_bfgs_scaling = True
bfgs_periodic_restart = 3

[AlgoCG]
cg_method = PR
cg_periodic_restart = False
cg_periodic_its = 5
cg_relative_restart = False
cg_restart_tol = 0.5

[AlgoTNM]
inner_newton = cg
max_it_inner_newton = 100
inner_newton_rtol = 1e-15
inner_newton_atol = 0.0

[Output]
verbose = True
save_results = False
save_txt = False
save_state = False
save_adjoint = False
save_gradient = False
time_suffix = False


Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
# {math}`\lambda` are the Lamé parameters which satisfy {math}`\mu \geq 0` and
# {math}`2\mu + d \lambda > 0`, where {math}`d` is the dimension of the problem.
#
# The volume constraint is treated by projecting the level-set function so
# that the updated level-set function satisfies the volume constraint, similar to
# a projected gradient method. For more details, we refer to our preprint
# [Baeck, Blauth, Leithäuser, Pinnau, and Sturm - A Novel Deflation Approach for
# Topology Optimization and Application for Optimization of Bipolar Plates of
# Electrolysis Cells](https://arxiv.org/abs/2406.17491), where the used method is
# described detailedly.
#
# ## Implementation
#
# The complete python code can be found in the file {download}`demo_projection.py
Expand Down Expand Up @@ -151,6 +159,8 @@ def value_shape(self):

J = cashocs.IntegralFunctional(alpha * inner(sigma(u), eps(u)) * dx)

# Note, that this is indeed the same as in {ref}`demo_cantilever` for the case that
# :math:`\gamma = 0`.
# Finally, we specify the generalized topological derivative of the problem
# with the lines

Expand All @@ -177,7 +187,8 @@ def value_shape(self):
)
# -
# This generalized topological derivative is again similar to {ref}`demo_cantilever`
# without the last term resulting from the volume penalty term in the objective.
# without the last term resulting from the volume penalty term in the objective, as
# :math:`\gamma = 0` in this demo since the volume constraint is dealt with differently.

# The update routine for the level-set function reads

Expand All @@ -193,7 +204,7 @@ def update_level_set():

vol_low = 0.5
vol_up = 1.25
vol = (vol_low, vol_up)
volume_restriction = (vol_low, vol_up)

# Now, we are able to define the
# {py:class}`TopologyOptimizationProblem <cashocs.TopologyOptimizationProblem>`.
Expand All @@ -208,7 +219,7 @@ def update_level_set():
dJ_in,
dJ_out,
update_level_set,
volume_restriction=vol,
volume_restriction=volume_restriction,
config=cfg,
)

Expand All @@ -219,12 +230,13 @@ def update_level_set():

# ::::{note}
# In the case of an equality constraint for the volume of {math}`\Omega` we
# have to exchange `vol` by a float describing the desired volume, in this
# case we choose 1.0.
# have to use a float for `volume_restriction` instead of a tuple. For example, if
# we consider a volume equality with target volume of 1, then we would have to use the
# following definition
# :::{code-block} python
# vol = 1.0
# volume_restriction = 1.0
# top = cashocs.TopologyOptimizationProblem(
# F, bcs, J, u, v, psi, dJ_in, dJ_out, update_level_set, volume_restriction=vol, config=cfg
# F, bcs, J, u, v, psi, dJ_in, dJ_out, update_level_set, volume_restriction=volume_restriction, config=cfg
# )
# :::
# ::::
Expand Down
Loading