使用python模拟三相电压在一个周期内进行矢量合成的过程;
结合欧拉公式:
注:图片都是选自网络上的,不是我做的,以此说明;
python的代码如下:
'''
author : sunyan
'''
from matplotlib import pyplot as plt
import numpy as np
import math
class SVPWM_sim:
def __init__(self):
plt.figure(figsize = (10, 10))
self.fre_to_time = 5
def three_phase_to_two(self):
for thate in range(0, 361, self.fre_to_time):
plt.cla() # 清除之前画的图
ua = math.cos(math.radians(thate))
ub = math.cos(math.radians(thate - 120))
uc = math.cos(math.radians(thate + 120))
xa0 = 0
ya0 = 0
xa1 = ua
ya1 = 0
xb0 = xa1
yb0 = ya1
xb1 = xb0 + ub * math.cos(math.radians(120))
yb1 = yb0 + ub * math.sin(math.radians(120))
xc0 = xb1
yc0 = yb1
xc1 = xc0 + uc * math.cos(math.radians(240))
yc1 = yc0 + uc * math.sin(math.radians(240))
xu0 = 0
yu0 = 0
xu1 = (3 / 2) * math.cos(math.radians(thate))
yu1 = (3 / 2) * math.sin(math.radians(thate))
plt.annotate('', xy = (xa1, ya1), xytext = (xa0, ya0), \
arrowprops = dict(color = 'blue', width = 1))
plt.annotate('', xy = (xb1, yb1), xytext = (xb0, yb0), \
arrowprops = dict(color = 'red', width = 1))
plt.annotate('', xy = (xc1, yc1), xytext = (xc0, yc0), \
arrowprops = dict(color = 'yellow', width = 1))
plt.annotate('', xy = (xu1, yu1), xytext = (xu0, yu0), \
arrowprops = dict(color = 'black', width = 1))
plt.xlim(-2, 2) # 设置x轴范围
plt.ylim(-2, 2) # 设置y轴范围
plt.grid(True)
plt.pause(0.01 * self.fre_to_time)
plt.show()