Exemple #1
0
 def __init__(self):
     super(AddDrop, self).__init__()
     self.term_in = pt.Source()
     self.term_pass = pt.Detector()
     self.term_add = pt.Detector()
     self.term_drop = pt.Detector()
     self.dc1 = pt.DirectionalCoupler()
     self.dc2 = pt.DirectionalCoupler()
     self.wg1 = pt.Waveguide()
     self.wg2 = pt.Waveguide()
     self.link("term_in:0", "0:dc1:2", "0:wg1:1", "1:dc2:3", "0:term_drop")
     self.link("term_add:0", "2:dc2:0", "0:wg2:1", "3:dc1:1", "0:term_pass")
Exemple #2
0
def conn():
    """ default connector """
    wg = pt.Waveguide()
    s = pt.Source()
    d = pt.Detector()
    conn = wg["ab"] * s["a"] * d["b"]
    return conn
Exemple #3
0
def nw():
    """ default network (source-waveguide-detector) """
    with pt.Network() as nw:
        nw.wg = pt.Waveguide(length=1e-5)
        nw.s = pt.Source()
        nw.d = pt.Detector()
        nw.link("s:0", "0:wg:1", "0:d")
    return nw
Exemple #4
0
def test_agrawal_soa():
    # fmt: off
    # single delay too many in buffermask:
    # target = np.array([0.00000, 0.00814, 0.10276, 0.04285, 0.02142, 0.12841, 0.03331, 0.04192, 0.14501, 0.02096])
    # delay compensated in buffermask:
    target = np.array([
        0.00000, 0.01252, 0.10493, 0.03503, 0.02863, 0.12833, 0.02530, 0.05175,
        0.14189, 0.01401
    ])
    # fmt: on
    with pt.Network() as nw:
        nw.src = pt.Source()
        nw.soa = pt.AgrawalSoa()
        nw.det = pt.Detector()
        nw.link("src:0", "0:soa:1", "0:det")
    env = pt.Environment(dt=6e-13, num_t=150)
    src = torch.tensor(
        0.3 * np.sin(0.0001 * 2 * np.pi * env.t * env.c / env.wl),
        dtype=torch.get_default_dtype(),
    )[:, None, None, None]
    with env:
        det = nw(src)[:, 0, 0, 0].detach().cpu().numpy()
    np.testing.assert_almost_equal(target, det[::15], decimal=5)
Exemple #5
0
def test_termination(unw):
    unw.terminate()
    unw.terminate([pt.Source("src"), pt.Detector("det")])
    if torch.cuda.is_available():  # pragma: no cover
        unw.cuda()
        unw.terminate()
Exemple #6
0
def d():
    """ default detector """
    return pt.Detector()