matto.sensitivity#
Objective and constraint sensitivities with respect to the physical design fields: the UFL forms are differentiated with respect to each field, and the state-dependent part comes from one adjoint solve per evaluation.
- class matto.sensitivity.Sensitivity(comm, state, objective_form, constraints)[source]#
Bases:
objectObjective and constraint sensitivities with respect to the physical fields.
Nothing here is specific to rho, phi, theta, or any material model. It works with whichever active design variables were created by design.py; the forms come from state.py.
Seen as one reverse sweep,
raw -> operators -> phys -> state solve -> u -> objective -> J,
this class is the transpose of the last two stages: it forms dJ/du, solves the adjoint for lambda, and returns dJ/dphys for every active field. DesignVariable.backward then carries that through the operator chain to dJ/draw.
The gradient vectors returned by evaluate() are work vectors owned by this object and are overwritten by the next evaluate().
- evaluate()[source]#
Evaluate the current objective, constraints, and sensitivities.
Returns two dictionaries, the function values and the gradients with respect to the physical fields:
function_values = { "objective": objective_value, "constraints": { "constraint_name": { "value": normalized physical value, "residual": MMA constraint g <= 0, }, }, } gradients = { "objective": {"variable_name": dJ/d(variable.phys)}, "constraints": { "constraint_name": {"variable_name": dg/d(variable.phys)}, }, }