`AdmittanceModels.PortOperation`

— ConstantThe functions allowed in a Cascade.

`AdmittanceModels.AdmittanceModel`

— TypeAn abstract representation of a linear mapping from inputs `x`

to outputs `y`

of the form `YΦ = Px`

, `y = QᵀΦ`

. Subtypes U <: AdmittanceModel are expected to implement:

```
get_Y(am::U)
get_P(am::U)
get_Q(am::U)
get_ports(am::U)
partial_copy(am::U; Y, P, ports)
compatible(AbstractVector{U})
```

`AdmittanceModels.Blackbox`

— Type```
Blackbox{T, U}(ω::Vector{Float64}, Y::Vector{U}, P::U, Q::U,
ports::UniqueVector{T}) where {T, U}
Blackbox(ω::Vector{<:Real}, Y::Vector{U}, P::U, Q::U,
ports::AbstractVector{T}) where {T, U}
```

An admittance model with constant `P`

and `Q`

but with varying `Y`

, indexed by a real variable `ω`

.

`AdmittanceModels.Blackbox`

— Method`Blackbox(ω::Vector{<:Real}, pso::PSOModel)`

Create a Blackbox for a PSOModel where `ω`

represents angular frequency.

`AdmittanceModels.Blackbox`

— Method```
Blackbox(ω::Vector{<:Real}, comp::CircuitComponent)
Blackbox(ω::Vector{<:Real}, comp::TransmissionLine)
Blackbox(ω::Vector{<:Real}, comp::Cascade)
```

Create a Blackbox model for a CircuitComponent.

`AdmittanceModels.Cascade`

— Type```
Cascade(components::Vector{CircuitComponent},
operations::Vector{Pair{PortOperation, Vector{String}}})
```

A system created by cascading and uniting several CircuitComponents and then applying PortOperations to the ports.

`AdmittanceModels.Circuit`

— Method`Circuit(q3d_file; matrix_types = [:capacitance])`

Return an `AdmittanceModels.Circuit`

from a plain text file generated by ANSYS Q3D containing RLGC simulation output.

**Args**

`q3d_file`

: the path to the text file.`matrix_type`

: A list of symbols indicating which type of matrix data to read. Currently, symbols in [:capacitance, :conductance] are the only available choices, and only the units in ["pF", "nF", "mF", "uF", "fF", "farad", "sie", "mSie"] are handled.

`AdmittanceModels.Circuit`

— Method```
Circuit(comp::SeriesComponent)
Circuit(comp::ParallelComponent)
Circuit(comp::TransmissionLine, vertex_prefix::AbstractString,
stages_per_segment::Union{Nothing, AbstractVector{Int}}=nothing)
```

Create a Circuit for a CircuitComponent.

`AdmittanceModels.CircuitComponent`

— TypeAn abstract representation of a circuit component e.g. a capacitor, inductor, or transmission line.

`AdmittanceModels.PSOModel`

— Type```
PSOModel{T, U}(K::U, G::U, C::U, P::U, Q::U, ports::UniqueVector{T}) where {T, U}
PSOModel(K::U, G::U, C::U, P::U, Q::U, ports::AbstractVector{T}) where {T, U}
```

A Positive Second Order model, representing the equations `(K + G∂ₜ + C∂²ₜ)Φ = Px`

, `y = Qᵀ∂ₜΦ`

.

`AdmittanceModels.PSOModel`

— Method```
PSOModel(circuit::Circuit, port_edges::Vector{<:Tuple},
port_names::AbstractVector, tree::SpanningTree)
```

Create a PSOModel for a circuit with ports on given edges and using the given spanning tree.

`AdmittanceModels.PSOModel`

— Method```
PSOModel(circuit::Circuit, port_edges::Vector{<:Tuple},
port_names::AbstractVector)
```

Create a PSOModel for a circuit with ports on given edges. The spanning tree where the first vertex is chosen as ground and all other vertices are neighbors of ground is used.

`AdmittanceModels.PSOModel`

— Method```
PSOModel(comp::SeriesComponent)
PSOModel(comp::ParallelComponent)
PSOModel(comp::TransmissionLine)
PSOModel(comp::Cascade)
```

Create a PSOModel for a CircuitComponent.

`AdmittanceModels.ParallelComponent`

— Type```
ParallelComponent(p::String, inv_inductance::Float64,
conductance::Float64, capacitance::Float64)
ParallelComponent(p::String, k::Real, g::Real, c::Real)
```

A parallel inductor, capacitor, and resistor with one port.

`AdmittanceModels.SeriesComponent`

— Type```
SeriesComponent(p1::String, p2::String, inv_inductance::Float64, conductance::Float64,
capacitance::Float64)
SeriesComponent(p1::String, p2::String, k::Real, g::Real, c::Real)
```

A parallel inductor, capacitor, and resistor between two ports.

`AdmittanceModels.TransmissionLine`

— Type```
TransmissionLine(ports::Vector{String}, propagation_speed::Float64,
characteristic_impedance::Float64, len::Float64,
locations::AbstractVector{Float64}, δ::Float64)
TransmissionLine(ports::Vector{String}, propagation_speed::Real,
characteristic_impedance::Real, len::Real; locations::Vector{<:Real}=Float64[],
δ::Real=len/100)
```

A transmission line with given propagation speed and characteristic impedance. Ports will be present at the two ends of the transmission line in addition to the `locations`

. `δ`

is the maximum length of an LC stage in the circuit approximation to a transmission line. It is ignored when constructing a Blackbox from a TransmissionLine.

`AdmittanceModels.admittance_matrices`

— Method`admittance_matrices(bbox::Blackbox)`

Find the admittance matrices `Y`

with `Yy = x`

for each `ω`

.

`AdmittanceModels.apply_transform`

— Method`apply_transform(am::AdmittanceModel, transform::AbstractMatrix{<:Number})`

Apply a linear transformation `transform`

to the coordinates of the model.

`AdmittanceModels.canonical_gauge`

— Function```
canonical_gauge(pso::PSOModel)
canonical_gauge(bbox::Blackbox)
```

Apply an invertible transformation that takes the model to coordinates in which `P`

is `[I ; 0]`

(up to floating point errors). Note this will create a dense model.

`AdmittanceModels.cascade`

— Method```
cascade(ams::AbstractVector{U}) where {T, U <: AdmittanceModel{T}}
cascade(ams::Vararg{U}) where {T, U <: AdmittanceModel{T}}
```

Cascade the models into one larger block diagonal model.

`AdmittanceModels.cascade_and_unite`

— Method```
cascade_and_unite(models::AbstractVector{U}) where {T, U <: AdmittanceModel{T}}
cascade_and_unite(models::Vararg{U}) where {T, U <: AdmittanceModel{T}}
```

Cascade all models and unite ports with the same name.

`AdmittanceModels.compatible`

— Function```
compatible(psos::AbstractVector{PSOModel{T, U}}) where {T, U}
compatible(bboxes::AbstractVector{Blackbox{T, U}}) where {T, U}
```

Check if the models can be cascaded. Always true for PSOModels and true for Blackboxes that share the same value of `ω`

.

`AdmittanceModels.get_P`

— Function```
get_P(pso::PSOModel)
get_P(bbox::Blackbox)
```

Return an input port matrix.

`AdmittanceModels.get_Q`

— Function```
get_Q(pso::PSOModel)
get_Q(bbox::Blackbox)
```

Return an output port matrix.

`AdmittanceModels.get_Y`

— Function```
get_Y(pso::PSOModel)
get_Y(bbox::Blackbox)
```

Return a vector of admittance matrices.

`AdmittanceModels.get_ports`

— Function```
get_ports(pso::PSOModel)
get_ports(bbox::Blackbox)
```

Return a vector of port identifiers.

`AdmittanceModels.impedance_matrices`

— Method`impedance_matrices(bbox::Blackbox)`

Find the impedance matrices `Z`

with `y = Zx`

for each `ω`

.

`AdmittanceModels.lossless_modes_dense`

— Method```
lossless_modes_dense(pso::PSOModel; min_freq::Real=0,
max_freq::Union{Real, Nothing}=nothing)
```

Use a dense svd solver to find the modes of the PSOModel neglecting loss. Each mode consists of an eigenvalue `λ`

and an eigenvector `v`

. The frequency of the mode is `imag(λ)/(2π)`

and the decay rate is `-2*real(λ)/(2π)`

. `min_freq`

and `max_freq`

give the frequency range in which to find eigenvalues.

`AdmittanceModels.lossless_modes_sparse`

— Method`lossless_modes_sparse(pso::PSOModel; num_modes=1, maxiter=200)`

Use a sparse generalized eigenvalue solver to find the `num_modes`

lowest frequency modes of the PSOModel neglecting loss. Each mode consists of an eigenvalue `λ`

and an eigenvector `v`

. The frequency of the mode is `imag(λ)/(2π)`

and the decay rate is `-2*real(λ)/(2π)`

.

`AdmittanceModels.lossy_modes_dense`

— Method```
lossy_modes_dense(pso::PSOModel; min_freq::Real=0,
max_freq::Union{Real, Nothing}=nothing, real_tol::Real=Inf, imag_tol::Real=Inf)
```

Use a dense eigenvalue solver to find the decaying modes of the PSOModel. Each mode consists of an eigenvalue `λ`

and a spatial distribution vector `v`

. The frequency of the mode is `imag(λ)/(2π)`

and the decay rate is `-2*real(λ)/(2π)`

. `min_freq`

and `max_freq`

give the frequency range in which to find eigenvalues. Passivity is enforced using an inverse power method solver, and `real_tol`

and `imag_tol`

are the tolerances used in that method to determine convergence of the real and imaginary parts of the eigenvalue.

`AdmittanceModels.nullbasis`

— Method`nullbasis(mat::AbstractMatrix{<:Number}; warn::Bool=true)`

Return a `SparseMatrixCSC`

whose columns form a basis for the null space of mat. If `mat`

satisfies the conditions of `sparse_nullbasis`

, a sparse matrix is returned. Otherwise a warning is issued and the `LinearAlgebra.nullspace`

function is used.

`AdmittanceModels.open_ports`

— Method```
open_ports(am::AdmittanceModel{T}, ports::AbstractVector{T}) where T
open_ports(am::AdmittanceModel{T}, ports::Vararg{T}) where T
```

Remove the given ports.

`AdmittanceModels.open_ports_except`

— Method```
open_ports_except(am::AdmittanceModel{T}, ports::AbstractVector{T}) where T
open_ports_except(am::AdmittanceModel{T}, ports::Vararg{T}) where T
```

Remove all ports except those specified.

`AdmittanceModels.partial_copy`

— Function```
partial_copy(pso::PSOModel{T, U};
Y::Union{Vector{V}, Nothing}=nothing,
P::Union{V, Nothing}=nothing,
Q::Union{V, Nothing}=nothing,
ports::Union{AbstractVector{W}, Nothing}=nothing) where {T, U, V, W}
partial_copy(bbox::Blackbox{T, U};
Y::Union{Vector{V}, Nothing}=nothing,
P::Union{V, Nothing}=nothing,
Q::Union{V, Nothing}=nothing,
ports::Union{AbstractVector{W}, Nothing}=nothing) where {T, U, V, W}
```

Create a new model with the same fields except those given as keyword arguments.

`AdmittanceModels.ports_to_indices`

— Method```
ports_to_indices(am::AdmittanceModel{T}, ports::AbstractVector{T}) where T
ports_to_indices(am::AdmittanceModel{T}, ports::Vararg{T}) where T
```

Find the indices corresponding to given ports.

`AdmittanceModels.scattering_matrices`

— Method`scattering_matrices(bbox::Blackbox, Z0::AbstractVector{<:Real})`

Find the scattering matrices that map incoming waves to outgoing waves on transmission lines with characteristic impedance `Z0`

for each `ω`

.

`AdmittanceModels.short_ports`

— Method```
short_ports(am::AdmittanceModel{T}, ports::AbstractVector{T}) where T
short_ports(am::AdmittanceModel{T}, ports::Vararg{T}) where T
```

Replace the given ports by short circuits.

`AdmittanceModels.short_ports_except`

— Method```
short_ports_except(am::AdmittanceModel{T}, ports::AbstractVector{T}) where T
short_ports_except(am::AdmittanceModel{T}, ports::Vararg{T}) where T
```

Replace all ports with short circuits, except those specified.

`AdmittanceModels.sparse_nullbasis`

— Method`sparse_nullbasis(mat::SparseMatrixCSC{<:Number, Int})`

Let `mat`

be a matrix with the following properties - for any two rows of `mat`

there is at most one column on which both rows are nonzero - any column of `mat`

has at most 2 nonzero values Produce a sparse matrix whose columns form a basis for the nullspace of `mat`

.

`AdmittanceModels.unite_ports`

— Method```
unite_ports(am::AdmittanceModel{T}, ports::AbstractVector{T}) where T
unite_ports(am::AdmittanceModel{T}, ports::Vararg{T}) where T
```

Unite the given ports into one port.

`AdmittanceModels.bfs_tree`

— Method`bfs_tree(adj::AbstractMatrix{Int}, root::Int)`

Produce the vertices and edges of the tree found by performing breadth first on the graph with adjacency matrix `adj`

starting from the vertex `root`

. The vertices includes all vertices of the tree besides the root.

`AdmittanceModels.closest_permutation`

— Method`closest_permutation(mat::AbstractMatrix{<:Real})`

Given an `m × n`

matrix `mat`

where `m ≥ n`

, find an assignment of rows to columns such that each column is assigned a distinct row and the absolute values of the entries corresponding to the assignment is as large as possible under lexicographical ordering. Return a matrix of Bools where each column has a single true in it corresponding to its assignment.

`AdmittanceModels.connected_row_column_graph`

— Method`connected_row_column_graph(mat::SparseMatrixCSC{<:Number, Int})`

Let `mat`

be a matrix with the following properties - for any two rows of `mat`

there is at most one column on which both rows are nonzero - any column of `mat`

has at most 2 nonzero values Produce a matrix `mat_connected`

with the same nullspace as `mat`

such that `row_column_graph(mat_connected)`

encodes a connected graph. Return `mat_connected`

and `row_column_graph(mat_connected)`

.

`AdmittanceModels.inv_power_eigen`

— Method```
inv_power_eigen(M::AbstractMatrix{<:Number};
v0::AbstractVector{<:Number}=rand(Complex{real(eltype(M))}, size(M, 1)),
λ0::Union{Number, Nothing}=nothing,
pred::Function=(x,y) -> norm(x-y) < eps())
```

Use the inverse power method to find an eigenvalue and eigenvector.

**Arguments**

`v0::AbstractVector{<:Number}`

: an initial value for the eigenvector. A random vector is used if`v0`

is not given.`λ0::Union{Number, Nothing}`

: an initial value for the eigenvalue.`v' * M * v`

is used if`λ0`

is not given.`pred::Function`

: a function taking two successive eigenvalue estimates. The algorithm halts when`pred`

returns true.

`AdmittanceModels.match_vectors`

— Method```
match_vectors(port_vectors::AbstractMatrix{<:Number},
eigenvectors::AbstractMatrix{<:Number})
```

For each column of `port_vectors`

find a corresponding column of `eigenvectors`

that has a similar "shape". Match each `port_vector`

to a different `eigenvector`

.

`AdmittanceModels.parse_q3d_txt`

— Method`parse_q3d_txt(filepath, matrix_type::Symbol)`

Parses a plain text file generated by ANSYS Q3D containing RLGC simulation output.

**Args**

`q3d_file`

: the path to the text file.`matrix_type`

: A`Symbol`

indicating the type of data to read. Currently, symbols in [:capacitance, :conductance] are the only available choices, and only the units in ["pF", "nF", "mF", "uF", "fF", "farad", "sie", "mSie"] are handled.

**Returns**

- A tuple
`(design_variation, net_names, matrix)`

, where:`design_variation`

is a`Dict`

of design variables`net_names`

is a`Vector`

of net names (strings)`matrix`

is the requested matrix

`AdmittanceModels.parse_value_and_unit`

— Method`parse_value_and_unit(s::AbstractString)`

Parse strings like "9.9e-9mm" => (9.9e-9, "mm").

`AdmittanceModels.row_column_graph`

— Method`row_column_graph(mat::SparseMatrixCSC{<:Number, Int})`

Let `mat`

be a matrix with the following properties - for any two rows of `mat`

there is at most one column on which both rows are nonzero - any column of `mat`

has at most 2 nonzero values The rows of `mat`

form a simple graph where two rows have an edge if and only if they share a nonzero column in `mat`

. We add one additional vertex to this graph and for each column with exactly one nonzero value, we add an edge between its nonzero row and the additional vertex. In this graph every column with at least one nonzero value is represented by an edge. Produce a matrix `A`

where `A[i,j]`

is the column shared by rows `i`

and `j`

if such a column exists, and `0`

otherwise. If `i == size(mat, 1) + 1`

, then `A[i,j]`

is chosen arbitrarily from the columns whose unique nonzero value is in row `j`

, or 0 if no such columns exist. The case where `j == size(mat, 1) + 1`

is analogous. `A`

is an adjacency matrix for the graph with extra information relating the graph to `mat`

.