方形導波管のモード関数¶

In [1]:
import numpy as np  
import matplotlib.pyplot as plt
import scienceplots
plt.style.use(['science', 'notebook'])

カットオフ波数,カットオフ波長,カットオフ周波数¶

In [2]:
def kc_mn_rw(m,n, a,b):
    CCC = 299.79
    kc = np.sqrt((m*np.pi/a)**2+(n*np.pi/b)**2)
    wlc = 2*np.pi/kc
    fc = CCC/wlc
    return kc, wlc, fc
In [3]:
def eps_m(m):
    if m==0:
        em = 1.0
    else:
        em = 2.0
    return em

モード関数¶

In [4]:
# imode = 1 (TE), -1 (TM)
def rectangular_waveguide_mode_eh(x,y, a,b,imode,m,n): # 方形導波管のモード関数
    kc, wlc, fc = kc_mn_rw(m,n, a,b)
    kx = m*np.pi/a
    ky = n*np.pi/b
    em = eps_m(m)
    en = eps_m(n)
    amn = np.sqrt(em*en/a/b)/kc
#    print('amn,kx,ky=',amn,kx,ky)
    kxx = kx*x
    sx, cx = np.sin(kxx), np.cos(kxx)
    kyy = ky*y
    sy, cy = np.sin(kyy), np.cos(kyy)
    if imode==1: # TE
        e_x, e_y = ky*cx*sy, -kx*sx*cy
    elif imode==-1: # TM
        e_x, e_y = -kx*cx*sy, -ky*sx*cy
    e_x, e_y = amn*e_x, amn*e_y
    h_x, h_y = -e_y, e_x
    return e_x, e_y, h_x, h_y

標準導波管の周波数帯域と方形断面寸法(辞書)¶

In [5]:
# 各キー: バンド名,値: (a[mm], b[mm], f_min[GHz], f_max[GHz])
waveguide_specs = {
    'L':  (165.10, 82.55, 1.14, 1.73),
    'S':  (72.14, 34.04, 2.60, 3.95),   # WRJ-3
    'C':  (47.55, 22.149, 3.94, 5.99),  # WRJ-5
    'WRJ-9': (28.50, 12.60, 7.05, 10.0), # WRJ-9
    'X':  (22.90, 10.20, 8.20, 12.50),  # WRJ-10
    'Ku': (15.799, 7.899, 11.9, 18.0),  # WRJ-15
    'K':  (10.668, 4.318, 17.6, 26.7),  # WRJ-24
    'Ka': (7.112, 3.556, 26.4, 40.1),   # WRJ-34
    'Q':  (5.590, 2.845, 33.0, 50.1),   # WRJ-40
}
band = 'X' # 選択するバンド
if band not in waveguide_specs:
    print(f"指定したバンド {band} は未定義のため,デフォルトのKu帯に切り替えます.")
    band = 'Ku'  # ← band を上書きして揃える
a, b, f_min, f_max = waveguide_specs.get(band)
band, a, b, f_min, f_max
Out[5]:
('X', 22.9, 10.2, 8.2, 12.5)

モード¶

In [6]:
mode_type = 'TE'   # 'TE' か 'TM' を選択
m, n = 1, 0        # モードの次数 m, n (>=0) 両方非零

xy座標系のメッシュグリッドの作成¶

In [7]:
x_min, x_max, n_x = 0.0, a, 61
y_min, y_max, n_y = 0.0, b, 31
x = np.linspace(x_min, x_max, n_x)
y = np.linspace(y_min, y_max, n_y)
xx, yy = np.meshgrid(x,y, indexing='xy') # xy座標の並び (デフォルト)

フィールド計算¶

In [8]:
if mode_type.upper() == 'TE':
    e_x, e_y, h_x, h_y = rectangular_waveguide_mode_eh(xx,yy, a,b,1,m,n) # 方形導波管のTEモード関数
elif mode_type.upper() == 'TM':
    e_x, e_y, h_x, h_y = rectangular_waveguide_mode_eh(xx,yy, a,b,-1,m,n) # 方形導波管のTMモード関数

振幅の最大値で正規化¶

In [9]:
e_amp = np.sqrt(np.abs(e_x)**2+np.abs(e_y)**2)
h_amp = np.sqrt(np.abs(h_x)**2+np.abs(h_y)**2)
e_x = e_x / e_amp.max()
e_y = e_y / e_amp.max()
h_x = h_x / h_amp.max()
h_y = h_y / h_amp.max()
e_amp = np.sqrt(np.abs(e_x)**2+np.abs(e_y)**2)
h_amp = np.sqrt(np.abs(h_x)**2+np.abs(h_y)**2)

電界のモード関数の$x$成分,$y$成分¶

In [10]:
# Diverging colormaps
Diverging_cmaps = ['PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',\
                   'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr',\
                   'seismic']#0-11
In [11]:
fig, ax = plt.subplots(1,2,figsize=(12, 4)) # グラフ領域の作成
v1 = np.linspace(-1.0, 1.0, 11)
v2 = np.linspace(-1.0, 1.0, 21)
mycolor = Diverging_cmaps[1]

CS1 = ax[0].contour(xx, yy, e_x, levels=v1, linewidths=0.4)# colors='gray'
ax[0].clabel(CS1, fmt='%1.1f', inline=1, fontsize=9) # 等高線の値を表示
CS1 = ax[0].contourf(xx, yy, e_x, levels=v2, cmap=mycolor)
cbar = fig.colorbar(CS1, ax=ax[0], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$e_x$")

CS2 = ax[1].contour(xx, yy, e_y, levels=v1, linewidths=0.4) # 等高線表示
ax[1].clabel(CS2, fmt='%1.1f', inline=1, fontsize=9) # 等高線の値を表示
CS2 = ax[1].contourf(xx, yy, e_y, levels=v2, cmap=mycolor)
cbar = fig.colorbar(CS2, ax=ax[1], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$e_y$")

[i.axis('scaled') for i in ax]
[i.set_xlabel("$x$ [mm]") for i in ax] # 横軸のラベル設定
[i.set_ylabel("$y$ [mm]") for i in ax] # 縦軸のラベル設定

fig.tight_layout()
plt.savefig(f"{mode_type.lower()}_{m}{n}_e.pdf")
plt.show()
No description has been provided for this image
In [12]:
mode_type.lower(),mode_type.upper()
Out[12]:
('te', 'TE')

磁界のモード関数の$x$成分,$y$成分¶

In [13]:
fig, ax = plt.subplots(1,2,figsize=(12, 4)) # グラフ領域の作成
v1 = np.linspace(-1.0, 1.0, 11)
v2 = np.linspace(-1.0, 1.0, 21)
mycolor = Diverging_cmaps[9]

CS1 = ax[0].contour(xx, yy, h_x, levels=v1, linewidths=0.4)# colors='gray'
ax[0].clabel(CS1, fmt='%1.1f', inline=1, fontsize=9) # 等高線の値を表示
CS1 = ax[0].contourf(xx, yy, h_x, levels=v2, cmap=mycolor)
cbar = fig.colorbar(CS1, ax=ax[0], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$h_x$")

CS2 = ax[1].contour(xx, yy, h_y, levels=v1, linewidths=0.4) # 等高線表示
ax[1].clabel(CS2, fmt='%1.1f', inline=1, fontsize=9) # 等高線の値を表示
CS2 = ax[1].contourf(xx, yy, h_y, levels=v2, cmap=mycolor)
cbar = fig.colorbar(CS2, ax=ax[1], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$h_y$")

[i.axis('scaled') for i in ax]
[i.set_xlabel("$x$ [mm]") for i in ax] # 横軸のラベル設定
[i.set_ylabel("$y$ [mm]") for i in ax] # 縦軸のラベル設定

fig.tight_layout()
plt.savefig(f"{mode_type.lower()}_{m}{n}_h.pdf")
plt.show()
No description has been provided for this image

モード関数の電界,磁界の力線¶

In [14]:
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(12, 4)) # グラフ領域の作成,nrows=縦に並べる数,ncols=横に並べる数

strm = ax[0].streamplot(xx, yy, e_x, e_y, color=e_amp, density=0.7, linewidth=3*e_amp, cmap="rainbow")
cbar = plt.colorbar(strm.lines, ax=ax[0], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$|e|$")

strm = ax[1].streamplot(xx, yy, h_x, h_y, color=h_amp, density=0.7, linewidth=3*h_amp, cmap="rainbow")
cbar = plt.colorbar(strm.lines, ax=ax[1], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$|h|$")

[i.axis('scaled') for i in ax]
[i.set_xlabel("$x$ [mm]") for i in ax] # 横軸のラベル設定
[i.set_ylabel("$y$ [mm]") for i in ax] # 縦軸のラベル設定
[i.set_xlim([0, a]) for i in ax] # 横軸の範囲指定
[i.set_ylim([0, b]) for i in ax] # 縦軸の範囲指定

fig.tight_layout()
plt.savefig(f"{mode_type.lower()}_{m}{n}_eh_streamplot.pdf")
plt.show()
No description has been provided for this image
In [15]:
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(12, 4)) # グラフ領域の作成,nrows=縦に並べる数,ncols=横に並べる数

CS1 = ax[0].contour(xx, yy, e_amp, 5, linewidths=0.4) # colors='gray'
ax[0].clabel(CS1,fmt='%1.1f', inline=1, fontsize=10) # 等高線の値を表示
strm = ax[0].streamplot(xx, yy, e_x, e_y, density=0.7, linewidth=3*e_amp, color='orange')
CS1 = ax[0].contourf(xx, yy, e_amp, 10, cmap="Blues")
cbar = plt.colorbar(strm.lines, ax=ax[0], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$|e|$")

CS2 = ax[1].contour(xx, yy, h_amp, 5, linewidths=0.4) # colors='gray'
ax[1].clabel(CS2,fmt='%1.1f', inline=1, fontsize=10) # 等高線の値を表示
strm = ax[1].streamplot(xx, yy, h_x, h_y, density=0.7, linewidth=3*e_amp, color='orange')
CS2 = ax[1].contourf(xx, yy, h_amp, 10, cmap="Blues")
cbar = plt.colorbar(strm.lines, ax=ax[1], pad=0.1, shrink=0.455, orientation="vertical")
cbar.set_label(r"$|h|$")

[i.axis('scaled') for i in ax]
[i.set_xlabel("$x$ [mm]") for i in ax] # 横軸のラベル設定
[i.set_ylabel("$y$ [mm]") for i in ax] # 縦軸のラベル設定
[i.set_xlim([0, a]) for i in ax] # 横軸の範囲指定
[i.set_ylim([0, b]) for i in ax] # 縦軸の範囲指定

fig.tight_layout()
plt.savefig(f"{mode_type.lower()}_{m}{n}_eh_streamplot2.pdf")
plt.show()
No description has been provided for this image
In [ ]: