flaport / sax

S + Autograd + XLA :: S-parameter based frequency domain circuit simulations and optimizations using JAX.
https://flaport.github.io/sax
Apache License 2.0
70 stars 17 forks source link

Issue on page /examples/02_all_pass_filter.html #37

Closed philippevelha closed 4 months ago

philippevelha commented 4 months ago

I defined an add-drop like:

ring, _ = sax.circuit( netlist={ "instances": { "lft": coupler, "top": waveguide, "bot": waveguide, "rgt": coupler, }, "connections": { "lft,in1": "top,in0", "lft,out1":"bot,in0", "rgt,in1": "top,out0", "rgt,out1":"bot,out0", }, "ports": { "in0": "lft,in0", "in1": "rgt,in1", "out0": "lft,out0", "out1": "rgt,out1", }, } )

I simulate the behaviour like below:

wl = jnp.linspace(1.54, 1.56, 10001) result = ring(wl=wl, lft={'coupling': 0.02}, top={'length': 100.0,'loss':0.00155}, bot={'length': 100.0,'loss':0.00155}, rgt={'coupling': 0.02}) print(result.values().sizeof()) plt.plot(1e3*wl, jnp.abs(result['in0', 'out0'])2, label="in0->out0") plt.plot(1e3*wl, jnp.abs(result['in0', 'in1'])*2, label="in0->in1", ls="--") plt.plot(1e3wl, jnp.abs(result['out0', 'out1'])2, label="out0->out1", ls="--") plt.xlabel("λ [nm]") plt.ylabel("T") plt.grid(True) plt.figlegend(ncol=2, loc="upper center") plt.show()

Whatever the backend I obtain a transmission greater than 1 or 2

flaport commented 4 months ago

I visualized the netlist with saxviz.visualize_netlist and got this:

image

clearly the ports on coupler rgt are doubly connected.

you can fix it like this:

netlist={
    "instances": {
        "lft": "coupler",
        "top": "straight",
        "bot": "straight",
        "rgt": "coupler",
    },
    "connections": {
        "lft,in1": "top,in0",
        "lft,out1": "bot,in0",
        "rgt,in1": "top,out0",
        "rgt,out1": "bot,out0",
    },
    "ports": {
        "in0": "lft,in0",
        "in1": "rgt,in0",
        "out0": "lft,out0",
        "out1": "rgt,out0",
    },
}

models = {
    "straight": sax.models.straight,
    "coupler": sax.models.coupler,
}

ring, _ = sax.circuit(
    netlist=netlist,
    models =models
)

which gives the following netlist visualization:

image

And the following result:

image