parametric_technology

photonforge.parametric_technology(decorated_function=None, name_prefix=None, use_parametric_cache_default=True)

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.

Parameters:
  • decorated_function (Callable | None) – Function that returns a Technology.

  • name_prefix (str | None) – Prefix for the technology name. If None, the decorated function name is used.

  • use_parametric_cache_default (bool) – Controls the default caching behavior for the decorated function.

Return type:

Callable

Example

>>> @parametric_technology
... def demo_technology(*, thickness=0.250, sidewall_angle=0):
...     layers = {
...         "Si": LayerSpec(
...             (1, 0), "Silicon layer", "#d2132e18", "//"
...         )
...     }
...     extrusion_specs = [
...         ExtrusionSpec(
...             MaskSpec((1, 0)),
...             td.Medium(permittivity=3.48**2),
...             (0, thickness),
...             sidewall_angle=sidewall_angle,
...         )
...     ]
...     port_specs = {
...         "STE": PortSpec(
...             "Single mode strip",
...             1.5,
...             (-0.5, thickness + 0.5),
...             target_neff=3.48,
...             path_profiles=[(0.45, 0, (1, 0))],
...         )
...     }
...     technology = 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 = [
...         monte_carlo.RandomVariable(
...             "sidewall_angle", value=sidewall_angle, stdev=2
...         ),
...         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().