首页 > 解决方案 > 实施离散 PI 控制器的仿真时间显着增加

问题描述

我开发了一个并网单相逆变器的动态相量模型。以 1e-05 的步长运行模拟的开环模型(具有调制指数和初始角度常数)持续时间为 0.3 秒,大约需要 45 秒。然而,实施采样率为 1e-4 的离散 PI 控制器会导致模拟持续时间约为 30 分钟。我怀疑是sample我的 PI 代码中的函数。如果有人可以帮助确定原因和可能的解决方法,我会很高兴。控制器代码如下。提前致谢。

model LinearController_DQ_InverterSP
 // reference currents
 parameter Real Id_ref[3] = {0.0, 10.0, 20.0}; 
 parameter Real Iq_ref[3] = {0.0, 5.0, 10.0};
 //step times
 parameter Real step_times[2] = {0.08, 0.12};
 // current reference currents
 Real Id_ref_curr;
 Real Iq_ref_curr;

 parameter Real Kp_cc = 0.0541 "Proportional term of controller";
 parameter Real Ki_cc = 55.577 "Integral term of controller";
 parameter Real T_sample = 1e-4 "Sampling period";
 
 // previous time step terms
 Real ud_prev(start = 0.0, fixed = true);
 Real uq_prev(start = 0.0, fixed = true);
 Real ed_prev(start = 0.0, fixed = true);
 Real eq_prev(start = 0.0, fixed = true);
 Real Vd_pcc_prev(start = 220*sqrt(2), fixed = true);
 Real Vq_pcc_prev(start = 0.0, fixed = true);
 
 // current time step terms
 Real ud_curr, uq_curr;
 Real ed_curr, eq_curr;
 Real Vin_d, Vin_q;

 Real a_const =  Kp_cc + Ki_cc * T_sample / 2;
 Real b_const = -Kp_cc + Ki_cc * T_sample / 2;
 
 Modelica.Blocks.Interfaces.RealOutput Mr(start = 0.87, fixed=true);  // modulation index
 Modelica.Blocks.Interfaces.RealOutput th(start=0.0, fixed=true) ; // angle
 Modelica.Blocks.Interfaces.RealInput Id ; // measured Id current 
 Modelica.Blocks.Interfaces.RealInput Iq ; // measure Iq current
 Modelica.Blocks.Interfaces.RealInput Vd_pcc ; // Vd of measured grid voltage
 Modelica.Blocks.Interfaces.RealInput Vq_pcc ; // Vq of measured grid voltage 


algorithm
   
   if time < step_times[1] then
     Id_ref_curr := Id_ref[1];
     Iq_ref_curr := Iq_ref[1];
   elseif (time > step_times[1]) and (time < step_times[2]) then
     Id_ref_curr := Id_ref[2];
     Iq_ref_curr := Iq_ref[2];
   else
     Id_ref_curr := Id_ref[3];
     Iq_ref_curr := Iq_ref[3];
   end if;
   
   when sample(0, T_sample) then
     //Calc error
       ed_curr := Id_ref_curr - Id;
       eq_curr := Iq_ref_curr - Iq;
     
    //Calc pid controller output
       ud_curr := ud_prev + a_const * ed_curr + b_const * ed_prev;
       uq_curr := uq_prev + a_const * eq_curr + b_const * eq_prev;
     
     //Apply feedforward term
       Vin_d := (Vd_pcc_prev + ud_prev);
       Vin_q := (Vq_pcc_prev + uq_prev);
     
     //Compute control signals
       th := atan(Vin_q / Vin_d);
       Mr := sqrt(Vin_d^2 + Vin_q^2) / 360;
     
     // Update values
       Vd_pcc_prev := Vd_pcc;
       Vq_pcc_prev := Vq_pcc;
       ed_prev := ed_curr;
       eq_prev := eq_curr;
       ud_prev := ud_curr;
       uq_prev := uq_curr;
   end when;

end LinearController_DQ_InverterSP;

标签: modelicadymolaopenmodelica

解决方案


您是否查看过积分器的步长以及它在两种场景之间的变化?通常,采样(或任何类型的离散化)迫使求解器通过引发事件来采取更小的步骤。因此,例如将步长从 1e-4s 扩大到 1e-3s 应该会将性能提高大约 10 倍。

关于此的一些参考资料:

如果不仔细查看示例(仅通过复制/粘贴不起作用),这应该是您怀疑的解释。


推荐阅读