compute_gradient_from_fields#

ClosedCurve.compute_gradient_from_fields(gradient_fields: ndarray, fdtd_session: FdtdSession, params: ndarray, polygon_name: str | None = None) ndarray#

Compute the gradient for a ClosedCurve parametrization.

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 optimization parameter values.

polygon_namestr, optional

Override for the FDTD CAD polygon name used when bounding the dEps/dP perturbations. When None (default), the polygon name in self.structure is used. Set by CombinedParametrization to disambiguate per-child polygons.

Returns:
np.ndarray

1D gradient array with length equal to the number of optimization parameters.