RepeatedCascade

class pmrf.models.composite.interconnected.cascade.RepeatedCascade(model: Model, values: Any, *, name: str | None = None, metadata: Any = None, method: Literal['a', 's'] = 'a')

Bases: Model

A cascade of many copies of one model, built under a single vmap.

One member model, plus a mapping from parameter names on it to arrays whose leading axis is the repeat axis. Parameters the mapping does not name are shared by every repeat. The member is traced once, under a vmap over that axis, and the sections are reduced with the pmrf.rf routines Cascade also uses. Writing the same cascade as Cascade([MicrostripLine(w=w_i, ...) for w_i in widths]) instead traces the member once per section and names it once per section.

Repeat axis versus batch axis

The repeat axis is physical: it indexes sections along the cascade, from the section at port 1 to the section at port \(N\). It leads each array in values, is reduced away, and never appears in the result’s shape.

The batch axis is the parameter batch dimension used everywhere else in ParamRF (pmrf.sweep()): one model at many parameter settings. It is added outside this model and survives into the result, so a sweep over a RepeatedCascade is a sweep over whole cascades, each with its own repeat axis. This is why the class is not called BatchedCascade. See ADR-0004.

Parameter names

The member keeps its own names under model (model.w), one set for the whole cascade. A repeated parameter’s value on the member is discarded, so it is fixed at construction and leaves the free set rather than offering an optimiser a parameter that moves nothing. The repeated values are themselves a free, unconstrained parameter, values.<name>. Fitting a shape rather than the values is what the profiled lines of ADR-0004 are for.

Mathematical Formulation

With \(M\) repeats and \(\theta_k\) the parameters of repeat \(k\) — the shared values, with the named entries replaced by values[name][k]:

\[A(f) = \prod_{k=0}^{M-1} A_{\mathrm{member}}(f; \theta_k)\]

or the corresponding ordered star product when method is 's'. Repeat \(0\) is at port 1.

param model:

The member model, repeated along the cascade. Must be a 2N-port.

type model:

Model

param values:

Parameter names on model, as pmrf.params() gives them, mapped to arrays whose leading axis is the repeat axis. All must agree on the length of that axis, which is the static repeat count. Values are in declared space and are checked against each parameter’s constraint.

type values:

dict[str, ArrayLike]

param method:

The domain the reduction runs in. ABCD needs no reference-impedance bookkeeping between sections; scattering is for members whose ABCD form is ill-conditioned. Scattering junctions are handled as in Cascade.

type method:

{‘a’, ‘s’}, default=’a’

raises ValueError:

If values is empty, names a parameter the member does not have, or its arrays disagree on the length of their leading axis; or if the member is not a 2N-port.

See also

Cascade

The same reduction over a sequence of distinct models.

Examples

n = 10
line = MicrostripLine(w=4e-3, h=1.6e-3, length=10e-3 / n)
taper = RepeatedCascade(line, {'w': jnp.linspace(3e-3, 6e-3, n)})
sorted(prf.params(taper, free_only=True))   # ['values.w']
mna(freq: Frequency) → MNAStamp

Overrides the generic Model.mna() fallback, which prefers .a() over .s() whenever both are overridden.

method: Literal['a', 's'] = 'a'

The cascade reduction algorithm method.

model: Model

The member model, repeated along the cascade.

property number_of_ports

Number of ports.

Return type:

int

property repeats: int

the length of the repeat axis. Static.

Type:

The number of repeats

values: dict[str, Array | ndarray | bool | number | bool | int | float | complex]

Parameter names on the member mapped to per-repeat values, repeat axis first.