The Topology Optimization Study
The Topology Optimization study () node collects all settings necessary for solving topology optimization problems. It serves the dual purpose of defining the optimization problem to be solved and choosing an optimization solver, as well as controlling important solver properties and solver output.
The complete optimization problem can be set up directly in the General Optimization study node when the objective function to be minimized or maximized is a global scalar expression and the only control variables to be varied are already defined as model parameters. The study step is incompatible with the Optimization interface.
When you add an Topology Optimization study node to a study, it is always inserted as the first node, at the top of the study sequence (below any parametric sweeps). The study only works with gradient-based optimization; see About Gradient-Based Solvers for more information.
This section describes the Topology Optimization study node available with the Optimization Module. See also Studies and Solvers in the COMSOL Multiphysics Reference Manual for more information about solvers in general. In this guide, see About the Optimization Solvers for details on the capability and settings of the individual optimization solvers.
Expressions for user-defined objective and constraint functions are evaluated in the global namespace, while the expressions for physics-defined objective and constraint expressions are evaluated in the component namespace. If there are a global parameter or function and a component variable or function with the same name (for example, par or func: root.par and compi.par, root.func, and compi.func) and a user-defined objective function or constraint with expression f(par) or func, it is evaluated as f(root.par) and root.func, while a physics-defined objective or constraint with expression f(par) or func is evaluated as f(compi.par) or compi.func. Note that the evaluation of the expressions of the user-defined objective and constraint functions in the Topology Optimization study differs from the evaluation in Results (where the expressions are evaluated in the component namespace).
The Settings window has the following sections:
Optimization Solver
Select an optimization solver and specify its most important parameters.
Method
Choose an optimization solver method. The Method list of available solvers contains the following gradient-based methods: GCMMA, MMA, and IPOPT.
The different solvers are more or less suitable for different types of topology optimization problems.
Study Step
Select the Study step to optimize over. The setting is hidden if the study only contains a single compatible study step.
Optimality Tolerance
Specify the relative Optimality tolerance. The value is applied relative to each control variable after scaling with its corresponding specified scale.
Maximum Number of Iterations
Specify the Maximum number of iterations. The default is 100. This number limits the number of iterations. Use The General Optimization Study to constrain the number of model evaluations directly. Note that the study will not throw a warning, if the solver terminates on the maximum number of iterations.
Move Limits
Select the Move limits checkbox to constrain the maximum absolute change of any (scaled) control variable. Sometimes this option can prevent optimization solver from returning bad local minima. The setting is only available with the MMA optimization solver.
Objective Function
You specify the objective function for the optimization problem in the table’s Expression column. Enter any globally available expression that evaluates to a real number. Optionally, you can add a description in the Description column. Click the Add Expression () and Replace Expression () buttons to search through a list of predefined expressions.
For an optimization objective that is expressed in terms of the solution u of a PDE, Integration (described in COMSOL Multiphysics Reference Manual) is one example of how you can define a scalar objective as required by the optimization solver. The evaluation of the objective function is similar to Global Variable Probe (described in COMSOL Multiphysics Reference Manual), so any variable that can be represented by a global variable probe is suitable as an objective.
Type
Select whether to perform a Minimization or a Maximization of the objective function. The default is to minimize the objective function.
Solution
Here you select which solution or solutions to use for evaluating the objective function when several solutions are present, like for Time Dependent or Eigenvalue studies. The possible choices are Auto (the default), Use first, Use last, Sum of objectives, Minimum of objectives, and Maximum of objectives. Note that the last three options first evaluate multiple objectives according to the Multiple objectives setting for each solution individually, and then compute the sum, minimum, or maximum of the individual results.
When using IPOPT, Auto is the only choice. MMA supports all options except when optimizing over a Time Dependent study step.
With Auto selected, the solver chooses the evaluation method based on the innermost study.
For the studies of Eigenvalue, Eigenfrequency, or Linear Buckling type (all described in COMSOL Multiphysics Reference Manual), the first solution corresponding to the smallest eigenvalue is chosen. For studies with parametric solutions (for example, studies in the Frequency Domain), the contributions from all solutions are summed (equivalent to the Sum of objectives option). For all other study types, the optimization solver selects the last solution, like the solution at the final time for a Time Dependent problem.
Condition-based Final Time
For time-dependent optimization, the objective is evaluated at the final time, but it is possible to let the optimization solver control this time by specifying a Stop expression. Note that this will be satisfied to the accuracy of the event tolerance on the Time-Dependent Solver.
Objective Scaling
Most optimization solvers benefit from a well-scaled objective function, so that the actual change in the objective is neither extremely small nor extremely large. The default value is None and corresponds to a scale of 1, while Manual allows specifying a custom scale. If Initial solution based scaling is used, the setting interacts with the solution setting, so that the initial sum, minimum, maximum, first, or last value is chosen as the scale.
Alternatively, the scale can be incorporated directly in the definition of the objective, but that would affect the output the in the log and in the objective table, while the Objective scaling setting only causes the objective to be divided by the scale internally in the solver.
Control Variables
If there is a Optimization or Sensitivity interface in the model, containing control variable nodes, these show up in a separate table under Control Variables. Use the Solve for column to deactivate individual control variables as needed.
Constraints
The first table under Constraints lets you specify additional constraints to be imposed on the optimum solution. The Expression column accepts any globally available expression which evaluates to a real number. Constraints can be functions of the control variables both directly and indirectly via PDE solution variables. The Lower bound and Upper bound columns can only contain parameter expressions; they must not depend on control variables, PDE solution variables, or any other user-defined variables, but can include model parameters, physical constants, and units. One bound column can be left blank to indicate that no upper or lower bound is required.
If there are multiple solutions, the constraints are imposed for all them, except if the Solution setting is set to First or Last under the Objective Function section. In which case the constraints are imposed only for the solution used to evaluate the objective function.
Output
Keep Solutions
Use the Keep solutions list to control how to store the solutions from the individual optimization solutions:
Select Only last (the default) if you want to save only the last solution.
Select All if you want to save all solutions.
Select Last N if you want to save the last N solutions. Then specify a positive integer in the Number of solutions to save field to define N (2 by default).
Select Every Nth if you want to save every Nth solution. Specify a positive integer in the Save every Nth field to define N (10 by default to save every 10th solution).
Select First and last if you want to save the first and last solution.
Plot
Select Plot and choose a Plot group to update after each major iteration of the optimization algorithm.
Probes
Select which Probes to evaluate and plot in each iteration.
Keep Objective Values in Table
Select the Keep objective values in table checkbox to retain the table containing control variable and objective function values after the solver completes. Choose an existing Output table, or select New to create a new table. After computing the study, the Output table setting will be changed to the table actually being used.
Objective values displayed on the last line of the table are the converged result of the optimization when the MMA, Levenberg–Marquardt, or IPOPT solver is used.
Select the Show individual objective values checkbox to include one table column for each contribution to the objective. Otherwise, only the total objective is displayed.
Select the Table graph checkbox to plot the objective function values displayed in the objective table. Choose an existing Plot window, including the standard Graphics window, or select New window. After computing the study, the Plot window setting will be changed to the window actually being used.
Keep Constraint Values in Table
Only available for derivative-free methods. Select the Keep constraint values in table checkbox to retain the table containing global constraint values after the solver completes. Choose an existing Constraint table, or select New to create a new table. After computing the study, the Constraint table setting will be changed to the table actually being used.