方形導波管

モジュールのインポート

import numpy as np
import matplotlib.pyplot as plt
import scienceplots
#Warning : As of version 2.0.0, you need to add import scienceplots before setting the style (plt.style.use('science')).
plt.style.use(['science', 'notebook'])

ユーザ関数

方形導波管モードの遮断波数,遮断波長,遮断周波数は,
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
方形導波管モードの位相定数,減衰定数は,
def beta_alpha(sk, kc): # 位相定数,減衰定数
    beta, wl_g, alpha = 0.0, 0.0, 0.0
    kz2 = sk**2-kc**2
    beta = np.where(sk>kc, np.sqrt(kz2), 0.0)
    alpha = np.where(sk<=kc, np.sqrt(-kz2), 0.0)
    return beta, alpha
方形導波管のモード関数の計算をするため,準備として,
def eps_m(m):
    if m==0:
        em = 1.0
    else:
        em = 2.0
    return em
方形導波管のモード関数の電界,磁界の $x$,$y$ 成分は,
# 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

方形導波管のモードの遮断特性

標準導波管の周波数帯域 [GHz]と方形断面の寸法 $a$,$b$ [mm]は,
band = 'X'
if band == 'L':
    a, b, f_min, f_max = 165.10, 82.55, 1.14, 1.73
elif band == 'S':
    a, b, f_min, f_max = 72.14, 34.04, 2.60, 3.95 # WRJ-3
elif band == 'C':
    a, b, f_min, f_max = 47.55, 22.149, 3.94, 5.99 # WRJ-5
elif band == 'X':
    a, b, f_min, f_max = 22.90, 10.20, 8.20, 12.50 # WRJ-10
elif band == 'Ku':
    a, b, f_min, f_max = 15.799, 7.899, 11.9, 18.0 # WRJ-15
elif band == 'K':
    a, b, f_min, f_max = 10.668, 4.318, 17.6, 26.7 # WRJ-24
elif band == 'Ka':
    a, b, f_min, f_max = 7.112, 3.556, 26.4, 40.1 # WRJ-34
elif band == 'Q':
    a, b, f_min, f_max =  5.590, 2.845, 33.0, 50.1 # WRJ-40
else:
    a, b, f_min, f_max = 28.50, 12.60, 7.05, 10.0 # WRJ-9
#    a, b, f_min, f_max = 8.636, 4.318, 21.7, 33.7
band, a, b, f_min, f_max
('X', 22.9, 10.2, 8.2, 12.5)
モードの次数の範囲を指定して,遮断特性を計算すると,
total_mode, i_max, j_max = 15, 4, 4
dict1 = {}
icp, icm = 1, -1
for i in range(i_max):
    for j in range(j_max):
        if i+j!=0:
            kc, wlc, fc = kc_mn_rw(i,j, a,b)
            st = 'TE '+ str(i) +',' + str(j)
            dict1[st] = [kc,icp,i,j]
        if i*j!=0:
            st = 'TM '+ str(i) +',' + str(j)
            dict1[st] = [kc,icm,i,j]
dict1
{'TE 0,1': [0.3079992797637052, 1, 0, 1],
 'TE 0,2': [0.6159985595274104, 1, 0, 2],
 'TE 0,3': [0.9239978392911157, 1, 0, 3],
 'TE 1,0': [0.13718745212182504, 1, 1, 0],
 'TE 1,1': [0.3371705108022337, 1, 1, 1],
 'TM 1,1': [0.3371705108022337, -1, 1, 1],
 'TE 1,2': [0.6310900271431348, 1, 1, 2],
 'TM 1,2': [0.6310900271431348, -1, 1, 2],
 'TE 1,3': [0.9341265460494785, 1, 1, 3],
 'TM 1,3': [0.9341265460494785, -1, 1, 3],
 'TE 2,0': [0.2743749042436501, 1, 2, 0],
 'TE 2,1': [0.4124865384635883, 1, 2, 1],
 'TM 2,1': [0.4124865384635883, -1, 2, 1],
 'TE 2,2': [0.6743410216044674, 1, 2, 2],
 'TM 2,2': [0.6743410216044674, -1, 2, 2],
 'TE 2,3': [0.9638742631138993, 1, 2, 3],
 'TM 2,3': [0.9638742631138993, -1, 2, 3],
 'TE 3,0': [0.4115623563654751, 1, 3, 0],
 'TE 3,1': [0.5140497344732935, 1, 3, 1],
 'TM 3,1': [0.5140497344732935, -1, 3, 1],
 'TE 3,2': [0.740835878259785, 1, 3, 2],
 'TM 3,2': [0.740835878259785, -1, 3, 2],
 'TE 3,3': [1.011511532406701, 1, 3, 3],
 'TM 3,3': [1.011511532406701, -1, 3, 3]}
遮断波数 $k_c$ の小さい順にソートして,
dict2_list = sorted(dict1.items(), key=lambda i: i[1][0])
#dict2 = dict(dict2_list) # 辞書型に変換
#dict2 # 辞書
dict2_list # リスト
[('TE 1,0', [0.13718745212182504, 1, 1, 0]),
 ('TE 2,0', [0.2743749042436501, 1, 2, 0]),
 ('TE 0,1', [0.3079992797637052, 1, 0, 1]),
 ('TE 1,1', [0.3371705108022337, 1, 1, 1]),
 ('TM 1,1', [0.3371705108022337, -1, 1, 1]),
 ('TE 3,0', [0.4115623563654751, 1, 3, 0]),
 ('TE 2,1', [0.4124865384635883, 1, 2, 1]),
 ('TM 2,1', [0.4124865384635883, -1, 2, 1]),
 ('TE 3,1', [0.5140497344732935, 1, 3, 1]),
 ('TM 3,1', [0.5140497344732935, -1, 3, 1]),
 ('TE 0,2', [0.6159985595274104, 1, 0, 2]),
 ('TE 1,2', [0.6310900271431348, 1, 1, 2]),
 ('TM 1,2', [0.6310900271431348, -1, 1, 2]),
 ('TE 2,2', [0.6743410216044674, 1, 2, 2]),
 ('TM 2,2', [0.6743410216044674, -1, 2, 2]),
 ('TE 3,2', [0.740835878259785, 1, 3, 2]),
 ('TM 3,2', [0.740835878259785, -1, 3, 2]),
 ('TE 0,3', [0.9239978392911157, 1, 0, 3]),
 ('TE 1,3', [0.9341265460494785, 1, 1, 3]),
 ('TM 1,3', [0.9341265460494785, -1, 1, 3]),
 ('TE 2,3', [0.9638742631138993, 1, 2, 3]),
 ('TM 2,3', [0.9638742631138993, -1, 2, 3]),
 ('TE 3,3', [1.011511532406701, 1, 3, 3]),
 ('TM 3,3', [1.011511532406701, -1, 3, 3])]
変数毎の配列に入れて,値を確認すると,
nno = np.arange(1,total_mode+1)
mode = np.empty(total_mode, dtype=object)
imode = np.empty(total_mode, dtype = np.int8)
m = np.empty(total_mode, dtype = np.int8)
n = np.empty(total_mode, dtype = np.int8)
for i in range(total_mode):
    mode[i] = dict2_list[i][0]
    imode[i] = dict2_list[i][1][1]
    m[i] = dict2_list[i][1][2]
    n[i] = dict2_list[i][1][3]
kc, wlc, fc = kc_mn_rw(m,n, a,b)
total_mode, nno, imode,  m, n, kc, wlc, fc
(15,
 array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15]),
 array(['TE 1,0', 'TE 2,0', 'TE 0,1', 'TE 1,1', 'TM 1,1', 'TE 3,0',
        'TE 2,1', 'TM 2,1', 'TE 3,1', 'TM 3,1', 'TE 0,2', 'TE 1,2',
        'TM 1,2', 'TE 2,2', 'TM 2,2'], dtype=object),
 array([ 1,  1,  1,  1, -1,  1,  1, -1,  1, -1,  1,  1, -1,  1, -1],
       dtype=int8),
 array([1, 2, 0, 1, 1, 3, 2, 2, 3, 3, 0, 1, 1, 2, 2], dtype=int8),
 array([0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2], dtype=int8),
 array([0.13718745, 0.2743749 , 0.30799928, 0.33717051, 0.33717051,
        0.41156236, 0.41248654, 0.41248654, 0.51404973, 0.51404973,
        0.61599856, 0.63109003, 0.63109003, 0.67434102, 0.67434102]),
 array([45.8       , 22.9       , 20.4       , 18.63503808, 18.63503808,
        15.26666667, 15.23246148, 15.23246148, 12.22291324, 12.22291324,
        10.2       ,  9.95608398,  9.95608398,  9.31751904,  9.31751904]),
 array([ 6.54563319, 13.09126638, 14.69558824, 16.08743694, 16.08743694,
        19.63689956, 19.68099512, 19.68099512, 24.52688602, 24.52688602,
        29.39117647, 30.11123658, 30.11123658, 32.17487389, 32.17487389]))
出力フォーマットを指定して,
print(f"{'no':>3s}:",f"{'mode':>6s}",f" {'kc':>11s}",f"{'wlc [mm]':>11s}",f"{'fc [GHz]':>11s}")
for i in range(total_mode):
    print(f"{nno[i]:3d}:",f"{mode[i]:7s}",f"{kc[i]:11.7f}",f"{wlc[i]:11.4f}",f"{fc[i]:11.4f}")
no:   mode           kc    wlc [mm]    fc [GHz]
 1: TE 1,0    0.1371875     45.8000      6.5456
 2: TE 2,0    0.2743749     22.9000     13.0913
 3: TE 0,1    0.3079993     20.4000     14.6956
 4: TE 1,1    0.3371705     18.6350     16.0874
 5: TM 1,1    0.3371705     18.6350     16.0874
 6: TE 3,0    0.4115624     15.2667     19.6369
 7: TE 2,1    0.4124865     15.2325     19.6810
 8: TM 2,1    0.4124865     15.2325     19.6810
 9: TE 3,1    0.5140497     12.2229     24.5269
10: TM 3,1    0.5140497     12.2229     24.5269
11: TE 0,2    0.6159986     10.2000     29.3912
12: TE 1,2    0.6310900      9.9561     30.1112
13: TM 1,2    0.6310900      9.9561     30.1112
14: TE 2,2    0.6743410      9.3175     32.1749
15: TM 2,2    0.6743410      9.3175     32.1749
出力する遮断周波数の上限を決めて,
f_stop = 18.0
ffc = fc[fc<f_stop]
n_mode = len(ffc)
ffc, n_mode
(array([ 6.54563319, 13.09126638, 14.69558824, 16.08743694, 16.08743694]), 5)
参考まで,ラムダ関数の使い方は,
l = list(map(lambda x: x**2, range(10))) # ラムダ関数の使い方
l
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
ラムダ関数を使えば,周波数サンプル点を不等間隔に設定でき,
i = 0
nf = 31
l2 = np.array(list(map(lambda x: ffc[i]+(f_stop-ffc[i])*(x/(nf-1))**4, range(nf))))
l2
array([ 6.54563319,  6.54564733,  6.54585945,  6.54677862,  6.54925333,
        6.55447143,  6.56396017,  6.57958619,  6.60355552,  6.63841356,
        6.68704512,  6.7526744 ,  6.83886498,  6.94951982,  7.08888128,
        7.26153111,  7.47239045,  7.72671982,  8.03011913,  8.38852768,
        8.80822416,  9.29582666,  9.85829263, 10.50291894, 11.23734183,
       12.06953694, 13.00781927, 14.06084325, 15.23760268, 16.54743074,
       18.        ])
同じことを,リスト内包表記を使っても行え,
l3 = np.array([ffc[i]+(f_stop-ffc[i])*(j/(nf-1))**4 for j in range(nf)]) # リスト内包表記   
l3
array([ 6.54563319,  6.54564733,  6.54585945,  6.54677862,  6.54925333,
        6.55447143,  6.56396017,  6.57958619,  6.60355552,  6.63841356,
        6.68704512,  6.7526744 ,  6.83886498,  6.94951982,  7.08888128,
        7.26153111,  7.47239045,  7.72671982,  8.03011913,  8.38852768,
        8.80822416,  9.29582666,  9.85829263, 10.50291894, 11.23734183,
       12.06953694, 13.00781927, 14.06084325, 15.23760268, 16.54743074,
       18.        ])
位相定数の周波数特性を求めると,
CCC = 299.79
fff = np.empty((n_mode,nf))
beta_f = np.empty((n_mode,nf))
alpha_f = np.empty((n_mode,nf))
for i in range(n_mode):
        ff = np.array([ffc[i]+(f_stop-ffc[i])*(j/(nf-1))**4 for j in range(nf)])# リスト内包表記   
        fff[i,:] = ff
        wwl = CCC/ff # 自由空間波長[mm]
        ssk = 2*np.pi/wwl # 自由空間波数
        beta_f[i,:] = np.sqrt(ssk**2-kc[i]**2)
fff
array([[ 6.54563319,  6.54564733,  6.54585945,  6.54677862,  6.54925333,
         6.55447143,  6.56396017,  6.57958619,  6.60355552,  6.63841356,
         6.68704512,  6.7526744 ,  6.83886498,  6.94951982,  7.08888128,
         7.26153111,  7.47239045,  7.72671982,  8.03011913,  8.38852768,
         8.80822416,  9.29582666,  9.85829263, 10.50291894, 11.23734183,
        12.06953694, 13.00781927, 14.06084325, 15.23760268, 16.54743074,
        18.        ],
       [13.09126638, 13.09127244, 13.09136334, 13.09175725, 13.09281778,
        13.09505398, 13.09912035, 13.10581683, 13.11608881, 13.13102712,
        13.15186803, 13.17999325, 13.21692996, 13.26435075, 13.32407367,
        13.39806223, 13.48842535, 13.59741741, 13.72743825, 13.88103313,
        14.06089277, 14.26985332, 14.51089638, 14.787149  , 15.10188367,
        15.45851832, 15.86061632, 16.31188651, 16.81618313, 17.37750591,
        18.        ],
       [14.69558824, 14.69559231, 14.69565351, 14.69591868, 14.69663259,
        14.69813794, 14.70087529, 14.70538316, 14.71229795, 14.72235397,
        14.73638344, 14.7553165 , 14.78018118, 14.81210343, 14.8523071 ,
        14.90211397, 14.9629437 , 15.03631388, 15.12384   , 15.22723545,
        15.34831155, 15.4889775 , 15.65124044, 15.83720539, 16.04907529,
        16.28915101, 16.55983129, 16.86361279, 17.20309011, 17.58095571,
        18.        ],
       [16.08743694, 16.0874393 , 16.08747472, 16.0876282 , 16.08804141,
        16.08891269, 16.09049704, 16.09310616, 16.09710837, 16.1029287 ,
        16.11104883, 16.12200711, 16.13639856, 16.15487486, 16.17814438,
        16.20697213, 16.24217982, 16.28464581, 16.33530512, 16.39514945,
        16.46522718, 16.54664333, 16.64055962, 16.74819442, 16.87082277,
        17.00977638, 17.16644363, 17.34226956, 17.5387559 , 17.75746103,
        18.        ],
       [16.08743694, 16.0874393 , 16.08747472, 16.0876282 , 16.08804141,
        16.08891269, 16.09049704, 16.09310616, 16.09710837, 16.1029287 ,
        16.11104883, 16.12200711, 16.13639856, 16.15487486, 16.17814438,
        16.20697213, 16.24217982, 16.28464581, 16.33530512, 16.39514945,
        16.46522718, 16.54664333, 16.64055962, 16.74819442, 16.87082277,
        17.00977638, 17.16644363, 17.34226956, 17.5387559 , 17.75746103,
        18.        ]])
プロットして,
fig = plt.figure() # グラフ領域の作成
plt.grid(color = "gray", linestyle="--")
plt.minorticks_on() # #補助目盛りをつける
plt.xlabel(r"$f$ [GHz]") # x軸のラベル設定
plt.ylabel(r"$\beta/k_0$") # y軸のラベル設定
plt.xlim(5, 18.0) # y軸範囲の設定
plt.ylim(0, 1.0) # y軸範囲の設定
plt.plot(fff[0,:], beta_f[0,:]/ssk, label=mode[0])
plt.plot(fff[1,:], beta_f[1,:]/ssk, label=mode[1])
plt.plot(fff[2,:], beta_f[2,:]/ssk, label=mode[2])
plt.plot(fff[3,:], beta_f[3,:]/ssk, label=mode[3])
plt.plot(fff[4,:], beta_f[4,:]/ssk, label=mode[4])
plt.legend(ncol=1, loc='upper left', fancybox=False, frameon=True)
fig.savefig('p3_tlt_s12_1.pdf')

方形導波管のモード関数

基本モードを指定して,
no = 0 # 遮断周波数の低い順(0から)
mode[no], imode[no], m[no], n[no]
('TE 1,0', 1, 1, 0)
if imode[no]==1:
    ismode='TE'
else:
    ismode="TM"
ismode
'TE'
遮断波数 $k_c$,遮断波長 $\lambda_c$ [mm],遮断周波数 $f_c$ [GHz]は,
kc, wlc, fc = kc_mn_rw(m[no],n[no], a,b)
kc, wlc, fc
(0.13718745212182504, 45.8, 6.545633187772927)
計算する周波数 $f$ [GHz]を与え,自由空間波長 $\lambda$ [mm],波数 $k$ は,
CCC = 299.79
f = 10.0 # 周波数[GHz]
wl = CCC/f # 自由空間波長[mm]
sk = 2*np.pi/wl # 自由空間波数
wl, sk
(29.979000000000003, 0.20958622059373513)
2次元の作図のためにのメッシュグリッドを作成して,
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座標の並び (デフォルト)
モード関数の2次元分布を計算して,
e_x, e_y, h_x, h_y = rectangular_waveguide_mode_eh(xx, yy, a,b,imode[no],m[no],n[no])
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_amp.max(), h_amp.max()
(0.0925331125372525, 0.0925331125372525)
ピーク値で正規化して,
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)
e_amp.max(), h_amp.max()
(1.0, 1.0)
カラーマップ名をリストに予め設定して,
# Diverging colormaps
Diverging_cmaps = ['PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu',\
                   'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr',\
                   'seismic'] # 0-11
電界の $x$ 成分 $e_x$,$y$ 成分 $e_y$は,
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()
fig.savefig('p3_tlt_s12_'+ismode+str(m[no])+str(n[no])+'_'+str(nno[no])+'R_exy.pdf')
plt.show()

磁界の $x$ 成分 $h_x$,$y$ 成分 $h_y$は,
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()
fig.savefig('p3_tlt_s12_'+ismode+str(m[no])+str(n[no])+'_'+str(nno[no])+'R_hxy.pdf')
plt.show()

電界および磁界の力線を描くと,
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()
fig.savefig('p3_tlt_s12_'+ismode+str(m[no])+str(n[no])+'_'+str(nno[no])+'R_streamplot.pdf')
plt.show()


電界および磁界の振幅を等高線図として,力線に重ね合わせて描くと,
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()
fig.savefig('p3_tlt_s12_'+ismode+str(m[no])+str(n[no])+'_'+str(nno[no])+'R_streamplot2.pdf')
plt.show()