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_fields method, with the per-child polygon_name override passed as an explicit kwarg. The results are concatenated to form the full gradient vector.

Project’s gradient pipeline already calls update_structure on this CombinedParametrization (which sets every child to nominal) before invoking compute_gradient_from_fields, so we do not repeat that update here – it would just slow the gradient evaluation down.

Parameters:
gradient_fieldsnp.ndarray

Adjoint gradient fields with shape (nx, ny, nz, 3), already summed over wavelengths.

fdtd_sessionFdtdSession

Active FDTD session used to compute finite-difference Jacobians.

paramsnp.ndarray

Current combined optimization parameter values.

polygon_namestr, optional

Ignored. Present only to match the BaseParametrization API; CombinedParametrization manages per-child polygon names internally via self._child_polygon_names.

Returns:
np.ndarray

1D gradient array with length equal to n_params.