Introduction
This introduction is intended to give you a jump start in your modeling work. It contains examples of the typical use of the Optimization Module and two tutorial models that introduce the workflow. The first tutorial solves a curve fitting problem, and the second example contains a topology optimization of a structural beam.
You can use the Optimization Module in combination with essentially any of the other products in the COMSOL product suite. The module is a general interface for computing optimal solutions to engineering problems to, for example, improve a design so that it minimizes energy consumption or maximizes the output. Any model inputs such as geometric dimensions and part shapes, material properties, and material distribution can be treated as design variables, and any model output can be an objective function.
Problems that may benefit from the systematic exploratory processes provided by the Optimization Module can be divided broadly into two classes:
Design problems with a single objective.
Here, the problem is to find the values of control variables or design variables that yield the best performance of a model, quantified by means of an objective function. Problems of this kind arise, for example, in structural optimization, antenna design, and process optimization. In many cases, improving the objective function in a robust way is more important than finding the absolute optimum.
Inverse problems, and in particular parameter estimation in PDEs.
Here the problem is to reliably determine the values of a set of parameters that provide simulated data that best matches measured data. Such problems arise in applications such as geophysical imaging, nondestructive testing, biomedical imaging, and weather data assimilations. Curve fitting also belongs to this category.
Problems of the above types can often be formulated more generally as optimization problems. The Optimization interface, Optimization study step, and Parameter Estimation study step in COMSOL Multiphysics are useful for solving design problems as well as inverse problems and parameter estimation.
Workflow and Examples
The workflow in the Optimization Module is quite straightforward and can be described by the following steps:
For PDE constrained optimization, first create the forward model containing the geometry and the physics. Define parameters under Global Definitions, or by adding control variables to an Optimization interface. Make sure the forward model solves properly for some reasonable values of the control variables before proceeding with defining the objective function and constraints, and then finally solve the optimization problem.
Note that if your optimization problem only requires global scalar control variables, objective functions and constraint expressions, you can set everything up directly in the Optimization study step. The Optimization interface is only needed if constraints must be applied at each mesh node individually, or if the objective function is of a nonglobal least-squares type.
Examples using the Optimization Module exist in the application library for the Optimization Module, as well as in the Application Libraries for several other modules. Search for optimization in the Application Libraries window search field to find models that use the Optimization Module in the products that your license includes. The models illustrate the use of the Optimization interfaces
The interfaces can be used across the different physics, so the absence of an example for particular combination of interface and physics does not indicate incompatibility, but this can be the case. In example, the shape and topology optimization interfaces rely heavily on gradient-based optimization and this is currently unsupported for explicit time stepping.
An Overview of Optimization Terminology
Assuming that you have solved a COMSOL Multiphysics model of a physical design, it is common to ascribe to it some figure of merit, a cost function, or — using a more general term — an objective function. This objective function can quantify almost anything about the performance of the system.
It is natural to question how this objective function changes when you vary some parameters or control variables. These variables or parameters can control any part of the design: dimensions, loads, boundary conditions, material properties, material distribution, and so forth. The control variables often have a set of bounds and design constraints associated with them: dimensions must be within some limits, geometric features must not come to close to each other, only certain materials are possible, and so on.
When optimizing a system modeled as a Multiphysics model, there may also be performance constraints present, which depend on the model solution. For example, when minimizing the weight of a part, it is often important to keep the maximum stress or temperature below a predefined safety limit.
In general, an optimization problem is when you want to improve the objective function by varying the control variables within some set of constraints. Optimization problems can be further categorized as topology, size, shape, and parameter optimization.
Optimization Algorithms
The Optimization Module contains the framework and functionality needed to perform gradient-based and gradient-free optimization on an existing COMSOL Multiphysics model.
The first algorithm is the IPOPT solver. When using IPOPT, the objective function can have any form and any constraints can be applied. The algorithm uses a gradient-based optimization technique to find optimal designs, and when the underlying PDE is stationary, frequency-, or time-dependent, analytic sensitivities of the objective function with respect to the control variables can be used. The main authors are Andreas Waechter and Carl Laird from IBM, but the code is still developed as an open-source project with many contributors.
The second and third algorithms are the MMA and GCMMA solvers, which are based on the method of moving asymptotes by Krister Svanberg of KTH (Royal Institute of Technology, Stockholm). The MMA solver can handle objective functions and constraints of the same very general form as IPOPT. It can solve min-max optimization problems, and it is well suited to handle problems with a large number of control variables, such as topology optimization. The globally convergent version of the solver is often referred to as GCMMA. Both MMA and GCMMA have support for limiting the step length via move limits.
The fourth algorithm is a Levenberg–Marquardt solver. When this solver is used, the objective function must be of least-squares type. Also, constraints are not supported. Since the Levenberg–Marquardt method is derived to solve problems of least-squares type, it typically converges faster than IPOPT and MMA for such problems. The solver can compute confidence intervals for the control variables, but this assumes that the measurement errors are small and follow a normal distribution.
In addition, the Optimization Module provides a number of gradient-free (derivative-free) optimization algorithms. Currently Nelder–Mead, BOBYQA, COBYLA, and EGO are supported. These methods can optimize a model with respect to design parameters (model parameters) including those that control the geometry sequence that defines the model geometry. Nelder–Mead and COBYLA support strict enforcement of constraints that only depend on the control variables (design constraint).
All optimization solvers are accessible from the same Optimization study step, which contains the ordinary solver sequence over which the optimization method iterates. The gradient-free methods can contain any other study sequence, including Study Reference links, which make it possible to evaluate different objective function contributions and constraints in different studies. The gradient-based methods are limited to optimizing over a single study step for types supporting the computation of analytic sensitivities: currently Stationary, Time Dependent, and Frequency Domain studies.
Optimization Module Applications
The Optimization Module provides versatile tools for optimization, curve fitting, parameter estimation, and inverse modeling. Optimization can involve solving a basic linear or quadratic programming problem, but you can also seamlessly incorporate optimization and parameter estimation as additions to, for example, models of structural mechanics, fluid flow, or chemical reactions. The optimizations can be an optimal shape or topology, or a maximization or minimization of some quantity, just to name a couple of examples.
The plot in Figure 1 shows the hydraulic conductivity obtained by inverse modeling using 24 observations in a model where the aim is to characterize an aquifer. The model is in the Subsurface Flow Module application library and combines the Optimization interface with a Darcy’s Law interface for the fluid flow in the aquifer. The inverse problem in this model is to estimate the hydraulic-conductivity field in the aquifer using experimental data in the form of hydraulic-head measurements from four dipole-pump tests.
Figure 1: Hydraulic conductivity obtained by inverse modeling in the Aquifer Characterization model.
Another application of the Optimization Module is to find the optimal distribution of porous material in a microchannel, where the objective is to minimize the horizontal velocity at the center of the channel. The plot in Figure 2 shows the x-component of the velocity field for the optimal solution and the distribution of the filling material in the open channel:
Figure 2: The horizontal velocity (surface plot) and velocity field (streamlines) after optimization. In addition, the contour γ = 0.5 indicates the border between open channel and filling material.
This model is in the Optimization Module Application Library. It combines a Laminar Flow interface for the single-phase flow in the channel and an Optimization interface, where the objective is a scaled x direction velocity that the optimization solver minimizes. The design variable gamma (γ) can be interpreted as the local porosity, ranging between 0 (filled) and 1 (open channel), so the contour γ = 0.5 indicates the border between the open channel and the filling.
About Parameter Estimation
You can use the Optimization Module to perform parameter estimation: to determine input values so that the output matches some experimental data — that is, to solve an inverse problem. The first tutorial (Tutorial Model — Curve Fitting) describes how to use the Optimization Module for parameter estimation. When solving an inverse problem, there is some set of experimental data that can be compared to the output of the model. Parameter estimation is used to adjust model inputs or properties such that the results agree with the experimental data. Typical objectives include estimating material properties or loads.
For several reasons, inverse problems are inherently the most difficult problems to solve. They are often ill-posed in the sense that they have multiple locally optimal solutions where the optimization algorithm may get stuck, or entire subspaces of equal merit may exist where the algorithm wanders around forever. In addition, the particular local optimum that is found depends strongly on the initial guess and on small perturbations in the experimental data. For these reasons, it is best to approach inverse problems with a good understanding of the underlying physics and mathematics of the problem. In particular, some problem-dependent regularization strategy is usually needed to make the optimization process robust.
Consider a COMSOL Multiphysics model of a physical system, such as a sample of a rubber-like material in simple uniaxial tension. One way to model rubber-like materials is using a Mooney–Rivlin model, which requires empirically determined material constants to describe the structural deformation. Assuming that there are experimental results relating load and deformation, as shown in Figure 3, it is possible to use parameter estimation to determine the material model constants that best fit this data. The curve shown in Figure 3 is computed based on the results of a parameter estimation; it is a least-squares fit of a COMSOL Multiphysics model with Mooney–Rivlin material parameters to the experimental data.
Figure 3: Experimental data and a best fit curve of the Mooney–Rivlin material model based upon a finite element model of a test sample.
About Topology Optimization
The second tutorial model in this guide (Tutorial Model — Topology Optimization) shows how to solve a model using topology optimization.
Consider a COMSOL Multiphysics model of a physical system, such as the bracket shown in Figure 4. The part is constrained at the top and loaded on the side. The part must support a known load while staying within acceptable limits on the deflection. However, an experienced structural engineer can quickly recognize that the part is overdesigned. It is possible to remove material from the part, which would reduce the total mass (the cost) of the part, while still staying within the limits on the deflection (the constraints). A closely related problem which is often easier to solve can be stated as: Minimize the compliance (the deflection) of the structure under the condition that the total mass must be reduced by at least some predefined factor.
Figure 4: A simple bracket design, and the solved finite element model showing stresses and deflections. This design has room for improvement.
One way to address this is to use topology optimization. Topology optimization treats the material distribution as the design variable. Design variables of this type are treated in the same way as the solution variables; they are interpolated using shape functions on the finite element mesh. Therefore, there is one design variable per mesh node or per mesh element, associated with a position in the geometry. We call this a control variable field.
The Optimization Module computes the derivative, or the sensitivity, of the objective function with respect to these discrete design variables. For topology optimization, the adjoint method is required, because all other methods are too slow. The optimization solver uses the sensitivity information to manipulate the design variables, within the limit of any user-defined constraints, in the direction of improved objective function values.
This is an iterative procedure, as illustrated in Figure 5. Starting with the initial design, the solver adjusts the control variables representing a fictitious material density in each element. This is repeated as long as some improvement in the objective function is possible and the constraints are not violated.
Figure 5: Topology optimization of the bracket, the material distribution, as defined by the finite element mesh, is modified to minimize the weight while satisfying a constraint on peak displacement. The design evolution is shown after 8, 12, 16, and 60 iterations.
A structural engineer will recognize that the resulting design is essentially a truss structure. This result also highlights an issue with topology optimization: The optimal design is often not a candidate for manufacture, it is only an approximation of a better design, as found via the current finite element mesh. With a modicum of engineering knowledge, it is still possible to use the results of a topology optimization as a design guide to build the next design iteration.
Although topology optimization is quick to set up, it has a couple of drawbacks. First, the resulting design does have some dependency on the mesh used. There are techniques known as regularization that you can use to avoid this and the topology model example in this guide includes regularization. Second, it is difficult to incorporate geometric constraints into the optimization algorithm and this can lead to impractical designs, but COMSOL does support the use of milling constraint for topology optimization. This can be used to reduce the design freedom, so that more practical designs are found. In any case, topology optimization should be used early in the design process as a guide for the overall structure of the system. The method becomes more difficult to use efficiently when the design is already quite rigid and only minor modifications to the design are possible. In such situations, size optimization and shape optimization become more useful.