motulator中的定子磁链指令生成算法分析 – 炸管小王子

1. 问题背景

在两电平逆变器驱动的 PMSM 系统中,参考电压 \(u_{s,ref}\) 由 FluxTorqueController 生成,
并在 PWM 环节受到直流母线电压的限制。当转速升高、反电动势增大时,\(u_{s,ref}\)
会接近甚至超过 \(u_{s,max} = k_u \cdot u_{\text{dc}} / \sqrt{3}\),此时参考电压被 PWM 饱和截断,
转矩指令无法完整实现,导致转速跟踪失败。

ReferenceGenerator 是定子磁链指令和受限转矩指令的生成器,
其核心方法 compute_flux_and_torque_refs() 负责在以下约束条件下
选择最优工作点:

  • MTPA 轨线:最大转矩电流比
  • 电压极限:弱磁区 \(\psi_{s,\max} = k_u \cdot u_{\text{dc}} / \sqrt{3} / |\omega_m|\)
  • 电流极限:\(i_s \le i_{s,\max}\)
  • MTPV 极限:最大转矩电压比(深度弱磁)

2. MTPA(最大转矩电流比)

2.1 数学条件

MTPA 条件定义为:在恒定电流幅值下,转矩对电流角的导数为零。

\[\tau = 1.5 \cdot n_p \cdot \operatorname{Im}(\psi_s \cdot i_s^*)\]

MTPA 条件: \(d\tau/d\gamma = 0\),其中 \(\gamma\) 为电流角

通过辅助磁链 \(\psi_a\) 可写为:

\[\operatorname{Re}(\psi_a \cdot i_s^*) = 0\]

2.2 辅助磁链 \(\psi_a\) 的三种等价形式

形式 表达式 说明
理论定义 \(\psi_a = \psi_s + j \cdot \partial\psi_s/\partial\delta\) 对电流角求导后构造
dq 展开式 \(\psi_a = \psi_s – L_{qq}\cdot i_d – j\cdot L_{dd}\cdot i_q + j\cdot L_{dq}\cdot i_s^*\) 用增量电感展开
向量形式 \(\psi_a = \psi_s + J \cdot \partial\psi_s/\partial\delta\) \(J\) 为 90° 旋转矩阵

2.3 实现过程

ControlLoci.compute_mtpa_locus(i_s_max) 的实现步骤:

  1. 在 [0, \(i_{s,\max}\)] 内线性取 16 个电流幅值点
  2. 对每个幅值,用 Brentq 求根 \(\operatorname{Re}(\psi_a \cdot i_s^*) = 0\),得到 MTPA 电流角 \(\gamma\)
  3. 计算 \(i_{s,dq} = |i_s| \cdot \exp(1j \cdot \gamma)\),并通过 psi_s_dq() 得到对应磁链
  4. 计算转矩 \(\tau = 1.5 \cdot n_p \cdot \operatorname{Im}(i_{s,dq} \cdot \psi_{s,dq}^*)\)
  5. 封装为 MTPALocus(含 \(i_{s,dq}\) vs \(\tau_M\) 插值器)

2.4 Brentq 求根

Brentq 是二分法 + 割线法 + 反二次插值的混合算法,搜索区间为 \([\pi/2, \pi]\)
(IPMSM 的 MTPA 电流角必然在此范围内):

def mtpa_cond(gamma):
    i_s_dq = i_s_abs · exp(1j · gamma)
    ψ_a_dq = par.aux_flux(i_s_dq)
    return Re(ψ_a_dq · i_s_dq*)  # MTPA: 求此函数的根

gamma_opt = root_scalar(mtpa_cond, bracket=[π/2, π], method="brentq").root

3. 参考指令生成流程

compute_flux_and_torque_refs(tau_M_ref, w_m, u_dc) 的顺序约束:

  1. MTPA 磁链:\(\psi_{s,\text{abs,mtpa}} = |F_{\text{MTPA}}(\tau_{M,\text{ref}})|\)
  2. 磁链限幅:\(\operatorname{clip}(\psi_{s,\text{abs,mtpa}}, \psi_{s,\min}, \psi_{s,\max})\)
  3. 弱磁(电压限幅):\(\psi_{s,\text{abs,ref}} = \min(\psi_{s,\text{abs,ref}}, \psi_{s,\max,\text{voltage}})\)
  4. 电流极限约束:\(\tau_{M,\text{ref}} = \min(\tau_{M,\text{cl}}, |\tau_{M,\text{ref}}|) \cdot \operatorname{sgn}\)
  5. MTPV 约束:\(\tau_{M,\text{ref}} = \min(k_{\text{mtpv}} \cdot \tau_{M,\text{mtpv}}, |\tau_{M,\text{ref}}|) \cdot \operatorname{sgn}\)

返回 (\(\psi_{s,\text{abs,ref}}\), \(\tau_{M,\text{ref}}\)) 给 FluxTorqueController 生成电压参考。

4. 电压极限圆可视化

下图展示了在 (\(i_d\), \(i_q\)) 平面上,不同直流母线电压和转速下的电压极限椭圆与电流极限圆。
有助于直观理解电压饱和瓶颈:

  • 电流极限圆(黑色):\(i_{s,\max} = 58\ \text{A}\) (= 2.0 pu)
  • 电压极限椭圆(彩色):\(V_{\text{dc}} = 180\ \text{V}\)(额定)vs \(V_{\text{dc}} = 150\ \text{V}\)(稳态低压预测)
  • 转速标注:1000 / 2000 / 3000 / 3600 / 4000 rpm
  • 坐标均为标幺值,\(|\psi_s|\) 等高线为背景

Voltage Limit Circles

在额定转速 3600 rpm 下,\(V_{\text{dc}}=180\ \text{V}\) 的电压椭圆半径约 0.69 pu,
\(V_{\text{dc}}=150\ \text{V}\) 的椭圆半径仅 0.57 pu,需更深的弱磁电流。
电流极限圆 2.0 pu 远大于椭圆,证实 电压饱和是主瓶颈,电流限幅远未触及

5. 总结

  • MTPA 使用 辅助磁链 \(\psi_a\) 将转矩最大化条件简化为一个点积方程
  • 16 点离散 + Brentq 求根即可覆盖全场,计算量极小
  • ReferenceGenerator 在弱磁区的 \(\psi_s\)、\(i_{s,\max}\) 公式忽略电阻压降,
    导致实际电压饱和点比算法估计值更低——这是电压型饱和的根因
  • 磁链曲面图直观展示了 (\(i_d\),\(i_q\)) 平面上的 MTPA 轨迹与电机非线性

附录:符号对照表

代码标识符 数学符号 说明
tau_M_ref \(\tau_{M,\text{ref}}\) 转矩参考值
tau_M_cl \(\tau_{M,\text{cl}}\) 电流极限约束后的转矩限值
tau_M_mtpv \(\tau_{M,\text{mtpv}}\) MTPV 极限对应的转矩
k_mtpv \(k_{\text{mtpv}}\) MTPV 安全系数
psi_s_abs_ref \(\psi_{s,\text{abs,ref}}\) 定子磁链幅值参考值
psi_s_max_voltage \(\psi_{s,\max,\text{voltage}}\) 电压极限对应的最大磁链
psi_s_min \(\psi_{s,\min}\) 最小磁链幅值限制
psi_s_max \(\psi_{s,\max}\) 最大磁链幅值限制
psi_s_ref \(\psi_{s,\text{ref}}\) 定子磁链参考值
psi_s_dq \(\psi_{s,dq}\) 定子磁链 dq 向量
u_s_ref \(u_{s,\text{ref}}\) 电压参考值
u_s_max \(u_{s,\max}\) 最大电压幅值
u_dc \(u_{\text{dc}}\) 直流母线电压
i_s_max \(i_{s,\max}\) 最大电流幅值
i_s_dq \(i_{s,dq}\) 定子电流 dq 向量
i_d \(i_d\) d 轴电流
i_q \(i_q\) q 轴电流
w_m \(\omega_m\) 机械角速度
n_p \(n_p\) 极对数

函数对应表

代码函数 数学记号 说明
_get_mtpa_flux(x) \(F_{\text{MTPA}}(x)\) MTPA 磁链函数
compute_mtpa_locus 计算 MTPA 轨线(离散点插值)
compute_flux_and_torque_refs 磁链与转矩参考值生成
clip(x, a, b) \(\operatorname{clip}(x, a, b)\) 限幅函数
sign(x) \(\operatorname{sgn}(x)\) 符号函数
psi_s_dq() \(\psi_{s,dq}\) 定子磁链 dq 分量计算