Skip to content

Instantly share code, notes, and snippets.

@takunoko
Created May 31, 2020 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takunoko/ba9bd9364221f712e245f423f6726370 to your computer and use it in GitHub Desktop.
Save takunoko/ba9bd9364221f712e245f423f6726370 to your computer and use it in GitHub Desktop.
三相交流を理解するために書いたプログラム
import numpy as np
import matplotlib.pyplot as plt
scale = 1/np.sqrt(2)
x = np.arange( 0, 4 * np.pi, 0.1) # x座標を 0 から 4pi (2周期) まで 0.1 きざみで取得
y1 = np.sin(x) * scale # 正弦波
y2 = np.roll(y1, int(len(x)/3)) # 位相を120度ずらす (波形を1/3移動)
y3 = np.roll(y1, int((len(x)*2)/3)) # 位相を240度ずらす (波形を2/3移動)
###########
## グラフ1 #
###########
# 三相交流のみ
plt.subplot(5, 1, 1)
plt.hlines([0], x[0], x[-1], color="darkgray", linestyles='dashed', linewidth = 1) # 中央線
plt.plot(x, y1, label='P1', color='red') # 赤
plt.plot(x, y2, label='P2', color='blue') # 青
plt.plot(x, y3, label='P3', color='green') # 緑
plt.legend() # キャプションを表示
###########
## グラフ2 #
###########
# 2線を取り出す
plt.subplot(5, 1, 2)
plt.hlines([0], x[0], x[-1], color="darkgray", linestyles='dashed', linewidth = 1) # 中央線
plt.plot(x, y1, label='P1', color='red') # 赤
plt.plot(x, y2, label='P2', color='blue') # 青
plt.legend() # キャプションを表示
###########
## グラフ3 #
###########
# 2線の電位差
plt.subplot(5, 1, 3)
plt.hlines([0], x[0], x[-1], color="darkgray", linestyles='dashed', linewidth = 1) # 中央線
y4 = y2 - y1 # P2 - P1 => 三相から二本を取得。その差分が電圧となる
plt.plot(x, y1, label='P1', color='red', linestyle='dotted', linewidth = 1) # 赤 (- - - - )
plt.plot(x, y2, label='P2', color='blue', linestyle='dotted', linewidth = 1) # 青 (- - - - )
plt.plot(x, y4, label='P2 - P1', color='purple') # 紫 電位差
plt.legend() # キャプションを表示
###########
## グラフ4 #
###########
# 2線から半分だけ降圧したもの
GND = y4/2
plt.subplot(5, 1, 4)
plt.plot(x, y4, label='P2 - P1', color='purple') # 電位差(200v)
plt.plot(x, GND, label='(P2 - P1) / 2 := GND', color='gold') # 半分だけ降圧
plt.hlines([0], x[0], x[-1], label='0', color="lime") # 全部降圧 = 0
plt.legend() # キャプションを表示
###########
## グラフ5 #
###########
# 黄を基準とした電位差の波形
plt.subplot(5, 1, 5)
plt.hlines([0], x[0], x[-1], label='GND', color="gold", linestyles='dashed', linewidth = 1) # 基準(半部だけ降圧)
plt.plot(x, y4 - GND, label='(P2 - P1) - GND', color='purple') # 降圧しない
plt.plot(x, -GND, label='GND - 0', color='lime') # 全部降圧
plt.legend() # キャプションを表示
plt.show() # グラフを表示
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment