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:02,  6.34it/s]


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

Width: 0.04, Frequency: 1.0 GHz
Effective epsilons [5.7727501-0.15749639j]
characteristic impedances [104.86116771+0.j]
Width: 0.04, Frequency: 2.0 GHz
Effective epsilons [5.75489676-0.10557441j]
characteristic impedances [104.55211314+0.j]

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


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

Width: 0.04, Frequency: 3.0 GHz
Effective epsilons [5.75276004-0.08781926j]
characteristic impedances [104.38347591+0.j]
Width: 0.04, Frequency: 4.0 GHz
Effective epsilons [5.75822768-0.07803904j]
characteristic impedances [104.31351446+0.j]

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


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

Width: 0.04, Frequency: 5.0 GHz
Effective epsilons [5.76865457-0.07124472j]
characteristic impedances [104.32724239+0.j]
Width: 0.04, Frequency: 6.0 GHz
Effective epsilons [5.78248377-0.06599418j]
characteristic impedances [104.41272805+0.j]

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


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

Width: 0.04, Frequency: 7.0 GHz
Effective epsilons [5.79869033-0.06173322j]
characteristic impedances [104.5581165+0.j]
Width: 0.04, Frequency: 8.0 GHz
Effective epsilons [5.8166094-0.05818274j]
characteristic impedances [104.75338063+0.j]

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


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

Width: 0.04, Frequency: 9.0 GHz
Effective epsilons [5.83581836-0.05516981j]
characteristic impedances [104.99104284+0.j]
Width: 0.04, Frequency: 10.0 GHz
Effective epsilons [5.85604843-0.05257384j]
characteristic impedances [105.26634584+0.j]

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


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

Width: 0.04, Frequency: 11.0 GHz
Effective epsilons [5.87712467-0.05030572j]
characteristic impedances [105.57665425+0.j]
Width: 0.04, Frequency: 12.0 GHz
Effective epsilons [5.89892812-0.04829789j]
characteristic impedances [105.92090502+0.j]

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


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

Width: 0.04, Frequency: 13.0 GHz
Effective epsilons [5.92137338-0.04649844j]
characteristic impedances [106.29910042+0.j]
Width: 0.04, Frequency: 14.0 GHz
Effective epsilons [5.94439574-0.0448672j]
characteristic impedances [106.71192256+0.j]

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


100%|██████████| 16/16 [00:02<00:00,  6.32it/s]


                                               

 33%|███▎      | 1/3 [00:02<00:05,  2.88s/it]
Width: 0.04, Frequency: 15.0 GHz
Effective epsilons [5.96794399-0.04337289j]
characteristic impedances [107.16046379+0.j]
Width: 0.04, Frequency: 16.0 GHz
Effective epsilons [5.9919765-0.04199107j]
characteristic impedances [107.64612066+0.j]

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


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

Width: 0.4, Frequency: 1.0 GHz
Effective epsilons [6.2585213-0.04360235j]
characteristic impedances [54.03425772+0.j]

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

Width: 0.4, Frequency: 2.0 GHz
Effective epsilons [6.26887933-0.02972074j]
characteristic impedances [53.99489555+0.j]

 19%|█▉        | 3/16 [00:03<00:13,  1.02s/it]

Width: 0.4, Frequency: 3.0 GHz
Effective epsilons [6.29131434-0.02516249j]
characteristic impedances [53.97440189+0.j]

 25%|██▌       | 4/16 [00:04<00:12,  1.03s/it]

Width: 0.4, Frequency: 4.0 GHz
Effective epsilons [6.32143425-0.02259772j]
characteristic impedances [53.99430905+0.j]

 31%|███▏      | 5/16 [00:05<00:11,  1.02s/it]

Width: 0.4, Frequency: 5.0 GHz
Effective epsilons [6.35656532-0.02071956j]
characteristic impedances [54.06175539+0.j]

 38%|███▊      | 6/16 [00:06<00:10,  1.03s/it]

Width: 0.4, Frequency: 6.0 GHz
Effective epsilons [6.39485033-0.01919669j]
characteristic impedances [54.17387194+0.j]

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

Width: 0.4, Frequency: 7.0 GHz
Effective epsilons [6.43510452-0.01791779j]
characteristic impedances [54.32364781+0.j]

 50%|█████     | 8/16 [00:08<00:08,  1.02s/it]

Width: 0.4, Frequency: 8.0 GHz
Effective epsilons [6.47662812-0.0168281j]
characteristic impedances [54.50410592+0.j]

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

Width: 0.4, Frequency: 9.0 GHz
Effective epsilons [6.51902264-0.01589067j]
characteristic impedances [54.71005129+0.j]

 62%|██████▎   | 10/16 [00:10<00:06,  1.02s/it]

Width: 0.4, Frequency: 10.0 GHz
Effective epsilons [6.56205629-0.01507681j]
characteristic impedances [54.93822085+0.j]

 69%|██████▉   | 11/16 [00:11<00:05,  1.03s/it]

Width: 0.4, Frequency: 11.0 GHz
Effective epsilons [6.60558082-0.01436341j]
characteristic impedances [55.18691848+0.j]

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

Width: 0.4, Frequency: 12.0 GHz
Effective epsilons [6.64948635-0.01373189j]
characteristic impedances [55.45541676+0.j]

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

Width: 0.4, Frequency: 13.0 GHz
Effective epsilons [6.69367944-0.01316734j]
characteristic impedances [55.74353967+0.j]

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

Width: 0.4, Frequency: 14.0 GHz
Effective epsilons [6.73807403-0.0126579j]
characteristic impedances [56.05136351+0.j]

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

Width: 0.4, Frequency: 15.0 GHz
Effective epsilons [6.78258878-0.01219416j]
characteristic impedances [56.37902233+0.j]

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


                                               

 67%|██████▋   | 2/3 [00:20<00:11, 11.35s/it]
Width: 0.4, Frequency: 16.0 GHz
Effective epsilons [6.82714703-0.01176865j]
characteristic impedances [56.72662243+0.j]

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


  6%|▋         | 1/16 [00:05<01:29,  5.98s/it]

Width: 3, Frequency: 1.0 GHz
Effective epsilons [7.60631557-0.02172081j]
characteristic impedances [17.02975561+0.j]

 12%|█▎        | 2/16 [00:11<01:23,  5.93s/it]

Width: 3, Frequency: 2.0 GHz
Effective epsilons [7.65828786-0.01510896j]
characteristic impedances [17.00585165+0.j]

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

Width: 3, Frequency: 3.0 GHz
Effective epsilons [7.73761216-0.01294771j]
characteristic impedances [17.00364919+0.j]

 25%|██▌       | 4/16 [00:23<01:10,  5.89s/it]

Width: 3, Frequency: 4.0 GHz
Effective epsilons [7.83175705-0.01175656j]
characteristic impedances [17.03886805+0.j]

 31%|███▏      | 5/16 [00:29<01:04,  5.89s/it]

Width: 3, Frequency: 5.0 GHz
Effective epsilons [7.93109312-0.01088155j]
characteristic impedances [17.11322639+0.j]

 38%|███▊      | 6/16 [00:35<00:58,  5.88s/it]

Width: 3, Frequency: 6.0 GHz
Effective epsilons [8.0294592-0.01016006j]
characteristic impedances [17.21822157+0.j]

 44%|████▍     | 7/16 [00:41<00:52,  5.85s/it]

Width: 3, Frequency: 7.0 GHz
Effective epsilons [8.12361142-0.00954233j]
characteristic impedances [17.34304246+0.j]

 50%|█████     | 8/16 [00:47<00:46,  5.85s/it]

Width: 3, Frequency: 8.0 GHz
Effective epsilons [8.21221436-0.0090059j]
characteristic impedances [17.47883249+0.j]

 56%|█████▋    | 9/16 [00:52<00:41,  5.89s/it]

Width: 3, Frequency: 9.0 GHz
Effective epsilons [8.29498294-0.00853564j]
characteristic impedances [17.61965438+0.j]

 62%|██████▎   | 10/16 [00:58<00:35,  5.93s/it]

Width: 3, Frequency: 10.0 GHz
Effective epsilons [8.37212972-0.00811941j]
characteristic impedances [17.76200757+0.j]

 69%|██████▉   | 11/16 [01:05<00:29,  5.97s/it]

Width: 3, Frequency: 11.0 GHz
Effective epsilons [8.4440606-0.00774724j]
characteristic impedances [17.90401852+0.j]

 75%|███████▌  | 12/16 [01:11<00:23,  5.96s/it]

Width: 3, Frequency: 12.0 GHz
Effective epsilons [8.51122586-0.00741109j]
characteristic impedances [18.0447973+0.j]

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

Width: 3, Frequency: 13.0 GHz
Effective epsilons [8.57405584-0.00710455j]
characteristic impedances [18.18398139+0.j]

 88%|████████▊ | 14/16 [01:23<00:12,  6.10s/it]

Width: 3, Frequency: 14.0 GHz
Effective epsilons [8.63293844-0.00682262j]
characteristic impedances [18.32147622+0.j]

 94%|█████████▍| 15/16 [01:29<00:06,  6.01s/it]

Width: 3, Frequency: 15.0 GHz
Effective epsilons [8.6882155-0.00656142j]
characteristic impedances [18.45730358+0.j]

100%|██████████| 16/16 [01:35<00:00,  5.97s/it]


                                               

100%|██████████| 3/3 [01:58<00:00, 51.24s/it]
100%|██████████| 3/3 [01:58<00:00, 39.62s/it]
Width: 3, Frequency: 16.0 GHz
Effective epsilons [8.74018655-0.00631793j]
characteristic impedances [18.59151991+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/bbb1b73eb1f1d8dbd48f5e99a0675098a3b5d752c49dd0f72a5310fdfd44f724.png ../../_images/8d56eebd857ebc426588a90506a85c2d0170fb9879b54f94a647221722c34988.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.