pmrf.models.lines

Classes

CoaxialLine([length, floating, renormalize, ...])

A coaxial line defined directly by its physical and material properties.

ConstantRLGCLine([length, floating, ...])

An RLGC line with constant, frequency-independent per-unit-length parameters.

DatasheetLine([length, floating, ...])

A transmission line defined by parameters typically found on a datasheet, such as nominal impedance and loss factors.

MicrostripLine([length, floating, ...])

A microstrip line defined by its geometric and material properties (i.e. width, height, dielectric constant, tan delta, rho).

RLGCLine([length, floating, renormalize, ...])

An abstract base class for a transmission line defined by its per-unit-length RLGC (Resistance, Inductance, G, Conductance) parameters.

TLine(length, floating, renormalize, *, ...)

class pmrf.models.lines.TLine(length: pmrf.parameters.Parameter = 1.0, floating: bool = False, renormalize: bool = True, *, name: str | None = None, separator: str = '_', metadata: dict = <factory>, _z0: complex = (50+0j), _param_groups: list[pmrf.parameters.ParameterGroup] = <factory>)[source]

Bases: Model

Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

length: Parameter = 1.0
floating: bool = False
renormalize: bool = True
__init__(length=1.0, floating=False, renormalize=True, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)
Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

Return type:

None

class pmrf.models.lines.RLGCLine(length=1.0, floating=False, renormalize=True, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)[source]

Bases: TLine

An abstract base class for a transmission line defined by its per-unit-length RLGC (Resistance, Inductance, G, Conductance) parameters.

This class provides the fundamental equations to calculate the ABCD-matrix of a transmission line given its propagation constant (gamma) and characteristic impedance (Z_c), which are derived from the RLGC values.

Derived classes must implement the rlgc method, which defines how the four distributed parameters (R, L, G, C) behave as a function of frequency.

Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

floating: bool = False
abstract rlgc(freq)[source]

Calculates the frequency-dependent RLGC parameters of the line.

This method must be implemented by any derived concrete class.

Parameters:

freq (Frequency) – The frequency axis at which to evaluate the parameters.

Returns:

A tuple containing the R, L, G, and C parameter vectors, in that order.

Return type:

tuple

z0_characteristic(frequency)[source]

Calculates the characteristic impedance from the line’s RLGC parameters.

Parameters:

frequency (Frequency) – The frequency axis for the calculation.

Returns:

The resultant ABCD-matrix.

Return type:

np.ndarray

s(frequency)[source]

Scattering parameter matrix.

If only a() is implemented, converts via pmrf.functions.conversions.a2s().

Parameters:
Returns:

S-parameter matrix with shape (nf, n, n).

Return type:

jnp.ndarray

Raises:

NotImplementedError – If neither a nor s is implemented in a subclass.

__init__(length=1.0, floating=False, renormalize=True, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)
Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

Return type:

None

class pmrf.models.lines.ConstantRLGCLine(length=1.0, floating=False, renormalize=True, R=0.0, L=2.8e-07, G=0.0, C=9e-11, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)[source]

Bases: RLGCLine

An RLGC line with constant, frequency-independent per-unit-length parameters.

This is the simplest transmission line model, where R, L, G, and C are single scalar values.

Example

import pmrf as prf

# Create a lossless 50-ohm line model
# L and C are chosen to produce Z0=50 and epr=2.2
lossless_line = prf.models.ConstantRLGCLine(
    L=368.8e-9, # nH/m
    C=147.5e-12, # pF/m
    length=0.1 # 10 cm
)

# Calculate its S-parameters over a frequency range
freq = prf.Frequency(start=1, stop=5, npoints=101, unit='ghz')
s = lossless_line.s(freq)

print(f"S21 magnitude at center frequency: {abs(s[freq.center_idx, 1, 0]):.3f}")

Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • R (Any)

  • L (Any)

  • G (Any)

  • C (Any)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

R: Parameter = 0.0
L: Parameter = 2.8e-07
G: Parameter = 0.0
C: Parameter = 9e-11
rlgc(_)[source]

Calculates the frequency-dependent RLGC parameters of the line.

This method must be implemented by any derived concrete class.

Parameters:
  • freq (Frequency) – The frequency axis at which to evaluate the parameters.

  • _ (Frequency)

Returns:

A tuple containing the R, L, G, and C parameter vectors, in that order.

Return type:

tuple

__init__(length=1.0, floating=False, renormalize=True, R=0.0, L=2.8e-07, G=0.0, C=9e-11, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)
Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • R (Any)

  • L (Any)

  • G (Any)

  • C (Any)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

Return type:

None

class pmrf.models.lines.DatasheetLine(length=1.0, floating=False, renormalize=True, zn=50.0, epr=1.0, epr_slope=None, k1=0.0, k2=0.0, loss_coeffs_normalized=False, freq_bounds=None, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)[source]

Bases: RLGCLine

A transmission line defined by parameters typically found on a datasheet, such as nominal impedance and loss factors.

This model provides a convenient way to define a transmission line from its nominal impedance, dielectric constant, and loss factors, rather than from the fundamental RLGC values directly. It includes terms for both skin effect loss (k1) and dielectric loss (k2).

Example

import pmrf as prf
import numpy as np

# Define a 1m coaxial cable from typical datasheet values
cable = prf.models.DatasheetCoaxial(
    zn=50.0,
    epr=2.1,
    k1=0.2, # Skin effect loss factor
    k2=0.01, # Dielectric loss factor
    length=1.0
)

freq = prf.Frequency(start=0.1, stop=10, npoints=201, unit='ghz')
s = cable.s(freq)

# Plot the insertion loss
# import matplotlib.pyplot as plt
# plt.plot(freq.f_scaled, 20*np.log10(abs(s[:,1,0])))
# plt.xlabel(f"Frequency ({freq.unit})")
# plt.ylabel("Insertion Loss (dB)")
# plt.grid(True)
# plt.show()

Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • zn (Any)

  • epr (Any)

  • epr_slope (Parameter | None)

  • k1 (Any)

  • k2 (Any)

  • loss_coeffs_normalized (bool)

  • freq_bounds (tuple | None)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

zn: Parameter = 50.0
epr: Parameter = 1.0
epr_slope: Parameter | None = None
k1: Parameter = 0.0
k2: Parameter = 0.0
loss_coeffs_normalized: bool = False
freq_bounds: tuple | None = None
rlgc(freq)[source]

Calculates the frequency-dependent RLGC parameters of the line.

This method must be implemented by any derived concrete class.

Parameters:

freq (Frequency) – The frequency axis at which to evaluate the parameters.

Returns:

A tuple containing the R, L, G, and C parameter vectors, in that order.

Return type:

tuple

__init__(length=1.0, floating=False, renormalize=True, zn=50.0, epr=1.0, epr_slope=None, k1=0.0, k2=0.0, loss_coeffs_normalized=False, freq_bounds=None, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)
Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • zn (Any)

  • epr (Any)

  • epr_slope (Parameter | None)

  • k1 (Any)

  • k2 (Any)

  • loss_coeffs_normalized (bool)

  • freq_bounds (tuple | None)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

Return type:

None

class pmrf.models.lines.CoaxialLine(length=1.0, floating=False, renormalize=True, din=0.00112, dout=0.0032, epr=1.0, mur=1.0, tand=0.0, rho=1.68e-08, epr_model='constant', mur_model='constant', tand_model='constant', rho_model='constant', separate_rho=False, neglect_skin_inductance=False, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)[source]

Bases: RLGCLine

A coaxial line defined directly by its physical and material properties.

This model calculates the RLGC parameters from the geometry (inner/outer diameters) and material properties (permittivity, permeability, loss tangent, resistivity). It provides a high-fidelity model that accounts for the skin effect in the conductors and frequency-dependent material properties.

Several material properties can be defined as frequency-dependent polynomials using the _model arguments (e.g., epr_model). The available models are:

  • ‘constant’: (Default) The parameter is a single scalar value.

  • ‘ppoly’: The parameter is a polynomial in the power basis. The Parameter value should be a list of coefficients.

  • ‘bpoly’: The parameter is a polynomial in the Bernstein basis. The Parameter value should be a list of coefficients.

Example

import pmrf as prf

# A coaxial cable where the dielectric constant (epr) varies with frequency
# We model epr as a 1st-order Bernstein polynomial (a line)
# The coefficients are the start and end values of the line.
phys_cable = prf.models.PhysicalCoaxial(
    din=0.9e-3,
    dout=2.95e-3,
    epr=[2.1, 2.05], # epr goes from 2.1 to 2.05 over the freq range
    epr_model='bpoly',
    tand=0.0004,
    rho=1.72e-8, # Copper resistivity
    length=0.5
)

freq = prf.Frequency(start=1, stop=20, npoints=101, unit='ghz')
s_phys = phys_cable.s(freq)

Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • din (Any)

  • dout (Any)

  • epr (Any)

  • mur (Any)

  • tand (Any)

  • rho (Any)

  • epr_model (str)

  • mur_model (str)

  • tand_model (str)

  • rho_model (str)

  • separate_rho (bool)

  • neglect_skin_inductance (bool)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

din: Parameter = 0.00112
dout: Parameter = 0.0032
epr: Parameter = 1.0
mur: Parameter = 1.0
tand: Parameter = 0.0
rho: Parameter = 1.68e-08
epr_model: str = 'constant'
mur_model: str = 'constant'
tand_model: str = 'constant'
rho_model: str = 'constant'
separate_rho: bool = False
neglect_skin_inductance: bool = False
interpolated(param, freq)[source]

Evaluates a potentially frequency-dependent parameter.

Parameters:
  • param (str) – The name of the parameter to evaluate (e.g., ‘epr’).

  • freq (Frequency) – The frequency axis for the evaluation.

Returns:

The parameter’s value across the frequency axis.

Return type:

np.ndarray

epr_f(freq)[source]

The relative permittivity (epsilon_r) as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

tand_f(freq)[source]

The loss tangent (tan_delta) as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

mur_f(freq)[source]

The relative permeability (mu_r) as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

rho_f(freq)[source]

The conductor resistivity (rho) as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

rhoin_f(freq)[source]

The inner conductor resistivity as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

rhoout_f(freq)[source]

The outer conductor resistivity as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

eps_f(freq)[source]

The complex permittivity (epsilon) as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

mu_f(freq)[source]

The complex permeability (mu) as a function of frequency.

Parameters:

freq (Frequency)

Return type:

Array

L_prime(freq)[source]

The per-unit-length external inductance.

Parameters:

freq (Frequency)

Return type:

Array

C_prime(freq)[source]

The per-unit-length capacitance.

Parameters:

freq (Frequency)

Return type:

Array

G_diel(freq)[source]

The per-unit-length dielectric conductance.

Parameters:

freq (Frequency)

Return type:

Array

R_skin(freq)[source]

The per-unit-length resistance due to skin effect.

Parameters:

freq (Frequency)

Return type:

Array

L_skin(freq)[source]

The per-unit-length internal inductance due to skin effect.

Parameters:

freq (Frequency)

Return type:

Array

Z_skin(freq)[source]

The per-unit-length internal impedance due to skin effect.

Parameters:

freq (Frequency)

rlgc(freq)[source]

Calculates the frequency-dependent RLGC parameters of the line.

This method must be implemented by any derived concrete class.

Parameters:

freq (Frequency) – The frequency axis at which to evaluate the parameters.

Returns:

A tuple containing the R, L, G, and C parameter vectors, in that order.

Return type:

tuple

__init__(length=1.0, floating=False, renormalize=True, din=0.00112, dout=0.0032, epr=1.0, mur=1.0, tand=0.0, rho=1.68e-08, epr_model='constant', mur_model='constant', tand_model='constant', rho_model='constant', separate_rho=False, neglect_skin_inductance=False, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)
Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • din (Any)

  • dout (Any)

  • epr (Any)

  • mur (Any)

  • tand (Any)

  • rho (Any)

  • epr_model (str)

  • mur_model (str)

  • tand_model (str)

  • rho_model (str)

  • separate_rho (bool)

  • neglect_skin_inductance (bool)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

Return type:

None

class pmrf.models.lines.MicrostripLine(length=1.0, floating=False, renormalize=True, w=0.003, h=0.0016, epr=4.3, tand=0.0, rho=0.0, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)[source]

Bases: RLGCLine

A microstrip line defined by its geometric and material properties (i.e. width, height, dielectric constant, tan delta, rho).

Note that h > w is not yet supported.

Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • w (Any)

  • h (Any)

  • epr (Any)

  • tand (Any)

  • rho (Any)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

w: Parameter = 0.003
h: Parameter = 0.0016
epr: Parameter = 4.3
tand: Parameter = 0.0
rho: Parameter = 0.0
rlgc(freq)[source]

Calculates the frequency-dependent RLGC parameters of the line.

This method must be implemented by any derived concrete class.

Parameters:

freq (Frequency) – The frequency axis at which to evaluate the parameters.

Returns:

A tuple containing the R, L, G, and C parameter vectors, in that order.

Return type:

tuple

__init__(length=1.0, floating=False, renormalize=True, w=0.003, h=0.0016, epr=4.3, tand=0.0, rho=0.0, *, name=None, separator='_', metadata=<factory>, _z0=(50+0j), _param_groups=<factory>)
Parameters:
  • length (Any)

  • floating (bool)

  • renormalize (bool)

  • w (Any)

  • h (Any)

  • epr (Any)

  • tand (Any)

  • rho (Any)

  • name (str | None)

  • separator (str)

  • metadata (dict)

  • _z0 (complex)

  • _param_groups (list[ParameterGroup])

Return type:

None