surface ¤
Differentiable fixed-pole rational surface fitting prototype.
AAA discovers a pole topology once. With that topology fixed, this module fits coefficient surfaces and refines them against complex S-parameter error using JAX autodiff and batching.
Classes:
| Name | Description |
|---|---|
PassivityShifts | Common diagonal shifts applied by sampled passivity projection. |
RationalSurface | Fixed-pole rational model whose coefficients vary over features. |
Functions:
| Name | Description |
|---|---|
evaluate_surface | Evaluate delay-embedded S parameters for every feature row. |
evaluate_surface_y | Evaluate de-embedded Y parameters for every feature row. |
initialize_surface | Initialize a shared-pole surface using fixed-pole linear fits. |
project_surface_passive | Guarantee Y-passivity on a grid by minimally shifting its D intercept. |
refine_surface | Refine coefficients, optionally enforcing sampled Y-passivity. |
surface_asymptotic_passivity_margins | Return the minimum Hermitian eigenvalues of D and E per corner. |
surface_from_fit | Wrap one fitted state-space model as a constant rational surface. |
surface_loss | Relative complex S-parameter MSE plus a nonnegative-delay penalty. |
surface_passivity_loss | Dimensionless squared penalty for sampled Y-passivity violations. |
surface_passivity_margins | Return |
PassivityShifts dataclass ¤
Common diagonal shifts applied by sampled passivity projection.
RationalSurface dataclass ¤
RationalSurface(
poles: Array,
residue_coeffs: Array,
D_coeffs: Array,
E_coeffs: Array,
tau_coeffs: Array,
omega_scale: Array,
z0: Array,
)
Fixed-pole rational model whose coefficients vary over features.
evaluate_surface ¤
evaluate_surface(model: RationalSurface, features: Array, freqs: Array) -> Array
Evaluate delay-embedded S parameters for every feature row.
Source code in circulax/fitting/surface.py
evaluate_surface_y ¤
evaluate_surface_y(model: RationalSurface, features: Array, freqs: Array) -> Array
Evaluate de-embedded Y parameters for every feature row.
Source code in circulax/fitting/surface.py
initialize_surface ¤
initialize_surface(
S: ndarray,
freqs: ndarray,
features: ndarray,
poles: ndarray,
*,
z0: complex = 50.0,
opts: FitOptions | None = None,
delay_scale: float = 1.0
) -> RationalSurface
Initialize a shared-pole surface using fixed-pole linear fits.
S has shape (corners, frequencies, ports, ports). Delay and residue identification are initialization steps outside the differentiable refinement path. features includes the desired surface basis and its intercept column.
Source code in circulax/fitting/surface.py
project_surface_passive ¤
project_surface_passive(
model: RationalSurface,
features: Array,
freqs: Array,
*,
minimum_conductance: float = 1e-12,
minimum_slope: float = 1e-12
) -> tuple[RationalSurface, PassivityShifts]
Guarantee Y-passivity on a grid by minimally shifting its D intercept.
The first feature must be an intercept equal to one. The returned metadata contains the common diagonal shifts applied to D and E.
Source code in circulax/fitting/surface.py
refine_surface ¤
refine_surface(
model: RationalSurface,
features: Array,
freqs: Array,
target_S: Array,
*,
steps: int = 200,
learning_rate: float = 0.0001,
enforce_passive: bool = False,
minimum_conductance: float = 1e-12,
minimum_slope: float = 1e-12,
passivity_weight: float = 1.0,
passivity_features: Array | None = None,
passivity_freqs: Array | None = None
) -> tuple[RationalSurface, Array]
Refine coefficients, optionally enforcing sampled Y-passivity.
Passive refinement uses a differentiable eigenvalue penalty and projects back onto sampled Y-passivity after every optimizer step. The first feature is therefore expected to be a constant intercept of one. Separate, denser feature and frequency grids may be supplied for projected updates without requiring target data on those grids. The cheaper differentiable penalty is evaluated on the training grid.
Source code in circulax/fitting/surface.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
surface_asymptotic_passivity_margins ¤
surface_asymptotic_passivity_margins(
model: RationalSurface, features: Array
) -> tuple[Array, Array]
Return the minimum Hermitian eigenvalues of D and E per corner.
Source code in circulax/fitting/surface.py
surface_from_fit ¤
surface_from_fit(
ss: SSModel, tau_per_port: ndarray, omega_scale: float, *, z0: complex = 50.0
) -> RationalSurface
Wrap one fitted state-space model as a constant rational surface.
Source code in circulax/fitting/surface.py
surface_loss ¤
surface_loss(
model: RationalSurface, features: Array, freqs: Array, target_S: Array
) -> Array
Relative complex S-parameter MSE plus a nonnegative-delay penalty.
Source code in circulax/fitting/surface.py
surface_passivity_loss ¤
surface_passivity_loss(
model: RationalSurface,
features: Array,
freqs: Array,
*,
minimum_conductance: float = 0.0,
minimum_slope: float = 0.0
) -> Array
Dimensionless squared penalty for sampled Y-passivity violations.
Source code in circulax/fitting/surface.py
surface_passivity_margins ¤
surface_passivity_margins(
model: RationalSurface, features: Array, freqs: Array
) -> Array
Return lambda_min(Re(Y)) at every corner and frequency.
Nonnegative values mean that the model is passive on the sampled grid.