Parametrization#

class lumopt2.parametrization.parametrization.Parametrization(func: Callable[[ndarray], dict[str, Any]], bounds: List[Tuple[float, float]], optimization_region: dict, initial_params: ndarray | None = None, directly_on_params: bool = True, use_jac: bool = True, dp: float | List[float] | None = None)#

Parametrized geometry using a user-defined function to map parameters.

Parameters:
funcCallable[[np.ndarray], dict[str, Any]]

A function that takes a parameter array and returns a dictionary mapping FDTD geometry property paths (strings) to those parameters. Property paths should be in the format “group_name::object_name::property_name” to match Lumerical’s naming convention.

boundsList[Tuple[float, float]]

List of (min, max) tuples defining bounds for each parameter. Should have a length of n_params.

optimization_regiondict

Dictionary defining the spatial region where optimization occurs.

initial_paramsOptional[np.ndarray], optional

Initial parameter values. If None, uses the midpoint of each bound (default: None). Will always be 1D array of shape (n_params,).

directly_on_paramsbool, optional

Compute d_eps/dp directly on the optimization parameters (‘p’) if True; if False, compute d_eps/dP with respect to the Lumerical geometry parameters (‘P’) first, and then use chain rule to obtain d_eps/dp. (Default: True).

use_jacbool, optional

If True, use the autograd-computed Jacobian dP/dp of the geometric parameters P with respect to the optimization parameters p to determine which geometric objects are affected by each optimization parameter for the purposes of the d_Eps calculation. If False, the class assumes that all geometric parameters in the optimization region are affected by the perturbation of each optimization parameter. This flag is only relevant when directly_on_params=True. (Default: True)

dpUnion[float, List[float], None], optional

Perturbation size(s) for finite difference calculations of dEps. If None, automatically calculates using machine precision and parameter bounds.

Methods

Parametrization.compute_dPgeom(params)

Compute the perturbation array for calculating d_Eps, i.e., how much (dP) should each Lumerical sim geometric property ('P') be perturbed for finite-difference gradient calculations given the optimization params ('p') and their perturbations ('dp').

Parametrization.compute_gradient_from_fields(...)

Compute the gradient for a Parametrization.

Parametrization.compute_lumerical_to_permittivity_jacobian(...)

Compute d_eps/dP, the (sparse) Jacobian of the permittivity wrt Lumerical Geometry Parameters ('P').

Parametrization.compute_opt_params_direct_to_permittivity_jacobian(...)

Compute d_eps/dp, the (sparse) Jacobian of the permittivity wrt optimization parameters ('p').

Parametrization.compute_params_to_lumerical_jacobian(params)

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

Parametrization.create_optimization_structures(...)

Add optimization structure to FDTD simulation.

Parametrization.get_bounds()

Get parameter bounds for optimization.

Parametrization.get_initial_params()

Get initial parameter values

Parametrization.store_mesh_info(fdtd_session)

Read the locked grid and store mesh info in structure.

Parametrization.update_structure(...[, ...])

Add parametrized geometry to FDTD simulation

Attributes

Parametrization.bounds

Parameter bounds for optimization.