topoptlab.objectives module

topoptlab.objectives.compliance(xPhys: ndarray, u: ndarray, KE: ndarray, edofMat: ndarray, i: int, matinterpol: Callable, matinterpol_kw: Dict, obj: float, **kwargs: Any) Tuple[float, ndarray, bool][source]

Update objective and gradient for stiffness maximization / compliance minimization.

Parameters:
  • xPhys (np.ndarray) – SIMP densities of shape (nel).

  • u (np.ndarray) – state variable (displacement, temperature) of shape (ndof).

  • KE (np.ndarray) – element stiffness matrix of shape (nedof).

  • edofMat (np.ndarray shape (nel,nedof)) – element degree of freedom matrix

  • i (int) – index of the problem. i-th problem is used to compute the objective function.

  • matinterpol (callable) – callable for material interpolation. Default is SIMP (simp).

  • matinterpol_kw (callable) – dictionary containing the arguments for the material interpolation.

  • obj (float) – objective function.

Returns:

  • obj (float) – updated objective function.

  • rhs_adj (np.ndarray) – right hand side of the adjoint problem. if problem is self adjoint, this is already the solution to the self-adjoint problem.

  • selfadjoint (bool, True) – obj. is selfadjoint, so no adjoint problem has to be solved

topoptlab.objectives.compliance_squarederror(xPhys: ndarray, u: ndarray, c0: float, KE: ndarray, edofMat: ndarray, i: int, matinterpol: Callable, matinterpol_kw: Dict, obj: float, **kwargs: Any) Tuple[float, ndarray, bool][source]

Update objective and gradient for stiffness/compliance control.

Parameters:
  • xPhys (np.ndarray) – SIMP densities of shape (nel).

  • u (np.ndarray) – state variable (displacement, temperature) of shape (ndof).

  • c0 (float) – target compliance

  • KE (np.ndarray) – element stiffness matrix of shape (nedof).

  • edofMat (np.ndarray) – element degree of freedom matrix of shape (nel,nedof)

  • i (int) – index of the problem. i-th problem is used to compute the objective function.

  • matinterpol (callable) – callable for material interpolation. Default is SIMP (simp).

  • matinterpol_kw (callable) – dictionary containing the arguments for the material interpolation.

  • obj (float) – objective function.

Returns:

  • obj (float) – updated objective function.

  • rhs_adj (np.ndarray) – right hand side of the adjoint problem. if problem is self adjoint, this is already the solution to the self-adjoint problem.

  • selfadjoint (bool, True) – obj. is selfadjoint, so no adjoint problem has to be solved

topoptlab.objectives.inverse_homogenization_control(u, u0, edofMat, i, KE, cellVolume, CH0, xPhys, matinterpol: Callable, matinterpol_kw: Dict, results, obj, **kwargs)[source]
topoptlab.objectives.inverse_homogenization_maximization(u: ndarray, u0: ndarray, edofMat: ndarray, i: int, KE: ndarray, cellVolume: float, xPhys: ndarray, Amax, Amin, penal, results, obj, **kwargs)[source]
topoptlab.objectives.var_maximization(u: ndarray, l: ndarray, i: int, obj: float, **kwargs: Any) Tuple[float, ndarray, bool][source]

Update objective and gradient for maximization of state variable in specified points. The mechanic version of this is the compliant mechanism with maximized displacement.

Parameters:
  • u (np.ndarray) – state variable (displacement, temperature) of shape (ndof).

  • l (np.ndarray) – indicator vector for state variable of shape (ndof). Is 1 or -1 at output nodes depending on which direction of the dof you want to maximize.

  • i (int) – index of the problem. i-th problem is used to compute the objective function.

  • obj (float) – objective function.

Returns:

  • obj (float) – updated objective function.

  • rhs_adj (np.ndarray) – right hand side for the adjoint problem

  • selfadjoint (bool, False) – obj. is not selfadjoint, so adjoint problem has to be solved

topoptlab.objectives.var_squarederror(u: ndarray, u0: ndarray, l: ndarray, i: int, obj: float, **kwargs: Any) Tuple[float, ndarray, bool][source]

Update objective and gradient for forcing a state variable to a specific values at certain points. The mechanic version of this is the compliant mechanism with controlled displacement.

Parameters:
  • u (np.ndarray) – state variable (displacement, temperature) of shape (ndof).

  • u0 (np.ndarray) – value that state variable is supposed to take. shape (ncontr).

  • l (np.ndarray) – indicator vector for state variable of shape (ndof). Is 1 at output nodes.

  • obj (float) – objective function.

Returns:

  • obj (float) – updated objective function.

  • rhs_adj (np.ndarray) – right hand side for the adjoint problem. if problem is self adjoint, this is already the solution to the self-adjoint problem.

  • selfadjoint (bool, False) – obj. is not selfadjoint, so adjoint problem has to be solved

topoptlab.objectives.volume(xPhys: ndarray, **kwargs: Any) Tuple[float, ndarray, bool][source]