Solvers

Solvers to solve topology optimization problems.

Todo

  • Make TopOptSolver an abstract class
  • Rename the current TopOptSolver to MMASolver(TopOptSolver)
  • Create a TopOptSolver using originality criterion

Base Solver

class topopt.solvers.TopOptSolver(problem, volfrac, filter, gui, maxeval=2000, ftol_rel=0.001)[source]

Solver for topology optimization problems using NLopt’s MMA solver.

__init__(problem, volfrac, filter, gui, maxeval=2000, ftol_rel=0.001)[source]

Create a solver to solve the problem.

Parameters:
  • problem (topopt.problems.Problem) – The topology optimization problem to solve.
  • volfrac (float) – The maximum fraction of the volume to use.
  • filter (topopt.filters.Filter) – A filter for the solutions to reduce artefacts.
  • gui (topopt.guis.GUI) – The graphical user interface to visualize intermediate results.
  • maxeval (int) – The maximum number of evaluations to perform.
  • ftol (float) – A floating point tolerance for relative change.
filter_variables(x)[source]

Filter the variables and impose values on passive/active variables.

Parameters:x (ndarray) – The variables to be filtered.
Returns:The filtered “physical” variables.
Return type:numpy.ndarray
ftol_rel

Relative tolerance for convergence.

Type:float
maxeval

Maximum number of objective evaluations (iterations).

Type:int
objective_function(x, dobj)[source]

Compute the objective value and gradient.

Parameters:
  • x (ndarray) – The design variables for which to compute the objective.
  • dobj (ndarray) – The gradient of the objective to compute.
Returns:

The objective value.

Return type:

float

objective_function_fdiff(x, dobj, epsilon=1e-06)[source]

Compute the objective value and gradient using finite differences.

Parameters:
  • x (ndarray) – The design variables for which to compute the objective.
  • dobj (ndarray) – The gradient of the objective to compute.
  • epsilon – Change in the finite difference to compute the gradient.
Returns:

The objective value.

Return type:

float

optimize(x)[source]

Optimize the problem.

Parameters:x (ndarray) – The initial value for the design variables.
Returns:The optimal value of x found.
Return type:numpy.ndarray
volume_function(x, dv)[source]

Compute the volume constraint value and gradient.

Parameters:
  • x (ndarray) – The design variables for which to compute the volume constraint.
  • dobj – The gradient of the volume constraint to compute.
Returns:

The volume constraint value.

Return type:

float

Specialized Solvers