From 0eda2775d6440c35cd9cabc525d998c827570780 Mon Sep 17 00:00:00 2001 From: Sebastian Blauth Date: Wed, 28 Aug 2024 08:38:55 +0200 Subject: [PATCH] Update the demo for volume projection in topology optimization --- .../projection/config.ini | 36 ------------------- .../projection/demo_projection.py | 26 ++++++++++---- 2 files changed, 19 insertions(+), 43 deletions(-) diff --git a/demos/documented/topology_optimization/projection/config.ini b/demos/documented/topology_optimization/projection/config.ini index ce7fa27e..d1218484 100644 --- a/demos/documented/topology_optimization/projection/config.ini +++ b/demos/documented/topology_optimization/projection/config.ini @@ -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 diff --git a/demos/documented/topology_optimization/projection/demo_projection.py b/demos/documented/topology_optimization/projection/demo_projection.py index 7f624992..faaa007e 100755 --- a/demos/documented/topology_optimization/projection/demo_projection.py +++ b/demos/documented/topology_optimization/projection/demo_projection.py @@ -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 @@ -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 @@ -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 @@ -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 `. @@ -208,7 +219,7 @@ def update_level_set(): dJ_in, dJ_out, update_level_set, - volume_restriction=vol, + volume_restriction=volume_restriction, config=cfg, ) @@ -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 # ) # ::: # ::::