Network connections
Join scattering networks at their ports, with their noise: connectS connects them one pair of ports at a time, solveS solves the whole connection at once, and cascadeS, intraconnectS and interconnectS are the operations they are built from. The noise covariances are symmetrized and counted in quanta, the vacuum being half a photon: a passive network given without one emits (I - S*S')/2. See conventions.
See network parameters and closed-form networks, or the API overview for other topics.
JosephsonCircuits.cascadeS Method
cascadeS(Sa, Sb)Cascade the scattering parameter matrix Sa with the scattering matrix Sb and return the combined scattering matrix. Each is a 2n port network whose first n ports are its inputs and last n its outputs, and the outputs of Sa are joined to the inputs of Sb, all at one reference impedance. Arrays of matrices, one per frequency along the dimensions after the first two, must have the same such dimensions; the element type of the result is that of the solves of the entries of both.
Examples
julia> Sa = [0.0 0.5;0.5 0.0];Sb = [0.0 0.1;0.1 0.0];JosephsonCircuits.cascadeS(Sa,Sb)
2×2 Matrix{Float64}:
0.0 0.05
0.05 0.0
julia> Sa=rand(Complex{Float64},2,2);Sb=rand(Complex{Float64},2,2);isapprox(JosephsonCircuits.cascadeS(Sa,Sb),JosephsonCircuits.AtoS(JosephsonCircuits.StoA(Sa)*JosephsonCircuits.StoA(Sb)))
true
julia> Sa=[rand(Complex{Float64},2,2) for i in 1:10];Sb=[rand(Complex{Float64},2,2) for i in 1:10];isapprox(JosephsonCircuits.cascadeS.(Sa,Sb),JosephsonCircuits.AtoS.(JosephsonCircuits.StoA.(Sa).*JosephsonCircuits.StoA.(Sb)))
trueReferences
D. J. R. Stock and L. J. Kaplan, "A Comment on the Scattering Matrix of Cascaded 2n-Ports (Correspondence)," in IRE Transactions on Microwave Theory and Techniques, vol. 9, no. 5, pp. 454-454, September 1961, doi: 10.1109/TMTT.1961.1125369 .
sourceJosephsonCircuits.connectS! Method
connectS!(plan::ConnectionPlan, scattering_parameters::AbstractVector,
noise_covariances::AbstractVector; noise::Bool = false,
nbatches::Int = Base.Threads.nthreads())Apply the merges of the ConnectionPlan plan to the networks of scattering parameters scattering_parameters and noise covariances noise_covariances, as connectS_initialize returns them, and return the scattering parameters, noise covariances and ports of the networks which remain: one network for each set of networks the connections join. The networks must have the numbers of ports the plan was made for. The noise covariances are propagated only when noise = true, and those of the networks given without covariances are then computed from their scattering parameters at each call, so the scattering parameter arrays of the networks can be updated in place between calls.
Examples
networks = [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5])];
connections = [[("S1",1),("S2",2)]];
init = JosephsonCircuits.connectS_initialize(networks, connections);
JosephsonCircuits.connectS!(init...)
# output
(S = [[0.5 0.5; 0.5 0.5]], ports = [[("S1", 2), ("S2", 1)]])JosephsonCircuits.connectS Method
connectS(networks, connections; small_splitters::Bool = true,
noise::Bool = false, Nmodes::Integer = 1,
nbatches::Int = Base.Threads.nthreads())Return the networks and ports resulting from connecting the networks in networks according to the connections in connections. networks is a vector of tuples of the network name and scattering parameter matrix such as [("network1name",rand(Complex{Float64},2,2)), ("network2name",rand(Complex{Float64},2,2))], optionally with the names of the ports as a third element, or with a noise covariance matrix as the third element and the port names as a fourth. connections is a vector of vectors of tuples of networks names and ports such as [[("network1name",1),("network2name",2)]] where network1 and network2 are the two networks being connected and 1 and 2 are integers describing the ports to connect, or a vector of pairwise connections (network1, network2, port1, port2) such as [("network1name", "network2name",1,2)]. The scattering parameters of all the networks are arrays of one type, such as Arrays, and the connections work on Arrays of their values; as for solveS, wrapped arrays such as KeyedArrays are taken when no connection joins more than two ports. A noise covariance of another array type than the scattering parameters of its network, a real Matrix for complex ones say, is taken as one of theirs.
The ports joined by a connection must share one real reference impedance. This function supports connections between more than two ports by automatically adding splitters, ideal lossless junctions for that impedance (see S_splitter!). With noise = true the noise covariance matrices are connected as well, the passive covariance (I - S S')/2 being used for a network given without one; with Nmodes > 1 the scattering matrices are multi-mode and connections names physical ports, each expanded to its Nmodes modes (see add_modes). The frequencies are split into nbatches batches run on threads when there are more of them than batches; one or fewer batches run on the calling task.
Returns
A named tuple with one entry per set of networks the connections join, and one per network they leave unconnected:
S: the vector of the scattering parameter arrays of the connected networks.C: withnoise = true, the vector of their noise covariance arrays.ports: the vector of the vectors of their ports, each a tuple of network name and port number.
A network which no connection touches is returned as the Array it was given, not a copy, and so is its covariance; a network of another array type is returned as an Array of its values.
Examples
networks = [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5])];
connections = [[("S1",1),("S2",2)]];
JosephsonCircuits.connectS(networks,connections)
# output
(S = [[0.5 0.5; 0.5 0.5]], ports = [[("S1", 2), ("S2", 1)]])networks = [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5],[("S3",5),("S3",6)])];
connections = [("S1","S3",1,6)];
JosephsonCircuits.connectS(networks,connections)
# output
(S = [[0.5 0.5; 0.5 0.5]], ports = [[("S1", 2), ("S3", 5)]])JosephsonCircuits.connectS_initialize Method
connectS_initialize(networks::AbstractVector, connections::AbstractVector;
small_splitters::Bool = true, noise = nothing, Nmodes::Integer = 1)Return what connectS! takes: the ConnectionPlan of the merges which connect the networks, made from their numbers of ports and the connections alone, and the vectors of the networks' scattering parameters and noise covariances, with splitters added where more than two ports meet. A network given without noise covariances has an empty array in their place, which connectS! replaces with the passive covariance (I - S S')/2 of its scattering parameters when it is called with noise = true; the noise keyword of this function is deprecated and has no effect. With Nmodes > 1 each physical port of connections is expanded into its Nmodes mode ports (see add_modes).
Examples
networks = [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5])];
connections = [[("S1",1),("S2",2)]];
JosephsonCircuits.connectS_initialize(networks,connections)
# output
(JosephsonCircuits.ConnectionPlan{String}([2, 2], [(1, 2, 1, 2)], [1], [[("S1", 2), ("S2", 1)]]), [[0.0 1.0; 1.0 0.0], [0.5 0.5; 0.5 0.5]], [Matrix{Float64}(undef, 0, 0), Matrix{Float64}(undef, 0, 0)])JosephsonCircuits.connectS_initialize Method
connectS_initialize(networks::AbstractVector{PassiveNetwork{T,N}},
connections::AbstractVector{Tuple{T,T,Int,Int}}) where {T,N}The method of connectS_initialize for networks with their ports named and splitters added, and connections between pairs of ports: return the ConnectionPlan of the connections and the vectors of the networks' scattering parameters and noise covariances, which connectS! takes.
Examples
networks = [JosephsonCircuits.PassiveNetwork("S1", [0.0 1.0; 1.0 0.0]), JosephsonCircuits.PassiveNetwork("S2", [0.5 0.5; 0.5 0.5])];
connections = [("S1","S2",1,2)];
JosephsonCircuits.connectS_initialize(networks,connections)
# output
(JosephsonCircuits.ConnectionPlan{String}([2, 2], [(1, 2, 1, 2)], [1], [[("S1", 2), ("S2", 1)]]), [[0.0 1.0; 1.0 0.0], [0.5 0.5; 0.5 0.5]], [Matrix{Float64}(undef, 0, 0), Matrix{Float64}(undef, 0, 0)])JosephsonCircuits.interconnectS! Method
interconnectS!(Sout, Cout, Sa, Sb, Ca, Cb, k, l;
nbatches = Base.Threads.nthreads())In place version of interconnectS with noise covariances, writing into Sout and Cout and returning both.
JosephsonCircuits.interconnectS! Method
interconnectS!(Sout, Sa, Sb, k, l; nbatches = Base.Threads.nthreads())In place version of interconnectS, writing into Sout.
JosephsonCircuits.interconnectS Method
interconnectS(Sa::AbstractArray, Sb::AbstractArray, Ca::AbstractArray,
Cb::AbstractArray,k::Int, l::Int;
nbatches::Int = Base.Threads.nthreads())Connect port k on an m port network, represented by the scattering parameter matrix Sa, to port l on an n port network, represented by the scattering parameter matrix Sb, resulting in a single (m+n-2) port network, as illustrated below:
Input network:
m | | k+1 | 2
| | |
| ... | ... |
|________| _________|________
| | | | 1
| Sa | | Sb |
| m x m | | n x n |
____|________|__________________|________|
1 | ... k l | ... |
| | |
| | |
2 | l+1 | | nOutput network:
m-1 | | k | m+1
| | |
| ... | ... |
|________|________|________
| | m
| S |
| m+n-2 x m+n-2 |
____|_________________|
1 | ... | ... |
| | |
| | |
2 | | | m+n-2
m-1+lArguments
Sa::Array: Array of scattering parameters representing the first network with ports along first two dimensions, followed by an arbitrary number of other dimensions (eg. frequency).Sb::Array: Array of scattering parameters representing the second network with ports along first two dimensions, followed by an arbitrary number of other dimensions (eg. frequency).Ca::Array: Array of noise covariances of the same dimensions asSa.Cb::Array: Array of noise covariances of the same dimensions asSb.k::Int: Port on first network, with one based indexing.l::Int: Port on second network, with one based indexing.
References
S. W. Wedge, "Computer-aided design of low noise microwave circuits," PhD thesis (1991). R. C. Compton and D. B. Rutledge, "Perspectives in Microwave Circuit Analysis," Proceedings of the 32nd Midwest Symposium on Circuits and Systems, vol. 2, pp. 716–718, Aug. 1989. doi: 10.1109/MWSCAS.1989.101955 V. A. Monaco and P. Tiberio, "Computer-Aided Analysis of Microwave Circuits," in IEEE Transactions on Microwave Theory and Techniques, vol. 22, no. 3, pp. 249-263, Mar. 1974, doi: 10.1109/TMTT.1974.1128208.
sourceJosephsonCircuits.interconnectS Method
interconnectS(Sa::AbstractArray, Sb::AbstractArray, k::Int, l::Int;
nbatches::Int = Base.Threads.nthreads())Connect port k on an m port network, represented by the scattering parameter matrix Sa, to port l on an n port network, represented by the scattering parameter matrix Sb, resulting in a single (m+n-2) port network, as illustrated below:
Input network:
m | | k+1 | 2
| | |
| ... | ... |
|________| _________|________
| | | | 1
| Sa | | Sb |
| m x m | | n x n |
____|________|__________________|________|
1 | ... k l | ... |
| | |
| | |
2 | l+1 | | nOutput network:
m-1 | | k | m+1
| | |
| ... | ... |
|________|________|________
| | m
| S |
| m+n-2 x m+n-2 |
____|_________________|
1 | ... | ... |
| | |
| | |
2 | | | m+n-2
m-1+lArguments
Sa::Array: Array of scattering parameters representing the first network with ports along first two dimensions, followed by an arbitrary number of other dimensions (eg. frequency).Sb::Array: Array of scattering parameters representing the second network with ports along first two dimensions, followed by an arbitrary number of other dimensions (eg. frequency).k::Int: Port on first network, with one based indexing.l::Int: Port on second network, with one based indexing.
References
V. A. Monaco and P. Tiberio, "Computer-Aided Analysis of Microwave Circuits," in IEEE Transactions on Microwave Theory and Techniques, vol. 22, no. 3, pp. 249-263, Mar. 1974, doi: 10.1109/TMTT.1974.1128208.
sourceJosephsonCircuits.intraconnectS! Method
intraconnectS!(Sout, Cout, Sa, Ca, k::Int, l::Int; nbatches::Int = Base.Threads.nthreads())See intraconnectS for description.
JosephsonCircuits.intraconnectS! Method
intraconnectS!(Sout, Sa, k::Int, l::Int; nbatches::Int = Base.Threads.nthreads())See intraconnectS for description.
JosephsonCircuits.intraconnectS Method
intraconnectS(Sa::AbstractArray, Ca::AbstractArray, k::Int, l::Int;
nbatches::Int = Base.Threads.nthreads())Connect ports k and l on the same m port microwave network represented by the scattering parameter matrix Sa, and noise covariance matrix Ca resulting in an (m-2) port network, as illustrated below:
Input network:
m | | l+1
| ... | l
|_________|__________
| | |
| Sa | ... |
| m x m | |
____|_________|_____ k+1 |
1 | ... | |
| | k |
2 | |__________|Output network:
m-2 | | l-1
| |
| ... |
|_________|
| |
| S | ...
|m-2 x m-2|
____|_________|_________
1 | ... k
|
|
2 |Arguments
Sa::Array: Array of scattering parameters representing the network with ports along first two dimensions, followed by an arbitrary number of other dimensions (eg. frequency).Ca::Array: Array of noise covariances of the same dimensions asSa.k::Int: First port to connect, with one based indexing.l::Int: Second port to connect, with one based indexing.
References
S. W. Wedge, "Computer-aided design of low noise microwave circuits," PhD thesis (1991). R. C. Compton and D. B. Rutledge, "Perspectives in Microwave Circuit Analysis," Proceedings of the 32nd Midwest Symposium on Circuits and Systems, vol. 2, pp. 716–718, Aug. 1989. doi: 10.1109/MWSCAS.1989.101955 V. A. Monaco and P. Tiberio, "Computer-Aided Analysis of Microwave Circuits," in IEEE Transactions on Microwave Theory and Techniques, vol. 22, no. 3, pp. 249-263, Mar. 1974, doi: 10.1109/TMTT.1974.1128208.
sourceJosephsonCircuits.intraconnectS Method
intraconnectS(Sa::AbstractArray, k::Int, l::Int;
nbatches::Int = Base.Threads.nthreads())Connect ports k and l on the same m port microwave network represented by the scattering parameter matrix Sa, resulting in an (m-2) port network, as illustrated below:
Input network:
m | | l+1
| ... | l
|_________|__________
| | |
| Sa | ... |
| m x m | |
____|_________|_____ k+1 |
1 | ... | |
| | k |
2 | |__________|Output network:
m-2 | | l-1
| |
| ... |
|_________|
| |
| S | ...
|m-2 x m-2|
____|_________|_________
1 | ... k
|
|
2 |Arguments
Sa::Array: Array of scattering parameters representing the network with ports along first two dimensions, followed by an arbitrary number of other dimensions (eg. frequency).k::Int: First port to connect, with one based indexing.l::Int: Second port to connect, with one based indexing.
References
R. C. Compton and D. B. Rutledge, "Perspectives in Microwave Circuit Analysis," Proceedings of the 32nd Midwest Symposium on Circuits and Systems, vol. 2, pp. 716–718, Aug. 1989. doi: 10.1109/MWSCAS.1989.101955 V. A. Monaco and P. Tiberio, "Computer-Aided Analysis of Microwave Circuits," in IEEE Transactions on Microwave Theory and Techniques, vol. 22, no. 3, pp. 249-263, Mar. 1974, doi: 10.1109/TMTT.1974.1128208.
sourceJosephsonCircuits.solveS! Method
solveS!(Se, Si, Ce, Ci, portse, portsi, gammaii, See, Sei, Sie, Sii,
See_indices, Sei_indices, Sie_indices, Sii_indices, gammaii_indexmap,
Sii_indexmap, scattering_parameters, noise_covariances, nbatches,
factorization, internal_ports, noise, ordering)In place version of solveS, taking the arrays returned by solveS_initialize, which it is meant to be called with as solveS!(init...). ordering is the fill reducing ordering of the connection matrix, chosen once by solveS_initialize (see fillordering), which every batch's factorization takes. It allows a network connection to be updated in place: change the arrays referenced by networks, then recompute the scattering parameters of the connected system. With noise, the passive covariances of the networks given without covariances are computed from their scattering parameters at each call. The arrays returned are those of the tuple, which the next call overwrites: copy a result to keep it.
Examples
networks = [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5])];
connections = [[("S1",1),("S2",2)]];
init = JosephsonCircuits.solveS_initialize(networks, connections);
JosephsonCircuits.solveS!(init...)
# output
(S = [0.5 0.5; 0.5 0.5], ports = [("S1", 2), ("S2", 1)], Sinternal = Float64[], portsinternal = [("S1", 1), ("S2", 2)])References
V. A. Monaco and P. Tiberio, "Computer-Aided Analysis of Microwave Circuits," in IEEE Transactions on Microwave Theory and Techniques, vol. 22, no. 3, pp. 249-263, Mar. 1974, doi: 10.1109/TMTT.1974.1128208.
sourceJosephsonCircuits.solveS Method
solveS(networks, connections; small_splitters::Bool = true,
noise::Bool = false, factorization = KLUfactorization(),
internal_ports::Bool = false, Nmodes::Integer = 1,
nbatches::Integer = Base.Threads.nthreads())Perform the connections between the networks in networks specified by the vector of vectors of tuples connections by solving one sparse linear system per frequency for the waves at the connected (internal) ports, and return the scattering parameters of the unconnected (external) ports. The ports joined by a connection must share one real reference impedance, and a connection of more than two ports is an ideal lossless junction for it (see S_splitter!).
Arguments
networks: a vector of tuples of the network name, scattering parameter matrix, and optionally the ports such as [("network1name",rand(Complex{Float64},2,2))] or [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5])]. The scattering parameters of all the networks are arrays of one type, such asArrays; views of arrays are not supported. Other wrapped arrays, such asKeyedArrays, are supported only when no connection joins more than two ports, since the splitter of such a junction is built as anArray.connections: a vector of vectors of tuples of networks names and ports such as [[("S1",1),("S2",2)]] or [[("network1name",1),("network2name",2)]] where network1 and network2 are the two networks being connected and 1 and 2 are integers describing the ports to connect, or a vector of pairwise connections(network1, network2, port1, port2)such as [("S1","S2",1,2)].
Keywords
small_splitters::Bool = true: if true, then generate any N port splitter by combining (N-2) 3 port splitters. if false, then make the N port splitter and connect the components to it.noise::Bool = false: also connect the noise covariance matrices of the networks. A network given as(name, S)gets the passive covariance(I - S S')/2; one given as(name, S, C)usesC, taken as an array of the type ofSif it is of another, a realMatrixfor a complexSsay.factorization = KLUfactorization(): the sparse factorization of the connection system;LUfactorizationis another good choice. The connection system is singular when the connections close a lossless loop of zero length, such as two ports of a lossless junction joined to each other, whichconnectSresolves;QRfactorizationsolves such a system. Near it, as for a resonator between nearly lossless mirrors, bothsolveSandconnectSlose accuracy as the machine epsilon over the distance to singularity, the noise covariances as well as the scattering parameters;connectSdoes better only for the scattering parameters, and only very close to a lossless loop.internal_ports::Bool = false: also return the waves at the internal ports.Nmodes::Integer = 1: the number of modes of each physical port when the scattering matrices are multi-mode, in which caseconnectionsnames physical ports and each is expanded to its modes (seeadd_modes).nbatches::Integer = Base.Threads.nthreads(): the number of batches to run on threads, one or fewer being one. Defaults to the number of threads with which Julia was launched.
Returns
A named tuple of:
S: the scattering parameters of the external ports, an array of size(ne, ne, ...)with the trailing dimensions of the networks' arrays.C: withnoise = true, the noise covariances of the waves the connected network emits at the external ports, of the size ofS.ports: the vector of tuples of network name and port number for the external ports.Sinternal: withinternal_ports = true, the waves leaving the networks at the internal ports for a unit wave incident at each external port, of size(ni, ne, ...); otherwise an empty vector.Cinternal: withnoise = true, the noise covariances of the waves leaving the networks at the internal ports, of size(ni, ni, ...)withinternal_ports = true; otherwise an empty vector.portsinternal: the vector of tuples of network name and port number for the internal ports.
Examples
networks = [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5])];
connections = [[("S1",1),("S2",2)]];
JosephsonCircuits.solveS(networks,connections;internal_ports=true)
# output
(S = [0.5 0.5; 0.5 0.5], ports = [("S1", 2), ("S2", 1)], Sinternal = [1.0 0.0; 0.5 0.5], portsinternal = [("S1", 1), ("S2", 2)])networks = [("S1",[0.0 1.0;1.0 0.0]),("S2",[0.5 0.5;0.5 0.5],[("S3",5),("S3",6)])];
connections = [("S1","S3",1,6)];
JosephsonCircuits.solveS(networks,connections)
# output
(S = [0.5 0.5; 0.5 0.5], ports = [("S1", 2), ("S3", 5)], Sinternal = Float64[], portsinternal = [("S1", 1), ("S3", 6)])References
V. A. Monaco and P. Tiberio, "Computer-Aided Analysis of Microwave Circuits," in IEEE Transactions on Microwave Theory and Techniques, vol. 22, no. 3, pp. 249-263, Mar. 1974, doi: 10.1109/TMTT.1974.1128208.
sourceJosephsonCircuits.solveS_initialize Method
solveS_initialize(networks, connections; small_splitters = true,
noise = false, factorization = KLUfactorization(),
internal_ports = false, Nmodes = 1,
nbatches = Base.Threads.nthreads())Build the arrays solveS! works on, from the same arguments as solveS: the external and internal port lists and scattering and covariance outputs, the connection matrix gammaii with the index maps into the networks' matrices, the networks' scattering parameters and noise covariances, and the fill reducing ordering of the connection matrix. Returned as a tuple to be splatted into solveS!.