Microstrip waveguide - vary width

Contents

Microstrip waveguide - vary width#

In this example we calculate effective epsilon of the microstrip waveguides from [1]

Hide code cell source
from collections import OrderedDict

import matplotlib.pyplot as plt
import numpy as np
import scipy.constants
import shapely
import shapely.ops
from shapely.geometry import LineString, box
from skfem import Basis, ElementTriP0
from skfem.io.meshio import from_meshio
from tqdm import tqdm

from femwell.maxwell.waveguide import compute_modes
from femwell.mesh import mesh_from_OrderedDict
def mesh_waveguide(filename, wsim, hclad, hsi, wcore, hcore):
    core = box(-wcore / 2, -hcore / 2, wcore / 2, hcore / 2)
    clad = box(-wsim / 2, -hcore / 2, wsim / 2, -hcore / 2 + hclad)
    silicon = box(-wsim / 2, -hcore / 2, wsim / 2, -hcore / 2 - hsi)

    combined = shapely.ops.unary_union([clad, silicon])

    polygons = OrderedDict(
        surface=LineString(combined.exterior),
        core_interface=core.buffer(hcore / 10).exterior,
        core=core,
        clad=clad,
        silicon=silicon,
    )

    resolutions = dict(
        core={"resolution": min(wcore / 20, hcore / 4), "distance": 1, "SizeMax": 0.5},
        core_interface={
            "resolution": min(wcore / 20, hcore / 4),
            "distance": 1,
            "SizeMax": 0.5,
        },
        # silicon={"resolution": 0.2, "distance": 5},
    )

    return mesh_from_OrderedDict(polygons, resolutions, filename=filename, default_resolution_max=5)
frequencies = np.linspace(1e9, 16e9, 16)
# widths = (0.04, 0.6, 0.8, 0.1, 0.14, 0.18, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.6, 3,)
widths = (
    0.04,
    0.4,
    3,
)
epsilon_effs = np.zeros((len(widths), len(frequencies), 1), dtype=complex)
characteristic_impedances = np.zeros((len(widths), len(frequencies), 1), dtype=complex)

for i, width in enumerate(tqdm(widths)):
    mesh = from_meshio(
        mesh_waveguide(
            filename="mesh.msh",
            wsim=10,
            hclad=10,
            hsi=0.64,
            wcore=width,
            hcore=0.005,
        )
    )
    mesh = mesh.scaled((1e-3,) * 2)

    for j, frequency in enumerate(tqdm(frequencies, leave=False)):
        basis0 = Basis(mesh, ElementTriP0(), intorder=4)
        epsilon = basis0.zeros().astype(complex)
        epsilon[basis0.get_dofs(elements="silicon")] = 9.9 + 0.0005
        epsilon[basis0.get_dofs(elements="clad")] = 1.0
        epsilon[basis0.get_dofs(elements="core")] = 1 - 1j * 1 / (
            18e-6 * 1e-3
        ) / scipy.constants.epsilon_0 / (2 * np.pi * frequency)
        # basis0.plot(np.real(epsilon), colorbar=True).show()

        modes = compute_modes(
            basis0,
            epsilon,
            wavelength=scipy.constants.speed_of_light / frequency,
            num_modes=1,
            metallic_boundaries=True,
        )
        print(f"Width: {width}, Frequency: {frequency/1e9} GHz")
        print(f"Effective epsilons {modes.n_effs**2}")
        # modes[0].show("E", part="real", plot_vectors=True, colorbar=True)

        epsilon_effs[i, j] = modes.n_effs**2

        # In work

        conductors = ("core_interface",)

        from skfem import Functional
        from skfem.helpers import inner

        @Functional(dtype=np.complex64)
        def current_form(w):
            return inner(np.array([w.n[1], -w.n[0]]), w.H)

        currents = np.zeros((len(conductors), len(modes)))

        for mode_i, mode in enumerate(modes):
            # modes[0].show("H", part="real", plot_vectors=True, colorbar=True)

            (ht, ht_basis), (hz, hz_basis) = mode.basis.split(mode.H)
            for conductors_i, conductor in enumerate(conductors):
                facet_basis = ht_basis.boundary(facets=mesh.boundaries[conductor])
                current = abs(current_form.assemble(facet_basis, H=facet_basis.interpolate(ht)))
                currents[conductors_i, mode_i] = current

        characteristic_impedances[i, j] = np.linalg.inv(currents).T @ np.linalg.inv(currents)
        print("characteristic impedances", characteristic_impedances[i, j])
Hide code cell output
  0%|          | 0/3 [00:00<?, ?it/s]

  0%|          | 0/16 [00:00<?, ?it/s]


  6%|▋         | 1/16 [00:00<00:03,  4.35it/s]

Width: 0.04, Frequency: 1.0 GHz
Effective epsilons [5.8712941-0.15326731j]
characteristic impedances [110.51632519+0.j]

 12%|█▎        | 2/16 [00:00<00:03,  4.41it/s]

Width: 0.04, Frequency: 2.0 GHz
Effective epsilons [5.85361969-0.10267281j]
characteristic impedances [110.08889768+0.j]

 19%|█▉        | 3/16 [00:00<00:02,  4.44it/s]

Width: 0.04, Frequency: 3.0 GHz
Effective epsilons [5.85099501-0.08536848j]
characteristic impedances [109.84457638+0.j]

 25%|██▌       | 4/16 [00:00<00:02,  4.47it/s]

Width: 0.04, Frequency: 4.0 GHz
Effective epsilons [5.8556182-0.07582812j]
characteristic impedances [109.69909008+0.j]

 31%|███▏      | 5/16 [00:01<00:02,  4.51it/s]

Width: 0.04, Frequency: 5.0 GHz
Effective epsilons [5.86496813-0.06919442j]
characteristic impedances [109.6359137+0.j]

 38%|███▊      | 6/16 [00:01<00:02,  4.54it/s]

Width: 0.04, Frequency: 6.0 GHz
Effective epsilons [5.87755843-0.06406416j]
characteristic impedances [109.64554827+0.j]

 44%|████▍     | 7/16 [00:01<00:01,  4.54it/s]

Width: 0.04, Frequency: 7.0 GHz
Effective epsilons [5.89240399-0.0598982j]
characteristic impedances [109.71805125+0.j]

 50%|█████     | 8/16 [00:01<00:01,  4.54it/s]

Width: 0.04, Frequency: 8.0 GHz
Effective epsilons [5.90886225-0.05642492j]
characteristic impedances [109.8443714+0.j]

 56%|█████▋    | 9/16 [00:01<00:01,  4.54it/s]

Width: 0.04, Frequency: 9.0 GHz
Effective epsilons [5.92652539-0.05347611j]
characteristic impedances [110.01734322+0.j]

 62%|██████▎   | 10/16 [00:02<00:01,  4.54it/s]

Width: 0.04, Frequency: 10.0 GHz
Effective epsilons [5.94513795-0.05093448j]
characteristic impedances [110.23218267+0.j]

 69%|██████▉   | 11/16 [00:02<00:01,  4.53it/s]

Width: 0.04, Frequency: 11.0 GHz
Effective epsilons [5.96453944-0.04871346j]
characteristic impedances [110.48622256+0.j]

 75%|███████▌  | 12/16 [00:02<00:00,  4.54it/s]

Width: 0.04, Frequency: 12.0 GHz
Effective epsilons [5.98462699-0.04674735j]
characteristic impedances [110.77831943+0.j]

 81%|████████▏ | 13/16 [00:02<00:00,  4.55it/s]

Width: 0.04, Frequency: 13.0 GHz
Effective epsilons [6.00533222-0.04498569j]
characteristic impedances [111.10860777+0.j]

 88%|████████▊ | 14/16 [00:03<00:00,  4.55it/s]

Width: 0.04, Frequency: 14.0 GHz
Effective epsilons [6.02660744-0.04338934j]
characteristic impedances [111.47794589+0.j]

 94%|█████████▍| 15/16 [00:03<00:00,  4.55it/s]

Width: 0.04, Frequency: 15.0 GHz
Effective epsilons [6.04841762-0.04192779j]
characteristic impedances [111.88775053+0.j]

100%|██████████| 16/16 [00:03<00:00,  4.42it/s]


                                               

 33%|███▎      | 1/3 [00:03<00:07,  3.97s/it]
Width: 0.04, Frequency: 16.0 GHz
Effective epsilons [6.07073575-0.0405771j]
characteristic impedances [112.33981374+0.j]

  0%|          | 0/16 [00:00<?, ?it/s]


  6%|▋         | 1/16 [00:01<00:21,  1.40s/it]

Width: 0.4, Frequency: 1.0 GHz
Effective epsilons [6.38175462-0.04265092j]
characteristic impedances [58.91529182+0.j]

 12%|█▎        | 2/16 [00:02<00:19,  1.38s/it]

Width: 0.4, Frequency: 2.0 GHz
Effective epsilons [6.39140243-0.02904808j]
characteristic impedances [59.1279069+0.j]

 19%|█▉        | 3/16 [00:04<00:17,  1.38s/it]

Width: 0.4, Frequency: 3.0 GHz
Effective epsilons [6.41263982-0.0245779j]
characteristic impedances [59.40055892+0.j]

 25%|██▌       | 4/16 [00:05<00:16,  1.38s/it]

Width: 0.4, Frequency: 4.0 GHz
Effective epsilons [6.44126916-0.02206328j]
characteristic impedances [59.6820971+0.j]

 31%|███▏      | 5/16 [00:06<00:15,  1.37s/it]

Width: 0.4, Frequency: 5.0 GHz
Effective epsilons [6.47473968-0.02022274j]
characteristic impedances [59.9607219+0.j]

 38%|███▊      | 6/16 [00:08<00:13,  1.37s/it]

Width: 0.4, Frequency: 6.0 GHz
Effective epsilons [6.51125386-0.01873081j]
characteristic impedances [60.2380295+0.j]

 44%|████▍     | 7/16 [00:09<00:12,  1.36s/it]

Width: 0.4, Frequency: 7.0 GHz
Effective epsilons [6.54964206-0.01747792j]
characteristic impedances [60.51736177+0.j]

 50%|█████     | 8/16 [00:10<00:10,  1.36s/it]

Width: 0.4, Frequency: 8.0 GHz
Effective epsilons [6.58920107-0.01641021j]
characteristic impedances [60.80124013+0.j]

 56%|█████▋    | 9/16 [00:12<00:09,  1.36s/it]

Width: 0.4, Frequency: 9.0 GHz
Effective epsilons [6.62952953-0.0154915j]
characteristic impedances [61.09163409+0.j]

 62%|██████▎   | 10/16 [00:13<00:08,  1.36s/it]

Width: 0.4, Frequency: 10.0 GHz
Effective epsilons [6.67040198-0.01469381j]
characteristic impedances [61.39044642+0.j]

 69%|██████▉   | 11/16 [00:15<00:06,  1.36s/it]

Width: 0.4, Frequency: 11.0 GHz
Effective epsilons [6.71168706-0.01399464j]
characteristic impedances [61.69967512+0.j]

 75%|███████▌  | 12/16 [00:16<00:05,  1.36s/it]

Width: 0.4, Frequency: 12.0 GHz
Effective epsilons [6.75329951-0.01337589j]
characteristic impedances [62.02137816+0.j]

 81%|████████▏ | 13/16 [00:17<00:04,  1.37s/it]

Width: 0.4, Frequency: 13.0 GHz
Effective epsilons [6.79517441-0.01282303j]
characteristic impedances [62.35755777+0.j]

 88%|████████▊ | 14/16 [00:19<00:02,  1.37s/it]

Width: 0.4, Frequency: 14.0 GHz
Effective epsilons [6.83725459-0.01232447j]
characteristic impedances [62.71005032+0.j]

 94%|█████████▍| 15/16 [00:20<00:01,  1.37s/it]

Width: 0.4, Frequency: 15.0 GHz
Effective epsilons [6.87948522-0.01187094j]
characteristic impedances [63.0804633+0.j]

100%|██████████| 16/16 [00:21<00:00,  1.36s/it]


                                               

 67%|██████▋   | 2/3 [00:26<00:15, 15.02s/it]
Width: 0.4, Frequency: 16.0 GHz
Effective epsilons [6.92181205-0.01145507j]
characteristic impedances [63.4701835+0.j]

  0%|          | 0/16 [00:00<?, ?it/s]


  6%|▋         | 1/16 [00:12<03:08, 12.58s/it]

Width: 3, Frequency: 1.0 GHz
Effective epsilons [7.72197706-0.02084239j]
characteristic impedances [18.71892757+0.j]

 12%|█▎        | 2/16 [00:24<02:53, 12.41s/it]

Width: 3, Frequency: 2.0 GHz
Effective epsilons [7.77089439-0.01451959j]
characteristic impedances [18.84111298+0.j]

 19%|█▉        | 3/16 [00:37<02:40, 12.37s/it]

Width: 3, Frequency: 3.0 GHz
Effective epsilons [7.84563215-0.01242895j]
characteristic impedances [19.0120698+0.j]

 25%|██▌       | 4/16 [00:49<02:29, 12.44s/it]

Width: 3, Frequency: 4.0 GHz
Effective epsilons [7.93428127-0.01127637j]
characteristic impedances [19.20713594+0.j]

 31%|███▏      | 5/16 [01:02<02:17, 12.51s/it]

Width: 3, Frequency: 5.0 GHz
Effective epsilons [8.02775497-0.01043376j]
characteristic impedances [19.41478234+0.j]

 38%|███▊      | 6/16 [01:15<02:06, 12.61s/it]

Width: 3, Frequency: 6.0 GHz
Effective epsilons [8.12026481-0.00974244j]
characteristic impedances [19.62763328+0.j]

 44%|████▍     | 7/16 [01:28<01:54, 12.75s/it]

Width: 3, Frequency: 7.0 GHz
Effective epsilons [8.20877938-0.00915282j]
characteristic impedances [19.84006458+0.j]

 50%|█████     | 8/16 [01:41<01:42, 12.85s/it]

Width: 3, Frequency: 8.0 GHz
Effective epsilons [8.29206805-0.00864227j]
characteristic impedances [20.04832833+0.j]

 56%|█████▋    | 9/16 [01:54<01:31, 13.01s/it]

Width: 3, Frequency: 9.0 GHz
Effective epsilons [8.36988911-0.00819566j]
characteristic impedances [20.25051585+0.j]

 62%|██████▎   | 10/16 [02:07<01:18, 13.01s/it]

Width: 3, Frequency: 10.0 GHz
Effective epsilons [8.44246521-0.00780105j]
characteristic impedances [20.44610844+0.j]

 69%|██████▉   | 11/16 [02:20<01:05, 13.11s/it]

Width: 3, Frequency: 11.0 GHz
Effective epsilons [8.51019396-0.00744873j]
characteristic impedances [20.63540946+0.j]

 75%|███████▌  | 12/16 [02:34<00:52, 13.19s/it]

Width: 3, Frequency: 12.0 GHz
Effective epsilons [8.57350669-0.00713085j]
characteristic impedances [20.81910108+0.j]

 81%|████████▏ | 13/16 [02:47<00:39, 13.28s/it]

Width: 3, Frequency: 13.0 GHz
Effective epsilons [8.63280876-0.00684123j]
characteristic impedances [20.99795981+0.j]

 88%|████████▊ | 14/16 [03:01<00:26, 13.47s/it]

Width: 3, Frequency: 14.0 GHz
Effective epsilons [8.68846011-0.00657503j]
characteristic impedances [21.17269413+0.j]

 94%|█████████▍| 15/16 [03:13<00:13, 13.04s/it]

Width: 3, Frequency: 15.0 GHz
Effective epsilons [8.74077384-0.00632849j]
characteristic impedances [21.34389237+0.j]

100%|██████████| 16/16 [03:25<00:00, 12.74s/it]


                                               

100%|██████████| 3/3 [03:56<00:00, 104.14s/it]
100%|██████████| 3/3 [03:56<00:00, 78.97s/it] 
Width: 3, Frequency: 16.0 GHz
Effective epsilons [8.79002158-0.00609871j]
characteristic impedances [21.51201047+0.j]

Hide code cell source
plt.figure(figsize=(10, 14))
plt.xlabel("Frequency / GHz")
plt.ylabel("Effective dielectric constant")

for i, width in enumerate(widths):
    plt.plot(frequencies / 1e9, epsilon_effs[i, :, 0].real)
    plt.annotate(
        xy=(frequencies[-1] / 1e9, epsilon_effs[i, :, 0].real[-1]),
        text=str(width),
        va="center",
    )

plt.show()

plt.figure(figsize=(10, 14))
plt.xlabel("Frequency / GHz")
plt.ylabel("Characteristic Impedance / Ohm")

for i, width in enumerate(widths):
    plt.plot(frequencies / 1e9, characteristic_impedances[i, :, 0].real)
    plt.annotate(
        xy=(frequencies[-1] / 1e9, characteristic_impedances[i, :, 0].real[-1]),
        text=str(width),
        va="center",
    )

plt.show()
../../_images/0eeea55f253a60fa1b0822b4c7870a332a6eae77aa46c7d16e68427944493b78.png ../../_images/6cfa61078c844fb2bbd4cac0413fb902bce373d52d411fafdc10eebd1242f5e3.png

Bibliography#

[1]

R.H. Jansen. High-speed computation of single and coupled microstrip parameters including dispersion, high-order modes, loss and finite strip thickness. IEEE Transactions on Microwave Theory and Techniques, 26(2):75–82, February 1978. URL: http://dx.doi.org/10.1109/TMTT.1978.1129316, doi:10.1109/tmtt.1978.1129316.