vdPauw.py ダウンロード/コピー
vdPauw.py
vdPauw.py
1"""
2概要:
3 ファンデルパウ法の補正係数を計算し、プロットするスクリプトです。
4
5詳細説明:
6 vdp_factor関数を用いてファンデルパウ補正係数fを計算し、抵抗比rに対する依存性をmatplotlibを用いてグラフ化します。
7
8関連リンク:
9 vdPauw_usage
10"""
11
12import numpy as np
13import matplotlib.pyplot as plt
14from scipy.optimize import brentq
15
16def vdp_factor(r):
17 """
18 概要:
19 ファンデルパウ補正係数を計算します。
20
21 詳細説明:
22 入力された抵抗比 r = Rab,cd / Rad,bc に対して、exp(-x*r) + exp(-x) = 1 を満たす x を求め、
23 補正係数 f = 2 * ln(2) / (x * (r + 1)) を計算して返します。
24
25 引数:
26 :param r: 抵抗比 Rab,cd / Rad,bc を指定します。
27 :type r: float
28
29 戻り値:
30 :returns: 計算されたファンデルパウ補正係数 f を返します。
31 :rtype: float
32 """
33
34 # exp(-x*r)+exp(-x)=1 を解く
35 func = lambda x: np.exp(-x*r) + np.exp(-x) - 1
36
37 x = brentq(func, 1e-10, 100)
38
39 # x = pi*R_AD,BC/Rs, Rs = pi/ln(2)*(R_AB,CD+R_AD,BC)/2*f
40 # よって f = 2*ln(2) / (x*(r+1))
41 f = 2 * np.log(2) / (x * (r + 1))
42 return f
43
44
45# 対数スケールで広く調べる
46r_values = np.logspace(-2, 2, 500)
47
48f_values = np.array([vdp_factor(r) for r in r_values])
49
50plt.figure(figsize=(8,6))
51plt.semilogx(r_values, f_values, lw=2)
52
53plt.xlabel(r"$R_{AB,CD}/R_{AD,BC}$", fontsize=14)
54plt.ylabel("Correction factor f", fontsize=14)
55plt.title("van der Pauw Correction Factor", fontsize=16)
56
57plt.grid(True, which="both", alpha=0.3)
58plt.ylim(0, 1.05)
59
60plt.tight_layout()
61plt.show()