parametric_technology
parametric_technology( decorated_function: collections.abc.Callable[ ..., photonforge.Technology ] | None = None, name_prefix: str | None = None, use_parametric_cache_default: bool = True,) -> collections.abc.Callable[..., photonforge.Technology]Decorator to create parametric technologies from functions.
If the name of the created technology is empty, this decorator sets it with name prefix and the values of the function arguments when called.
Technologies can be cached to avoid duplication. They are cached based
on the calling arguments (specifically, argument id). Regardless of
the default setting, each technology can use or skip caching by setting
the bool keyword argument use_parametric_cache in the decorated
function call.
Args
- decorated_function: Function that returns a Technology.
- name_prefix: Prefix for the technology name. If
None, the decorated function name is used. - use_parametric_cache_default: Controls the default caching behavior for the decorated function.
Example
>>> @pf.parametric_technology... def demo_technology(*, thickness=0.250, sidewall_angle=0):... layers = {... "Si": pf.LayerSpec(... (1, 0), "Silicon layer", "#d2132e18", "//"... )... }... extrusion_specs = [... pf.ExtrusionSpec(... pf.MaskSpec((1, 0)),... td.Medium(permittivity=3.48**2),... (0, thickness),... sidewall_angle=sidewall_angle,... )... ]... port_specs = {... "STE": pf.PortSpec(... "Single mode strip",... 1.5,... (-0.5, thickness + 0.5),... target_neff=3.48,... path_profiles=[(0.45, 0, (1, 0))],... )... }... technology = pf.Technology(... "Demo technology",... "1.0",... layers,... extrusion_specs,... port_specs,... td.Medium(permittivity=1.45**2),... )... # Add random variables to facilitate Monte Carlo runs:... technology.random_variables = [... pf.monte_carlo.RandomVariable(... "sidewall_angle", value=sidewall_angle, stdev=2... ),... pf.monte_carlo.RandomVariable(... "thickness",... value_range=[thickness - 0.01, thickness + 0.01],... ),... ]... return technology>>> technology = demo_technology(sidewall_angle=10, thickness=0.3)>>> technology.random_variables[RandomVariable('sidewall_angle', **{'value': 10, 'stdev': 2}), RandomVariable('thickness', **{'value_range': (0.29, 0.31)})]Note
It is generally a good idea to force parametric technologies to
accept only keyword arguments (by using the * as first argument
in the argument list), because those are stored for future updates
of the created technology with Technology.update.