代码拉取完成,页面将自动刷新
import numpy as np
from scipy import integrate
import equations as eqs
import curve_funcs as cfs
import plot as plot
import pprint
'''
这个类是ANPC-1三电平的拓扑计算结果和曲线
'''
class ANPC_OneThreeLevelCalculator:
def __init__(self, input_param, inter_param):
"""
input_param: 字典, 界面的应用工况输入参数
inter_param: 字典, 输入的中间参数
"""
# 传入的应用工况输入参数
self.input_param = input_param
self.fout = self.input_param['fout']
self.PF = self.input_param['PF']
self.Vout = self.input_param['Vout']
self.Vdc = self.input_param['Vdc']
self.I_rms = self.input_param['I_rms']
self.Rgon_T1 = self.input_param['Rgon_T1']
self.Rgoff_T1 = self.input_param['Rgoff_T1']
self.Rgon_T2 = self.input_param['Rgon_T2']
self.Rgoff_T2 = self.input_param['Rgoff_T2']
self.Rgon_T5 = self.input_param['Rgon_T5']
self.Rgoff_T5 = self.input_param['Rgoff_T5']
self.fsw = self.input_param['fsw']
self.Th = self.input_param['Th']
# 传入的中间参数, 积分变量为t
self.inter_param = inter_param
self.Vref = self.inter_param['Vref']
self.Rgon_T1_test = self.inter_param['Rgon_T1_test']
self.Rgoff_T1_test = self.inter_param['Rgoff_T1_test']
self.Rgon_T2_test = self.inter_param['Rgon_T2_test']
self.Rgoff_T2_test = self.inter_param['Rgoff_T2_test']
self.Rgon_T5_test = self.inter_param['Rgon_T5_test']
self.Rgoff_T5_test = self.inter_param['Rgoff_T5_test']
# 需要计算的中间参数
self.w = 2.0 * np.pi * self.fout
# self.theta = self.w * self.inter_param['t']
# t = 100
# self.theta = self.w * t
self.m = self.Vout * 1.414 * 2.0 / self.Vdc
self.phi = np.arccos(self.PF)
# self.IC_theta = self.I_rms * 1.414 * np.sin(self.theta)
self.Vfactor_diode = np.power((0.5 * self.Vdc / self.Vref), 0.6)
self.Vfactor_IGBT = np.power((0.5 * self.Vdc / self.Vref), 1.0)
# 计算开关电阻参数
def cal_R_param(self, coefs):
"""
coefs: 字典,存储了T1,T2, D1, D2, D5, T5的开关电阻计算公式的系数,形如{'T1_on':coef, 'T1_off':coef, 'T2_on':coef, 'T2_off':coef, 'D5_rec':coef, 'D7_rec':coef,}
coef: 列表,形如[a, b, c, d],对应每个管子的四个系数
"""
self.T1_on_coef = coefs['T1_on']
self.T1_off_coef = coefs['T1_off']
self.T2_on_coef = coefs['T2_on']
self.T2_off_coef = coefs['T2_off']
self.D1_rec_coef = coefs['D1_rec']
self.D5_rec_coef = coefs['D5_rec']
self.T5_on_coef = coefs['T5_on']
self.T5_off_coef = coefs['T5_off']
# 计算得到电阻参数 # TODO 公式不一样
self.Rgon_factor_T1 = eqs.equ_R_param(self.Rgon_T1, self.Rgon_T1_test, self.T1_on_coef)
self.Rgoff_factor_T1 = eqs.equ_R_param(self.Rgoff_T1, self.Rgoff_T1_test, self.T1_off_coef)
self.Rgon_factor_T2 = eqs.equ_R_param(self.Rgon_T2, self.Rgon_T2_test, self.T2_on_coef)
self.Rgoff_factor_T2 = eqs.equ_R_param(self.Rgoff_T2, self.Rgoff_T2_test, self.T2_off_coef)
self.Rgrec_factor_D1 = eqs.equ_R_param(self.Rgon_T2, self.Rgon_T2_test, self.D1_rec_coef)
self.Rgrec_factor_D5 = eqs.equ_R_param(self.Rgon_T1, self.Rgon_T1_test, self.D5_rec_coef)
self.Rgon_factor_T5 = eqs.equ_R_param(self.Rgon_T5, self.Rgon_T5_test, self.T5_on_coef) # TODO 没给出公式
self.Rgoff_factor_T5 = eqs.equ_R_param(self.Rgoff_T5, self.Rgoff_T5_test, self.T5_off_coef) # TODO 没给出公式
# 以字典形式返回
return {'Rgon_factor_T1':self.Rgon_factor_T1, 'Rgoff_factor_T1':self.Rgoff_factor_T1,
'Rgon_factor_T2':self.Rgon_factor_T2, 'Rgoff_factor_T2':self.Rgoff_factor_T2,
'Rgrec_factor_D1':self.Rgrec_factor_D1, 'Rgrec_factor_D5':self.Rgrec_factor_D5,
'Rgon_factor_T5':self.Rgon_factor_T5, 'Rgoff_factor_T5':self.Rgoff_factor_T5,
}
# 计算损耗
def cal_loss(self, R_coefs, loss_coefs, Rth):
"""
R_coefs: 字典,存储了T1,T2, D5, D7的开关电阻计算公式的系数,{'T1_on':coef, 'T1_off':coef, 'T2_on':coef, 'T2_off':coef, 'D5_rec':coef, 'D7_rec':coef,}
loss_coefs: 字典,{'Vce_Ic_T1':coef, 'EonT1':coef, 'EoffT1':coef,
'Vce_Ic_T2':coef, 'EonT2':coef, 'EoffT2':coef,
'Vf_IC_D1':coef, 'Erec_D1':coef,
'Vf_IC_D2':coef, 'Erec_D2':coef,}
coef: 列表,形如[a, b, c, d],对应每个管子的四个损耗系数
Rth: 字典,包含Rth_T1,Rth_T2,Rth_D1,Rth_D2
积分计算使用scipy库的 integrate.quad() 方法实现
ret, dat = integrate.quad(func, a, b, args=()); func为待积分函数(项),a为积分下限,b为积分上限,args为传入func中的常数项
integrate.quad() 函数具体用法: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html#scipy.integrate.quad
"""
self.Rth_T1 = Rth['Rth_T1']
self.Rth_T2 = Rth['Rth_T2']
self.Rth_T5 = Rth['Rth_T5']
self.Rth_D1 = Rth['Rth_D1']
self.Rth_D2 = Rth['Rth_D2']
self.Rth_D5 = Rth['Rth_D5']
# 计算开关电阻参数,self.R_params 为包含所有管子开关电阻参数的字典
self.R_params = self.cal_R_param(R_coefs)
# self.coef_Irms 为 I_rms * 1.414,用于后续计算IC(theta)=I_rms * 1.414 * sin(theta)的传参
self.coef_Irms = self.I_rms * 1.414
# 计算 T1/T4 loss
# 读取用于计算 Vce_Ic_T1(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.Vce_Ic_T1_coef_l0 = loss_coefs['Vce_Ic_T1'][0]
self.Vce_Ic_T1_coef_l1 = loss_coefs['Vce_Ic_T1'][1]
self.Vce_Ic_T1_coef_l2 = loss_coefs['Vce_Ic_T1'][2]
self.Vce_Ic_T1_coef_l3 = loss_coefs['Vce_Ic_T1'][3]
# 计算 Pcon_T1 SPWM方式
Pcon_T1_spwm, _ = integrate.quad(eqs.integrand_Pcon_T1_spwm, 0, np.pi-self.phi, args=(self.coef_Irms, self.Vce_Ic_T1_coef_l0, self.Vce_Ic_T1_coef_l1, self.Vce_Ic_T1_coef_l2, self.Vce_Ic_T1_coef_l3, self.m, self.phi))
self.Pcon_T1_spwm = Pcon_T1_spwm/(2.0*np.pi)
# 计算 Pcon_T1 SVPWM方式
Pcon_T1_svpwm, _ = integrate.quad(eqs.integrand_Pcon_T1_svpwm, 0, np.pi-self.phi, args=(self.coef_Irms, self.Vce_Ic_T1_coef_l0, self.Vce_Ic_T1_coef_l1, self.Vce_Ic_T1_coef_l2, self.Vce_Ic_T1_coef_l3, self.m, self.phi))
self.Pcon_T1_svpwm = Pcon_T1_svpwm/(2.0*np.pi)
# 读取用于计算 EonT1(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.EonT1_coef_l0 = loss_coefs['EonT1'][0]
self.EonT1_coef_l1 = loss_coefs['EonT1'][1]
self.EonT1_coef_l2 = loss_coefs['EonT1'][2]
self.EonT1_coef_l3 = loss_coefs['EonT1'][3]
# 计算 PSW_T1_ON
PSW_T1_ON, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, 0, np.pi-self.phi, args=(self.coef_Irms, self.EonT1_coef_l0, self.EonT1_coef_l1, self.EonT1_coef_l2, self.EonT1_coef_l3))
self.PSW_T1_ON = self.fsw * self.Vfactor_IGBT * self.R_params['Rgon_factor_T1'] * PSW_T1_ON /(2.0*np.pi)
# print('PSW_T1_ON: ', self.PSW_T1_ON)
# 读取用于计算 EoffT1(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.EoffT1_coef_l0 = loss_coefs['EoffT1'][0]
self.EoffT1_coef_l1 = loss_coefs['EoffT1'][1]
self.EoffT1_coef_l2 = loss_coefs['EoffT1'][2]
self.EoffT1_coef_l3 = loss_coefs['EoffT1'][3]
# 计算 PSW_T1_OFF
PSW_T1_OFF, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, 0, np.pi-self.phi, args=(self.coef_Irms, self.EoffT1_coef_l0, self.EoffT1_coef_l1, self.EoffT1_coef_l2, self.EoffT1_coef_l3))
self.PSW_T1_OFF = self.fsw * self.Vfactor_IGBT * self.R_params['Rgoff_factor_T1'] * PSW_T1_OFF /(2.0*np.pi)
# print('PSW_T1_OFF: ', self.PSW_T1_OFF)
# 计算 PSW_T1, TER_T1
self.PSW_T1 = self.PSW_T1_ON + self.PSW_T1_OFF
self.TER_T1_spwm = self.Th + self.Rth_T1*(self.Pcon_T1_spwm+self.PSW_T1)
self.TER_T1_svpwm = self.Th + self.Rth_T1*(self.Pcon_T1_svpwm+self.PSW_T1)
# 总损耗,两种调制模式
self.tot_T1_spwm = self.Pcon_T1_spwm+self.PSW_T1
self.tot_T1_svpwm = self.Pcon_T1_svpwm+self.PSW_T1
# 计算 T2/T3 loss
# 读取用于计算 Vce_Ic_T2(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.Vce_Ic_T2_coef_l0 = loss_coefs['Vce_Ic_T2'][0]
self.Vce_Ic_T2_coef_l1 = loss_coefs['Vce_Ic_T2'][1]
self.Vce_Ic_T2_coef_l2 = loss_coefs['Vce_Ic_T2'][2]
self.Vce_Ic_T2_coef_l3 = loss_coefs['Vce_Ic_T2'][3]
# 计算 Pcon_T2 SPWM方式,两部分积分分开计算,再求和
Pcon_T2_spwm_part1, _ = integrate.quad(eqs.integrand_ANPC_Pcon_T2_spwm_part1, 0, np.pi-self.phi, args=(self.coef_Irms, self.Vce_Ic_T2_coef_l0, self.Vce_Ic_T2_coef_l1, self.Vce_Ic_T2_coef_l2, self.Vce_Ic_T2_coef_l3))
Pcon_T2_spwm_part2, _ = integrate.quad(eqs.integrand_Pcon_T2_spwm_part2, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vce_Ic_T2_coef_l0, self.Vce_Ic_T2_coef_l1, self.Vce_Ic_T2_coef_l2, self.Vce_Ic_T2_coef_l3, self.m, self.phi))
self.Pcon_T2_spwm = (Pcon_T2_spwm_part1+Pcon_T2_spwm_part2)/(2.0*np.pi)
# 计算 Pcon_T2 SVPWM方式,两部分积分分开计算,再求和
Pcon_T2_svpwm_part1, _ = integrate.quad(eqs.integrand_ANPC_Pcon_T2_spwm_part1, 0, np.pi-self.phi, args=(self.coef_Irms, self.Vce_Ic_T2_coef_l0, self.Vce_Ic_T2_coef_l1, self.Vce_Ic_T2_coef_l2, self.Vce_Ic_T2_coef_l3))
Pcon_T2_svpwm_part2, _ = integrate.quad(eqs.integrand_Pcon_T2_svpwm_part2, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vce_Ic_T2_coef_l0, self.Vce_Ic_T2_coef_l1, self.Vce_Ic_T2_coef_l2, self.Vce_Ic_T2_coef_l3, self.m, self.phi))
self.Pcon_T2_svpwm = (Pcon_T2_svpwm_part1+Pcon_T2_svpwm_part2)/(2.0*np.pi)
# 读取用于计算 EonT2(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.EonT2_coef_l0 = loss_coefs['EonT2'][0]
self.EonT2_coef_l1 = loss_coefs['EonT2'][1]
self.EonT2_coef_l2 = loss_coefs['EonT2'][2]
self.EonT2_coef_l3 = loss_coefs['EonT2'][3]
# 计算 PSW_T2_ON
PSW_T2_ON, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.EonT2_coef_l0, self.EonT2_coef_l1, self.EonT2_coef_l2, self.EonT2_coef_l3))
self.PSW_T2_ON = self.fsw * self.Vfactor_IGBT * self.R_params['Rgon_factor_T2'] * PSW_T2_ON /(2.0*np.pi)
# 读取用于计算 EoffT2(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.EoffT2_coef_l0 = loss_coefs['EoffT2'][0]
self.EoffT2_coef_l1 = loss_coefs['EoffT2'][1]
self.EoffT2_coef_l2 = loss_coefs['EoffT2'][2]
self.EoffT2_coef_l3 = loss_coefs['EoffT2'][3]
# 计算 PSW_T2_OFF
PSW_T2_OFF, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.EoffT2_coef_l0, self.EoffT2_coef_l1, self.EoffT2_coef_l2, self.EoffT2_coef_l3))
self.PSW_T2_OFF = self.fsw * self.Vfactor_IGBT * self.R_params['Rgoff_factor_T2'] * PSW_T2_OFF /(2.0*np.pi)
# 计算 PSW_T2, TER_T2
self.PSW_T2 = self.PSW_T2_ON + self.PSW_T2_OFF
self.TER_T2_spwm = self.Th + self.Rth_T2*(self.Pcon_T2_spwm+self.PSW_T2)
self.TER_T2_svpwm = self.Th + self.Rth_T2*(self.Pcon_T2_svpwm+self.PSW_T2)
# 总损耗,两种调制模式
self.tot_T2_spwm = self.Pcon_T2_spwm+self.PSW_T2
self.tot_T2_svpwm = self.Pcon_T2_svpwm+self.PSW_T2
# 计算 D1/D4 loss
# 读取用于计算 Vf_IC_D1(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.Vf_IC_D1_coef_l0 = loss_coefs['Vf_IC_D1'][0]
self.Vf_IC_D1_coef_l1 = loss_coefs['Vf_IC_D1'][1]
self.Vf_IC_D1_coef_l2 = loss_coefs['Vf_IC_D1'][2]
self.Vf_IC_D1_coef_l3 = loss_coefs['Vf_IC_D1'][3]
# 计算 Pcon_D1 SPWM方式
Pcon_D1_spwm, _ = integrate.quad(eqs.integrand_Pcon_D1_spwm, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vf_IC_D1_coef_l0, self.Vf_IC_D1_coef_l1, self.Vf_IC_D1_coef_l2, self.Vf_IC_D1_coef_l3, self.m, self.phi))
self.Pcon_D1_spwm = Pcon_D1_spwm/(2.0*np.pi)
# 计算 Pcon_D1 SVPWM方式
Pcon_D1_svpwm, _ = integrate.quad(eqs.integrand_Pcon_D1_svpwm, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vf_IC_D1_coef_l0, self.Vf_IC_D1_coef_l1, self.Vf_IC_D1_coef_l2, self.Vf_IC_D1_coef_l3, self.m, self.phi))
self.Pcon_D1_svpwm = Pcon_D1_svpwm/(2.0*np.pi)
# 读取用于计算 Erec_D1(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.Erec_D1_coef_l0 = loss_coefs['Erec_D1'][0]
self.Erec_D1_coef_l1 = loss_coefs['Erec_D1'][1]
self.Erec_D1_coef_l2 = loss_coefs['Erec_D1'][2]
self.Erec_D1_coef_l3 = loss_coefs['Erec_D1'][3]
# 计算 Prec_D1, TER_D7
Prec_D1, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Erec_D1_coef_l0, self.Erec_D1_coef_l1, self.Erec_D1_coef_l2, self.Erec_D1_coef_l3))
self.Prec_D1 = self.Vfactor_diode * self.fsw * self.R_params['Rgrec_factor_D1'] * Prec_D1 /(2.0*np.pi)
self.TER_D1_spwm = self.Th + self.Rth_D1*(self.Pcon_D1_spwm+self.Prec_D1)
self.TER_D1_svpwm = self.Th + self.Rth_D1*(self.Pcon_D1_svpwm+self.Prec_D1)
# 总损耗,两种调制模式
self.tot_D1_spwm = self.Pcon_D1_spwm+self.Prec_D1
self.tot_D1_svpwm = self.Pcon_D1_svpwm+self.Prec_D1
# 计算 D2/D3 loss
# 读取用于计算 Vf_IC_D2(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.Vf_IC_D2_coef_l0 = loss_coefs['Vf_IC_D2'][0]
self.Vf_IC_D2_coef_l1 = loss_coefs['Vf_IC_D2'][1]
self.Vf_IC_D2_coef_l2 = loss_coefs['Vf_IC_D2'][2]
self.Vf_IC_D2_coef_l3 = loss_coefs['Vf_IC_D2'][3]
# Pcon_D2 SPWM方式
Pcon_D2_spwm, _ = integrate.quad(eqs.integrand_Pcon_D1_spwm, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vf_IC_D2_coef_l0, self.Vf_IC_D2_coef_l1, self.Vf_IC_D2_coef_l2, self.Vf_IC_D2_coef_l3, self.m, self.phi))
self.Pcon_D2_spwm = Pcon_D2_spwm/(2.0*np.pi)
# Pcon_D2 SVPWM方式,两部分积分分开计算,再求和
Pcon_D2_svpwm, _ = integrate.quad(eqs.integrand_Pcon_D1_svpwm, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vf_IC_D2_coef_l0, self.Vf_IC_D2_coef_l1, self.Vf_IC_D2_coef_l2, self.Vf_IC_D2_coef_l3, self.m, self.phi))
self.Pcon_D2_svpwm = Pcon_D2_svpwm/(2.0*np.pi)
# # 读取用于计算 Erec_D2(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
# self.Erec_D2_coef_l0 = loss_coefs['Erec_D2'][0]
# self.Erec_D2_coef_l1 = loss_coefs['Erec_D2'][1]
# self.Erec_D2_coef_l2 = loss_coefs['Erec_D2'][2]
# self.Erec_D2_coef_l3 = loss_coefs['Erec_D2'][3]
# # 计算 Prec_D2, TER_D5
# Prec_D2, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, 0, np.pi-self.phi, args=(self.coef_Irms, self.Erec_D2_coef_l0, self.Erec_D2_coef_l1, self.Erec_D2_coef_l2, self.Erec_D2_coef_l3))
# self.Prec_D2 = self.fsw * self.R_params['Rgrec_factor_D5'] * self.Vfactor_diode * Prec_D2 /(2.0*np.pi)
self.Prec_D2 = 0.0
self.TER_D2_spwm = self.Th + self.Rth_D2*(self.Pcon_D2_spwm+self.Prec_D2)
self.TER_D2_svpwm = self.Th + self.Rth_D2*(self.Pcon_D2_svpwm+self.Prec_D2)
# 总损耗,两种调制模式
self.tot_D2_spwm = self.Pcon_D2_spwm+self.Prec_D2
self.tot_D2_svpwm = self.Pcon_D2_svpwm+self.Prec_D2
# 计算 D5/D6 loss
self.Vf_IC_D5_coef_l0 = loss_coefs['Vf_IC_D5'][0]
self.Vf_IC_D5_coef_l1 = loss_coefs['Vf_IC_D5'][1]
self.Vf_IC_D5_coef_l2 = loss_coefs['Vf_IC_D5'][2]
self.Vf_IC_D5_coef_l3 = loss_coefs['Vf_IC_D5'][3]
Pcon_D5_spwm, _ = integrate.quad(eqs.integrand_Pcon_T2_spwm_part1, 0.0, np.pi-self.phi, args=(self.coef_Irms, self.Vf_IC_D5_coef_l0, self.Vf_IC_D5_coef_l1, self.Vf_IC_D5_coef_l2, self.Vf_IC_D5_coef_l3, self.m, self.phi))
self.Pcon_D5_spwm = Pcon_D5_spwm/(2.0*np.pi)
Pcon_D5_svpwm, _ = integrate.quad(eqs.integrand_Pcon_T2_svpwm_part1, 0.0, np.pi-self.phi, args=(self.coef_Irms, self.Vf_IC_D5_coef_l0, self.Vf_IC_D5_coef_l1, self.Vf_IC_D5_coef_l2, self.Vf_IC_D5_coef_l3, self.m, self.phi))
self.Pcon_D5_svpwm = Pcon_D5_svpwm/(2.0*np.pi)
self.Erec_D5_coef_l0 = loss_coefs['Erec_D5'][0]
self.Erec_D5_coef_l1 = loss_coefs['Erec_D5'][1]
self.Erec_D5_coef_l2 = loss_coefs['Erec_D5'][2]
self.Erec_D5_coef_l3 = loss_coefs['Erec_D5'][3]
Prec_D5, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, 0, np.pi-self.phi, args=(self.coef_Irms, self.Erec_D5_coef_l0, self.Erec_D5_coef_l1, self.Erec_D5_coef_l2, self.Erec_D5_coef_l3))
self.Prec_D5 = self.fsw * self.R_params['Rgrec_factor_D5'] * self.Vfactor_diode * Prec_D5 /(2.0*np.pi)
self.TER_D5_spwm = self.Th + self.Rth_D5*(self.Pcon_D5_spwm+self.Prec_D5)
self.TER_D5_svpwm = self.Th + self.Rth_D5*(self.Pcon_D5_svpwm+self.Prec_D5)
# 总损耗,两种调制模式
self.tot_D5_spwm = self.Pcon_D5_spwm+self.Prec_D5
self.tot_D5_svpwm = self.Pcon_D5_svpwm+self.Prec_D5
# 计算 T5/T6 loss
self.Vce_Ic_T5_coef_l0 = loss_coefs['Vce_Ic_T5'][0]
self.Vce_Ic_T5_coef_l1 = loss_coefs['Vce_Ic_T5'][1]
self.Vce_Ic_T5_coef_l2 = loss_coefs['Vce_Ic_T5'][2]
self.Vce_Ic_T5_coef_l3 = loss_coefs['Vce_Ic_T5'][3]
# 计算 Pcon_T2 SPWM方式,两部分积分分开计算,再求和
Pcon_T5_spwm, _ = integrate.quad(eqs.integrand_Pcon_T2_spwm_part2, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vce_Ic_T5_coef_l0, self.Vce_Ic_T5_coef_l1, self.Vce_Ic_T5_coef_l2, self.Vce_Ic_T5_coef_l3, self.m, self.phi))
self.Pcon_T5_spwm = Pcon_T5_spwm/(2.0*np.pi)
Pcon_T5_svpwm, _ = integrate.quad(eqs.integrand_Pcon_T2_svpwm_part2, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.Vce_Ic_T5_coef_l0, self.Vce_Ic_T5_coef_l1, self.Vce_Ic_T5_coef_l2, self.Vce_Ic_T5_coef_l3, self.m, self.phi))
self.Pcon_T5_svpwm = Pcon_T5_svpwm/(2.0*np.pi)
# 读取用于计算 EonT5(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.EonT5_coef_l0 = loss_coefs['EonT5'][0]
self.EonT5_coef_l1 = loss_coefs['EonT5'][1]
self.EonT5_coef_l2 = loss_coefs['EonT5'][2]
self.EonT5_coef_l3 = loss_coefs['EonT5'][3]
# 计算 PSW_T5_ON
PSW_T5_ON, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.EonT5_coef_l0, self.EonT5_coef_l1, self.EonT5_coef_l2, self.EonT5_coef_l3))
self.PSW_T5_ON = self.fsw * self.Vfactor_IGBT * self.R_params['Rgon_factor_T5'] * PSW_T5_ON /(2.0*np.pi)
# 读取用于计算 EoffT5(IC)=a+b*IC+c*IC^2+d*IC^3 的四个系数
self.EoffT5_coef_l0 = loss_coefs['EoffT5'][0]
self.EoffT5_coef_l1 = loss_coefs['EoffT5'][1]
self.EoffT5_coef_l2 = loss_coefs['EoffT5'][2]
self.EoffT5_coef_l3 = loss_coefs['EoffT5'][3]
# 计算 PSW_T5_OFF
PSW_T5_OFF, _ = integrate.quad(eqs.integrand_PSW_ON_OFF, np.pi-self.phi, np.pi, args=(self.coef_Irms, self.EoffT5_coef_l0, self.EoffT5_coef_l1, self.EoffT5_coef_l2, self.EoffT5_coef_l3))
self.PSW_T5_OFF = self.fsw * self.Vfactor_IGBT * self.R_params['Rgoff_factor_T5'] * PSW_T5_OFF /(2.0*np.pi)
# 计算 PSW_T5, TER_T5
self.PSW_T5 = self.PSW_T5_ON + self.PSW_T5_OFF
self.TER_T5_spwm = self.Th + self.Rth_T2*(self.Pcon_T2_spwm+self.PSW_T2)
self.TER_T5_svpwm = self.Th + self.Rth_T2*(self.Pcon_T2_svpwm+self.PSW_T2)
# T5 总损耗,两种调制模式
self.tot_T5_spwm = self.Pcon_T5_spwm+self.PSW_T5
self.tot_T5_svpwm = self.Pcon_T5_svpwm+self.PSW_T5
# 计算 系统总损耗 total loss 和 效率 eta
self.Ptot_spwm = (self.Pcon_T1_spwm+self.PSW_T1+self.Pcon_T2_spwm+self.PSW_T2+self.Pcon_D1_spwm+self.Prec_D1+self.Pcon_D2_spwm+self.Prec_D2+self.Pcon_D5_spwm+self.Prec_D5+self.Pcon_T5_spwm+self.PSW_T5)*2.0
self.eta_spwm = (self.Vout*self.I_rms)/(self.Ptot_spwm+self.Vout*self.I_rms)
self.Ptot_svpwm = (self.Pcon_T1_svpwm+self.PSW_T1+self.Pcon_T2_svpwm+self.PSW_T2+self.Pcon_D1_svpwm+self.Prec_D1+self.Pcon_D2_svpwm+self.Prec_D2+self.Pcon_D5_svpwm+self.Prec_D5+self.Pcon_T5_svpwm+self.PSW_T5)*2.0
self.eta_svpwm = (self.Vout*self.I_rms)/(self.Ptot_svpwm+self.Vout*self.I_rms)
# 将所有的计算结果以字典格式返回
return {'Vout':self.Vout, 'I_rms':self.I_rms,
'Pcon_T1_spwm':self.Pcon_T1_spwm, 'Pcon_T1_svpwm':self.Pcon_T1_svpwm, 'PSW_T1':self.PSW_T1, 'PSW_T1_ON':self.PSW_T1_ON, 'PSW_T1_OFF':self.PSW_T1_OFF,
'Pcon_T2_spwm':self.Pcon_T2_spwm, 'Pcon_T2_svpwm':self.Pcon_T2_svpwm, 'PSW_T2':self.PSW_T2, 'PSW_T2_ON':self.PSW_T2_ON, 'PSW_T2_OFF':self.PSW_T2_OFF,
'Pcon_D1_spwm':self.Pcon_D1_spwm, 'Pcon_D1_svpwm':self.Pcon_D1_svpwm, 'Prec_D1':self.Prec_D1,
'Pcon_D2_spwm':self.Pcon_D2_spwm, 'Pcon_D2_svpwm':self.Pcon_D2_svpwm, 'Prec_D2':self.Prec_D2,
'Pcon_D5_spwm':self.Pcon_D5_spwm, 'Pcon_D5_svpwm':self.Pcon_D5_svpwm, 'Prec_D5':self.Prec_D5,
'Pcon_T5_spwm':self.Pcon_T5_spwm, 'Pcon_T5_svpwm':self.Pcon_T5_svpwm, 'PSW_T5':self.PSW_T5, 'PSW_T5_ON':self.PSW_T5_ON, 'PSW_T5_OFF':self.PSW_T5_OFF,
'system_total_loss_spwm':self.Ptot_spwm, 'system_efficiency_spwm':self.eta_spwm,
'system_total_loss_svpwm':self.Ptot_svpwm, 'system_efficiency_svpwm':self.eta_svpwm,
'T1_total_loss_spwm':self.tot_T1_spwm, 'T1_total_loss_svpwm':self.tot_T1_svpwm,
'T2_total_loss_spwm':self.tot_T2_spwm, 'T2_total_loss_svpwm':self.tot_T2_svpwm,
'D1_total_loss_spwm':self.tot_D1_spwm, 'D1_total_loss_svpwm':self.tot_D1_svpwm,
'D2_total_loss_spwm':self.tot_D2_spwm, 'D2_total_loss_svpwm':self.tot_D2_svpwm,
'D5_total_loss_spwm':self.tot_D5_spwm, 'D5_total_loss_svpwm':self.tot_D5_svpwm,
'T5_total_loss_spwm':self.tot_T5_spwm, 'T5_total_loss_svpwm':self.tot_T5_svpwm,
'TER_T1_spwm':self.TER_T1_spwm, 'TER_T1_svpwm':self.TER_T1_svpwm,
'TER_T2_spwm':self.TER_T2_spwm, 'TER_T2_svpwm':self.TER_T2_svpwm,
'TER_D1_spwm':self.TER_D1_spwm, 'TER_D1_svpwm':self.TER_D1_svpwm,
'TER_D2_spwm':self.TER_D2_spwm, 'TER_D2_svpwm':self.TER_D2_svpwm,
'TER_D5_spwm':self.TER_D5_spwm, 'TER_D5_svpwm':self.TER_D5_svpwm,
'TER_T5_spwm':self.TER_T5_spwm, 'TER_T5_svpwm':self.TER_T5_svpwm,
}
# 画曲线
def draw_curve(self, rc_coefs):
'''
rc_coefs: 字典,存储 RC(用于动态结温公式)的系数,{'T1':coef, 'T2':coef, 'D1':coef, 'D2':coef,}
coef: 列表,形如[c0, c1, c2, c3, c4, c5, c6, c7], 对应每个管子的8个动态结温公式中 RC 系数
'''
# 将 时间t的区间 离散化,离散为500个点,在后续计算中,分别计算每个t值对应的损耗值,得到纵坐标,组成曲线图
t = np.linspace(0.0, 1/self.fout, 500)
# 画出 T1/T4 的曲线
# 动态损耗计算,计算每个时间t对应的损耗值
Pcon_T1_spwm_values = np.array([cfs.Pcon_T1_spwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vce_Ic_T1_coef_l0, self.Vce_Ic_T1_coef_l1, self.Vce_Ic_T1_coef_l2, self.Vce_Ic_T1_coef_l3, self.m, self.phi) for t_ in t])
Pcon_T1_svpwm_values = np.array([cfs.Pcon_T1_svpwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vce_Ic_T1_coef_l0, self.Vce_Ic_T1_coef_l1, self.Vce_Ic_T1_coef_l2, self.Vce_Ic_T1_coef_l3, self.m, self.phi) for t_ in t])
# 在计算开关损耗时,没有将fsw,Vfactor_IGBT,Rgon_factor等参数考虑进来,后续会考虑
PSW_T1_ON_values = np.array([cfs.PSW_T1_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.EonT1_coef_l0, self.EonT1_coef_l1, self.EonT1_coef_l2, self.EonT1_coef_l3, self.phi) for t_ in t])
PSW_T1_OFF_values = np.array([cfs.PSW_T1_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.EoffT1_coef_l0, self.EoffT1_coef_l1, self.EoffT1_coef_l2, self.EoffT1_coef_l3, self.phi) for t_ in t])
# 分别计算 SPWM,SVPWM方式下的损耗和,Pcon_T1+PSW_T1_ON+PSW_T1_OFF, 在这里考虑 fsw,Vfactor_IGBT,Rgon_factor等参数
P_T1_spwm_curve_values = Pcon_T1_spwm_values + self.fsw*self.Vfactor_IGBT*self.Rgon_factor_T1*PSW_T1_ON_values + self.fsw*self.Vfactor_IGBT*self.Rgoff_factor_T1*PSW_T1_OFF_values
P_T1_svpwm_curve_values = Pcon_T1_svpwm_values + self.fsw*self.Vfactor_IGBT*self.Rgon_factor_T1*PSW_T1_ON_values + self.fsw*self.Vfactor_IGBT*self.Rgoff_factor_T1*PSW_T1_OFF_values
# # 将t和损耗值 作为参数 传入 plot_curve 函数,画出动态损耗曲线
# self.Pcon_T1_spwm_curve_img = plot.plot_curve(t, P_T1_spwm_curve_values)
# self.Pcon_T1_svpwm_curve_img = plot.plot_curve(t, P_T1_svpwm_curve_values)
# 动态结温计算,计算每个时间t对应的结温值
T1_c = rc_coefs['T1']
RC_T1 = np.array([cfs.RC(t_, T1_c[0], T1_c[1], T1_c[2], T1_c[3], T1_c[4], T1_c[5], T1_c[6], T1_c[7]) for t_ in t])
TER_T1_spwm_curve_values = self.Th + RC_T1*P_T1_spwm_curve_values
TER_T1_svpwm_curve_values = self.Th + RC_T1*P_T1_svpwm_curve_values
# # 将t和结温值 作为参数 传入 plot_curve 函数,画出动态结温曲线
# self.TER_T1_spwm_curve_img = plot.plot_curve(t, TER_T1_spwm_curve_values)
# self.TER_T1_svpwm_curve_img = plot.plot_curve(t, TER_T1_svpwm_curve_values)
# 画出 T2/T3 的曲线
# 动态损耗计算
Pcon_T2_spwm_values = np.array([cfs.ANPC_Pcon_T2_spwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vce_Ic_T2_coef_l0, self.Vce_Ic_T2_coef_l1, self.Vce_Ic_T2_coef_l2, self.Vce_Ic_T2_coef_l3, self.m, self.phi) for t_ in t])
Pcon_T2_svpwm_values = np.array([cfs.ANPC_Pcon_T2_svpwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vce_Ic_T2_coef_l0, self.Vce_Ic_T2_coef_l1, self.Vce_Ic_T2_coef_l2, self.Vce_Ic_T2_coef_l3, self.m, self.phi) for t_ in t])
# 在计算开关损耗时,没有将fsw,Vfactor_IGBT,Rgon_factor等参数考虑进来,后续会考虑
PSW_T2_ON_values = np.array([cfs.PSW_T2_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.EonT2_coef_l0, self.EonT2_coef_l1, self.EonT2_coef_l2, self.EonT2_coef_l3, self.phi) for t_ in t])
PSW_T2_OFF_values = np.array([cfs.PSW_T2_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.EoffT2_coef_l0, self.EoffT2_coef_l1, self.EoffT2_coef_l2, self.EoffT2_coef_l3, self.phi) for t_ in t])
# 分别计算 SPWM,SVPWM方式下的损耗和,Pcon_T2+PSW_T2_ON+PSW_T2_OFF,在这里考虑 fsw,Vfactor_IGBT,Rgon_factor等参数
P_T2_spwm_curve_values = Pcon_T2_spwm_values + self.fsw*self.Vfactor_IGBT*self.Rgon_factor_T2*PSW_T2_ON_values + self.fsw*self.Vfactor_IGBT*self.Rgoff_factor_T2*PSW_T2_OFF_values
P_T2_svpwm_curve_values = Pcon_T2_svpwm_values + self.fsw*self.Vfactor_IGBT*self.Rgon_factor_T2*PSW_T2_ON_values + self.fsw*self.Vfactor_IGBT*self.Rgoff_factor_T2*PSW_T2_OFF_values
# # 将t和损耗值 作为参数 传入 plot_curve 函数,画出动态损耗曲线
# self.Pcon_T2_spwm_curve_img = plot.plot_curve(t, P_T2_spwm_curve_values)
# self.Pcon_T2_svpwm_curve_img = plot.plot_curve(t, P_T2_svpwm_curve_values)
# 动态结温计算,计算每个时间t对应的结温值
T2_c = rc_coefs['T2']
RC_T2 = np.array([cfs.RC(t_, T2_c[0], T2_c[1], T2_c[2], T2_c[3], T2_c[4], T2_c[5], T2_c[6], T2_c[7]) for t_ in t])
TER_T2_spwm_curve_values = self.Th + RC_T2*P_T2_spwm_curve_values
TER_T2_svpwm_curve_values = self.Th + RC_T2*P_T2_svpwm_curve_values
# # 将t和结温值 作为参数 传入 plot_curve 函数,画出动态结温曲线
# self.TER_T2_spwm_curve_img = plot.plot_curve(t, TER_T2_spwm_curve_values)
# self.TER_T2_svpwm_curve_img = plot.plot_curve(t, TER_T2_svpwm_curve_values)
# 画出 D1/D4 的损耗曲线
# 动态损耗计算
Pcon_D1_spwm_values = np.array([cfs.Pcon_D1_spwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vf_IC_D1_coef_l0, self.Vf_IC_D1_coef_l1, self.Vf_IC_D1_coef_l2, self.Vf_IC_D1_coef_l3, self.m, self.phi) for t_ in t])
Pcon_D1_svpwm_values = np.array([cfs.Pcon_D1_svpwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vf_IC_D1_coef_l0, self.Vf_IC_D1_coef_l1, self.Vf_IC_D1_coef_l2, self.Vf_IC_D1_coef_l3, self.m, self.phi) for t_ in t])
# 在计算Prec时,没有将fsw,Vfactor_diode,Rgrec_factor等参数考虑进来,后续会考虑
Prec_D1_values = np.array([cfs.Prec_D1_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Erec_D1_coef_l0, self.Erec_D1_coef_l1, self.Erec_D1_coef_l2, self.Erec_D1_coef_l3, self.phi) for t_ in t])
# 分别计算 SPWM,SVPWM方式下的损耗和,Pcon_D1+Prec_D1, 在这里考虑 fsw,Vfactor_diode,Rgrec_factor等参数
P_D1_spwm_curve_values = Pcon_D1_spwm_values + self.fsw*self.Vfactor_diode*self.Rgrec_factor_D1*Prec_D1_values
P_D1_svpwm_curve_values = Pcon_D1_svpwm_values + self.fsw*self.Vfactor_diode*self.Rgrec_factor_D1*Prec_D1_values
# # 将t和损耗值 作为参数 传入 plot_curve 函数,画出动态损耗曲线
# self.Pcon_D1_spwm_curve_img = plot.plot_curve(t, P_D1_spwm_curve_values)
# self.Pcon_D1_svpwm_curve_img = plot.plot_curve(t, P_D1_svpwm_curve_values)
# 动态结温计算,计算每个时间t对应的结温值
D1_c = rc_coefs['D1']
RC_D1 = np.array([cfs.RC(t_, D1_c[0], D1_c[1], D1_c[2], D1_c[3], D1_c[4], D1_c[5], D1_c[6], D1_c[7]) for t_ in t])
TER_D1_spwm_curve_values = self.Th + RC_D1*P_D1_spwm_curve_values
TER_D1_svpwm_curve_values = self.Th + RC_D1*P_D1_svpwm_curve_values
# # 将t和结温值 作为参数 传入 plot_curve 函数,画出曲线
# self.TER_D7_spwm_curve_img = plot.plot_curve(t, TER_D7_spwm_curve_values)
# self.TER_D7_svpwm_curve_img = plot.plot_curve(t, TER_D7_svpwm_curve_values)
# 画出 D2/D3 的损耗曲线 Pcon_D2+Prec_D2
# 动态损耗计算
Pcon_D2_spwm_values = np.array([cfs.Pcon_D1_spwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vf_IC_D2_coef_l0, self.Vf_IC_D2_coef_l1, self.Vf_IC_D2_coef_l2, self.Vf_IC_D2_coef_l3, self.m, self.phi) for t_ in t])
Pcon_D2_svpwm_values = np.array([cfs.Pcon_D1_svpwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vf_IC_D2_coef_l0, self.Vf_IC_D2_coef_l1, self.Vf_IC_D2_coef_l2, self.Vf_IC_D2_coef_l3, self.m, self.phi) for t_ in t])
# 在计算Prec时,没有将fsw,Vfactor_diode,Rgrec_factor等参数考虑进来,后续会考虑
Prec_D2_values = np.array([cfs.ANPC_Prec_T2_t(t_) for t_ in t])
# 分别计算 SPWM,SVPWM方式下的损耗和,在这里考虑 fsw,Vfactor_diode,Rgrec_factor等参数
P_D2_spwm_curve_values = Pcon_D2_spwm_values + Prec_D2_values
P_D2_svpwm_curve_values = Pcon_D2_svpwm_values + Prec_D2_values
# # 将t和损耗值 作为参数 传入 plot_curve 函数,画出曲线
# self.Pcon_D2_spwm_curve_img = plot.plot_curve(t, P_D2_spwm_curve_values)
# self.Pcon_D2_svpwm_curve_img = plot.plot_curve(t, P_D2_svpwm_curve_values)
# 动态结温计算,计算每个时间t对应的结温值
D2_c = rc_coefs['D2']
RC_D2 = np.array([cfs.RC(t_, D2_c[0], D2_c[1], D2_c[2], D2_c[3], D2_c[4], D2_c[5], D2_c[6], D2_c[7]) for t_ in t])
TER_D2_spwm_curve_values = self.Th + RC_D2*P_D2_spwm_curve_values
TER_D2_svpwm_curve_values = self.Th + RC_D2*P_D2_svpwm_curve_values
# # 将t和结温值 作为参数 传入 plot_curve 函数,画出曲线
# self.TER_D5_spwm_curve_img = plot.plot_curve(t, TER_D5_spwm_curve_values)
# self.TER_D5_svpwm_curve_img = plot.plot_curve(t, TER_D5_svpwm_curve_values)
# 画出 D5/D6 的损耗曲线 Pcon_D5+Prec_D5
# 动态损耗计算
Pcon_D5_spwm_values = np.array([cfs.ANPC_Pcon_D5_spwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vf_IC_D5_coef_l0, self.Vf_IC_D5_coef_l1, self.Vf_IC_D5_coef_l2, self.Vf_IC_D5_coef_l3, self.m, self.phi) for t_ in t])
Pcon_D5_svpwm_values = np.array([cfs.ANPC_Pcon_D5_svpwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vf_IC_D5_coef_l0, self.Vf_IC_D5_coef_l1, self.Vf_IC_D5_coef_l2, self.Vf_IC_D5_coef_l3, self.m, self.phi) for t_ in t])
# 在计算Prec时,没有将fsw,Vfactor_diode,Rgrec_factor等参数考虑进来,后续会考虑
Prec_D5_values = np.array([cfs.PSW_T1_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vf_IC_D5_coef_l0, self.Vf_IC_D5_coef_l1, self.Vf_IC_D5_coef_l2, self.Vf_IC_D5_coef_l3, self.phi) for t_ in t])
# 分别计算 SPWM,SVPWM方式下的损耗和,在这里考虑 fsw,Vfactor_diode,Rgrec_factor等参数
P_D5_spwm_curve_values = Pcon_D5_spwm_values + self.fsw*self.Vfactor_diode*self.Rgrec_factor_D5*Prec_D5_values
P_D5_svpwm_curve_values = Pcon_D5_svpwm_values + self.fsw*self.Vfactor_diode*self.Rgrec_factor_D5*Prec_D5_values
# 动态结温计算,计算每个时间t对应的结温值
D5_c = rc_coefs['D5']
RC_D5 = np.array([cfs.RC(t_, D5_c[0], D5_c[1], D5_c[2], D5_c[3], D5_c[4], D5_c[5], D5_c[6], D5_c[7]) for t_ in t])
TER_D5_spwm_curve_values = self.Th + RC_D5*P_D5_spwm_curve_values
TER_D5_svpwm_curve_values = self.Th + RC_D5*P_D5_svpwm_curve_values
# 画出 T5/T6 的曲线
# 动态损耗计算,计算每个时间t对应的损耗值
Pcon_T5_spwm_values = np.array([cfs.ANPC_Pcon_T5_spwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vce_Ic_T5_coef_l0, self.Vce_Ic_T5_coef_l1, self.Vce_Ic_T5_coef_l2, self.Vce_Ic_T5_coef_l3, self.m, self.phi) for t_ in t])
Pcon_T5_svpwm_values = np.array([cfs.ANPC_Pcon_T5_svpwm_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.Vce_Ic_T5_coef_l0, self.Vce_Ic_T5_coef_l1, self.Vce_Ic_T5_coef_l2, self.Vce_Ic_T5_coef_l3, self.m, self.phi) for t_ in t])
# 在计算开关损耗时,没有将fsw,Vfactor_IGBT,Rgon_factor等参数考虑进来,后续会考虑
PSW_T5_ON_values = np.array([cfs.PSW_T2_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.EonT5_coef_l0, self.EonT5_coef_l1, self.EonT5_coef_l2, self.EonT5_coef_l3, self.phi) for t_ in t])
PSW_T5_OFF_values = np.array([cfs.PSW_T2_loss_t(t_, 2*np.pi*self.fout, self.coef_Irms, self.EoffT5_coef_l0, self.EoffT5_coef_l1, self.EoffT5_coef_l2, self.EoffT5_coef_l3, self.phi) for t_ in t])
# 分别计算 SPWM,SVPWM方式下的损耗和,Pcon_T1+PSW_T1_ON+PSW_T1_OFF, 在这里考虑 fsw,Vfactor_IGBT,Rgon_factor等参数
P_T5_spwm_curve_values = Pcon_T5_spwm_values + self.fsw*self.Vfactor_IGBT*self.Rgon_factor_T5*PSW_T5_ON_values + self.fsw*self.Vfactor_IGBT*self.Rgoff_factor_T5*PSW_T5_OFF_values
P_T5_svpwm_curve_values = Pcon_T5_svpwm_values + self.fsw*self.Vfactor_IGBT*self.Rgon_factor_T5*PSW_T5_ON_values + self.fsw*self.Vfactor_IGBT*self.Rgoff_factor_T5*PSW_T5_OFF_values
# # 将t和损耗值 作为参数 传入 plot_curve 函数,画出动态损耗曲线
# self.Pcon_T1_spwm_curve_img = plot.plot_curve(t, P_T1_spwm_curve_values)
# self.Pcon_T1_svpwm_curve_img = plot.plot_curve(t, P_T1_svpwm_curve_values)
# 动态结温计算,计算每个时间t对应的结温值
T5_c = rc_coefs['T5']
RC_T5 = np.array([cfs.RC(t_, T5_c[0], T5_c[1], T5_c[2], T5_c[3], T5_c[4], T5_c[5], T5_c[6], T5_c[7]) for t_ in t])
TER_T5_spwm_curve_values = self.Th + RC_T5*P_T5_spwm_curve_values
TER_T5_svpwm_curve_values = self.Th + RC_T5*P_T5_svpwm_curve_values
# 最高结温
max_T1_spwm = np.max(TER_T1_spwm_curve_values)
max_T1_svpwm = np.max(TER_T1_svpwm_curve_values)
max_T2_spwm = np.max(TER_T2_spwm_curve_values)
max_T2_svpwm = np.max(TER_T2_svpwm_curve_values)
max_D1_spwm = np.max(TER_D1_spwm_curve_values)
max_D1_svpwm = np.max(TER_D1_svpwm_curve_values)
max_D2_spwm = np.max(TER_D2_spwm_curve_values)
max_D2_svpwm = np.max(TER_D2_svpwm_curve_values)
max_D5_spwm = np.max(TER_D5_spwm_curve_values)
max_D5_svpwm = np.max(TER_D5_svpwm_curve_values)
max_T5_spwm = np.max(TER_T5_spwm_curve_values)
max_T5_svpwm = np.max(TER_T5_svpwm_curve_values)
# 返回用于画曲线的数据点,每个图500个点
# t(numpy数组)为横坐标,'spwm_Pcon'等对应的值(numpy数组)为 纵坐标
# 'max_TER_spwm'等 对应的值为最高结温的数值
return {'t':t,
'T14':{'spwm_Pcon':P_T1_spwm_curve_values, # SPWM模式的损耗曲线纵坐标
'svpwm_Pcon':P_T1_svpwm_curve_values, # SVPWM模式的损耗曲线纵坐标
'spwm_TER':TER_T1_spwm_curve_values, # SPWM模式的结温曲线纵坐标
'svpwm_TER':TER_T1_svpwm_curve_values, # SVPWM模式的结温曲线纵坐标
'max_TER_spwm':max_T1_spwm, # 最高结温 SPWM模式
'max_TER_svpwm':max_T1_svpwm, # 最高结温 SVPWM模式
},
'T23':{'spwm_Pcon':P_T2_spwm_curve_values,
'svpwm_Pcon':P_T2_svpwm_curve_values,
'spwm_TER':TER_T2_spwm_curve_values,
'svpwm_TER':TER_T2_svpwm_curve_values,
'max_TER_spwm':max_T2_spwm,
'max_TER_svpwm':max_T2_svpwm,
},
'D14':{'spwm_Pcon':P_D1_spwm_curve_values,
'svpwm_Pcon':P_D1_svpwm_curve_values,
'spwm_TER':TER_D1_spwm_curve_values,
'svpwm_TER':TER_D1_svpwm_curve_values,
'max_TER_spwm':max_D1_spwm,
'max_TER_svpwm':max_D1_svpwm,
},
'D23':{'spwm_Pcon':P_D2_spwm_curve_values,
'svpwm_Pcon':P_D2_svpwm_curve_values,
'spwm_TER':TER_D2_spwm_curve_values,
'svpwm_TER':TER_D2_svpwm_curve_values,
'max_TER_spwm':max_D2_spwm,
'max_TER_svpwm':max_D2_svpwm,
},
'D56':{'spwm_Pcon':P_D5_spwm_curve_values,
'svpwm_Pcon':P_D5_svpwm_curve_values,
'spwm_TER':TER_D5_spwm_curve_values,
'svpwm_TER':TER_D5_svpwm_curve_values,
'max_TER_spwm':max_D5_spwm,
'max_TER_svpwm':max_D5_svpwm,
},
'T56':{'spwm_Pcon':P_T5_spwm_curve_values,
'svpwm_Pcon':P_T5_svpwm_curve_values,
'spwm_TER':TER_T5_spwm_curve_values,
'svpwm_TER':TER_T5_svpwm_curve_values,
'max_TER_spwm':max_T5_spwm,
'max_TER_svpwm':max_T5_svpwm,
},
}
# # 将所有的曲线图以字典格式返回,返回字典中的值为 PIL库格式的图像
# # 带 Pcon 的为动态损耗
# # 带 TER 的为动态结温
# return {'T14':{'spwm_Pcon':self.Pcon_T1_spwm_curve_img,
# 'svpwm_Pcon':self.Pcon_T1_svpwm_curve_img,
# 'spwm_TER':self.TER_T1_spwm_curve_img,
# 'svpwm_TER':self.TER_T1_svpwm_curve_img,
# 'max_TER_spwm':max_T1_spwm, # 最高结温 SPWM模式
# 'max_TER_svpwm':max_T1_svpwm, # 最高结温 SVPWM模式
# },
# 'T23':{'spwm_Pcon':self.Pcon_T2_spwm_curve_img,
# 'svpwm_Pcon':self.Pcon_T2_svpwm_curve_img,
# 'spwm_TER':self.TER_T2_spwm_curve_img,
# 'svpwm_TER':self.TER_T2_svpwm_curve_img,
# 'max_TER_spwm':max_T2_spwm,
# 'max_TER_svpwm':max_T2_svpwm,
# },
# 'D14':{'spwm_Pcon':self.Pcon_D1_spwm_curve_img,
# 'svpwm_Pcon':self.Pcon_D1_svpwm_curve_img,
# 'spwm_TER':self.TER_D7_spwm_curve_img,
# 'svpwm_TER':self.TER_D7_svpwm_curve_img,
# 'max_TER_spwm':max_D1_spwm,
# 'max_TER_svpwm':max_D1_svpwm,
# },
# 'D23':{'spwm_Pcon':self.Pcon_D2_spwm_curve_img,
# 'svpwm_Pcon':self.Pcon_D2_svpwm_curve_img,
# 'spwm_TER':self.TER_D5_spwm_curve_img,
# 'svpwm_TER':self.TER_D5_svpwm_curve_img,
# 'max_TER_spwm':max_D2_spwm,
# 'max_TER_svpwm':max_D2_svpwm,
# }}
if __name__ == '__main__':
# 使用示例
input_param = {'fout':50,
'PF':1,
'Vout':230,
'Vdc':800,
'I_rms':50,
'Rgon_T1':7.5,
'Rgoff_T1':7.5,
'Rgon_T2':7.5,
'Rgoff_T2':7.5,
'Rgon_T5':7.5,
'Rgoff_T5':7.5,
'fsw':8000.0,
'Th':80,
}
inter_param = {'Vref':600,
'Rgon_T1_test':7.5,
'Rgoff_T1_test':7.5,
'Rgon_T2_test':7.5,
'Rgoff_T2_test':7.5,
'Rgon_T5_test':7.5,
'Rgoff_T5_test':7.5,
}
'''
R_coefs: 字典,{'T1_on':coef, 'T1_off':coef, 'T2_on':coef, 'T2_off':coef, 'D5_rec':coef, 'D7_rec':coef,}
loss_coefs: 字典,{'Vce_Ic_T1':coef, 'EonT1':coef, 'EoffT1':coef,
'Vce_Ic_T2':coef, 'EonT2':coef, 'EoffT2':coef,
'Vf_IC_D1':coef, 'Erec_D1':coef,
'Vf_IC_D2':coef, 'Erec_D2':coef,}
'''
R_coefs = {'T1_on':[1.411, 2.933, -0.08713, 0.001509],
'T1_off':[9.102, 0.9719, -0.03199, 0.0006902],
'T2_on':[1.756, 1.39, 0.02054, -0.000799],
'T2_off':[7.31, 0.2901, 0.01963, -0.0005018],
'D1_rec':[7.31, 0.2901, 0.01963, -0.0005018],
'D5_rec':[1.411, 2.933, -0.08713, 0.001509],
'T5_on':[1.411, 2.933, -0.08713, 0.001509], # TODO: 没有给参数
'T5_off':[9.102, 0.9719, -0.03199, 0.0006902], # TODO: 没有给参数
}
loss_coefs = {'Vce_Ic_T1':[0.4583, 0.009759, -1.793e-5, 1.917e-8],
'EonT1':[0.1336e-3, 0.02462e-3, -2.968e-8, -4.381e-22],
'EoffT1':[-0.0934e-3, 0.03348e-3, -7.518e-8, 1.513e-10],
'Vce_Ic_T2':[0.4583, 0.009759, -1.793e-5, 1.917e-8],
'EonT2':[0.1092e-3, 0.02513e-3, -3.439e-8, 1.585e-11],
'EoffT2':[0.3307e-3, 0.02194e-3, 4.065e-9, 3.47e-23],
'Vce_Ic_T5':[0.589, 0.01118, -2.605e-5, 4.135e-8],
'EonT5':[3.425e-3, 0.0344e-3, 5.487e-7, 1.697e-10],
'EoffT5':[1.262e-3, 0.1214e-3, 2.549e-7, 4.14e-10],
'Vf_IC_D1':[0.6151, 0.008692, -1.897e-5, 1.539e-8],
'Erec_D1':[0.1081e-3, 0.01401e-3, -2.868e-8, 3.296e-11],
'Vf_IC_D2':[0.5725, 0.00809, -1.766e-5, 1.432e-8],
'Vf_IC_D5':[0.4568, 0.01567, -4.62e-5, 5.927e-8],
'Erec_D5':[2.26e-3, 0.06049e-3, -2.741e-7, 4.819e-10],
}
Rth = {'Rth_T1':0.1, 'Rth_T2':0.1, 'Rth_D1':0.1, 'Rth_D2':0.1, 'Rth_T5':0.1, 'Rth_D5':0.1}
# 用于动态结温公式中的 RC_T1 的8个系数
rc_coefs = {'T1':[0.024, 0.001, 0.044, 0.01, 0.02, 0.1, 0.056, 10.0],
'T2':[0.024, 0.001, 0.044, 0.01, 0.02, 0.1, 0.056, 10.0],
'D1':[0.024, 0.001, 0.044, 0.01, 0.02, 0.1, 0.056, 10.0],
'D2':[0.024, 0.001, 0.044, 0.01, 0.02, 0.1, 0.056, 10.0],
'T5':[0.024, 0.001, 0.044, 0.01, 0.02, 0.1, 0.056, 10.0],
'D5':[0.024, 0.001, 0.044, 0.01, 0.02, 0.1, 0.056, 10.0],
}
# 初始化类
calculator = ANPC_OneThreeLevelCalculator(input_param, inter_param)
# 计算损耗
losses = calculator.cal_loss(R_coefs, loss_coefs, Rth)
# 在终端打印以字典格式打印结果
pprint.pprint(losses)
# 画曲线图
curve_img = calculator.draw_curve(rc_coefs)
# 打开一个窗口,展示某一曲线图
# curve_img['T14']['spwm_Pcon'].show()
# curve_img['T14']['spwm_TER'].show()
# print('out: ', curve_img['T14']['spwm_Pcon'])
# curve_img['T14']['spwm_TER'].save()
# curve_img['T14']['spwm_Pcon'].save('T14_spwm_Pcon.png')
# curve_img['T14']['svpwm_Pcon'].save('T14_svpwm_Pcon.png')
# curve_img['T14']['spwm_TER'].save('T14_spwm_TER.png')
# curve_img['T14']['svpwm_TER'].save('T14_svpwm_TER.png')
# curve_img['T23']['spwm_Pcon'].save('T23_spwm_Pcon.png')
# curve_img['T23']['svpwm_Pcon'].save('T23_svpwm_Pcon.png')
# curve_img['T23']['spwm_TER'].save('T23_spwm_TER.png')
# curve_img['T23']['svpwm_TER'].save('T23_svpwm_TER.png')
# curve_img['D14']['spwm_Pcon'].save('D14_spwm_Pcon.png')
# curve_img['D14']['svpwm_Pcon'].save('D14_svpwm_Pcon.png')
# curve_img['D14']['spwm_TER'].save('D14_spwm_TER.png')
# curve_img['D14']['svpwm_TER'].save('D14_svpwm_TER.png')
# curve_img['D23']['spwm_Pcon'].save('D23_spwm_Pcon.png')
# curve_img['D23']['svpwm_Pcon'].save('D23_svpwm_Pcon.png')
# curve_img['D23']['spwm_TER'].save('D23_spwm_TER.png')
# curve_img['D23']['svpwm_TER'].save('D23_svpwm_TER.png')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。