Skip to content

Capacitor

Capacitor(
*,
capacitance: Annotated[float, exclusiveMinimum=0, units='F'],
port_map: dict[
str,
tuple[str, Annotated[complex, units='Ω']]
| tuple[str, str, Annotated[complex, units='Ω']],
]
| None = None,
) -> None

Two-terminal capacitor.

MNA stamp: Y=−jωCY = -j\omega C admittance between terminals (exp(-i\omega t) convention).

Circuit diagram:

C
t1 ---||--- t2

Args

  • capacitance: Capacitance.
  • port_map: Port mappings from terminals (see LumpedModel).

Example

>>> capacitor = pf.Capacitor(capacitance=1e-12) # 1 pF
MethodDescription
autograd_smatrixCompute an autograd-compatible S matrix for traced parameters.
estimate_costEstimate the cost for S matrix computation.
s_matrixCompute the S matrix for a component using this lumped model.
setup_time_stepperSet up a time stepper for time-domain simulation.
startStart the S-matrix computation for this lumped model.
start_mnaStart the MNA matrix computation for this lumped model.
transformApply a transformation to this model.
updateUpdate this lumped 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.

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 lumped 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 LumpedModel.start_mna.

Returns

SMatrix: Computed S matrix.

Set up a time stepper for time-domain simulation.

start(self, component, frequencies, **kwargs)

Start the S-matrix computation for this lumped model.

Calls start_mna to get the MNA matrix, then wraps the result in a runner that converts to S-parameters using the port_map.

Args

  • component (Component): Component to perform the calculation.
  • frequencies (Sequence[float]): Frequency values at which to calculate the scattering parameters (in Hz).
  • **kwargs (object): Passed to start_mna.

Returns

LumpedModelRunner: Runner with status, mna_matrix, and s_matrix attributes.

start_mna(
self,
component: photonforge.Component | None,
frequencies: list[float],
**kwargs: object,
) -> photonforge.MNAMatrix

Start the MNA matrix computation for this lumped model.

Important

This is an abstract method that must be implemented by derived classes.

Return an MNAMatrix containing the MNA stamp for this component, if the calculation can be performed synchronously.

Otherwise, it must return an object with attributes status and mna_matrix that will be pooled to check the calculation progress. The status attribute must return a dictionary with 'progress' (a number from 0 to 100 indicating the calculation progress) and 'message' (one of 'running', 'success', or 'error', indicating the current calculation status). The 'mna_matrix' attribute should return the computed MNAMatrix once the calculation is successful (or None otherwise).

Terminal naming convention: Terminal names starting with _ are reserved for auxiliary branch-current variables (e.g., _I for an inductor branch current, _I1 / _I2 for transmission line branch currents). User-defined terminal names for physical nodes should not start with _ to avoid collisions when elements are composed inside a larger MNA hierarchy.

Args

  • component (Component): Component to perform the calculation.
  • frequencies (Sequence[float]): Frequency values at which to calculate the matrix parameters (in Hz).
  • **kwargs (object): Additional keyword arguments.

Returns

MNAMatrix | object: Either an MNA matrix directly, or a runner with status and mna_matrix attributes.

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 lumped model.

Args

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

Returns

LumpedModel: This lumped model.

AttributeDescription
parametric_functionstr: Function used to update a parametric component.
parametric_kwargsdict[str, object]: Keyword arguments used to update a parametric component.
port_mapdict[str, tuple[str, complex] | tuple[str, str, complex]] | None: Mapping from port names to (signal_terminal, impedance) or (signal_terminal, reference_terminal, impedance) tuples.
propertiesProperties: Object properties.
random_variableslist[RandomVariable]: Random variables associated to this model’s parameters.
time_stepperTimeStepper | None: Time stepper associated with this model.

str: Function used to update a parametric component.

dict[str, object]: Keyword arguments used to update a parametric component.

dict[str, tuple[str, complex] | tuple[str, str, complex]] | None: Mapping from port names to (signal_terminal, impedance) or (signal_terminal, reference_terminal, impedance) tuples.

Properties: Object properties.

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

TimeStepper | None: Time stepper associated with this model.