学习SVPWM过程中使用python做一些模拟与仿真(一)

使用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()

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值