Free-Shape Optimization


In Flux, a free-shape optimization may be run in Magneto-Static or in Transient Magnetic applications of the Flux 2D module, to do this the user must define an optimization problem. An optimization problem defines the objective function and the constraints as seen in this part.

The following topics are covered in this documentation:
  • Adjoint method
  • Coupling with Optistruct
  • How to set up a Free-Shape optimization in Flux
  • Limitations
  • Example of application

Adjoint method

Based on the movement of the mesh nodes and not on geometrical entities such as lines, the adjoint method allows the computation of a semi-analytical sensitivity with a reduced computation time compared to finite difference. While keeping the regions and materials bounds and preventing overlapping of mesh elements, the mesh nodes will move into the most attractive direction defined by the sensitivity computation on the objective function over a computation scenario. In Flux this method requires structural information such as the lines to move of the electromagnetic design, it also requires defining an optimization problem (response, objective function, constraints) and defining a solving scenario. It must be kept in mind that only the mesh is moving and not the geometrical entities, however with the macro named CreateGeomFromOS.PFM in the folder .../Extensions/Macros/Macros_Flux2D_Shape_Optimization, it is possible to rebuild geometrical entities such as lines and points from the mesh nodes. For more information dealing with the adjoint method, see this page.

Coupling with Optistruct

As mentioned before, the displacement of the nodes is managed by the sensitivities computed by Flux but also by OptiStruct which allows the nodes of the mesh to move. In order to run a complete free-shape optimization, a coupling with Optistruct must be managed before starting anything else:
  • Install OptiStruct2021.1 available on
  • Set the OptiStruct installation path in the Flux Supervisor > Options > Coupled software and add your local installation path such as C:\Program files\Altair\hwsolvers\scripts

How to set up Free-Shape Optimization in Flux

The first step to run a free-shape optimization in Flux is to define an optimization problem:
  • In the data tree on the left, in the Solver, then in the Optimization node, select the node Responses, choose a response in the shortlist, a response is a physical quantity that will take part of the optimization problem, the list of each available response is summarized here, the responses are the physical quantity to be optimized.
  • Select now the node Constraints in the data tree. Three types of constraints may be defined: a structural constraint with its lower and upper bounds for volume constraints, a constraint on node displacement may be set with the axis or double axis symmetry constraint and a constraint on physical quantities using one or several Responses. For more information about these constraints, see this page. It is not mandatory to have a constraint in the optimization problem to run a free-free-shape optimization in Flux;
  • Select the node Optimization problem:
    • Set the field Minimization or maximization on the chosen value, this field allows the user to choose if the objective function must be increased or decreased.
    • In the field Objective function to optimize, set the operation to apply on the objective function, it can be defined on the available shortlist, or with a custom function defined with Compose, if the function is defined with Compose, an additional parameter will be required such as the function's name. An oml file type may be used to define an objective function and several constraints.
      Note: More information about the Predefined operations are available here and about the Compose function are available here.
    • Select the Responses and the Constraints previously defined
      Note: Several responses may be selected at the same time, in Flux this feature is named Multi-response where a linkage is operated between all the values. Be sure that all the responses are in the same range of values.
      Note: Several constraints may be selected also at the same time.
  • In the Solving menu, choose Run Free-Shape Optimization, it asks you to:
    • Select the lines where the nodes of the mesh can move
    • Choose a solving scenario
    • Select a working directory for the temporary files created during the optimization
    • Choose your optimization problem previously defined
    • Choose the remeshing strategy (with remeshing or without remeshing), it allows to improve the optimization by adding nodes and elements between two optimization iterations, when the mesh becomes of too poor quality following displacements. More fine-tuning of this option may be set in the Optimization options.
  • To set different options on the optimizer, see the node Optimization options, more information is available on this page
Note: A similar algorithm also exists in Advanced mode and is named: Run Free-Shape Optimization (finite difference), this algorithm is not based on the adjoint method as explained before but on the finite difference method. This approach allows the user to run a Free-Shape Optimization with all kinds of sensors and formulas as Responses, however the main drawback of this method is its really huge computation time.


  • No remeshing during the solving scenario (including the variation of geometrical parameters, and compressible mechanical sets)
  • No adaptative time step during solving
  • Some restrictions about the selected lines (no lines at the interface between two faces with the same material on both sides, no lines on the sliding cylinder)
  • The mesh in the zone to optimize must be thin and regular


This example may be seen as an extension of the example available in the supervisor in the 2D Application Note section named: Free-Shape Optimization of a synchronous reluctance machine

Let's consider the modeling of the following electrical machine represented by only one-quarter of the full device.

Figure 1. Four poles electrical machine with three current phases
In that example, only the shape of the rotor will be optimized and we want to:
  • Reduce the weight of the rotor
  • Increase the mean value of the torque

To run the free-shape optimization, the selected response is the Torque computed on a path (Maxwell Tensor) as explained on this page.

In this optimization problem, two constraints are chosen:
  • A one-axis symmetry constraint
  • A constraint on the volume of the rotor in order to decrease its weight
The symmetry constraint may be set as follows:

Figure 2. Origin point and symmetry axis for the one-axis symmetry constraint

The origin axis is set to (0,0) and the symmetry axis is set to (0.5,0.5).

For the constraint on the volume, we want to reduce the volume of iron in the rotor by about 20%, in the upper bound the value corresponding to 80% of the total volume is filled, in the lower bound 60% of the volume is filled.

Even if at the starting point the initial design is not between the bounds, the optimization algorithm will deteriorate the objective function in order to find a design that fits the bounds, then the algorithm will start to optimize the design in order to increase or decrease the objective function.

In the objective function, we choose to Maximize the Average of the Torque response previously defined

In the end, the lines where the nodes can move are selected as depicted in the figure below (the lines are surrounded in yellow):

Figure 3. Lines to be considered during the optimization process

The scenario is piloted by the mechanical set angle and is covering an electrical period with two degrees per computation step.

Using the Free-Shape Optimization, we obtain several files in the temporary folder (.wmv for HyperView) to see the results, check the mesh of the Project_OptimizationResults.FLU:

Figure 4. Initial design of the reluctance synchronous machine (a) and final design of the reluctance synchronous machine (b)
Even though the initial motor already has good performances, the use of Free-Shape Optimization brings remarkable improvements. As shown in Table 1, a 4.8% increase in the mean torque is achieved, with a rotor mass reduction of 20%. Figure 4 shows the initial and optimized rotor configuration.
Table 1. Comparison between the initial design and the final design of the synchronous reluctance machine
  Initial design Final design Difference
Mean torque (N.m) 11.9 12.5 + 4.8%
Rotor weight (kg) 0.5 0.4 - 20%

Figure 5. Displacement of the nodes during the optimization process

Further reading