示例#1
0
    def connect_circuit(netlist):
        """
        Connects the s-matrices of a photonic circuit given its Netlist
        and returns a single 'SimulatedComponent' object containing the frequency
        array, the assembled s-matrix, and a list of the external nets (negative 
        integers).

        Parameters
        ----------
        component_list : List[SimulatedComponent]
            A list of the components to be connected.
        net_count : int
            The total number of internal nets in the component list.

        Returns
        -------
        combined : ScatteringMatrix
            After the circuit has been fully connected, the result is a single 
            ComponentSimulation with fields f (frequency), s (s-matrix), and nets 
            (external ports: negative numbers, as strings).

        Notes
        -----
        This function doesn't actually store ``combined`` on each iteration 
        through the netlist. That's because the Pin objects can only reference
        one PinList at a time, which in turn can only reference one Element.
        Since we transferring the actual Pin objects between lists, keeping
        a reference to the Pin also keeps a reference to the ``combined`` 
        Element alive. Hence, we track pins but not the ``SimulationResult``.
        """
        _logger = _module_logger.getChild('SweepSimulation.connect_circuit')

        # FIXME: What if there are no items in the netlist (only one element
        # in the circuit)?
        for net in netlist:
            p1, p2 = net
            if p1.element == p2.element:
                _logger.debug('Internal connection')
                combined = ScatteringMatrix()
                combined.s = innerconnect_s(p1.element.s, p1.index, p2.index)
                pinlist = p1.pinlist
                pinlist.remove(p1, p2)
                combined.pinlist = pinlist
            else:
                _logger.debug('External connection')
                combined = ScatteringMatrix()
                combined.s = connect_s(p1.element.s, p1.index, p2.element.s,
                                       p2.index)
                pinlist = p1.pinlist + p2.pinlist
                pinlist.remove(p1, p2)
                combined.pinlist = pinlist
        return combined
示例#2
0
import matplotlib.pyplot as plt
import numpy as np

from simphony.library import ebeam, sipann
from simphony.connect import innerconnect_s, connect_s
from simphony.simulation import freq2wl, wl2freq

# First, we'll set up the frequency range we wish to perform the simulation on.
freq = np.linspace(wl2freq(1600e-9), wl2freq(1500e-9), 2000)

# Get the scattering parameters for each of the elements in our network.
half_ring_left = sipann.sipann_dc_halfring(radius=10).s_parameters(freq)
half_ring_right = sipann.sipann_dc_halfring(radius=10).s_parameters(freq)
term = ebeam.ebeam_terminator_te1550().s_parameters(freq)

### CONFIGURATION 1 ###
n1 = connect_s(half_ring_left, 1, half_ring_right, 3)
n2 = innerconnect_s(n1, 2, 4)
n3 = connect_s(n2, 1, term, 0)

### CONFIGURATION 2 ###
m1 = connect_s(half_ring_right, 1, half_ring_left, 3)
m2 = innerconnect_s(m1, 2, 4)
m3 = connect_s(term, 0, m2, 3)

plt.plot(freq, np.abs(n3[:, 1, 2])**2, 'b.')
plt.plot(freq, np.abs(m3[:, 0, 1])**2, 'r--')
plt.tight_layout()
plt.show()