compute_gradient_from_fields#
- abstractmethod BaseParametrization.compute_gradient_from_fields(gradient_fields: ndarray, fdtd_session: FdtdSession, params: ndarray, polygon_name: str | None = None) ndarray#
Compute the gradient of the FOM with respect to optimization parameters.
Contracts the adjoint gradient fields with the parametrization-specific Jacobian chain (d_eps/dp) to produce the scalar gradient vector.
- 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 by parametrizations that need to query the simulation, e.g. to compute finite-difference Jacobians).
- params
np.ndarray Current optimization parameter values.
- polygon_name
str,optional Override for the FDTD CAD polygon name. Used by
CombinedParametrizationto disambiguate per-child polygons in the shared simulation. Concrete parametrizations that don’t represent a polygon accept and ignore this argument.
- gradient_fields
- Returns:
np.ndarray1D gradient array with length equal to the number of optimization parameters.