compute_params_to_lumerical_jacobian#

Parametrization.compute_params_to_lumerical_jacobian(params: ndarray) ndarray#

Compute the Jacobian matrix dP[i]/dp[j] of the parametrization function using automatic differentiation.

The Jacobian J[i,j] represents the derivative of the output (geometric) property P[i] with respect to the optimization parameter p[j]. This uses autograd for exact derivatives (when available) or falls back to finite differences.

Parameters:
paramsnp.ndarray

Parameter values at which to compute Jacobian.

Returns:
np.ndarray

Jacobian matrix of shape (n_outputs, n_params) where n_outputs is the total number of scalar property values returned by the parametrization.

Raises:
ValueError

If autograd is not available., or if result contains NaNs.

RuntimeError

If Jacobian computation fails.

Examples

>>> def my_func(p):
...     return {"circle::radius": p[0], "rect::x": p[0] + p[1]}
>>> geom = ParametrizedGeometry(my_func, bounds=[(0,1), (0,1)])
>>> J = geom.compute_params_to_lumerical_jacobian(np.array([0.5, 0.3]))
>>> # J will be [[1.0, 0.0],   # d(circle::radius)/dp
>>> #            [1.0, 1.0]]   # d(rect::x)/dp