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.stress_pnorm(u: ndarray, i: int, edofMat: ndarray, B: ndarray, C_es: ndarray, xPhys: ndarray, stress_vm: ndarray, dsvm: ndarray, penal_sig: float, Pnorm: float, obj: float, dscale: ndarray, cs: ndarray, strain: ndarray, **kwargs: Any) Tuple[float, ndarray, ndarray, bool][source]
Aggregated relaxed von Mises stress objective. The relaxed stress is defined as
stress_re = stress_vm / (xPhys_s ** penal_sig)
and the global p-norm objective is
J = ( (1/n) * sum stress_re**Pnorm )**(1/Pnorm)
- Parameters:
u (ndarray of shape (ndof, nload)) – Global displacement field.
i (int) – index of the problem. i-th problem is used to compute the objective function.
edofMat (ndarray of shape (ne, ndof_el)) – Element degree-of-freedom connectivity matrix.
B (ndarray of shape (ne, nvoigt, ndof_el)) – Element strain-displacement matrix.
C_es (ndarray of shape (ne, nvoigt, nvoigt)) – Interpolated constitutive matrix for each element.
xPhys (np.ndarray, shape (ne, 1)) – Physical density field.
stress_vm (np.ndarray, shape (ne, 1)) – Element-wise von Mises stress.
dsvm (np.ndarray, shape (ne, nvoigt)) – Derivative of the elemental von Mises stress with respect to the elemental stress vector,dsvm = d(stress_vm) / d(stress)
penal_sig (float) – Penalization exponent used in the relaxed stress measure.
Pnorm (float) – Exponent used for p-norm aggregation.
obj (float) – Accumulated objective value.
dscale (ndarray of shape (ne, 1)) – Derivative of the interpolation factor with respect to the physical density field,
cs (ndarray of shape (ne, nvoigt, nvoigt)) – Base constitutive tensor for each element before density interpolation.
strain (ndarray of shape (ne, nvoigt)) – Element strain vector in Voigt notation for each element.
**kwargs (dict) – Unused extra arguments for compatibility with the optimization driver.
- Returns:
obj (float) – Updated objective value.
rhs_adj (ndarray of shape (ndof, 1)) – Adjoint right-hand side associated with the stress objective.
selfadjoint (bool) – Always False. The stress p-norm objective is not treated as self-adjoint in this implementation.
- 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