Skip to content

BraggGratingModel

BraggGratingModel(
*,
period: Annotated[float, exclusiveMinimum=0, units='μm']
| collections.abc.Sequence[
Annotated[float, exclusiveMinimum=0, units='μm']
]
| photonforge.Expression
| photonforge.Interpolator
| str,
num_periods: Annotated[int, exclusiveMinimum=0],
coupling_coefficient: Annotated[float, minimum=0, units='μm⁻¹'],
n_eff: Annotated[float, exclusiveMinimum=0] | photonforge.Interpolator,
n_group: Annotated[float, exclusiveMinimum=0] | None = None,
reference_frequency: Annotated[float, minimum=0, units='Hz']
| None = None,
order: Annotated[int, exclusiveMinimum=0] = 1,
loss: Annotated[float, minimum=0, units='dB/μm'] = 0.0,
apodization: Literal['uniform', 'gaussian', 'raised-cosine', 'blackman']
| collections.abc.Sequence[float]
| photonforge.Interpolator
| photonforge.Expression
| str = 'uniform',
apodization_parameter: float = 3.0,
phase_shifts: collections.abc.Sequence[
tuple[
typing.Annotated[float, maximum=1, minimum=0],
typing.Annotated[float, units='rad'],
]
] = (),
num_sections: Annotated[int, exclusiveMinimum=0] | None = None,
ports: Annotated[collections.abc.Sequence[str], maxItems=2, minItems=2]
| None = None,
) -> None

Waveguide Bragg grating from coupled-mode theory.

Two counter-propagating modes exchange power along the grating,

dAdz=iσ^A+iκBdBdz=−iσ^B−iκ∗Aσ^=2πneff/λ−mπ/Λ\begin{gathered} \frac{{\rm d}A}{{\rm d}z} = i\hat\sigma A + i\kappa B \\ \frac{{\rm d}B}{{\rm d}z} = -i\hat\sigma B - i\kappa^{*}A \\ \hat\sigma = 2\pi n_{\rm eff}/\lambda-m\pi/\Lambda \end{gathered}

for grating order mm. Each section of length ℓ\ell has the closed-form solution

γ=∣κ∣2−σ^2S=sinh⁡γℓγD=cosh⁡γℓ+iσ^Sr=iκ∗SDt=1D\begin{gathered} \gamma = \sqrt{|\kappa|^2 - \hat\sigma^2} \\ S = \frac{\sinh\gamma\ell}{\gamma} \\ D = \cosh\gamma\ell + i\hat\sigma S \\ r = \frac{i\kappa^{*}S}{D} \\ t = \frac{1}{D} \end{gathered}

written with SS rather than sinh⁡γℓ\sinh\gamma\ell so the γ→0\gamma\to 0 limit at the band edge is taken analytically. Discretization only matters when the grating varies along its length.

Args

  • period: Grating period Λ\Lambda. A 1D array, Interpolator, Expression or expression string over the normalized position u in [0, 1] gives an arbitrary chirp profile.
  • num_periods: Number of grating periods.
  • coupling_coefficient: Peak coupling κ\kappa. Scaled along the grating by apodization.
  • n_eff: Effective index of the unperturbed waveguide, or an Interpolator over frequency for full dispersion.
  • n_group: Group index. With reference_frequency this adds first-order dispersion to a scalar n_eff. Ignored if n_eff is an Interpolator.
  • reference_frequency: Frequency at which a scalar n_eff applies.
  • order: Grating order mm.
  • loss: Power propagation loss of the underlying waveguide, in dB/μm.
  • apodization: Profile of κ\kappa along the grating: one of "uniform", "gaussian", "raised-cosine", "blackman", a 1D array, Interpolator, Expression or expression string in u over [0, 1] for an arbitrary analytic window.
  • apodization_parameter: Shape parameter for "gaussian" and "raised-cosine".
  • phase_shifts: Sequence of (position, phase) pairs, with position the normalized coordinate u in [0, 1] and phase in radians. Each applies a step in the grating phase from that point on, so a phase of π\pi is the standard quarter-wave shift and opens a transmission resonance at the Bragg wavelength.
  • num_sections: Number of sections used to discretize the grating. If None, min(num_periods, 400) is used.
  • ports: Input and output port names. If not set, the sorted list of port names of the relevant classification is used.

Note

The average index change that usually accompanies apodization, which chirps the local Bragg wavelength unless it is compensated, is not modelled. Supply it through period if it matters.

References

Erdogan, T. (1997). Fiber grating spectra. Journal of Lightwave Technology, 15(8), 1277-1294.

MethodDescription
autograd_smatrixCompute an autograd-compatible S matrix for traced parameters.
black_box_componentCreate a black-box component using this model.
bragg_wavelengthBragg wavelength from the mean period and the effective index.
estimate_costEstimate the cost for S matrix computation.
s_matrixCompute the S matrix for a component using this model.
sectionsPer-section coupling, period and length.
setup_time_stepperObtain a time stepper for a component using this model.
startStart computing the S matrix response from a component.
transformApply a transformation to this model.
updateUpdate this model.

autograd_smatrix(
self,
*,
component,
traced_params,
frequencies,
component_for_params,
param_names,
show_progress=True,
model_kwargs=None,
)

Compute an autograd-compatible S matrix for traced parameters.

Important

This is an abstract method that must be implemented by derived classes that support autograd-based S-matrix computation.

Args

  • component (Component): Nominal component associated with this autograd evaluation.
  • traced_params (ndarray): Traced parameter vector used by autograd.
  • frequencies (Sequence[float]): Frequency values at which to calculate the scattering parameters (in Hz).
  • component_for_params (Callable[[ndarray], Component]): Callback that returns the component for a given traced parameter vector.
  • param_names (Sequence[str]): Flattened traced parameter names aligned with traced_params.
  • show_progress (bool): Progress display hint from Component.s_matrix.
  • model_kwargs (dict[str, Any] | None): Model-specific keyword arguments forwarded from Component.s_matrix.

Returns

AutogradSMatrix: Autograd-compatible S matrix.

black_box_component(
self,
port_spec: str | photonforge.PortSpec | None = None,
technology: photonforge.Technology | None = None,
name: str | None = None,
) -> photonforge.Component

Create a black-box component using this model.

The layout is the model’s schematic symbol in a box, sized by the port width, with the port profiles drawn as stubs. The box spans the model’s length when it is set.

Args

  • port_spec: Port specification used in the component. If None, look for "port_spec" in config.default_kwargs.
  • technology: Component technology. If None, the default technology is used.
  • name: Component name. If None a default is used.

Returns

Component with ports and model.

bragg_wavelength(self, frequency: float | None = None) -> float

Bragg wavelength from the mean period and the effective index.

The Bragg condition λB=2neff(λB)Λ/m\lambda_B = 2 n_{\rm eff}(\lambda_B)\Lambda/m is solved self-consistently, so a dispersive n_eff is evaluated at the Bragg wavelength itself. This is where a uniform grating reflects most strongly.

Args

  • frequency: If set, n_eff is evaluated at this frequency instead of being solved for, and the result is 2neff(f)Λ/m2 n_{\rm eff}(f)\Lambda/m.

Returns

Bragg wavelength in μm.

estimate_cost(self, *args, **kwargs)

Estimate the cost for S matrix computation.

All arguments are passed to the model’s start method with the addition of the keyword argument cost_estimation=True.

Returns

float: Cost estimation.

s_matrix(self, component, frequencies, show_progress=True, model_kwargs={})

Compute the S matrix for a component using this model.

Args

  • component (Component): Component to perform the calculation.
  • frequencies (Sequence[float]): Frequency values at which to calculate the scattering parameters (in Hz).
  • show_progress (bool): If True, show computation progress.
  • model_kwargs (dict[str, object]): Keyword arguments passed to Model.start. Accepted arguments depend on the model type.

Returns

SMatrix: Computed S matrix.

Example

Compute only the responses from mode 0 of P0 with Tidy3D to reduce the number and cost of simulations:

>>> model = pf.Tidy3DModel()
>>> s_matrix = model.s_matrix( # doctest: +SKIP
... component,
... frequencies,
... model_kwargs={"inputs": ("P0@0",)},
... )

A port name such as ("P0",) selects all modes of that port. All outputs for the selected inputs are returned; responses from unselected inputs are not computed. Use Model.estimate_cost with the same inputs passed directly to estimate the reduced run.

sections(self) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

Per-section coupling, period and length.

Returns

Tuple (kappa, period, length), each of length num_sections. kappa is complex and already carries the apodization and the cumulative grating phase from phase_shifts.

setup_time_stepper(
self,
component,
time_step,
carrier_frequency=0,
show_progress=True,
time_stepper_kwargs={},
)

Obtain a time stepper for a component using this model.

Args

  • component (Component): Component for the time stepper.
  • time_step (float): The interval between time steps (in seconds).
  • carrier_frequency (float): The carrier frequency used to construct the time stepper. The carrier should be omitted from the input signals, as it is handled automatically by the time stepper.
  • show_progress (bool): If True, show computation progress.
  • time_stepper_kwargs (dict[str, object]): Keyword arguments passed to TimeStepper.setup. Each time stepper type can accept a different set of arguments. Check the documentation for the each time stepper’s setup_state method for more information.

Returns

TimeStepper: Initialized time stepper.

start(
self,
component: photonforge.Component,
frequencies: collections.abc.Sequence[float],
**kwargs: object,
) -> photonforge.SMatrix

Start computing the S matrix response from a component.

Args

  • component: Component from which to compute the S matrix.
  • frequencies: Sequence of frequencies at which to perform the computation.
  • **kwargs: Unused.

Returns

S matrix for the requested frequencies, including reflection.

transform(
self, translation=(0, 0), rotation=0, scaling=1, x_reflection=False
)

Apply a transformation to this model.

The base implementation is a no-op and returns self. Derived classes can override this method to transform model-specific geometry settings.

Args

  • translation (Sequence[float] | complex): Translation vector.
  • rotation (float): Rotation angle in degrees.
  • scaling (float): Magnification factor.
  • x_reflection (bool): Mirror across the horizontal axis.

Returns

Model: This object with transformations applied.

update(self, *args, **kwargs)

Update this model.

All contents of the model are updated with the contents from the updated version. object contents or modifications introduced after the model creation (outside of the original parametric function) are not propagated.

The model’s time stepper does not participate in the update, unless the __init__ method of the derived model class replaces it via set_time_stepper.

Args

  • *args (object): Positional arguments to the parametric model.
  • **kwargs (object): Keyword arguments to the parametric model.

Returns

Model: This model.

Note

The original keyword arguments used to generate the model are stored and updated with the passed kwargs. This updated version is used in the function call and will be stored for future updates. Positional arguments are not stored.

AttributeDescription
parametric_functionstr: Function used to update the model.
parametric_kwargsdict[str, object]: Keyword arguments used to update the model.
propertiesProperties: Object properties.
random_variableslist[RandomVariable]: Random variables associated to the model’s parameters.
time_stepperTimeStepper | None: Time stepper associated with this model.

str: Function used to update the model.

dict[str, object]: Keyword arguments used to update the model.

Properties: Object properties.

list[RandomVariable]: Random variables associated to the model’s parameters.

TimeStepper | None: Time stepper associated with this model.