compute_gradient_from_fields#
- CombinedParametrization.compute_gradient_from_fields(gradient_fields: ndarray, fdtd_session: FdtdSession, params: ndarray, polygon_name: str | None = None) ndarray#
Compute the gradient by delegating to each child parametrization.
Each child computes its own portion of the gradient using its
compute_gradient_from_fieldsmethod, with the per-childpolygon_nameoverride passed as an explicit kwarg. The results are concatenated to form the full gradient vector.Project’s gradient pipeline already calls
update_structureon thisCombinedParametrization(which sets every child to nominal) before invokingcompute_gradient_from_fields, so we do not repeat that update here – it would just slow the gradient evaluation down.- Parameters:
- gradient_fields
np.ndarray Adjoint gradient fields with shape
(nx, ny, nz, 3), already summed over wavelengths.- fdtd_session
FdtdSession Active FDTD session used to compute finite-difference Jacobians.
- params
np.ndarray Current combined optimization parameter values.
- polygon_name
str,optional Ignored. Present only to match the
BaseParametrizationAPI;CombinedParametrizationmanages per-child polygon names internally viaself._child_polygon_names.
- gradient_fields
- Returns:
np.ndarray1D gradient array with length equal to
n_params.